C# code tutorial

PDF to Image PDF Creating & Inserting PDF Digital Signature PDF Extracting PDF Processing & Editing PDF Protecting PDF Chart PDF Barcode

Popular .NET SDK

Convert PDF to JPG, split PDF document to individual jpg images. Supports all versions of PDF 1.0 - 1.7.

PDF to jpeg conversion is a tool to quickly take your vector-based file format (PDF document) and rasterize it to a pixel-based format (raster image file).

XsPDF .NET PDF to Jpg converting control supports converting PDF document to a range of high-quality separate jpg image files in .NET development using C# programming language. The advantage PDF to jpeg library is taking low memory and thread safe. Owing to jpg image's small-size feature, it's counted as a more suitable choice for publishing in web services than PDF document file.

In this article, it shows how to change PDF file to a group of jpeg images and pictures in C# class application. Developers can customize the converted image size and DPI resolution. Thumbnails can be created from PDF pages. Password protected PDF document can be converted and changed to Jpeg image files.

Guide in Visual Studio
  1. Please firstly download our .NET PDF to Image SDK free package.
  2. Create a sample project in Visual Studio, like a Console Application or ASP.NET Web Application.
  3. Copy "XsPDF.dll" from unzipped folder to your .NET project Bin folder. Besides "XsPDF.dll", also copy the folder of suitable "XsPDF.Native.dll" based on your system, x86 or x64.
  4. Add your project reference to "XsPDF.dll" and "System.Drawing". Ready to perform conversion now.
How to Convert PDF to JPG in C#.NET class?

Now let’s move to test PDF to jpeg conversion features in your sample project. The following is a piece of C#.NET class code that shows how to load a PDF file and convert it to jpeg images. You can easily choose to keep the original page size or not.

// Create a PDF converter instance by loading a local file 
PdfImageConverter pdfConverter = new PdfImageConverter("sample.pdf");

// Set the dpi, the output image will be rendered in such resolution
pdfConverter.DPI = 96;

// the output image will be rendered to grayscale image or not
pdfConverter.GrayscaleOutput = false;

for (int i = 0; i < pdfConverter.PageCount; i++)
    // Convert each pdf page to jpeg image with original page size
    //Image pageImage = pdfConverter.PageToImage(i);
    // Convert pdf to jpg in customized image size
    Image pageImage = pdfConverter.PageToImage(i, 500, 800);

    // Save converted image to jpeg format
    pageImage.Save("Page " + i + ".jpg", ImageFormat.Jpeg);

More Excel tutorial