2
0

MinimalApiExamples.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. using ShimSkiaSharp;
  8. using SKTypeface = SkiaSharp.SKTypeface;
  9. namespace QuestPDF.Examples
  10. {
  11. public class MinimalApiExamples
  12. {
  13. [Test]
  14. public void MinimalApi()
  15. {
  16. Document
  17. .Create(container =>
  18. {
  19. container.Page(page =>
  20. {
  21. page.Size(PageSizes.A5);
  22. page.Margin(1.5f, Unit.Centimetre);
  23. page.Header()
  24. .Text("Hello PDF!", TextStyle.Default.SemiBold().Size(20));
  25. page.Content()
  26. .PaddingVertical(1, Unit.Centimetre)
  27. .Column(x =>
  28. {
  29. x.Spacing(10);
  30. x.Item().Text(Placeholders.LoremIpsum());
  31. x.Item().Image(Placeholders.Image(200, 100));
  32. });
  33. });
  34. })
  35. .GeneratePdf("hello.pdf");
  36. Process.Start("explorer.exe", "hello.pdf");
  37. }
  38. }
  39. }