FrameExample.cs 1.3 KB

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