C#: Online Guide
How To: Word SDK
Document Pages Processing
Document Pages Processing
  |  
Home ›› XDoc.Word ›› C# Word: Process Document Pages

C# Word - Document Pages Processing in C#.NET


Provide a Series of Methods to Setup and Modify Pages in Word Document for C# Users




Overview



C#.NET Word document pages processing Interface control (XDoc.Word).//More TODO is a tool that can let C# users to process document pages on an existing file. By using related APIs, users can create a new Word document and process pages on it.


Related .net document control helps:
c# asp.net pdf editor: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
c# asp.net mvc document viewer: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
c# asp.net tiff viewer: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
c# asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net sharepoint document viewer open source: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net annotate pdf using c#: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
c# asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET




C# DLLs: Document Page Processing



Add references:


  RasterEdge.Imaging.Basic.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;




Set Page Color in Word Document



In C# class programming, you can use specific APIs to set page colors in Word document. If you want to set pages color as Cyan, the demo code as follow will help you to achieve.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Set page color to document
doc0.SetPagesColor(Color.Cyan);
//Save the document
doc0.Save(@"");





Set Page Size in Word Document



If you want to set sizes of all page in document, you can use this demo code below.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Set pages size to document
doc0.SetPagesSize(10000, 10000);
//Save the document
doc0.Save(@"");





Set Page Margin in Word Document



If you want to set margins of all pages in document, you can use demo code as follow.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Set pages margin to document
doc0.SetPagesMargin(100, 100, 200, 200);
//Save the document
doc0.Save(@"");





Set Page Orientation in Word Document



You can set page orientations of all pages in document. We provide two type for pages orientation, they are landscape and portrait. And the following demo code will show you how to set pages as landscape .




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Set pages orientation to document
doc0.SetPagesOrientation(OrientationType.Landscape);
//Save the document
doc0.Save(@"");





Set Text Directions of All Pages in Word File



You can set text directions of all pages in document, the demo code as follow.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Set text direction to document
doc0.SetTextDirection(TextDirection.TbRl);
//Save the document
doc0.Save(@"");





Render Word Page to Image



Sometimes you need to render the document after editing it, we provide this method to help you achieve this requirement, and the demo code as follow show you how to render all pages to image after modification.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Get page count
int pageCount = doc0.GetPageCount();
//Render all pages to image
doc0.RenderToImage(@"",@"",ImageType.PNG);