C# PDF 转换为图像代码示例(无质量损失)
using IronPdf;
using IronSoftware.Drawing;

var pdf = PdfDocument.FromFile("Example.pdf");

// Extract all pages to a folder as image files
pdf.RasterizeToImageFiles(@"C:\image\folder\*.png");

// Dimensions and page ranges may be specified
pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80);

// Extract all pages as AnyBitmap objects
AnyBitmap[] pdfBitmaps = pdf.ToBitmap();
NuGet Download
PM > Install-Package IronPdf
C# PDF 转换为图像代码示例(无质量损失)

C# PDF 转换为图像代码示例(无质量损失)

要将PDF文档转换为图像,可以在RasterizeToImageFiles方法。 可以使用PdfDocument.FromFile方法加载PDF文档,或者使用适用于.NET Core的任意PDF生成方法。

RasterizeToImageFiles将PDF的每一页渲染为光栅化图像。 第一个参数指定每个图像应使用的命名模式。 可以使用可选参数来自定义每个图像的质量和尺寸。 另一个选项允许该方法将选定的 PDF 页面转换为图像。

精选代码示例的第24行展示了ToBitMap方法。 在任何AnyBitmap对象。

学习使用 IronPDF 将 PDF 栅格化为图像
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 21,916,531版本:2026.11刚刚发布