C#: Online Guide
How To: Word SDK
File: Create, Load a Word File
File: Create, Load a Word File
  |  
Home ›› XDoc.Word ›› C# Word: Create, Load a Word File

C# Word - Word Creating in C#.NET


Tell Users How to Create New Word File and Load Word from Other Files




Overview



C#.NET Word document file creating library control, RasterEdge XDoc.Word SDK for .NET, is a robust & thread-safe .NET solution which provides a reliable and quick approach for C# developers to create a highly-secure and industry-standard Word document file. The Word document file created by RasterEdge C# Word document creator library is searchable and can be fully populated with editable text and graphics programmatically.


Related .net document control helps:
asp.net dotnetnuke pdf editor control: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net mvc pdf editor control: ASP.NET MVC PDF Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
file redact asp.net: Redact document ASP.NET: add, delete, apply redaction on PDF files in web browser using C#.net
view file asp.net: View multiple document formats in ASP.NET, MVC, Ajax, Azure using C# control
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net edit pdf page control: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net sharepoint pdf editor control: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites


This Visual C# .NET Word document creation control toolkit can not only allow developers to generate standard Word document file but also offer them the ability to count the page numbers of generated Word document by simple C# programming code. As this Word document creator library is built in .NET Framework 2.0 and designed specifically for .NET applications, C# developers can easily use this professional Word document generating SDK in all .NET developing applications, including ASP.NET web services and Windows Forms application.


After creating a Word document in C#.NET using this Word document creating toolkit, if you need to add some text and draw some graphics on created Word document file, you can also use this C#.NET Word document drawing library control.




C# DLLs: Word Creating



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 New Word Document With One Blank Page in C# Project



In C# class programming, you can use specific APIs to create Word file. And the Word document can contain one empty page or multiple empty pages. The following example will tell you how to create a Word document with one empty page.




String outputFile = Program.RootPath + "\\" + "output.docx";

//  Create a new Word Document object with one blank page
DOCXDocument doc = DOCXDocument.Create(outputFile);

//  Save the new created Word document into file
doc.Save(outputFile);





Extract Word Document From Existing Word File Using C#



You may also load or create a Word document object from existing Word file in C#.net.




//  Load from a file
String inputFilePath1 = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc1 = new DOCXDocument(inputFilePath1);
if (doc1 == null) throw new Exception("fail to load the file");
//  ...





Load Word From Stream Object in C# Project



Word document can be loaded from a stream object in C# programming.




//  Load from a stream
String inputFilePath = Program.RootPath + "\\" + "2.docx";
using (FileStream fileStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read))
{
    DOCXDocument doc = new DOCXDocument(fileStream);
    if (doc == null) throw new Exception("fail to load word document from the stream");
    //  ...
}