.NET 6 使用NuGet下载pdfium.dll,已经安装了PdfiumViewer.Updated的2.14.4版本
时间: 2024-02-24 10:58:32 浏览: 31
如果你已经安装了PdfiumViewer.Updated的2.14.4版本,那么pdfium.dll应该已经被包含在该包中了,你可以尝试以下解决方法:
1. 确认你的项目引用了PdfiumViewer.Updated包。在Visual Studio的Solution Explorer中,找到你的项目,右键点击“References”,选中“Add Reference”,在“NuGet”选项卡中找到并添加PdfiumViewer.Updated包。
2. 确认你的项目已经正确引用了PdfiumViewer库。在代码中,使用以下语句引用PdfiumViewer库:
```
using PdfiumViewer;
```
3. 确认你的代码中使用的PdfiumViewer版本是否与你安装的PdfiumViewer.Updated版本一致。如果你的代码中使用的PdfiumViewer版本与你安装的PdfiumViewer.Updated版本不一致,可能会导致找不到pdfium.dll的错误。
如果你已经按照以上步骤进行了操作,但是仍然出现找不到pdfium.dll的错误,请检查你的项目是否正确设置了pdfium.dll的目录,或者尝试重新安装PdfiumViewer.Updated包。
希望以上解决方法能够帮到你解决问题。
相关问题
在.NET 6里NuGet源中什么版本的Ghostscript可以将PDF转成图片
在.NET 6的NuGet源中,可以使用Ghostscript.NET.Standard 1.2.0版本来将PDF转成图片。Ghostscript.NET是一个.NET封装库,它提供了Ghostscript的API接口,可以方便地在.NET中使用Ghostscript。在使用Ghostscript.NET时,需要将Ghostscript的安装目录添加到系统环境变量中,以便Ghostscript.NET能够找到Ghostscript可执行文件。以下是使用Ghostscript.NET来将PDF转成图片的示例代码:
```csharp
using Ghostscript.NET;
using Ghostscript.NET.Rasterizer;
string inputFile = @"C:\input.pdf";
string outputFile = @"C:\output.png";
using (var rasterizer = new GhostscriptRasterizer())
{
rasterizer.Open(inputFile);
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
var img = rasterizer.GetPage(300, 300, pageNumber);
img.Save(outputFile, ImageFormat.Png);
}
}
```
在上面的示例代码中,首先创建一个GhostscriptRasterizer对象,然后打开PDF文件,遍历每一页,将每一页转成PNG格式的图片,最后保存到指定的输出文件中。请注意,此示例代码需要在已安装Ghostscript的计算机上运行。
.NET 6 如何使用System.Drawing.Common将PDF转换成图片
要将PDF文件转换为图片,需要使用System.Drawing.Common和PdfRenderer NuGet包。以下是.NET 6中将PDF文件转换为图片的示例代码:
```csharp
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using PdfRenderer;
// Load the PDF file
using var stream = new FileStream("example.pdf", FileMode.Open, FileAccess.Read);
var document = PdfDocument.Load(stream);
// Convert each page of the PDF document to an image
for (var i = 0; i < document.PageCount; i++)
{
var page = document.GetPage(i);
using var image = new Bitmap(page.Width, page.Height);
using var graphics = Graphics.FromImage(image);
graphics.Clear(Color.White);
page.Render(graphics);
// Save the image to a file
var fileName = $"page{i + 1}.png";
image.Save(fileName, ImageFormat.Png);
}
```
这段代码使用PdfRenderer库加载PDF文件并将每个页面转换为图像。每个页面都作为Bitmap对象渲染,然后使用Save()方法将其保存为PNG文件。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)