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

C# Word - Section Processing in C#.NET


Provide a Series of Methods to Setup and Modify Sections in Word Document for Users




Overview



C#.NET Word document sections processing Interface control (XDoc.Word). c# print pdf itextsharp, add image to pdf itextsharp vb.net, how to convert pdf to word using asp net c#, c# split pdf itextsharp, c# parse pdf itextsharp, how to write pdf file in asp.net c#. It can help users to process sections on an existing or a new Word document by using our API.


Related .net document control helps:
asp.net annotate pdf control: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
powerpoint viewer asp.net mvc: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net edit pdf text color: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET




C# DLLs: Word Section 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;




Create Section in Word Document



The following demo code shows you how to create a new section for the document. pdf to jpg c#, vb.net code to convert pdf to word, convert pdf to jpg vb.net, vb.net pdf editor, c# pdf bookmarks, vb.net pdf password, convert pdf to bitmap vb.net.




String docFilePath = @"";
//Open the document
DOCXDocument document =DOCXDocument.Open(docFilePath);
//Get the main document
IDocument doc = document.GetDocument();
//Create a section for document
ISection section = doc.CreateSection(0);
//Save the document
doc.Save(@"");





Pages Setup In Section



In C# class programming, you can use specific APIs in class IDocument to set Word pages. We can also set pages in each section, and the following demo code shows you how to do this work.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Create a section
ISection section = doc0.CreateSection(0);
//Section setup
//Create pageborders
section.CreatePageBorders();
//Page width
section.SetPageWidth(15000);
//Page height
section.SetPageHeight(12000);
//Margin
section.SetLeftMargin(500);
//Page orientation
section.SetPageLayout(OrientationType.Landscape);
//MORE TODO:
//
//Save the document
doc0.Save(@"");





Header and Footer Processing In Section



You can create header and footer in section with specified type. Before creating header or footer, you may need to check whether current section has included the same type of header or footer. If yes, it will not create new header or footer. What's more, you can also modify the header or footer existed in current section according to the standard supported by section. The following demo code shows how to create a header and footer in section.




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 all setion
List<ISection> sections = doc0.GetAllSetion();
//Get the first section
ISection section = sections[0];
//Create a header for section
IHeader header = section.CreateHeader(HeaderAndFooterType.Default);
//Create paragraph for header
IParagraph paraheader = header.CreateParagraph();
//Create run and text in para
IRun runheader = paraheader.CreateARun();
runheader.CreateText("Header Created in Section!");

//Create a footer for section
IFooter footer = section.CreateFooter(HeaderAndFooterType.Default);
//Create paragraph for footer
IParagraph parafooter = footer.CreateParagraph();
//Create run and text in para
IRun runfooter = parafooter.CreateARun();
runfooter.CreateText("Footer Created in Section!");

//Save the document
doc0.Save(@"");





Paragraph and Table Processing In Section



We provide methods for users to processing paragraph and table in section. You can use them to modify, delete, add and create paragraphs or tables in a section. The following demo code shows you how to create a table and paragraph in a section.




String docFilePath = @"";
//Open the document
DOCXDocument document =DOCXDocument.Open(docFilePath);
//Get the main document
IDocument doc = document.GetDocument();
//Create a empty paragraph for document
IParagraph paragraph = doc.CreateParagraph();
//Save the document
doc.Save(@"");