C# Word Library
C# Word - Document Pages Processing in C#.NET
Provide a Series of Methods to Setup and Modify Pages in Word Document for C# Users
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.
Set Page Color in Word Document
In C# class programming, you can use specific APIs to set page colors in Word document.
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);