StyledBoxTests.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.ConformanceTests;
  7. internal class StyledBoxTests : ConformanceTestBase
  8. {
  9. protected override Document GetDocumentUnderTest()
  10. {
  11. var avoidTransparency = TestContext.CurrentContext.Test.Arguments.FirstOrDefault() is PDFA_Conformance.PDFA_1A or PDFA_Conformance.PDFA_1B;
  12. return Document
  13. .Create(document =>
  14. {
  15. document.Page(page =>
  16. {
  17. page.Margin(60);
  18. page.Content()
  19. .PaddingVertical(30)
  20. .SemanticSection()
  21. .Column(column =>
  22. {
  23. column.Spacing(30);
  24. column.Item()
  25. .SemanticHeader1()
  26. .Text("Conformance Test: Styled Boxes")
  27. .FontSize(36)
  28. .Bold()
  29. .FontColor(Colors.Blue.Darken2);
  30. column.Item()
  31. .Background(Colors.Blue.Lighten4)
  32. .Padding(20)
  33. .Text("Background only")
  34. .FontSize(16);
  35. column.Item()
  36. .Border(2, Colors.Blue.Darken2)
  37. .Padding(20)
  38. .Text("Border only")
  39. .FontSize(16);
  40. column.Item()
  41. .Background(Colors.White)
  42. .Shadow(new BoxShadowStyle
  43. {
  44. OffsetX = 5,
  45. OffsetY = 5,
  46. Blur = avoidTransparency ? 0 : 10,
  47. Spread = 5,
  48. Color = Colors.Grey.Medium
  49. })
  50. .Padding(20)
  51. .Text("Simple shadow")
  52. .FontSize(16);
  53. column.Item()
  54. .Border(1, Colors.Purple.Lighten4)
  55. .Background(Colors.Purple.Lighten5)
  56. .CornerRadius(15)
  57. .Padding(20)
  58. .Text("Rounded corners")
  59. .FontSize(16);
  60. });
  61. });
  62. });
  63. }
  64. protected override SemanticTreeNode? GetExpectedSemanticTree()
  65. {
  66. return ExpectedSemanticTree.DocumentRoot(root =>
  67. {
  68. root.Child("Sect", sect =>
  69. {
  70. sect.Child("H1", h1 => h1.Alt("Conformance Test: Styled Boxes"));
  71. foreach (var i in Enumerable.Range(1, 4))
  72. sect.Child("P");
  73. });
  74. });
  75. }
  76. }