Padding.cs 5.3 KB

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