C#: Online Guide
How To: Word SDK
Convert Word to Png, Gif, Bitmap ... Images
Convert Word to Png, Gif, Bitmap … images
  |  
Home ›› XDoc.Word ›› C# Word: Convert Word to Png, Gif, Bitmap ... Images

C# Word - Render Word to Other Images


Online C# Tutorial for How to Convert Word to Raster Images, .NET Graphics, and REImage




Word to Multiple Image Forms Conversion



RasterEdge.com provides C# developers with mature Word document processing and rendering library SDK. Our XDoc.Word allows C# developers to perform high performance conversions from Word document to multiple image forms. Besides raster image Jpeg, images forms like Png, Bmp, Gif, .NET Graphics, and REImage (an intermediate class) are also supported. In the following parts, we provide some examples for these Word conversions.


Related .net document control helps:
asp.net file viewer: ASP.NET Document Viewer Control in C#: View, Annotate, Redact web document files in ASP.NET using C#
asp.net dotnetnuke pdf editor control: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net excel file viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications
asp.net azure file viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net image file viewer: ASP.NET Image Document Viewer Control: view, annotate, redact, convert image files in html web browser
file annotation asp.net: ASP.NET Document Annotation Control: text comment, drawing on files online using ASP.NET component




C# DLLs for Conversion from Word to Images



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Word;




C# Sample Code for Word to Png



You can use this sample code to convert Word file to Png image.




// Load a Word file.
String inputFilePath = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc = new DOCXDocument(inputFilePath);

// Get the first page of Word file.
DOCXPage page = (DOCXPage)doc.GetPage(0);

// Convert the first Word page to a PNG file.
page.ConvertToImage(ImageType.PNG, Program.RootPath + "Output.png");





C# Sample Code for Word to Bmp



Or use this piece of C# code to implement Word to Bmp conversion.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

// Load a Word file.
String inputFilePath = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc = new DOCXDocument(inputFilePath);

// Get the first page of Word file.
DOCXPage page = (DOCXPage)doc.GetPage(0);

// Convert the first Word page to a BMP file.
page.ConvertToImage(ImageType.BMP, Program.RootPath + "\\Output.bmp");





C# Sample Code for Word to Gif



You can also directly change Word to Gif image file in C# program.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

// Load a Word file.
String inputFilePath = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc = new DOCXDocument(inputFilePath);

// Get the first page of Word file.
DOCXPage page = (DOCXPage)doc.GetPage(0);

// Convert the first Word page to a GIF file.
page.ConvertToImage(ImageType.GIF, Program.RootPath + "\\Output.gif");





C# Sample Code for Word to REImage



Instead, you may render Word to REImage (an intermediate class) and then do further manipulations.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

// Load a Word file.
String inputFilePath = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc = new DOCXDocument(inputFilePath);

// Get the first page of Word.
DOCXPage page = (DOCXPage)doc.GetPage(0);

// Convert the first page to a REImage object.
REImage image = (REImage)page.ConvertToImage();

// Do something ...





C# Sample Code for Word to .NET Bitmap



Moreover, our SDK also allows you to render Word to .NET Bitmap in C# programming.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

// Load a Word file.
String inputFilePath = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc = new DOCXDocument(inputFilePath);

// Get the first page of Word.
DOCXPage page = (DOCXPage)doc.GetPage(0);

// Render the page to a Bitmap with default setting.
Bitmap bitmap1 = page.GetBitmap();
bitmap1.Save(inputFilePath + "_1.bmp");
//  ...

// Enlarge the page with factor 2.
float zoomRatio = 2.0F;
Bitmap bitmap2 = page.GetBitmap(zoomRatio);
bitmap2.Save(inputFilePath + "_2.bmp");
//  ...

// Render the page with a resolution of 300 dpi.
int targetResolution = 300;
Bitmap bitmap3 = page.GetBitmap(targetResolution);
bitmap3.Save(inputFilePath + "_3.bmp");
//  ...