MinimalApiExamples.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Diagnostics;
  2. using NUnit.Framework;
  3. using QuestPDF.Examples.Engine;
  4. using QuestPDF.Fluent;
  5. using QuestPDF.Helpers;
  6. using QuestPDF.Infrastructure;
  7. namespace QuestPDF.Examples
  8. {
  9. public class MinimalApiExamples
  10. {
  11. [Test]
  12. public void MinimalApi()
  13. {
  14. Document
  15. .Create(container =>
  16. {
  17. container.Page(page =>
  18. {
  19. page.Size(PageSizes.A4);
  20. page.Margin(2, Unit.Centimetre);
  21. page.PageColor(Colors.White);
  22. page.DefaultTextStyle(x => x.FontSize(20));
  23. page.Header()
  24. .Text("Hello PDF!")
  25. .SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
  26. page.Content()
  27. .PaddingVertical(1, Unit.Centimetre)
  28. .Column(x =>
  29. {
  30. x.Spacing(20);
  31. x.Item().Text(Placeholders.LoremIpsum());
  32. x.Item().Image(Placeholders.Image(200, 100));
  33. });
  34. page.Footer()
  35. .AlignCenter()
  36. .Text(x =>
  37. {
  38. x.Span("Page ");
  39. x.CurrentPageNumber();
  40. });
  41. });
  42. })
  43. .GeneratePdf("hello.pdf");
  44. }
  45. }
  46. }