FrameExample.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. .FileName()
  29. .ShowResults()
  30. .Render(container =>
  31. {
  32. container
  33. .Background("#FFF")
  34. .Padding(25)
  35. .Stack(stack =>
  36. {
  37. for(var i=1; i<=4; i++)
  38. {
  39. stack.Item().Row(row =>
  40. {
  41. row.RelativeColumn(2).LabelCell(Placeholders.Label());
  42. row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
  43. });
  44. }
  45. });
  46. });
  47. }
  48. }
  49. }