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

How to Convert PDF to JPG in .NET

This tutorial will use IronPDF for C# .NET to convert PDF to JPG images.

IronPDF - .NET Library

IronPDF for .NET is a library that allows users to create, edit, and manage PDF files. It is very popular among C# developers because of its PDF generation component, which allows them to work with PDF files without Adobe Acrobat installed. IronPDF for .NET allows conversion between different formats like HTML to PDF, URL to PDF, and Images to PDF.

It also supports adding custom headers & footers, digital signatures, annotations, and attachments, user and owner passwords, and other security options. IronPDF has a fast Chromium Engine for a better rendering experience. It renders a pixel-perfect PDF. It also provides full multithreading and async support.

Now, the next section will discuss how to convert PDF format to image formats like PNG or JPG programmatically using IronPDF.

Prerequisites

Before starting, Visual Studio's latest version is recommended to be downloaded from the official Visual Studio website and installed. This is necessary for building C# apps, helping set up the .NET environment, and preparing to make a PDF to JPG converter.

IronPDF Installation

To install IronPDF, there are multiple ways:

  1. You can download IronPDF using the NuGet Package Manager into your C# project created using Visual Studio. Access NuGet Package Manager via Tools or by right-clicking Solution Explorer. Browse for the IronPDF package and install it.
  2. Another way to install IronPDF is by directly downloading it from the NuGet IronPDF page.

Convert PDF File to Images using IronPDF

Load PDF Document

To load a PDF file from a local location into this project, IronPDF provides a FromFile method present in the PdfDocument class. The following code example helps to open an existing PDF file for editing:

using IronPdf;

// Load the PDF document from a local path
PdfDocument pdf = PdfDocument.FromFile("Example.pdf");
using IronPdf;

// Load the PDF document from a local path
PdfDocument pdf = PdfDocument.FromFile("Example.pdf");
$vbLabelText   $csharpLabel

Convert PDF Documents to Images

Now, the file is opened for editing. IronPDF provides a RasterizeToImageFiles method to convert PDF pages to Image format. With the following one line of code, it is very easy to convert the entire PDF document into JPG images using IronPDF's Rasterize Method.

// Convert all pages of the PDF into JPG images and save them to the specified folder
pdf.RasterizeToImageFiles(@"C:\image\folder\*.jpg");
// Convert all pages of the PDF into JPG images and save them to the specified folder
pdf.RasterizeToImageFiles(@"C:\image\folder\*.jpg");
$vbLabelText   $csharpLabel

The converted files from the above code will be saved in the given path. The PDF contains 562 pages, and IronPDF takes no time to convert all PDF pages to JPG images. The RasterizeToImageFiles method does all the hard work, and the name of images is a digit that starts from 1 and is incremented by each page.

How to Convert PDF to JPG in .NET, Figure 2: The images extracted from the PDF file The images extracted from the PDF file

Convert Specific PDF Pages

The RasterizeToImageFiles method provides other options too for more control over PDF Pages to JPG conversion. The following code helps to convert PDF pages in a range from page 11 to 21.

using System.Collections.Generic;
using System.Linq;

// Set the Page Range
IEnumerable<int> pageIndexes = Enumerable.Range(10, 11); // Corrected range to cover pages 11 to 21

// Path, PageIndexes, ImageType and Dimensions may be specified
pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", pageIndexes, 850, 650, IronPdf.Imaging.ImageType.Default, 300);
using System.Collections.Generic;
using System.Linq;

// Set the Page Range
IEnumerable<int> pageIndexes = Enumerable.Range(10, 11); // Corrected range to cover pages 11 to 21

// Path, PageIndexes, ImageType and Dimensions may be specified
pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", pageIndexes, 850, 650, IronPdf.Imaging.ImageType.Default, 300);
$vbLabelText   $csharpLabel

In the above convert a range of PDF pages to JPG example using IronPDF, a lot of things are happening. Let's have a look at them one by one.

  • First Parameter: A valid path with an optional image extension is provided as a string.
  • Second Parameter: pageIndexes provide a page range that needs to be converted to JPG images programmatically.
  • Third Parameter: Specify the maximum image width in pixels.
  • Fourth Parameter: Specify the maximum height of the image in pixels.
  • Fifth Parameter: The default image type will save images in PNG format if the extension is not mentioned in the path. Other formats available include PNG, GIF, TIFF, JPG, and Bitmap.
  • Sixth Parameter: Set the desired resolution of the output image files. Except for Windows, DPI will be ignored in Linux and macOS.

The JPG conversion output will be:

How to Convert PDF to JPG in .NET, Figure 2: The images extracted with more control The images extracted with more control

Convert URL to PDF and then PDF to Images

Sometimes there is a need to capture the products listed on a website as images for some purpose. Let's say there are hundreds of products listed on a website page. Taking screenshots will be a time-consuming and hectic task. IronPDF provides the facility to convert a URL to PDF and use the generated PDF document to save each page to an image.

The following code takes the Amazon website page as a URL and renders it to a pixel-perfect PDF. After that, each page of the generated PDF is converted to a separate JPG file.

using IronPdf;

// Create a PDF renderer using the Chromium rendering engine
ChromePdfRenderer renderer = new ChromePdfRenderer();

// Render the URL to a PDF document
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.amazon.com/?tag=hp2-brobookmark-us-20");

// Convert each page of the PDF to separate JPG image files
pdf.RasterizeToImageFiles(@"C:\image\folder\amazon_pdf_image_*.jpg");
using IronPdf;

// Create a PDF renderer using the Chromium rendering engine
ChromePdfRenderer renderer = new ChromePdfRenderer();

// Render the URL to a PDF document
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.amazon.com/?tag=hp2-brobookmark-us-20");

// Convert each page of the PDF to separate JPG image files
pdf.RasterizeToImageFiles(@"C:\image\folder\amazon_pdf_image_*.jpg");
$vbLabelText   $csharpLabel

How to Convert PDF to JPG in .NET, Figure 3: Extracted images from an Amazon website Extracted images from an Amazon website

Conclusion

This article demonstrated how to convert PDF documents to JPG images using IronPDF for the .NET Framework. The RasterizeToImageFiles method produces images that contain the page number along with the document name, as shown in the above code examples. IronPDF can convert PDF pages into images in different formats: PNG, JPG, GIF, and many more.

The IronPDF Library provides full control over the output image format, dimensions, and resolution to its users. IronPDF also provides other PDF tools such as rotating PDF pages, changing PDF text, setting margins, etc. To learn more about IronPDF for .NET and to access additional features to manipulate PDF files, please refer to the following IronPDF examples for PDF manipulation. For more information on how to convert PDF to different format images, visit these code samples for IronPDF JPG conversion.

The IronPDF .NET Library is free for development but needs to be licensed for commercial use at Iron Software Licensing Page.

Download the IronPDF for .NET Library Zip File and give it a try.

자주 묻는 질문

.NET에서 PDF를 JPG로 변환하려면 어떻게 해야 하나요?

IronPDF의 RasterizeToImageFiles 메서드를 사용하여 PDF 페이지를 JPG 이미지로 변환할 수 있습니다. 이 메서드를 사용하면 출력 이미지 형식, 크기 및 해상도를 제어할 수 있습니다.

IronPDF를 사용하여 PDF의 특정 페이지를 JPG로 변환할 수 있나요?

예, IronPDF를 사용하면 RasterizeToImageFiles 메서드에서 페이지 범위를 지정하여 PDF의 특정 페이지를 JPG로 변환할 수 있습니다.

.NET 프로젝트에 IronPDF를 설치하려면 어떻게 하나요?

IronPDF는 Visual Studio의 NuGet 패키지 관리자를 사용하여 설치할 수 있습니다. 패키지 관리자에서 IronPDF를 검색하여 프로젝트에 추가할 수 있습니다.

JPG 이미지로 변환하기 전에 URL을 PDF로 변환할 수 있나요?

예, IronPDF는 Chromium 렌더링 엔진을 사용하여 URL을 PDF로 변환한 다음 결과 PDF를 JPG 이미지로 변환할 수 있습니다.

IronPDF에서 PDF 변환을 위해 지원하는 이미지 형식은 무엇인가요?

IronPDF는 PDF 페이지를 JPG, PNG, GIF, TIFF, 비트맵을 포함한 여러 이미지 형식으로 변환하는 기능을 지원합니다.

IronPDF는 상업적 사용을 위한 라이선스가 필요하나요?

IronPDF는 개발 목적으로는 무료이지만 상업적으로 사용하려면 라이선스가 필요합니다. 라이선스 세부 정보는 Iron 소프트웨어 라이선스 페이지에서 확인할 수 있습니다.

Windows 이외의 운영 체제에서도 IronPDF를 사용할 수 있나요?

IronPDF는 주로 Windows 환경을 위해 설계되었지만 DPI 설정과 같은 일부 기능이 완전히 지원되지 않을 수 있지만 Linux 및 macOS에서도 사용할 수 있습니다.

IronPDF의 고급 기능에는 어떤 것이 있나요?

IronPDF는 사용자 정의 머리글 및 바닥글 추가, 디지털 서명, 주석 및 첨부 파일 추가와 같은 고급 기능을 제공합니다. 또한 멀티 스레딩 및 비동기 작업을 지원하여 성능을 향상시킵니다.

PDF를 JPG 이미지로 변환할 때 IronPDF가 .NET 10과 호환되나요?

예, IronPDF는 .NET 10과 완벽하게 호환되며, RasterizeToImageFiles와 같은 PDF-이미지 변환 메서드를 포함하므로 호환성 문제 없이 .NET 10 프로젝트에서 PDF 페이지를 JPG 이미지로 변환할 수 있습니다.

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

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

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