RowExamples.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. public class RowExamples
  9. {
  10. [Test]
  11. public void Stability()
  12. {
  13. // up to version 2021.12, this code would always result with the infinite layout exception
  14. RenderingTest
  15. .Create()
  16. .ProducePdf()
  17. .MaxPages(100)
  18. .PageSize(250, 150)
  19. .ShowResults()
  20. .Render(container =>
  21. {
  22. container
  23. .Padding(25)
  24. .Row(row =>
  25. {
  26. row.RelativeColumn().Stack(stack =>
  27. {
  28. stack.Item().ShowOnce().Element(CreateBox).Text("X");
  29. stack.Item().Element(CreateBox).Text("1");
  30. stack.Item().Element(CreateBox).Text("2");
  31. });
  32. row.RelativeColumn().Stack(stack =>
  33. {
  34. stack.Item().Element(CreateBox).Text("1");
  35. stack.Item().Element(CreateBox).Text("2");
  36. });
  37. });
  38. });
  39. static IContainer CreateBox(IContainer container)
  40. {
  41. return container
  42. .ExtendHorizontal()
  43. .ExtendVertical()
  44. .Background(Colors.Grey.Lighten4)
  45. .Border(1)
  46. .AlignCenter()
  47. .AlignMiddle()
  48. .ShowOnce();
  49. }
  50. }
  51. }
  52. }