Guide for C#
Core Document Formats
PDF to Raster Image (Bmp, Gif, Jpeg, Png)
Additional Features

C# PDF - Render PDF to Raster Images

How to Convert & Render PDF to Raster Images (Bmp, Gif, Jpeg, Png, Tiff) in C#

Visual C#
Home > .NET Imaging SDK > C# > Convert PDF to Raster Images
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

PDF Rendering to Raster Images in C#
RasterEdge.com provides C# developers with mature PDF document processing and rendering library. Integrate with .NET Image Core DLLs, users may easily render and convert PDF document to raster images, especially for Tiff image. Using our C#.NET PDF Document Add-On, you can render target PDF document to Bmp image format through C# programming. Bmp is a device-independent raster image file format which can be used to store 2D digital images. As a raster image, Bmp file is built pixel by pixel and it can be easily edited. Generally, the color of individual pixel can be changed.
Our C#.NET PDF Doc Add-On supports simple PDF to Gif conversion using C# code. Gif is abbreviated from Graphics Interchange Format and Gif images are compressed using the lossless data compression technology. Therefore, Gif images are of small file size while preserving the visual quality. In our daily life, we can see many logos in Gif format.
If you want to convert your PDF document to Jpeg file, you may use this advanced PDF Document Add-On for C#.NET. Jpeg is short for Joint Photographic Experts Group and the Jpeg file is really small. Due to its small size property, Jpeg images are often used on web sites or in E-mails. When the Jpeg image is compressed and saved, its image quality will maintain the same.
It is easy to convert & render PDF document to Png (Portable Network Graphics) in C#.NET by using our PDF Doc Conversion Add-On for C#. Png file has the ability to integrate low-resolution images with fast loading speed. It is the most widely used lossless-compression raster graphics on the Internet.
In this part, you will see navigation for this C# PDF rendering to raster images guide page.
  • Supported functions of this PDF to Raster Images Conversion Control for C#.NET
  • APIs provided to convert PDF document to multiple raster images in C# class
  • C# sample codes used to convert PDF to Bmp, Gif, Jpeg, and Png raster images
Functions for PDF to Raster Images in C#
  • Advanced PDF to Raster Images Control, completely compiled in managed Visual C#
  • Support to decode and rasterize PDF document through version 1.7 in C# programming
  • Able to load PDF document from local file or memory stream within C#.NET project
  • Render PDF to various raster image formats, including but not limited to Bmp, Gif, Jpeg, Png & Tiff
  • Free to convert selected PDF document page(s) to raster image file(s) using C# code based on own needs
  • Capable of specifying resolution and bit depth options in PDF rendering process in C#.NET
Converting PDF to Raster Images with C# APIs
Using our C#.NET PDF Add-On to convert PDF document to raster images, you need to generate REImage from a particular page of the PDF document in the first place. Then, you are able to convert the PDF document by transforming the REImage to other image files. In this section, we will offer the two APIs.
// Render PDFs to get a REImage collection, or choose specific page to render.     
BasePage PDFDocument.GetPage(int pageIdx);
BaseImage PDFPage.toImage();
BaseImage PDFPage.toImage(int height, int width);

// Render PDFs in other image formats using Image Convert APIs.
void REFile.SaveImageFile(REImage image, String filePath);
C# Demo Codes for PDF to Raster Images
We offer free C# sample codes online for you to convert PDF document to four raster images, including Bmp, Gif, Jpeg, Png. Here is a table of the four C# sample codes. You may click to expand specific section to see detail C# demo code. For C# PDF-to-Tiff rendering, please see online guide: Convert & Render PDF to TIFF in C#.NET.
Use C# Demo Code to Render & Convert PDF to BMP
/// <summary>
/// To view, edit or save images of a pdf file, firstly generate REImage from a particular page of the document.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List<REImage> GetReImageForPDFDocument(PDFDocument doc)
{
   List<REImage> imageList = new List<REImage>();
   for (int i = 0; i < doc.GetPageCount(); i++)
   {
      PDFPage tmpPage = (PDFPage)doc.GetPage(i);

      REImage tmpImage = (REImage)tmpPage.ToImage();
                
      imageList.Add(tmpImage);
   }

   return imageList;
}


/// <summary>
/// You can transform REImage to BMP image use this C# code.
/// <param name="doc"></param>
public void ConvertPDFToBMP(PDFDocument doc)
{
   List<REImage> imageList = GetReImageForPDFDocument(doc);
   int imgCount = 0;

   foreach (REImage img in imageList)
   {
      REFile.SaveImageFile(img, @"C:\" + imgCount + ".bmp", new BMPEncoder());
      ++imgCount;
   }     

}
Use C# Demo Code to Render & Convert PDF to GIF
/// <summary>
/// To view, edit or save images of a pdf file, firstly generate REImage from a particular page of the document.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List<REImage> GetReImageForPDFDocument(PDFDocument doc)
{
   List<REImage> imageList = new List<REImage>();
   for (int i = 0; i < doc.GetPageCount(); i++)
   {
      PDFPage tmpPage = (PDFPage)doc.GetPage(i);

      REImage tmpImage = (REImage)tmpPage.ToImage();
                
      imageList.Add(tmpImage);
   }

   return imageList;
}


/// <summary>
/// You can transform REImage to GIF image use this C# code.
/// <param name="doc"></param>
public void ConvertPDFToGIF(PDFDocument doc)
{
   List<REImage> imageList = GetReImageForPDFDocument(doc);
   int imgCount = 0;

   foreach (REImage img in imageList)
   {
      REFile.SaveImageFile(img, @"C:\" + imgCount + ".gif", new GIFEncoder());
      ++imgCount;
   }     

}
How to Convert PDF to JPEG in Visual C# Class
/// <summary>
/// To view, edit or save images of a pdf file, firstly generate REImage from a particular page of the document.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List<REImage> GetReImageForPDFDocument(PDFDocument doc)
{
   List<REImage> imageList = new List<REImage>();
   for (int i = 0; i < doc.GetPageCount(); i++)
   {
      PDFPage tmpPage = (PDFPage)doc.GetPage(i);

      REImage tmpImage = (REImage)tmpPage.ToImage();
                
      imageList.Add(tmpImage);
   }

   return imageList;
}


/// <summary>
/// You can transform REImage to JPEG image use this C# code.
/// <param name="doc"></param>
public void ConvertPDFToJPEG(PDFDocument doc)
{
   List<REImage> imageList = GetReImageForPDFDocument(doc);
   int imgCount = 0;

   foreach (REImage img in imageList)
   {
      REFile.SaveImageFile(img, @"C:\" + imgCount + ".jpeg", new JPGEncoder());
      ++imgCount;
   }     

}
How to Convert PDF to PNG in Visual C# Class
/// <summary>
/// To view, edit or save images of a pdf file, firstly generate REImage from a particular page of the document.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List<REImage> GetReImageForPDFDocument(PDFDocument doc)
{
   List<REImage> imageList = new List<REImage>();
   for (int i = 0; i < doc.GetPageCount(); i++)
   {
      PDFPage tmpPage = (PDFPage)doc.GetPage(i);

      REImage tmpImage = (REImage)tmpPage.ToImage();
                
      imageList.Add(tmpImage);
   }

   return imageList;
}


/// <summary>
/// You can transform REImage to PNG image use this C# code.
/// <param name="doc"></param>
public void ConvertPDFToPNG(PDFDocument doc)
{
   List<REImage> imageList = GetReImageForPDFDocument(doc);
   int imgCount = 0;

   foreach (REImage img in imageList)
   {
      REFile.SaveImageFile(img, @"C:\" + imgCount + ".png", new PNGEncoder());
      ++imgCount;
   }     

}


Recommend this to Google+