2021-10-23 02:59:47 +02:00
|
|
|
using System;
|
|
|
|
|
using QuestPDF.Drawing;
|
2021-07-26 11:35:52 +02:00
|
|
|
using QuestPDF.Elements;
|
2021-03-01 16:24:59 +01:00
|
|
|
using QuestPDF.Fluent;
|
|
|
|
|
using QuestPDF.Helpers;
|
|
|
|
|
using QuestPDF.Infrastructure;
|
|
|
|
|
|
|
|
|
|
namespace QuestPDF.Examples.Engine
|
|
|
|
|
{
|
|
|
|
|
public class SimpleDocument : IDocument
|
|
|
|
|
{
|
2021-07-28 21:36:51 +02:00
|
|
|
public const int ImageScalingFactor = 2;
|
|
|
|
|
|
2021-10-23 02:59:47 +02:00
|
|
|
private Action<IDocumentContainer> Content { get; }
|
2021-08-26 22:25:33 +02:00
|
|
|
private int MaxPages { get; }
|
2021-03-01 16:24:59 +01:00
|
|
|
|
2021-12-25 11:53:39 +01:00
|
|
|
public SimpleDocument(Action<IDocumentContainer> content, int maxPages, bool applyCaching, bool applyDebugging)
|
2021-03-01 16:24:59 +01:00
|
|
|
{
|
2021-10-23 02:59:47 +02:00
|
|
|
Content = content;
|
2021-08-26 22:25:33 +02:00
|
|
|
MaxPages = maxPages;
|
2023-05-07 04:05:39 +02:00
|
|
|
|
|
|
|
|
QuestPDF.Settings.EnableCaching = applyCaching;
|
|
|
|
|
QuestPDF.Settings.EnableDebugging = applyDebugging;
|
|
|
|
|
QuestPDF.Settings.DocumentLayoutExceptionThreshold = MaxPages;
|
2021-03-01 16:24:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 04:05:39 +02:00
|
|
|
public DocumentSettings GetSettings()
|
2021-03-01 16:24:59 +01:00
|
|
|
{
|
2023-05-07 04:05:39 +02:00
|
|
|
return new DocumentSettings()
|
2021-03-01 16:24:59 +01:00
|
|
|
{
|
2023-05-12 00:48:16 +02:00
|
|
|
ImageRasterDpi = PageSizes.PointsPerInch * ImageScalingFactor
|
2021-03-01 16:24:59 +01:00
|
|
|
};
|
|
|
|
|
}
|
2021-07-26 11:35:52 +02:00
|
|
|
|
|
|
|
|
public void Compose(IDocumentContainer container)
|
2021-03-01 16:24:59 +01:00
|
|
|
{
|
2021-10-23 02:59:47 +02:00
|
|
|
Content(container);
|
2021-03-01 16:24:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|