Padding.cs 5.3 KB

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