SimpleDocument.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using QuestPDF.Drawing;
  2. using QuestPDF.Elements;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.Examples.Engine
  7. {
  8. public class SimpleDocument : IDocument
  9. {
  10. public const int ImageScalingFactor = 2;
  11. private IContainer Container { get; }
  12. private Size Size { get; }
  13. public SimpleDocument(IContainer container, Size size)
  14. {
  15. Container = container;
  16. Size = size;
  17. }
  18. public DocumentMetadata GetMetadata()
  19. {
  20. return new DocumentMetadata()
  21. {
  22. RasterDpi = PageSizes.PointsPerInch * ImageScalingFactor,
  23. DocumentLayoutExceptionThreshold = 10
  24. };
  25. }
  26. public void Compose(IDocumentContainer container)
  27. {
  28. container.Page(page =>
  29. {
  30. page.Size(new PageSize(Size.Width, Size.Height));
  31. page.Content().Container().Element(Container as Container);
  32. });
  33. }
  34. }
  35. }