RowExamples.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.DefaultTextStyle(x => x.FontSize(20));
  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 AutoItem()
  42. {
  43. // TODO: improve and update documentation
  44. Document
  45. .Create(document =>
  46. {
  47. document.Page(page =>
  48. {
  49. page.MinSize(new PageSize(0, 0));
  50. page.MaxSize(new PageSize(500, 300));
  51. page.DefaultTextStyle(x => x.FontSize(20));
  52. page.Content()
  53. .Padding(25)
  54. .Row(row =>
  55. {
  56. row.AutoItem().Text("Auto column");
  57. row.RelativeItem().Text(Placeholders.LoremIpsum());
  58. });
  59. });
  60. })
  61. .GeneratePdf();
  62. }
  63. [Test]
  64. public void SpacingExample()
  65. {
  66. Document
  67. .Create(document =>
  68. {
  69. document.Page(page =>
  70. {
  71. page.MinSize(new PageSize(0, 0));
  72. page.MaxSize(new PageSize(1000, 1000));
  73. page.DefaultTextStyle(x => x.FontSize(20));
  74. page.Content()
  75. .Padding(25)
  76. .Width(220)
  77. .Height(50)
  78. .Row(row =>
  79. {
  80. row.Spacing(10);
  81. row.RelativeItem(2).Background(Colors.Grey.Medium);
  82. row.RelativeItem(3).Background(Colors.Grey.Lighten1);
  83. row.RelativeItem(5).Background(Colors.Grey.Lighten2);
  84. });
  85. });
  86. })
  87. .GenerateImages(x => "row-spacing.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  88. }
  89. }