DPI-based image scaling prototype (not ready for production)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,5 +89,29 @@ namespace QuestPDF.Examples
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImageResolutionScaling()
|
||||
{
|
||||
var image = Image.FromFile("large-image.jpg");
|
||||
|
||||
Document
|
||||
.Create(document =>
|
||||
{
|
||||
document.Page(page =>
|
||||
{
|
||||
page.Size(11000, 11000);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,12 @@
|
||||
<None Update="pdf-icon.svg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="large-image.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="large-image.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
Reference in New Issue
Block a user