更新时间:2023-02-12 21:15:31
图书馆 pdfiumviewer 可能会对您有所帮助。它也可以作为nuget使用。
The library pdfiumviewer might be helpful here. It is also available as nuget.
尝试以下代码(更改路径以适合您的设置)。
Try out the following code (change paths to suit your setup).
try
{
using (var document = PdfiumViewer.PdfDocument.Load(@"input.pdf"))
{
var image = document.Render(0, 300, 300, true);
image.Save(@"output.png", ImageFormat.Png);
}
}
catch (Exception ex)
{
// handle exception here;
}
编辑2:更改代码以显示页面索引为0正如SC下面的评论所指出的
编辑1:更新解决方案 你试过pdfsharp吗?
Edit 1: Updated solution
Have you tried pdfsharp?