Padding.cs 5.3 KB

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