PDF to JPEG Converter
The Documentize PDF to JPEG Converter for .NET is a powerful tool that simplifies the conversion of PDF documents into high-quality JPEG images. This plugin is designed to make your content more accessible across platforms by transforming PDF pages into widely-used image formats.
How to Convert PDF Pages to JPEG
To convert a PDF document into JPEG images, follow these steps:
- Create an instance of
PdfToJpegOptions
to configure the conversion process. - Add the input PDF File using the
AddInput
method. - Set the output Directory path for the JPEG images using the
AddOutput
method. - Run the
Process
method to convert the PDF pages into JPEG images.
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Add input File path
4options.AddInput(new FileDataSource("path_to_input.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
7// Perform the process
8JpegConverter.Process(options);
Customizing PDF to JPEG Conversion
You can customize the conversion process by adjusting resolution, selecting page ranges, or setting image quality. Here’s how to convert the first page of a PDF at 200 DPI:
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Process only the first page
4options.PageList = new List<int> { 1 };
5// Set output resolution to 200 DPI
6options.OutputResolution = 200;
7// Set output quality to 50
8options.Quality = 50;
9// Add input File path
10options.AddInput(new FileDataSource("path_to_input.pdf"));
11// Set output Directory path
12options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
13// Perform the process
14JpegConverter.Process(options);
How to get results without a directory, or in the form of streams
The Process method returns a ResultContainer
object that holds information about the conversion results. You can get streams of the converted JPEG files as shown below:
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Add input File path
4options.AddInput(new FileDataSource("path_to_input.pdf"));
5// Perform the process
6var results = JpegConverter.Process(options);
7// Get stream results
8foreach (var result in results.ResultCollection)
9{
10 var streamResultPage1 = result.ToStream();
11}
Key Features:
- Convert PDF to JPEG: Effortlessly convert entire PDF documents or specific pages into JPEG images.
- Custom Resolution: Adjust the resolution (e.g., 300 dpi) for high-quality outputs.
- Page set: Select specific pages for conversion.
- Quick Conversion: Fast and efficient process with minimal effort.