PageBackgroundForegroundExample.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Linq;
  3. using NUnit.Framework;
  4. using QuestPDF.Examples.Engine;
  5. using QuestPDF.Fluent;
  6. using QuestPDF.Helpers;
  7. using QuestPDF.Infrastructure;
  8. namespace QuestPDF.Examples
  9. {
  10. public class PageBackgroundForegroundExample
  11. {
  12. [Test]
  13. public void PageBackgroundForeground()
  14. {
  15. RenderingTest
  16. .Create()
  17. .ProduceImages()
  18. .MaxPages(100)
  19. .ShowResults()
  20. .RenderDocument(document =>
  21. {
  22. document.Page(page =>
  23. {
  24. page.Size(PageSizes.A4);
  25. page.Margin(1, Unit.Inch);
  26. page.DefaultTextStyle(TextStyle.Default.FontSize(16));
  27. page.PageColor(Colors.White);
  28. const string transparentBlue = "#662196f3";
  29. page.Background()
  30. .AlignTop()
  31. .ExtendHorizontal()
  32. .Height(200)
  33. .Background(transparentBlue);
  34. page.Foreground()
  35. .AlignBottom()
  36. .ExtendHorizontal()
  37. .Height(250)
  38. .Background(transparentBlue);
  39. page.Header().Text("Background and foreground").Bold().FontColor(Colors.Blue.Darken2).FontSize(36);
  40. page.Content().PaddingVertical(25).Column(column =>
  41. {
  42. column.Spacing(25);
  43. foreach (var i in Enumerable.Range(0, 100))
  44. column.Item().Background(Colors.Grey.Lighten2).Height(75);
  45. });
  46. });
  47. });
  48. }
  49. }
  50. }