FrameExample.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. 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
  21. {
  22. [Test]
  23. public void Frame(IContainer container)
  24. {
  25. RenderingTest
  26. .Create()
  27. .PageSize(550, 400)
  28. .Render(container =>
  29. {
  30. container
  31. .Background("#FFF")
  32. .Padding(25)
  33. .Stack(stack =>
  34. {
  35. for(var i=1; i<=4; i++)
  36. {
  37. stack.Item().Row(row =>
  38. {
  39. row.RelativeColumn(2).LabelCell().Text(Placeholders.Label());
  40. row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
  41. });
  42. }
  43. });
  44. });
  45. }
  46. }
  47. }