RowExamples.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 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.DefaultTextStyle(x => x.FontSize(20));
  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. }