FrameExample.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 ? Colors.Grey.Lighten2 : Colors.White)
  15. .Padding(10);
  16. }
  17. public static void LabelCell(this IContainer container, string text) => container.Cell(true).Text(text, TextStyle.Default.Medium());
  18. public static IContainer ValueCell(this IContainer container) => container.Cell(false);
  19. }
  20. public class FrameExample
  21. {
  22. [Test]
  23. public void Frame()
  24. {
  25. RenderingTest
  26. .Create()
  27. .PageSize(550, 400)
  28. .ShowResults()
  29. .Render(container =>
  30. {
  31. container
  32. .Background("#FFF")
  33. .Padding(25)
  34. .Stack(stack =>
  35. {
  36. for(var i=1; i<=4; i++)
  37. {
  38. stack.Item().Row(row =>
  39. {
  40. row.RelativeColumn(2).LabelCell(Placeholders.Label());
  41. row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
  42. });
  43. }
  44. });
  45. });
  46. }
  47. }
  48. }