DefaultTextStyleExample.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using NUnit.Framework;
  2. using QuestPDF.Examples.Engine;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.Examples
  7. {
  8. public class DefaultTextStyleExample
  9. {
  10. [Test]
  11. public void DefaultTextStyle()
  12. {
  13. RenderingTest
  14. .Create()
  15. .ProducePdf()
  16. .ShowResults()
  17. .RenderDocument(container =>
  18. {
  19. container.Page(page =>
  20. {
  21. // all text in this set of pages has size 20
  22. page.DefaultTextStyle(TextStyle.Default.Size(20));
  23. page.Margin(20);
  24. page.Size(PageSizes.A4);
  25. page.Background(Colors.White);
  26. page.Content().Column(column =>
  27. {
  28. column.Item().Text(Placeholders.Sentence());
  29. column.Item().Text(text =>
  30. {
  31. // text in this block is additionally semibold
  32. text.DefaultTextStyle(TextStyle.Default.SemiBold());
  33. text.Line(Placeholders.Sentence());
  34. // this text has size 20 but also semibold and red
  35. text.Span(Placeholders.Sentence()).Color(Colors.Red.Medium);
  36. });
  37. });
  38. });
  39. });
  40. }
  41. }
  42. }