
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.
What is Aspose.Words for .NET?
Aspose.Words for .NET is a powerful .NET word processing API designed to help software developers create, edit, and convert Word documents without needing Microsoft Word or any external tools. Supporting a wide array of formats—such as DOC, DOCX, RTF, HTML, PDF, EPUB, OpenDocument, and more—it allows you to generate, read, edit, and manipulate documents programmatically. The C# DOCX API works seamlessly across platforms including Windows, Linux, and macOS, making it a flexible solution for office automation API requirements. Software developers can easily use it to create Word documents in .NET applications or edit existing ones with precise control over layout, content, and structure.
This powerful .NET DOC API offers robust Word document conversion in .NET, supporting over 35 file formats with high fidelity to original formatting. You can convert Word DOCX to PDF, extract or insert specific pages, and handle batch file processing. The API also includes rich features like inserting headers, footers, watermarks, images, shapes, hyperlinks, bookmarks, and tables. It simplifies advanced document tasks like merging, splitting, cloning document fragments, and protecting files. Whether you're building reports from templates or embedding HTML, this all-in-one solution helps you efficiently convert word processing documents and automate document workflows in C#.
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
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.
How to Convert PDF Document to DOCX via .NET API?
Document doc = new Document(MyDir + "Pdf Document.pdf");
doc.Save(ArtifactsDir + "BaseConversions.PdfToDocx.docx");
How to 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?/h3>// 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";
doc.Save(dataDir);
// 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";
doc.Save(dataDir);
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.
How to 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;
doc.AppendChild(cloneSection);
// 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.
doc.Save(dataDir);