CustomFirstPageExample.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class CustomFirstPageExample
  6. {
  7. [Test]
  8. public void Example()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.Size(PageSizes.A5);
  16. page.Margin(30);
  17. page.DefaultTextStyle(x => x.FontSize(20));
  18. page.Header().Column(column =>
  19. {
  20. column.Item().ShowOnce().Background(Colors.Blue.Lighten2).Height(80);
  21. column.Item().SkipOnce().Background(Colors.Green.Lighten2).Height(60);
  22. });
  23. page.Content().PaddingVertical(20).Column(column =>
  24. {
  25. column.Spacing(20);
  26. foreach (var _ in Enumerable.Range(0, 20))
  27. column.Item().Background(Colors.Grey.Lighten3).Height(40);
  28. });
  29. page.Footer().AlignCenter().Text(text =>
  30. {
  31. text.CurrentPageNumber();
  32. text.Span(" / ");
  33. text.TotalPages();
  34. });
  35. });
  36. })
  37. .GeneratePdf("example-custom-first-page.pdf");
  38. }
  39. }