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

C# Word - Run Processing in C#.NET


Provide Various Methods to Setup and Modify Run in Word Document for C# Users




Overview



With C#.NET Word document paragraph processing Interface control (XDoc.Word).//More TODO, users are allowed to process run in an existing word file or a new Word document.


Related .net document control helps:
document annotation asp.net: ASP.NET Document Annotation Control: text comment, drawing on files online using ASP.NET component
asp.net open pdf password: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#
asp.net azure pdf editor: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
asp.net sharepoint pdf editor: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites
asp.net office document viewer: ASP.NET Office Word Document Viewer: view MS Office Word files online using C# in ASP.NET web applications
asp.net document viewer: ASP.NET Document Viewer Control in C#: View, Annotate, Redact web document files in ASP.NET using C#
asp.net image viewer: ASP.NET Image Document Viewer Control: view, annotate, redact, convert image files in html web browser




C# DLLs: Word Run 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 Run in Paragraph



The following demo code will show you how to create a run in current paragraph. There's no content in run until you create some in it.




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();
//Create a run for paragraph
IRun run = paragraph.CreateARun();
//Save the document
doc.Save(@"");





Set Properties of Run



We provide a series of APIs to set properties of run in word document. The following demo code will show you how to operate this work.




String docFilePath = @"C:\input.docx";
//Open the document 
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main document 
IDocument doc = document.GetDocument();
//Create a paragraph for document. 
IParagraph paragraph = doc.CreateParagraph();
//Create a run for paragraph. 
IRun run = paragraph.CreateARun();
//Create text for run             run.CreateText("Text Created");
//Set Properties for run. 
//Set highlight color 
run.SetHighlightColor(HighLightColor.Cyan);
//Set Italic 
run.SetItalic(true);
//Set text color             run.SetTextColor(Color.Blue);
//Set strike out 
run.SetStrikeOut(true);
//Set underline Color 
run.SetUnderlineColor(Color.Black);
//Set underline Style 
run.SetUnderlineStyle(UnderlineStyle.Single);            //Set Bold 
run.SetBold(true);
//Set Shadow Color 
run.SetShadowColor(false, Color.Brown);
//Text border 
run.CreateBorder();
doc.Save(@"C:\output.docx");





Process Text Content



If you need to process text content in run, you may use following C# demo code.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main document
IDocument doc = document.GetDocument();
//Create a paragraph for document.
IParagraph paragraph = doc.CreateParagraph();
//Create a run for paragraph.
IRun run = paragraph.CreateARun();
//Create text for run
run.CreateText("ABCDEFGHI");
//Delete Char
run.DeleteChar("A");
//Append text
run.AppendText("Text Appended");
//Replace char
run.ReplaceChar('B', 'b');
//MORE TODO:
//
//
doc.Save(@"");