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:
asp.net mvc pdf editor using c#: ASP.NET MVC PDF Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net pdf editor using c#: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
c# asp.net pdf document viewer: ASP.NET PDF Document Viewer in C#: view, annotate, redact Adobe PDF files online in ASP.NET
c# asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
asp.net webforms pdf editor using c#: ASP.NET WebForms PDF Editor: create, view, edit, annotate, redact PDF file in ASP.NET WebForms application
c# asp.net image viewer: ASP.NET Image Document Viewer Control: view, annotate, redact, convert image files in html web browser
c# asp.net dnn document viewer: DNN Document Viewer Control: view, annotate, redact, convert documents in dotnetnuke 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);