2
0

FrameExample.cs 1.8 KB

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