Padding.cs 5.4 KB

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