Guide for C#
Core Document Formats
Setting Rendering Option
Additional Features

C# Word - How to Set Word Rendering Options

Set C# Word Rendering Region, Conversion Mode & Rendered Image Resolution

Visual C#
Home > .NET Imaging SDK > C# > Set Word Rendering Options
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C# Word Rendering and Converting control library is a well designed and runtime royalty free assembly of RasterEdge .NET Imaging SDK which guarantees that users are capable of rendering and converting Word document to daily used documents & raster and vector images, such as PDF, tiff, png, gif, jpeg, bmp, svg, ect. Except for fundamental converting capability, our smart and powerful C# Word rendering application still enables users to adjust and set Word rendering options.
Related .net document control helps:
asp.net office document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net edit pdf text control: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net pdf document viewer c#: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm...
asp.net image viewer jquery: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net sharepoint document viewer free: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net view text file: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
In all, C#.NET developers can choose a target size or resolution of rendered image from Word document. Besides, developers can specify a region of Word document page as a source to render. You can also choose to batch convert the whole Word document as well as deliberately control Word conversion page by page. Below is a C# guide on how to set Word document rendering and converting options by using different APIs.
C# APIs: Get Width and Height of Original Word Page
Before rendering and converting any Word document pages, you may use "DOCXPage.GetWidth();" and "DOCXPage.GetHeight();" to get the width and height of the original Word document page in inches.
C# APIs and Code: If You Know Target Image Dimension (Not Too Big)
If you already know your target image dimension and the target size is not too big. The following C#.NET APIs are better choices for Word conversion. Sample C# code is also provided here.
REImage ConvertToImage(Size targetSize);
Bitmap GetBitmap(float zoomValue);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
public static void TestWordToImageWithSpecifiedSize(Size size)
{
// load Word document
DOCXDocument doc = new DOCXDocument (@"c:\sample.docx");

// compute zoom out factor
// get the first page as sample page
DOCXPage page = (DOCXPage)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 adjust to specified size.
page.GetBitmap(new Rectangle(0, 0, (int)originalWidth, (int)originalHeight), size);

// or specify dimension with a fixed ratio between the orignal and the target, with width set to target width
// and height be adjusted accordingly
page.GetBitmap(size.Width / originalWidth);
}
C# APIs and Code: Process High Resolution/Size Image in Partitions
For C#.NET Word document conversion, if the target image is required to be high resolution or in large size, you may want to process it in partitions. And these APIs work better. Sample C# code is also provided here.
REImage CropImage(Rectangle sourceRegion, Size targetSize);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
void Draw(Graphics g, PointF loaction, Rectangle sourceRectangle, Size targetSize);
// load Word document
DOCXDocument doc = new DOCXDocument (@"c:\sample.docx");

// compute zoom out factor
// get the first page as sample page
DOCXPage page = (DOCXPage)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 and zoom in by a factor of 4
page.GetBitmap(new Rectangle(0, 0, (int)(originalWidth / 2), (int)(originalHeight)), new Size((int)(originalWidth / 2*4), (int)(originalHeight*4)));
Note that, the source region is in pixel and is measured using 96 default resolution. The original dimension of Word page can be computed using widthInPixel = page.GetWidth()*96 and heightInPixel = page.GetHeight() * 96. For example, to convert the left half of Word page to image, you can set the source rectangle to start at (0, 0) and with the half of original width and height.
C# APIs: Convert Entire Word Document to Images at a Time
With following two C# APIs, users are supposed to convert the whole Word document to images at a time.
void ConvertToImages(ImageType target, String directory, String fileName);
void ConvertToImages(ImageType targetType, float zoomValue, String directory, String fileName);
Other Related C# Word Rendering and Converting Tutorials


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