Padding.cs 5.5 KB

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