SimpleDocument.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Elements;
  4. using QuestPDF.Fluent;
  5. using QuestPDF.Helpers;
  6. using QuestPDF.Infrastructure;
  7. namespace QuestPDF.Examples.Engine
  8. {
  9. public class SimpleDocument : IDocument
  10. {
  11. public const int ImageScalingFactor = 2;
  12. private Action<IDocumentContainer> Content { get; }
  13. private int MaxPages { get; }
  14. private bool ApplyCaching { get; }
  15. private bool ApplyDebugging { get; }
  16. public SimpleDocument(Action<IDocumentContainer> content, int maxPages, bool applyCaching, bool applyDebugging)
  17. {
  18. Content = content;
  19. MaxPages = maxPages;
  20. ApplyCaching = applyCaching;
  21. ApplyDebugging = applyDebugging;
  22. }
  23. public DocumentMetadata GetMetadata()
  24. {
  25. return new DocumentMetadata()
  26. {
  27. RasterDpi = PageSizes.PointsPerInch * ImageScalingFactor,
  28. DocumentLayoutExceptionThreshold = MaxPages,
  29. ApplyCaching = ApplyCaching,
  30. ApplyDebugging = ApplyDebugging
  31. };
  32. }
  33. public void Compose(IDocumentContainer container)
  34. {
  35. Content(container);
  36. }
  37. }
  38. }