DecorationTests.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. namespace QuestPDF.ConformanceTests;
  6. internal class DecorationTests : ConformanceTestBase
  7. {
  8. protected override Document GetDocumentUnderTest()
  9. {
  10. QuestPDF.Settings.EnableDebugging = true;
  11. return Document
  12. .Create(document =>
  13. {
  14. document.Page(page =>
  15. {
  16. page.Size(600, 975);
  17. page.Margin(50);
  18. page.Content()
  19. .Decoration(decoration =>
  20. {
  21. decoration.Before()
  22. .Column(column =>
  23. {
  24. column.Item()
  25. .ShowOnce()
  26. .Height(50)
  27. .Width(200)
  28. .SemanticImage("First page: decoration before")
  29. .Image(Placeholders.Image);
  30. column.Item()
  31. .SkipOnce()
  32. .Text("Second page: decoration before");
  33. });
  34. decoration
  35. .Content()
  36. .PaddingVertical(25)
  37. .Column(column =>
  38. {
  39. column.Spacing(25);
  40. foreach (var i in Enumerable.Range(1, 15))
  41. {
  42. column.Item()
  43. .Width(200)
  44. .Height(50)
  45. .Background(Colors.Grey.Lighten3)
  46. .AlignCenter()
  47. .AlignMiddle()
  48. .Text($"Item {i}");
  49. }
  50. });
  51. decoration.After()
  52. .Column(column =>
  53. {
  54. column.Item()
  55. .ShowOnce()
  56. .Height(50)
  57. .Width(200)
  58. .SemanticImage("First page: decoration after")
  59. .Image(Placeholders.Image);
  60. column.Item()
  61. .SkipOnce()
  62. .Text("Second page: decoration after");
  63. });
  64. });
  65. });
  66. });
  67. }
  68. protected override SemanticTreeNode? GetExpectedSemanticTree()
  69. {
  70. return ExpectedSemanticTree.DocumentRoot(root =>
  71. {
  72. root.Child("Figure", figure => figure.Alt("First page: decoration before"));
  73. foreach (var i in Enumerable.Range(1, 10))
  74. root.Child("P");
  75. root.Child("Figure", figure => figure.Alt("First page: decoration after"));
  76. foreach (var i in Enumerable.Range(1, 5))
  77. root.Child("P");
  78. });
  79. }
  80. }