HyperlinkInFooterTests.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. namespace QuestPDF.ConformanceTests;
  6. internal class HyperlinkInFooterTests : 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. .PaddingVertical(25)
  18. .Column(column =>
  19. {
  20. column.Spacing(15);
  21. column.Item()
  22. .SemanticHeader1()
  23. .Text("Conformance Test: Hyperlink in Footer")
  24. .FontSize(24)
  25. .Bold()
  26. .FontColor(Colors.Blue.Darken2);
  27. column.Item().Text("Please find the link in the footer.");
  28. foreach (var i in Enumerable.Range(1, 25))
  29. column.Item().Width(100).Height(50).Background(Colors.Grey.Lighten3);
  30. });
  31. page.Footer()
  32. .SemanticLink("Link to the QuestPDF website")
  33. .Hyperlink("https://www.questpdf.com")
  34. .Text("https://www.questpdf.com")
  35. .Underline()
  36. .FontColor(Colors.Blue.Darken2);
  37. });
  38. });
  39. }
  40. protected override SemanticTreeNode? GetExpectedSemanticTree()
  41. {
  42. return ExpectedSemanticTree.DocumentRoot(root =>
  43. {
  44. root.Child("H1", h1 => h1.Alt("Conformance Test: Hyperlink in Footer"));
  45. root.Child("P");
  46. // the first occurrence of footer content should be treated as content,
  47. // all subsequent occurrences should be marked as artifacts.
  48. root.Child("Link", link =>
  49. {
  50. link.Alt("Link to the QuestPDF website");
  51. link.Child("P");
  52. });
  53. });
  54. }
  55. }