PDF to PNG - pqScan.com
C# PDF to PNG Conversion Converting PDF into PNG Image Files in C# Using .NET PDF Converter SDK Online Demo Download Trial Purchase Now

How to Convert PDF to PNG in C# .NET?

back to home  >  .NET PDF to Image SDK  >  How to Convert PDF to Image in .NET  >  C# PDF to PNG Converting Guide

To achieve fast and accurate PDF to PNG conversion in CSharp, you may use pqScan PDF to Image SDK for .NET, affordable and competitive PDF converter software. This .NET PDF library is compatible with all .NET Frameworks 2.0 and upwards, and can be included in any .NET program (ASP.NET, WinForms, Console application, etc). Of course, x86 and x64 platforms are supported with no doubt.

In order to use advanced PDF document conversion function of this .NET library in C# application, like converting PDF to PNG image, you need to download free trial package online and copy the file "PQScan.PDFToImage.dll" into your Bin folder, and then add a reference to it.

Convert PDF File to PNG Image - C# Sample

This C# sample introduces how to load a PDF document from file at disk, and then render and convert it to PNG image file in C# .NET project using pqScan PDF to Image Converter SDK.

using System;
using System.Drawing;
using System.Drawing.Imaging;
using PQScan.PDFToImage;

namespace PDF2PNG
{
  class Program
  {
    static void Main(string[] args)
    {
      // Create an instance of PQScan.PDFToImage.PDFDocument object.
      PDFDocument pdfDoc = new PDFDocument();

      // Load a PDF document.
      pdfDoc.LoadPDF("sample.pdf");

      // Get its total page count.
      int count = pdfDoc.PageCount;

      for (int i = 0; i < count; i++)
      {
        // Convert page to image.
        Bitmap pngImage = pdfDoc.ToImage(i);

        // Save image as png file format.
        pngImage.Save("output" + i + ".png", ImageFormat.Png);
      }
    }
  }
}

We also offer Visual C# demo for how to change and turn PDF file stream to PNG image file format. Moreover, in this coding sample, PNG image size can be set.

using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using PQScan.PDFToImage;

namespace PDFToPNG
{
  class Program
  {
    static void Main(string[] args)
    {
      // Make a new instance of PQScan.PDFToImage.PDFDocument object.
      PDFDocument pdf = new PDFDocument();

      // Create a file stream with PDF message.
      FileStream stream = new FileStream("sample.pdf", FileMode.Open);

      // Load PDF document from file stream.
      pdf.LoadPDF(stream);

      // Set rendered png image width.
      int width = pdf.GetPageWidth(0) / 2;

      // Set rendered png image height.
      int height = pdf.GetPageHeight(0) / 2;

      // Convert the first PDF page to image with the required size.
      Bitmap png = pdf.ToImage(0, width, height);

      // Save image to png file format.
      png.Save("result.png", ImageFormat.Png);
    }
  }
}

convert pdf to png in c#

For more help of changing rendered image size, please see online guide: How to change image size while converting from PDF page using C#.

pqScan SDK
.NET PDF to Image Software
Online Guide
.NET PDF to Image Converting
Conversion Type
Converting PDF to JPEG in .NET Converting PDF to Multi-page TIF in .NET Converting PDF to Bitmap in C# Converting PDF to Multi-page TIFF in C# Converting PDF to GIF in VB.NET Converting PDF to JPG in VB.NET Converting PDF to BMP in VB.NET Converting PDF to TIFF in ASP.NET View All Image Types >>
We've found pqScan .NET PDF to Image on Google and this component significantly reduces the development time (about 50%). In addition, the awesome support you provide really helps us a lot. Thanks pqScan Team! Borg Higgins