FooterTests.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. namespace QuestPDF.ConformanceTests;
  6. internal class FooterTests : 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.Content()
  17. .PaddingBottom(25)
  18. .Column(column =>
  19. {
  20. column.Spacing(25);
  21. column.Item()
  22. .SemanticHeader1()
  23. .Text("Conformance Test: Footer")
  24. .FontSize(24)
  25. .Bold()
  26. .FontColor(Colors.Blue.Darken2);
  27. column.Item()
  28. .Text("Footer content should not be present in the semantic tree.");
  29. column.Item()
  30. .SemanticDivision()
  31. .Column(column =>
  32. {
  33. foreach (var i in Enumerable.Range(1, 12))
  34. {
  35. column.Item()
  36. .Width(200)
  37. .Height(100)
  38. .Background(Colors.Grey.Lighten2)
  39. .AlignCenter()
  40. .AlignMiddle()
  41. .Text($"Item {i}");
  42. }
  43. });
  44. });
  45. page.Footer()
  46. .AlignCenter()
  47. .Text(text =>
  48. {
  49. text.CurrentPageNumber();
  50. text.Span(" / ");
  51. text.TotalPages();
  52. });
  53. });
  54. });
  55. }
  56. protected override SemanticTreeNode? GetExpectedSemanticTree()
  57. {
  58. return ExpectedSemanticTree.DocumentRoot(root =>
  59. {
  60. root.Child("H1", h1 => h1.Alt("Conformance Test: Footer"));
  61. root.Child("P");
  62. root.Child("Div", div =>
  63. {
  64. foreach (var i in Enumerable.Range(1, 12))
  65. div.Child("P");
  66. });
  67. });
  68. }
  69. }