RowExamples.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class RowExamples
  6. {
  7. [Test]
  8. public void SimpleExample()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.MinSize(new PageSize(0, 0));
  16. page.MaxSize(new PageSize(1000, 1000));
  17. page.Margin(25);
  18. page.Content()
  19. .Padding(25)
  20. .Width(325)
  21. .Row(row =>
  22. {
  23. row.ConstantItem(100)
  24. .Background(Colors.Grey.Medium)
  25. .Padding(10)
  26. .Text("100pt");
  27. row.RelativeItem()
  28. .Background(Colors.Grey.Lighten1)
  29. .Padding(10)
  30. .Text("75pt");
  31. row.RelativeItem(2)
  32. .Background(Colors.Grey.Lighten2)
  33. .Padding(10)
  34. .Text("150pt");
  35. });
  36. });
  37. })
  38. .GenerateImages(x => "row-simple.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  39. }
  40. [Test]
  41. public void SpacingExample()
  42. {
  43. Document
  44. .Create(document =>
  45. {
  46. document.Page(page =>
  47. {
  48. page.MinSize(new PageSize(0, 0));
  49. page.MaxSize(new PageSize(1000, 1000));
  50. page.Margin(25);
  51. page.Content()
  52. .Padding(25)
  53. .Width(220)
  54. .Height(50)
  55. .Row(row =>
  56. {
  57. row.Spacing(10);
  58. row.RelativeItem(2).Background(Colors.Grey.Medium);
  59. row.RelativeItem(3).Background(Colors.Grey.Lighten1);
  60. row.RelativeItem(5).Background(Colors.Grey.Lighten2);
  61. });
  62. });
  63. })
  64. .GenerateImages(x => "row-spacing.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  65. }
  66. [Test]
  67. public void CustomSpacingExample()
  68. {
  69. Document
  70. .Create(document =>
  71. {
  72. document.Page(page =>
  73. {
  74. page.MinSize(new PageSize(250, 0));
  75. page.MaxSize(new PageSize(250, 1000));
  76. page.Margin(25);
  77. page.Content()
  78. .Height(50)
  79. .Row(row =>
  80. {
  81. row.RelativeItem().Background(Colors.Grey.Darken1);
  82. row.ConstantItem(10);
  83. row.RelativeItem().Background(Colors.Grey.Medium);
  84. row.ConstantItem(20);
  85. row.RelativeItem().Background(Colors.Grey.Lighten1);
  86. row.ConstantItem(30);
  87. row.RelativeItem().Background(Colors.Grey.Lighten2);
  88. });
  89. });
  90. })
  91. .GenerateImages(x => "row-spacing-custom.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  92. }
  93. }