我想要获得与使用 Adobe Acrobat 中的将 pdf 导出为 png 相同的图像质量。
但不知怎的,这对我不起作用。如果我借助 Adobe Acrobat 工具将 pdf 导出为 png,得到的尺寸为: 宽度:11264 pix 高度:15940 pix
正如您所看到的,我为您提供了阅读 pdf 并在每页创建图像的方法。我的可能性是使用 .Render 方法,它需要int page(index) float dpiX, float dpiY, bool forPrinting
但有些怎么对保存的图像没有影响呢?
using (var document = PdfiumViewer.PdfDocument.Load(file))
{
//This int is used to get the page count for each document
int pagecount = document.PageCount;
//With the int pagecount we can create as may screenshots as there are pages in the document
for (int index = 0; index < pagecount; …Run Code Online (Sandbox Code Playgroud) 我想阅读我的PDF的所有页面并将它们保存为图像,到目前为止我所做的只是让我0 = 1首先定义的页面等等.我是否有机会定义范围?
static void Main(string[] args)
{
try
{
string path = @"C:\Users\test\Desktop\pdfToWord\";
foreach (string file in Directory.EnumerateFiles(path, "*.pdf")) {
using (var document = PdfiumViewer.PdfDocument.Load(file))
{
int i = 1;
var image = document.Render(0,300,300, true);
image.Save(@"C:\Users\test\Desktop\pdfToWord\output.png", ImageFormat.Png);
}
}
}
catch (Exception ex)
{
// handle exception here;
}
Run Code Online (Sandbox Code Playgroud)