푸터 콘텐츠로 바로가기
IRONPDF 사용

How to Convert a PDF to an Image in C#

Converting PDFs to images in C# is pretty common. You might want thumbnails, web previews, or even archive copies. With IronPDF, this process is becomes an easy task. This is thanks to its RasterizeToImageFiles method, which lets you convert PDF files into image files like PNG images, JPEG images, TIFF images, or BMP with just a few lines of code.

In this article, we’ll walk through everything you need to know to convert PDFs to PNG, JPG, TIFF, or BMP. You’ll see how to handle full documents, specific page ranges, and even web pages rendered as PDFs. By the end, you’ll have a solid workflow for generating high-quality images from PDFs in your .NET projects.

Why Convert PDF Documents to Images in C#?

Converting PDF pages to images has practical applications in modern .NET Framework or .NET apps. Document management systems need thumbnails for fast visual navigation, while web apps benefit from image formats for better browser compatibility and faster load times.

Additionally, converting PDFs to images makes sure your PDF looks right on any platform with limited PDF library support. Whether you’re working with multiple pages or a single page, IronPDF handles this process in just a few lines of code without worrying about errors or complicated rendering.

Getting Started with IronPDF

First, create a new C# console application in Visual Studio and install IronPDF via NuGet Package Manager:

Install-Package IronPdf

How to Convert a PDF to an Image in C#: Figure 1 - IronPDF being Installed via the NuGet Package Manager Console

IronPDF supports .NET Framework, .NET Core, and .NET 5+, ensuring your PDF to images workflow is compatible with any version of .NET you're using. Once installed, you can start converting PDF pages to image files in your program.

How to Convert PDF Pages to Image Files?

The simplest way to convert a PDF to images involves loading the document and calling the RasterizeToImageFiles method:

using IronPdf;
class Program
{
    static void Main(string[] args)
    {
        // Load an existing PDF document
        var pdfDocument = PdfDocument.FromFile("report.pdf");
        // Convert all pages to PNG images
        pdfDocument.RasterizeToImageFiles(@"C:\images\page_*.png");
    }
}
using IronPdf;
class Program
{
    static void Main(string[] args)
    {
        // Load an existing PDF document
        var pdfDocument = PdfDocument.FromFile("report.pdf");
        // Convert all pages to PNG images
        pdfDocument.RasterizeToImageFiles(@"C:\images\page_*.png");
    }
}
$vbLabelText   $csharpLabel

This code converts each page of the PDF into a separate PNG file. The asterisk (*) in the filename pattern gets replaced with the page number automatically. For proper resource management, wrap the PdfDocument in a using statement to ensure disposal.

After running the code, we can see in the output directory that even though our PDF has multiple pages within it, our code doesn't specify what pages to convert, so each one has been saved as an individual image file:

How to Convert a PDF to an Image in C#: Figure 2 - PDF to Image example for converting all pages

For converting specific pages, specify the page range:

// Specify the page indexes for conversion
int[] pageIndexes = new[] { 0, 1, 2 };
// Convert pages 1-3 to JPG images
pdfDocument.RasterizeToImageFiles(@"C:\images\page_*.jpg", pageIndexes);
// Specify the page indexes for conversion
int[] pageIndexes = new[] { 0, 1, 2 };
// Convert pages 1-3 to JPG images
pdfDocument.RasterizeToImageFiles(@"C:\images\page_*.jpg", pageIndexes);
$vbLabelText   $csharpLabel

Note that page indexing starts at 0, so the first page has pageIndex = 0.

How to Convert a PDF to an Image in C#: Figure 3 - Specified PDF pages converted to image

How to Control Image Quality?

Image quality directly impacts file size and visual clarity. IronPDF lets you control this through DPI (dots per inch) settings:

// High-quality conversion at 300 DPI
pdfDocument.RasterizeToImageFiles(@"C:\images\high_quality_*.png", DPI: 300);
// Web-optimized at 150 DPI
pdfDocument.RasterizeToImageFiles(@"C:\images\web_*.jpg", DPI: 150);
// High-quality conversion at 300 DPI
pdfDocument.RasterizeToImageFiles(@"C:\images\high_quality_*.png", DPI: 300);
// Web-optimized at 150 DPI
pdfDocument.RasterizeToImageFiles(@"C:\images\web_*.jpg", DPI: 150);
$vbLabelText   $csharpLabel

The default 96 DPI works for basic previews, but increase it to 150-300 DPI for print-quality images. Higher DPI values produce sharper images but larger file sizes.

How to Convert a PDF to an Image in C#: Figure 4 - High-quality converted PDF beside the original

Which Image Formats Are Supported?

IronPDF supports multiple image formats through the ImageType parameter:

// Convert to different formats
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.png", IronPdf.Imaging.ImageType.Png);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.jpg", IronPdf.Imaging.ImageType.Jpeg);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.tiff", IronPdf.Imaging.ImageType.Tiff);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.bmp", IronPdf.Imaging.ImageType.Bitmap);
// Convert to different formats
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.png", IronPdf.Imaging.ImageType.Png);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.jpg", IronPdf.Imaging.ImageType.Jpeg);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.tiff", IronPdf.Imaging.ImageType.Tiff);
pdfDocument.RasterizeToImageFiles(@"C:\images\output_*.bmp", IronPdf.Imaging.ImageType.Bitmap);
$vbLabelText   $csharpLabel

Choose PNG for images requiring transparency, JPEG for photographs and web content, TIFF for archival purposes, and BMP when uncompressed images are needed. The IronPDF API reference provides detailed information about all supported ImageType options.

How to Handle Advanced Scenarios?

IronPDF excels at handling complex PDF to image conversion scenarios. One particularly useful feature is converting web pages directly to images via PDF rendering. For more HTML conversion options, explore the HTML to PDF conversion guide:

// Convert a webpage to images
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument webPdf = renderer.RenderUrlAsPdf("https://apple.com");
webPdf.RasterizeToImageFiles(@"C:\images\webpage_*.png", DPI: 200);
// Convert a webpage to images
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument webPdf = renderer.RenderUrlAsPdf("https://apple.com");
webPdf.RasterizeToImageFiles(@"C:\images\webpage_*.png", DPI: 200);
$vbLabelText   $csharpLabel

This approach captures dynamic web content perfectly, maintaining all styling and JavaScript-rendered elements.

For batch processing multiple PDFs, implement a simple loop:

string[] pdfFiles = Directory.GetFiles(@"C:\pdfs", "*.pdf");
foreach (string pdfPath in pdfFiles)
{
    using (var pdf = PdfDocument.FromFile(pdfPath))
    {
        string outputPath = Path.Combine(@"C:\images", 
            Path.GetFileNameWithoutExtension(pdfPath) + "_*.png");
        pdf.RasterizeToImageFiles(outputPath);
    }
}
string[] pdfFiles = Directory.GetFiles(@"C:\pdfs", "*.pdf");
foreach (string pdfPath in pdfFiles)
{
    using (var pdf = PdfDocument.FromFile(pdfPath))
    {
        string outputPath = Path.Combine(@"C:\images", 
            Path.GetFileNameWithoutExtension(pdfPath) + "_*.png");
        pdf.RasterizeToImageFiles(outputPath);
    }
}
$vbLabelText   $csharpLabel

Conclusion

IronPDF makes it easy to convert PDF documents into image files in C#. Whether you’re creating thumbnails, PNG images, JPEG images, or handling TIFF conversion for multiple pages, the RasterizeToImageFiles method handles everything.

You can customize output formats, control image quality with DPI settings, and even convert web pages rendered as PDFs into images, all without complex setup. For more advanced PDF features, check IronPDF's extensive documentation that includes sample code and explanations to explore everything IronPDF can do.

Ready to implement PDF to image conversion in your C# application? Start with a free trial for unlimited conversions and priority support.

자주 묻는 질문

C#을 사용하여 PDF를 이미지로 변환하려면 어떻게 해야 하나요?

최소한의 코딩 작업으로 PDF 문서를 PNG, JPEG, TIFF 또는 BMP와 같은 다양한 이미지 형식으로 변환할 수 있는 RasterizeToImageFiles 메서드를 제공하는 IronPDF 라이브러리를 사용할 수 있습니다.

IronPDF는 PDF 변환을 위해 어떤 이미지 형식을 지원하나요?

IronPDF는 PDF 파일을 PNG, JPEG, TIFF, BMP 등 여러 이미지 형식으로 변환하는 기능을 지원합니다.

PDF를 C#으로 이미지로 변환해야 하는 이유는 무엇인가요?

PDF를 이미지로 변환하는 것은 썸네일, 웹 미리 보기를 만들거나 PDF보다 이미지가 더 적합한 보관 목적에 유용할 수 있습니다.

IronPDF는 PDF를 이미지로 변환하는 데 사용하기 쉬운가요?

예, IronPDF는 개발자 친화적으로 설계되어 몇 줄의 코드만으로 RasterizeToImageFiles 기능을 사용하여 PDF를 이미지로 변환할 수 있습니다.

IronPDF는 여러 페이지의 PDF를 이미지로 변환할 수 있나요?

예, IronPDF는 여러 페이지로 구성된 PDF 문서를 처리할 수 있으므로 각 페이지를 별도의 이미지 파일로 변환할 수 있습니다.

IronPDF는 PDF 문서를 고해상도 이미지로 변환할 수 있나요?

IronPDF를 사용하면 출력 이미지의 해상도를 지정할 수 있으므로 PDF 문서에서 고해상도 이미지를 생성할 수 있습니다.

IronPDF는 .NET 10과 호환되나요?

Yes-IronPDF는 .NET 10 프로젝트와 완벽하게 호환되며, PDF-이미지 변환, HTML 렌더링, RasterizeToImageFiles API와 같은 모든 일반적인 기능을 해결 방법 없이 .NET 10 애플리케이션에서 바로 사용할 수 있도록 지원합니다.

PDF를 이미지로 변환하기 위해 어떤 .NET 버전과 플랫폼을 지원하나요?

IronPDF는 .NET 10, 9, 8, 7, 6, 5, .NET Core, .NET Standard 및 .NET Framework를 지원합니다. 컨테이너화된 환경을 포함하여 Windows, macOS, Linux에서 작동합니다.

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.