RotateExamples.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class RotateExamples
  6. {
  7. [Test]
  8. public void Example()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.MinSize(new PageSize(0, 0));
  16. page.MaxSize(new PageSize(500, 1000));
  17. page.DefaultTextStyle(x => x.FontSize(20));
  18. page.Margin(25);
  19. page.Content()
  20. .Row(row =>
  21. {
  22. row.AutoItem()
  23. .RotateLeft()
  24. .AlignCenter()
  25. .Text("Definition")
  26. .Bold().FontColor(Colors.Blue.Darken2);
  27. row.AutoItem()
  28. .PaddingHorizontal(15)
  29. .LineVertical(2).LineColor(Colors.Blue.Medium);
  30. row.RelativeItem()
  31. .Background(Colors.Blue.Lighten5)
  32. .Padding(15)
  33. .Text(text =>
  34. {
  35. text.Span("A variable").Bold();
  36. text.Span(" is a named storage location in memory that holds a value which can be modified during program execution.");
  37. });
  38. });
  39. });
  40. })
  41. .GenerateImages(x => "rotate.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  42. }
  43. [Test]
  44. public void FreeExample()
  45. {
  46. Document
  47. .Create(document =>
  48. {
  49. document.Page(page =>
  50. {
  51. page.MinSize(new PageSize(0, 0));
  52. page.MaxSize(new PageSize(1000, 1000));
  53. page.Content()
  54. .Background(Colors.Grey.Lighten2)
  55. .Padding(25)
  56. .Row(row =>
  57. {
  58. row.Spacing(25);
  59. AddIcon(0);
  60. AddIcon(30);
  61. AddIcon(45);
  62. AddIcon(80);
  63. void AddIcon(float angle)
  64. {
  65. const float itemSize = 100;
  66. row.AutoItem()
  67. .Width(itemSize)
  68. .AspectRatio(1)
  69. .TranslateX(itemSize / 2)
  70. .TranslateY(itemSize / 2)
  71. .Rotate(angle)
  72. .TranslateX(-itemSize / 2)
  73. .TranslateY(-itemSize / 2)
  74. .Svg("Resources/compass.svg");
  75. }
  76. });
  77. });
  78. })
  79. .GenerateImages(x => "rotate-free.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  80. }
  81. }