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-10-23 02:59:47 +02:00
|
|
|
public SimpleDocument(Action<IDocumentContainer> content, int maxPages)
|
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;
|
2021-03-01 16:24:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DocumentMetadata GetMetadata()
|
|
|
|
|
{
|
|
|
|
|
return new DocumentMetadata()
|
|
|
|
|
{
|
2021-07-28 21:36:51 +02:00
|
|
|
RasterDpi = PageSizes.PointsPerInch * ImageScalingFactor,
|
2021-08-26 22:25:33 +02:00
|
|
|
DocumentLayoutExceptionThreshold = MaxPages
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|