2021.3.0 Generating images functionality, ShowIf element, fixed mutating TextStyle
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
using SkiaSharp;
|
||||
|
||||
@@ -60,23 +61,13 @@ namespace QuestPDF.Examples.Engine
|
||||
var container = new Container();
|
||||
methodInfo.Invoke(this, new object[] {container});
|
||||
|
||||
var iteration = 1;
|
||||
Func<int, string> fileNameSchema = i => $"{fileName.ToLower()}-${i}.png";
|
||||
|
||||
while (iteration <= 1)
|
||||
{
|
||||
var imageData = RenderPage(container, size);
|
||||
|
||||
if (imageData == null)
|
||||
return;
|
||||
|
||||
var path = Path.Combine(ResultPath, $"{fileName.ToLower()}-${iteration}.png");
|
||||
File.WriteAllBytes(path, imageData);
|
||||
|
||||
if (showResult)
|
||||
Process.Start("explorer", path);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
var document = new SimpleDocument(container, size);
|
||||
document.GenerateImages(fileNameSchema);
|
||||
|
||||
if (showResult)
|
||||
Process.Start("explorer", fileNameSchema(0));
|
||||
}
|
||||
|
||||
private byte[] RenderPage(Element element, Size size)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.Examples.Engine
|
||||
{
|
||||
public class SimpleDocument : IDocument
|
||||
{
|
||||
private IContainer Container { get; }
|
||||
private Size Size { get; }
|
||||
|
||||
public SimpleDocument(IContainer container, Size size)
|
||||
{
|
||||
Container = container;
|
||||
Size = size;
|
||||
}
|
||||
|
||||
public DocumentMetadata GetMetadata()
|
||||
{
|
||||
return new DocumentMetadata()
|
||||
{
|
||||
RasterDpi = PageSizes.PointsPerInch * 2,
|
||||
Size = Size
|
||||
};
|
||||
}
|
||||
|
||||
public void Compose(IContainer container)
|
||||
{
|
||||
container.Element(Container.Child);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user