Added support for image DPI scaling
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.Examples.Engine
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
public static void GeneratePdfAndOpen(this Document document, string? fileName = null)
|
||||
{
|
||||
fileName ??= $"{Guid.NewGuid():D}.pdf";
|
||||
|
||||
var filePath = Path.GetTempPath() + fileName;
|
||||
var documentData = document.GeneratePdf();
|
||||
File.WriteAllBytes(filePath, documentData);
|
||||
|
||||
Process.Start("explorer", filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,29 +66,7 @@ namespace QuestPDF.Examples
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReusingTheSameImageFileShouldBePossible()
|
||||
{
|
||||
var image = Image.FromBinaryData(Placeholders.Image(300, 100)).DisposeAfterDocumentGeneration();
|
||||
|
||||
RenderingTest
|
||||
.Create()
|
||||
.ProducePdf()
|
||||
.PageSize(PageSizes.A4)
|
||||
.ShowResults()
|
||||
.Render(container =>
|
||||
{
|
||||
container
|
||||
.Padding(20)
|
||||
.Column(column =>
|
||||
{
|
||||
column.Spacing(20);
|
||||
|
||||
foreach (var i in Enumerable.Range(0, 1000))
|
||||
column.Item().Image(image);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ImageResolutionScaling()
|
||||
@@ -100,18 +78,12 @@ namespace QuestPDF.Examples
|
||||
{
|
||||
document.Page(page =>
|
||||
{
|
||||
page.Size(11000, 11000);
|
||||
page.Size(210, 210);
|
||||
page.Margin(50);
|
||||
page.Content().Image(image);
|
||||
});
|
||||
})
|
||||
.GeneratePdfAndOpen();
|
||||
|
||||
//Console.WriteLine(documentData.Length);
|
||||
|
||||
// var filePath = Path.GetTempPath() + $"test.pdf";
|
||||
// File.WriteAllBytes(filePath, documentData);
|
||||
// Console.WriteLine(filePath);
|
||||
.GeneratePdf($"test.pdf");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user