PDF to PNG Converter
The Documentize PDF to PNG Converter for .NET is an advanced tool that allows you to convert PDF documents into high-quality PNG images. This plugin is designed to make your content more versatile, accessible, and easier to share by transforming PDF pages into widely supported image formats.
Key Features:
- Convert PDF to PNG: Quickly and efficiently convert entire PDF documents or specific pages into PNG images.
- Customizable Resolution: Set the desired DPI (e.g., 300 DPI) for high-quality image output.
- Batch Processing: Convert multiple PDF pages or entire documents in one go.
- Easy Output Management: Specify output directories for each converted PNG file.
- Quick Conversion: Fast, efficient, and requires minimal effort to configure.
How to Convert PDF to PNG
To convert a PDF document into PNG images, follow these steps:
- Create an instance of the
Png
class. - Create an instance of
PngOptions
to configure the conversion process. - Add the input PDF file using the
AddInput
method. - Specify the output directory for the PNG images using the
AddOutput
method. - Run the
Process
method to convert the PDF pages into PNG images.
1var converter = new Png();
2var options = new PngOptions();
3
4// Add the input PDF file
5options.AddInput(new FileDataSource(@"C:\Samples\sample.pdf"));
6
7// Specify output directory for PNG images
8options.AddOutput(new FileDataSource(@"C:\Samples\images"));
9
10// Process the PDF to PNG conversion
11converter.Process(options);
Customizing PDF to PNG Conversion
You can customize the conversion by adjusting the resolution and selecting specific pages. For example, to convert only the first page of a PDF at 300 DPI:
1var converter = new Png();
2var options = new PngOptions();
3
4// Set output resolution to 300 DPI
5options.OutputResolution = 300;
6
7// Convert only the first page
8options.PageRange = new PageRange(1);
9
10// Add input and output paths
11options.AddInput(new FileDataSource(@"C:\Samples\sample.pdf"));
12options.AddOutput(new FileDataSource(@"C:\Samples\output_page_1.png"));
13
14// Process the conversion
15converter.Process(options);
Batch Processing for PDF to PNG Conversion
The PDF to PNG Converter plugin also supports batch processing, allowing you to convert multiple pages or even entire PDF documents into individual PNG files.
1var converter = new Png();
2var options = new PngOptions();
3
4// Add input PDF file
5options.AddInput(new FileDataSource(@"C:\Samples\input.pdf"));
6
7// Set output paths for each page
8options.AddOutput(new FileDataSource(@"C:\Samples\output_page_1.png"));
9options.AddOutput(new FileDataSource(@"C:\Samples\output_page_2.png"));
10
11// Process the batch conversion
12converter.Process(options);
Handling Conversion Results
After processing the conversion, the Process method returns a ResultContainer
object containing the conversion results. You can print the output paths of the PNG images as follows:
1ResultContainer resultContainer = converter.Process(options);
2
3// Print the output paths of the PNG images
4foreach (FileResult result in resultContainer.ResultCollection)
5{
6 Console.WriteLine(result.Data.ToString());
7}