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) 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.
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 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. 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 .NET PDF Doc Conversion Add-On. 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. For C# PDF-to-Tiff rendering, please see online guide: Convert & Render PDF to TIFF in C#.NET.
  • Supported functions of PDF to Raster Images Conversion Control for C#.NET
  • APIs provided to convert PDF document to raster images collection in C# class
  • APIs for converting PDF page to raster image file in C# class
  • APIs used for converting PDF page to Bitmap in C# class
  • C# demo code for converting PDF to raster image
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 Bmp, Gif, Jpeg & Png
  • Free to convert PDF document or selected page to raster image file(s) using C# code based on own needs
  • Capable of specifying resolution in PDF rendering process in C#.NET
Convert PDF to Raster Images Collection with C# APIs
C# programmers can convert PDF document to raster images collection. And this is a bulk operation with customized options.
void ConvertToImages(ImageType targetType, int resolution, String directory, String fileName);
void ConvertToImages(ImageType targetType, float zoomValue, String directory, String fileName);
These methods will automatically convert every page in PDF document to raster image files, with the page index append to fileName. Note that, the resolution is default to be 96 dpi for monitor displaying purpose. C#.NET users can adjust resolution to enlarge or reduce the size of image file or specify the zoomValue to adjust image size. Meanwhile, the original image size can be obtained with zoomValue set to be 1.
Convert PDF Page to Image File with C# APIs
To get full control over C#.NET PDF rendering process, you can work with PDFPage object. First, get specific PDFPage object from PDF document by BasePage GetPage(int index), and then you can render PDFPage object to REImage or other raster image formats with customized parameters. And below are related APIs.
REImage CropImage(Rectangle sourceRegion, Size targetSize);
REImage ConvertToImage();
void ConvertToImage(ImageType toType,String filePath);
void ConvertToImage(ImageType toType,int resolution, String filePath);
If you want to zoom in the page with a large factor, say 8x and paint the whole page. This will cost not only a very high usage of memory resource but also a considerable amount of time to proceed. The common practice is to show part of the page with a zoom in factor at a time. And CropImage API is designed for this purpose.
Convert PDF Page to Bitmap with C# APIs
In .NET Framework, Bitmap is a very common class in image processing. RasterEdge .NET PDF Add-on DLL provides C# developers with APIs to directly convert PDFPage to Bitmap object which then can be drew on graphics of (for example) WinForms control.
Bitmap GetBitmap();
Bitmap GetBitmap(float zoomValue);
Bitmap GetBitmap(float zoomValue);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
Please note, C#.NET APIs returning a Bitmap object are faster than return a REImage object, so you may use it for application that requires a high speed performance.
C# Demo Codes for PDF to Raster Images
We offer free C# sample code online for you to convert PDF document to raster images (Bmp, Gif, Jpeg, Png).
// load PDF document
PDFDocument doc = new PDFDocument(@"c:\sample.pdf");

// compute zoom out factor
// get the first PDF page as sample page
PDFPage page =(PDFPage)doc.GetPage(0);

// the original height and width are measured at 96 dpi
float originalWidth = page.GetWidth()*96;

// assume you want a thumbnail size of 500 pixel in width compute the zoomfactor
float zoomFactor = 500f/originalWidth;
string directory = @"c:\Thumbnail";

// construct thumbnail image under the directory with a file name thumail01.png, thumnail02.png
doc.ConvertToImages(ImageType.PNG,zoomFactor,directory,"thumbnail");


Recommend this to Google+