ColumnExamples.cs 3.3 KB

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