ShowOnceExample.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using NUnit.Framework;
  2. using QuestPDF.Examples.Engine;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.Examples
  7. {
  8. public class ShowOnceExample
  9. {
  10. [Test]
  11. public void ShowOnce()
  12. {
  13. RenderingTest
  14. .Create()
  15. .ProduceImages()
  16. .ShowResults()
  17. .RenderDocument(container =>
  18. {
  19. container.Page(page =>
  20. {
  21. page.Margin(20);
  22. page.Size(PageSizes.A7.Landscape());
  23. page.Background(Colors.White);
  24. page.Header().Text("With show once", TextStyle.Default.SemiBold());
  25. page.Content().PaddingVertical(5).Row(row =>
  26. {
  27. row.RelativeItem()
  28. .Background(Colors.Grey.Lighten2)
  29. .Border(1)
  30. .Padding(5)
  31. .ShowOnce()
  32. .Text(Placeholders.Label());
  33. row.RelativeItem(2)
  34. .Border(1)
  35. .Padding(5)
  36. .Text(Placeholders.Paragraph());
  37. });
  38. page.Footer().Text(text =>
  39. {
  40. text.Span("Page ");
  41. text.CurrentPageNumber();
  42. text.Span(" out of ");
  43. text.TotalPages();
  44. });
  45. });
  46. });
  47. }
  48. }
  49. }