FrameExample.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Linq;
  2. using QuestPDF.Examples.Engine;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.Examples
  7. {
  8. static class SimpleExtension
  9. {
  10. private static IContainer Cell(this IContainer container, bool dark)
  11. {
  12. return container
  13. .Border(1)
  14. .Background(dark ? "#EEE" : "#FFF")
  15. .Padding(10);
  16. }
  17. public static IContainer LabelCell(this IContainer container) => container.Cell(true);
  18. public static IContainer ValueCell(this IContainer container) => container.Cell(false);
  19. }
  20. public class FrameExample: ExampleTestBase
  21. {
  22. [ImageSize(550, 400)]
  23. [ShowResult]
  24. public void Frame(IContainer container)
  25. {
  26. container
  27. .Background("#FFF")
  28. .Padding(25)
  29. .Stack(stack =>
  30. {
  31. for(var i=1; i<=4; i++)
  32. {
  33. stack.Element().Row(row =>
  34. {
  35. row.RelativeColumn(2).LabelCell().Text(TextPlaceholder.Label());
  36. row.RelativeColumn(3).ValueCell().Text(TextPlaceholder.Paragraph());
  37. });
  38. }
  39. });
  40. }
  41. }
  42. }