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.

How to Convert PDF to PNG

To convert a PDF document into PNG images, follow these steps:

  1. Create an instance of PdfToPngOptions to configure the conversion process.
  2. Add the input PDF File using the AddInput method.
  3. Set the output Directory path for the PNG images using the AddOutput method.
  4. Run the Process method to convert the PDF pages into PNG images.
1// Create PdfToPngOptions object to set instructions
2var options = new PdfToPngOptions();
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
8PngConverter.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 200 DPI:

 1// Create PdfToPngOptions object to set instructions
 2var options = new PdfToPngOptions()
 3// Process only the first page
 4options.PageList = new List<int> { 1 };
 5// Set output resolution to 200 dpi
 6options.OutputResolution = 200;
 7// Add input File path
 8options.AddInput(new FileDataSource("path_to_input.pdf"));
 9// Set output Directory path
10options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
11// Perform the process
12PngConverter.Process(options);

Handling Conversion Results

The Process method returns a ResultContainer object that holds information about the conversion results. You can get streams of the converted PNG files as shown below:

 1// Create PdfToJpegOptions object to set instructions
 2var options = new PdfToPngOptions();
 3// Add input File path
 4options.AddInput(new FileDataSource("path_to_input.pdf"));
 5// Perform the process
 6var results = PngConverter.Process(options);
 7// Get stream results
 8foreach (var result in results.ResultCollection)
 9{
10    var streamResultPage1 = result.ToStream();
11}

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.
  • Page set: Select specific pages for conversion.
  • Easy Output Management: Specify output directories for each converted PNG file.
  • Quick Conversion: Fast, efficient, and requires minimal effort to configure.
 English