Padding.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 Examples
  9. {
  10. [Test]
  11. public void Padding()
  12. {
  13. RenderingTest
  14. .Create()
  15. .PageSize(300, 300)
  16. .ShowResults()
  17. .Render(container =>
  18. {
  19. container
  20. .Background(Colors.Red.Lighten2)
  21. .Padding(50)
  22. .Background(Colors.Green.Lighten2)
  23. .PaddingVertical(50)
  24. .Background(Colors.Blue.Lighten2)
  25. .PaddingHorizontal(50)
  26. .Background(Colors.Grey.Darken2);
  27. });
  28. }
  29. [Test]
  30. public void Border()
  31. {
  32. RenderingTest
  33. .Create()
  34. .PageSize(200, 150)
  35. .Render(container =>
  36. {
  37. container
  38. .Background(Colors.Grey.Lighten3)
  39. .Padding(25)
  40. .AlignBottom()
  41. .AlignCenter()
  42. .BorderBottom(2)
  43. .BorderColor(Colors.Black)
  44. .Background(Colors.White)
  45. .Padding(5)
  46. .AlignCenter()
  47. .Text("Sample text")
  48. .FontFamily("Segoe UI emoji");
  49. });
  50. }
  51. [Test]
  52. public void Alignment()
  53. {
  54. RenderingTest
  55. .Create()
  56. .PageSize(200, 150)
  57. .Render(container =>
  58. {
  59. container
  60. .Column(column =>
  61. {
  62. column
  63. .Item()
  64. .Height(100)
  65. .Background(Colors.White)
  66. .AlignLeft()
  67. .AlignMiddle()
  68. .Width(50)
  69. .Height(50)
  70. .Background(Colors.Grey.Darken2);
  71. column
  72. .Item()
  73. .Height(100)
  74. .Background(Colors.Grey.Lighten4)
  75. .AlignCenter()
  76. .AlignMiddle()
  77. .Width(50)
  78. .Height(50)
  79. .Background(Colors.Grey.Darken3);
  80. column
  81. .Item()
  82. .Height(100)
  83. .Background(Colors.Grey.Lighten3)
  84. .AlignRight()
  85. .AlignMiddle()
  86. .Width(50)
  87. .Height(50)
  88. .Background(Colors.Black);
  89. });
  90. });
  91. }
  92. [Test]
  93. public void Expand()
  94. {
  95. RenderingTest
  96. .Create()
  97. .PageSize(200, 150)
  98. .Render(container =>
  99. {
  100. container
  101. .Column(column =>
  102. {
  103. column
  104. .Item()
  105. .Height(150)
  106. .Row(row =>
  107. {
  108. row.RelativeItem()
  109. .Extend()
  110. .Background(Colors.White)
  111. .Height(50)
  112. .Width(50)
  113. .Background(Colors.Grey.Darken2);
  114. row.RelativeItem()
  115. .Extend()
  116. .Background(Colors.Grey.Lighten3)
  117. .Height(50)
  118. .ExtendHorizontal()
  119. .Background(Colors.Grey.Darken2);
  120. });
  121. column
  122. .Item()
  123. .Height(150)
  124. .Row(row =>
  125. {
  126. row.RelativeItem()
  127. .Extend()
  128. .Background(Colors.Grey.Lighten3)
  129. .ExtendVertical()
  130. .Width(50)
  131. .Background(Colors.Grey.Darken2);
  132. row.RelativeItem()
  133. .Extend()
  134. .Background(Colors.Grey.Lighten3)
  135. .ExtendVertical()
  136. .ExtendHorizontal()
  137. .Background(Colors.Grey.Darken2);
  138. });
  139. });
  140. });
  141. }
  142. }
  143. }