1. Products
  2.   Word Processing
  3.   .NET
  4.   Aspose.Words for .NET

Aspose.Words for .NET


C# .NET API to Process Microsoft Word Documents

Advanced Word document processing API to create, modify, convert, & render word files without using Microsoft Word or other third-party software.

Aspose.Words for .NET is an advanced class library that enables software developers to perform a great range of document processing and manipulation tasks. Aspose.Words supports several popular file formats such as DOC, OOXML, RTF, HTML, OpenDocument, PDF, XPS, EPUB, and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word® or other third-party software. The API can be used to develop software applications for a wide range of operating systems, such as Windows, Linux, and Mac OS, and various others.

The Aspose.Words for .NET enables software developers to import and export their documents to over 35 supported file formats. You can easily open and convert Word documents to DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, HTML, MHTML, AZW3, ODT, OTT, TXT, MD, PDF, EPUB, and many more. It supports converting documents between all of its supported formats with most of the conversion performed with high fidelity that ensures minimal formatting loss. It is also possible to convert whole documents or particular pages of a document.

Aspose.Words for .NET is very easy to handle and there are several advanced features parts of the library such as Generate documents or reports from scratch, creating documents using templates, inserting headers and footers, adding new paragraphs, inserting lists or tables, text, fields, add hyperlinks, insert bookmarks and images, insert shapes and textboxes, insert watermarks, extract images, joining or splitting documents, copying fragments between documents, protecting and unprotecting documents, modifying document properties, inserting HTML fragments into the document and many more.

Previous Next

Getting Started with Aspose.Words for .NET

The recommend way to install Aspose.Words for .NET is using NuGet. Please use the following command for a smooth installation.

Install Aspose.Words for .NET via NuGet

NuGet\Install-Package Aspose.Words -Version 23.1.0 
You can also download it directly from Aspose product page.

Word Document Conversion to Other File Formats

Aspose.Words for .NET library has included a powerful converter that helps developers in converting Word documents from one format to another format inside their own .NET applications. The library has included support for conversion to and from numerous popular file formats. Here are the most popular conversion combinations supported by the library, Word (Doc, Docx) conversion to PDF & vice versa, convert word and PDF document to Image, Document to Markdown export, Convert HTML to PDF, Convert PDF to EPUB, Convert Word to HTML, Convert Mobi to EPUB, Convert RTF to PDF, Convert ODT to PDF, Convert DOCX to DOC, Convert HTML to Word and many man more. The following example shows the power of the API, with just two lines of C# code you can convert various documents file format.

Convert PDF Document to DOCX via .NET API

Document doc = new Document(MyDir + "Pdf Document.pdf");
doc.Save(ArtifactsDir + "BaseConversions.PdfToDocx.docx");

Convert Word DOCX to HTML via C# .NET API

// Load the document from disk.
Document doc = new Document(dataDir + "Test File.docx");

// Save the document into HTML.
doc.Save(dataDir + "Document", SaveFormat.Html);

Use Mail Merge & Reporting via .NET API

Mail Merge is a popular feature that allows developers to merge data from data source to a Word template document. It can be used to quickly and easily create documents such as letters, labels, and envelopes etc. Aspose.Words for .NET has included complete support for generating documents from templates with mail merge fields. The library allows users to create even more complex documents such as reports, catalogs, inventories, and invoices using the standard mail merge technique. The library simplifies the process of creating a document using the Mail Merge Template. You can use several ways to create a Mail Merge Template. The library supports various data sources for mail merge such as DataTable, DataView, DataSet, IDataReader, an array of values supported by ADO .NET & so on.

Working with Charts in Word Files via .NET API

Chart is a graphical representation of data which can be used to communicate information graphically. Aspose.Words for .NET has included support for creating OOXML charts from the scratch as well as modifies existing charts inside .NET applications. The library has included various types of charts such as Bar chart, Line chart, Pie chart, Area chart, Column chart, Scatter chart, Surface chart, Stock chart, Radar chart and so on. The library supports working with Chart Data Label of a Single ChartSeries as well as Chart Series collection. The libraries has included support for format number of chart data label, set chart axis properties, format number value of axis and so on.

How to Insert Scatter Chart via C# API

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert Scatter chart.
Shape shape = builder.InsertChart(ChartType.Scatter, 432, 252);
Chart chart = shape.Chart;

// Use this overload to add series to any type of Scatter charts.
chart.Series.Add("AW Series 1", new double[] { 0.7, 1.8, 2.6 }, new double[] { 2.7, 3.2, 0.8 });

dataDir = dataDir + "TestInsertScatterChart_out.docx";

Manage Images in Word Documents via C# .NET API

Aspose.Words for .NET library enables software developers to add and manage various kinds of images inside their word documents. The library supports inserting images from a URL, from a stream, using an image object, from a byte array, Inline or floating at a specific position, Percentage scale or custom size and so on. The library also supports extracting images from a Word documents. It is also possible to insert barcodes to a document page and modify properties of barcodes. You can also customize image size, crop image and save images as WMF.  

Insert Barcode on Each Document Page via .NET API

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithImages();
// Create a blank documenet.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// The number of pages the document should have.
int numPages = 4;
// The document starts with one section, insert the barcode into this existing section.
InsertBarcodeIntoFooter(builder, doc.FirstSection, 1, HeaderFooterType.FooterPrimary);

for (int i = 1; i < numPages; i++)
    // Clone the first section and add it into the end of the document.
    Section cloneSection = (Section)doc.FirstSection.Clone(false);
    cloneSection.PageSetup.SectionStart = SectionStart.NewPage;

    // Insert the barcode and other information into the footer of the section.
    InsertBarcodeIntoFooter(builder, cloneSection, i, HeaderFooterType.FooterPrimary);

dataDir  = dataDir + "Document_out.docx";
// Save the document as a PDF to disk. You can also save this directly to a stream.