Files
QuestPDF/QuestPDF.Examples/Engine/SimpleDocument.cs
T

43 lines
1.2 KiB
C#
Raw Normal View History

2021-10-23 02:59:47 +02:00
using System;
using QuestPDF.Drawing;
using QuestPDF.Elements;
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-12-25 11:53:39 +01:00
private bool ApplyCaching { get; }
private bool ApplyDebugging { get; }
2021-12-25 11:53:39 +01:00
public SimpleDocument(Action<IDocumentContainer> content, int maxPages, bool applyCaching, bool applyDebugging)
{
2021-10-23 02:59:47 +02:00
Content = content;
2021-08-26 22:25:33 +02:00
MaxPages = maxPages;
2021-12-25 11:53:39 +01:00
ApplyCaching = applyCaching;
ApplyDebugging = applyDebugging;
}
public DocumentMetadata GetMetadata()
{
return new DocumentMetadata()
{
2021-07-28 21:36:51 +02:00
RasterDpi = PageSizes.PointsPerInch * ImageScalingFactor,
2021-12-25 11:53:39 +01:00
DocumentLayoutExceptionThreshold = MaxPages,
ApplyCaching = ApplyCaching,
ApplyDebugging = ApplyDebugging
};
}
public void Compose(IDocumentContainer container)
{
2021-10-23 02:59:47 +02:00
Content(container);
}
}
}