XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
Guide for C#
Core Document Formats
Set PDF Rendering Option
Additional Features

C# PDF - Setting PDF Rendering Options

C# Guide to Set PDF Document Rendering Option with Mature .NET APIs

Visual C#
Home > .NET Imaging SDK > C# > Set Document Rendering Options

"This online guide content is Out Dated!
    Please get the latest XDoc.PDF C# Developer Guide here.
"

RasterEdge C#.NET PDF Rendering and Converting SDK provides well designed and highly flexible solution for users to customize and specify a powerful PDF rendering application in C#. On this tutorial page, you will be suggested with some mature .NET APIs and sample codes for setting PDF document rendering options.
In details, this .NET PDF SDK is capable of not only converting single or multi-page PDF document to or from other image formats, but also enabling users to personalize PDF converting properties. For example, with this C# PDF rendering toolkit, users are able to control rendered image resolution, region size of PDF page or rendered picture, as well as batch or individual PDF to image conversion. We also provide guide for setting PDF rendering options in VB.NET program.
Use C# APIs & Demo Codes to Set PDF Rendering Options
RasterEdge allows Visual C# programmers to control fully on PDF rendering process. To be specific, C#.NET programmers can choose the size/resolution of image rendered. Also specifying the region of PDF document page to render and the target size of the rendered picture. Meanwhile, C#.NET users can choose to batch convert the whole PDF document as well as deliberately control conversion page by page. Aspects below demonstrate how to set PDF document rendering options by using different .NET APIs and sample codes in C# applications.

If you already know your target image dimension and the size is not considerably big, the following C#.NET APIs are better choice.

REImage ConvertToImage(Size targetSize);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
public static void TestPDFToImageWithSpecifiedSize(Size size)
{
// load PDF document
PDFDocument doc = new PDFDocument(@"c:\sample.pdf");

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

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

// get the image which sources the whole page and be adjusted to specified size
page.GetBitmap(new Rectangle(0, 0, originalWidth, originalHeight), size);

// adjust with a fixed ratio, with width set to the target width
page.GetBitmap(size.Width / originalWidth);
}
Note: the source region is in pixel and is measured using 96 default resolution. The original dimension of PDF page can be computed using widthInPixel = page.GetWidth()*96 and heightInPixel = page.GetHeight()*96. For example, to convert the left half of PDF document page, you can set the source rectangle to start at (0, 0) and with the original height in pixel and half of the original width in pixel.

If the target image is required to be high resolution or in large size and you may want to process it in partition, these C#.NET APIs will work better.

REImage CropImage(Rectangle sourceRegion, Size targetSize);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
void Draw(Graphics g, PointF loaction, Rectangle sourceRectangle, Size targetSize);
// load PDF document
PDFDocument doc = new PDFDocument(@"c:\sample.pdf");

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

// the orignial height and width are measured at 96 dpi of this page
float originalWidth = page.GetWidth() * 96;
float originalHeight = page.GetHeight() * 96;

// get the image which sources the left half of page
page.GetBitmap(new Rectangle(0, 0, originalWidth / 2, originalHeight), new Size(originalWidth / 2, originalHeight));
Note: Please see the note issue in the first situation.

If you want to convert the whole PDF document to images in C# at a time, you can use the following .NET APIs in PDFDocument.

void ConvertToImages(ImageType target, String directory, String fileName);
void ConvertToImages(ImageType targetType, float zoomValue, String directory, String fileName);
More C# PDF Rendering & Converting Guide
Besides the above mentioned PDF rendering options in C#, our .NET PDF rendering and converting library SDK still supports other practical applications:


Recommend this to Google+


RasterEdge.com is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2017 Raster Edge.com