AccessibilityExamples.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class AccessibilityExamples
  6. {
  7. [Test]
  8. public void MinimalExample()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.Size(PageSizes.A5);
  16. page.Margin(30);
  17. page.Header()
  18. .PaddingBottom(15)
  19. .SemanticHeader1()
  20. .Text("Accessibility Test Document")
  21. .FontColor(Colors.Blue.Darken3)
  22. .FontSize(24)
  23. .Bold();
  24. page.Content()
  25. .Column(column =>
  26. {
  27. column.Spacing(20);
  28. column.Item()
  29. .SemanticSection()
  30. .Column(column =>
  31. {
  32. column.Item()
  33. .PaddingBottom(10)
  34. .SemanticHeader2()
  35. .Text("Section with text content")
  36. .FontColor(Colors.Blue.Darken1)
  37. .FontSize(16);
  38. column.Item()
  39. .Text(Placeholders.Paragraphs())
  40. .FontSize(12)
  41. .ParagraphSpacing(8);
  42. });
  43. column.Item()
  44. .PreventPageBreak()
  45. .SemanticSection()
  46. .Column(column =>
  47. {
  48. column.Item()
  49. .PaddingBottom(10)
  50. .SemanticHeader2()
  51. .Text("Section with image")
  52. .FontColor(Colors.Blue.Darken1)
  53. .FontSize(16);
  54. column.Item()
  55. .Width(250)
  56. .SemanticImage("Image showing a laptop")
  57. .Image("Resources/product.jpg");
  58. });
  59. });
  60. });
  61. })
  62. .WithMetadata(new DocumentMetadata
  63. {
  64. Language = "en-US",
  65. Title = "Accessibility Test",
  66. Subject = "This document shows how easy it is to create accessible PDF documents with QuestPDF"
  67. })
  68. .WithSettings(new DocumentSettings
  69. {
  70. PDFA_Conformance = PDFA_Conformance.PDFA_3A,
  71. PDFUA_Conformance = PDFUA_Conformance.PDFUA_1
  72. })
  73. .GeneratePdf("accessibility-minimal-example.pdf");
  74. }
  75. }