HeaderTests.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. namespace QuestPDF.ConformanceTests;
  6. internal class HeaderTests : ConformanceTestBase
  7. {
  8. protected override Document GetDocumentUnderTest()
  9. {
  10. return Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.Margin(60);
  16. page.Header()
  17. .Column(column =>
  18. {
  19. column.Spacing(25);
  20. column.Item()
  21. .SemanticHeader1()
  22. .Text("Conformance Test: Header")
  23. .FontSize(24)
  24. .Bold()
  25. .FontColor(Colors.Blue.Darken2);
  26. column.Item()
  27. .ShowOnce()
  28. .Text("Only the first page of the Header should be present in the semantic tree.");
  29. column.Item()
  30. .SkipOnce()
  31. .Text("This item should NOT be present in the semantic tree.");
  32. });
  33. page.Content()
  34. .PaddingTop(25)
  35. .SemanticDivision()
  36. .Column(column =>
  37. {
  38. column.Spacing(25);
  39. foreach (var i in Enumerable.Range(1, 12))
  40. {
  41. column.Item()
  42. .Width(200)
  43. .Height(100)
  44. .Background(Colors.Grey.Lighten2)
  45. .AlignCenter()
  46. .AlignMiddle()
  47. .Text($"Item {i}");
  48. }
  49. });
  50. });
  51. });
  52. }
  53. protected override SemanticTreeNode? GetExpectedSemanticTree()
  54. {
  55. return ExpectedSemanticTree.DocumentRoot(root =>
  56. {
  57. root.Child("H1", h1 => h1.Alt("Conformance Test: Header"));
  58. root.Child("P");
  59. root.Child("Div", div =>
  60. {
  61. foreach (var i in Enumerable.Range(1, 12))
  62. div.Child("P");
  63. });
  64. });
  65. }
  66. }