Wordize 25.4.0

dotnet add package Wordize --version 25.4.0
                    
NuGet\Install-Package Wordize -Version 25.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wordize" Version="25.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wordize" Version="25.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Wordize" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wordize --version 25.4.0
                    
#r "nuget: Wordize, 25.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Wordize&version=25.4.0
                    
Install Wordize as a Cake Addin
#tool nuget:?package=Wordize&version=25.4.0
                    
Install Wordize as a Cake Tool

Word Document Processing .NET API

Version 25.4 Nuget

banner

Product Page | Docs | Demos | Free Support | Temporary License

Wordize for .NET is a class library that can be used by C#, F#, VB.NET developers for a variety of document-processing tasks, including converting, rendering, report generation, signing, comparing, splitting and merging. Our library is self-sufficient and doesn't depend on any third-party software, such as Microsoft Word, OpenOffice, and similar office suites.

This package can be used to develop applications for a vast range of operating systems (Windows, Linux, macOS, iOS, Android) and platforms such as Windows Azure, Xamarin.Android, Xamarin.iOS, Xamarin.Mac. You can build both 32-bit and 64-bit software, including ASP.NET, WCF, and WinForms.

Functionality

  • Comprehensive document conversion with 35+ supported file formats. For example, you can convert PDF to Word and Word to PDF documents with professional quality.
  • Document comparison feature.
  • Flexible LINQ Reporting Engine, designed to fetch data from databases, XML, JSON, OData, external documents.
  • Report generation feature using Mail Merge.
  • High-fidelity rendering of Word documents to PDF, XPS, JPG, PNG and other imaging formats.
  • Document signing feature.
  • Document merging feature.
  • Ability to replace text in documents with simple text or formatted with HTML or Markdown syntax text.
  • Ability to split documents using different split criteria.
  • Easy way to add watermarks into the document.

To become familiar with the most popular Wordize functionality, please have a look at our free online applications.

Supported Formats

Read and Write Formats

Microsoft Word: DOC, DOT, DOCX, DOTX, DOTM, FlatOpc, FlatOpcMacroEnabled, FlatOpcTemplate, FlatOpcTemplateMacroEnabled, RTF, Microsoft Word 2003 WordprocessingML
OpenDocument: ODT, OTT
Web: HTML, MHTML
Markdown: MD
Fixed Layout: PDF
Text: TXT
eBook: AZW3, EPUB, MOBI

Read-Only Formats

Microsoft Word: DocPreWord60
Other: XML (XML Document), CHM

Write-Only Formats

Fixed Layout: XPS, OpenXps
PostScript: PS, EPS
Printer: PCL
Markup: XamlFixed, HtmlFixed, XamlFlow, XamlFlowPack
Image: SVG, TIFF, PNG, BMP, JPEG, GIF
Metafile: EMF
Other: XLSX

Getting Started

So, you probably want to jump up and start coding your document processing application on C#, F# or Visual Basic right away? Let us show you how to do it in a few easy steps.

Run Install-Package Wordize from the Package Manager Console in Visual Studio to fetch the NuGet package. If you want to upgrade to the latest package version, please run Update-Package Wordize.

You can run the following code snippets in C# to see how our library works.

Setting Wordize License using C#

In evaluation mode Wordize injects an evaluation watermark into the processed document and limits the maximum size of the processed document to several hundreds of paragraphs. It is required to set the license to use Wordize features without evaluation version limitations. Base license allows working with MS Word document formats. The set of supported document formats and allowed features can be extended by applying the appropriate licenses:

Wordize.Settings.SetLicense(@"Wordize.Net.lic");
// Add license that allows working with web formats, such as HTML, MHTML or Markdown
Wordize.Settings.SetLicense(@"Wordize.Web.Net.lic");
// Add license that enables LINQ Reporting Engine
Wordize.Settings.SetLicense(@"Wordize.Reporting.Net.lic");

Conversion

Wordize for .NET allows you to convert between various document formats, the following code demonstrates how to convert DOCX to PDF.

Converter.Convert(@"C:\Temp\in.docx", @"C:\Temp\out.pdf");

For convenience, you can use the fluent API to perform document conversion operations. Conversion is as simple as specifying the input and output documents. The input can be either a file path or a stream containing the input file data. The following example demonstrates how to convert a DOCX file to PDF:

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();

Sometimes it is required to specify additional document load options, for example for conversion password encrypted document. In this case simply pass the appropriate LoadOptions:

Converter.Create()
    .From(@"C:\Temp\encrypted.docx", new LoadOptions() { Password = "1234" })
    .To(@"C:\Temp\out.pdf")
    .Execute();

The result can be saved directly to a file, a stream, or a list of streams. The last is particularly useful when saving the result as images, where each page of the document is saved as a separate stream and added to the list. You can specify multiple output types at the same time.

MemoryStream outStream = new MemoryStream();
List<Stream> outputStreams = new List<Stream>();

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.rtf")
    .To(outStream, SaveFormat.Odt)
    .To(outputStreams, SaveFormat.Png) // Note: a separate stream is created for each page. The streams disposing is the consumer responsibility.
    .Execute();

The output document format can be detected automatically based on the specified file extension, as shown above. Alternatively, the output format can be set explicitly. Additionally, you can specify advanced save options by passing the appropriate SaveOptions instance. The following example demonstrates how to convert a document to PDF with Ua2 compliance.

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf", new PdfSaveOptions() { Compliance = PdfCompliance.PdfUa2 })
    .Execute();

The processor context allows configuring the document layout process using LayoutOptions, specifying font settings with FontSettings, and setting a warning callback to receive notifications about issues during document processing. The following code example demonstrates configuring of LayoutOptions:

ConverterContext context = new ConverterContext();
context.LayoutOptions.CommentDisplayMode = Layout.CommentDisplayMode.Hide;
context.LayoutOptions.RevisionOptions.ShowRevisionMarks = false;
context.LayoutOptions.RevisionOptions.ShowRevisionBars = false;

Converter.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();

The following example demonstrates how to specify fonts folder location using FontSettings:

ConverterContext context = new ConverterContext();
context.FontSettings = new FontSettings();
context.FontSettings.SetFontsFolder(@"C:\Temp\Fonts", true);

Converter.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();

Note: The example above demonstrates how to configure font settings for a specific document processing operation. If you need to configure font settings globally, you can use Wordize.Settings.DefaultFontSettings:

Wordize.Settings.DefaultFontSettings.SetFontsFolder(@"C:\Temp\Fonts", true);

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();

The following code example demonstrates how to receive notifications about font substitution upon performing document processing operation:

ConverterContext context = new ConverterContext();
context.WarningCallback = new FontSubstitutionWarningCallback();

Converter.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();
private class FontSubstitutionWarningCallback : IWarningCallback
{
    public void Warning(WarningInfo info)
    {
        if (info.WarningType == WarningType.FontSubstitution)
            Console.WriteLine(info.Description);
    }
}

Comparing documents

Wordize for .NET allows you to compare documents, the differences in the resulting document are marked with revisions.

Comparer.Compare(@"C:\Temp\v1.docx", @"C:\Temp\v2.docx", @"C:\Temp\out.docx", "Wordize", DateTime.Now);

Alternatively, you can use the fluent API to achieve the same result:

Comparer.Create()
    .From(@"C:\Temp\v1.docx")
    .From(@"C:\Temp\v2.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

ComparerContext allow configuring the documents comparison process:

ComparerContext context = new ComparerContext();
context.Author = "James Bond";
context.CompareOptions.IgnoreFormatting = true;

Comparer.Create(context)
    .From(@"C:\Temp\v1.docx")
    .From(@"C:\Temp\v2.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

If one of the documents being compared contains revisions, they are accepted by default. You can control this behavior using the ComparerContext.AcceptRevisions property. Setting this property to false will reject revisions in the input documents.

Signing documents

The common scenario of document signing is when input document format matches the output document format. In such scenario it is not required to parse the document. Wordize allows signing document without loading the document into internal document object model in the following formats: Doc, Dot, Docx, Dotx, Docm, Dotm, Odt, Ott, Xps and OpenXps format. Signer class provides a convenient way to perform such type of signing:

CertificateHolder holder = CertificateHolder.Create(@"C:\Temp\my.pfx", "mypassword");
Signer.Sign(@"C:\Temp\in.docx", @"C:\Temp\out.docx", holder);

Alternatively, you can use the fluent API to achieve the same result:

SignerContext context = new SignerContext();
context.CertificateHolder = CertificateHolder.Create(@"C:\Temp\morzal.pfx", "test");
context.SignOptions = new SignOptions();
context.SignOptions.Comments = "My Signature";
context.SignOptions.SignTime = DateTime.Now;

Signer.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Another scenario involves signing the resulting document, for example, after filling a template with data. In this case, signature details can be specified in the appropriate SaveOptions. Apart from the formats listed above, Wordize also supports signing PDF documents in this scenario.

DocSaveOptions docSaveOptions = new DocSaveOptions();
docSaveOptions.DigitalSignatureDetails =
    new DigitalSignatureDetails(CertificateHolder.Create(@"C:\Temp\morzal.pfx", "test"), new SignOptions() { Comments = "My Signature" });

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.doc", docSaveOptions)
    .Execute();

The following example demonstrates how to convert a DOCX document to PDF and sign the output PDF.

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.DigitalSignatureDetails = 
    new PdfDigitalSignatureDetails(CertificateHolder.Create(@"C:\Temp\morzal.pfx", "test"), "Signing Reason", "Signing Location", DateTime.Now);

Converter.Create()
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.pdf", pdfSaveOptions)
    .Execute();

With this approach, the output of any processor can be signed if saved in the following formats:

  • DOC or DOT by specifying DocSaveOptions.DigitalSignatureDetails
  • DOCX, DOTX, DOCM, or DOTM by specifying OoxmlSaveOptions.DigitalSignatureDetails
  • ODT or OTT by specifying OdtSaveOptions.DigitalSignatureDetails
  • XPS or OpenXPS by specifying XpsSaveOptions.DigitalSignatureDetails
  • PDF by specifying PdfSaveOptions.DigitalSignatureDetails

Note: If the input and output file formats passed to Signer do not match, and the output file format supports signing, the signing process is performed similarly to conversion by specifying DigitalSignatureDetails in the appropriate SaveOptions.

Fill template with data using Mail Merge

Wordize for .NET allows template with data using Mail Merge feature.

string[] fieldNames = new string[] { "FirstName", "Location", "SpecialCharsInName()" };
string[] fieldValues = new string[] { "James Bond", "London", "Classified" };

MailMerger.Execute(@"C:\Temp\in.docx", @"C:\Temp\out.docx", fieldNames, fieldValues);

Executing a simple mail merge, mail merge with regions, or both in a single call is equally straightforward using the fluent interface. The following code demonstrates how to perform a simple mail merge using arrays of field names and values as the data source:

string[] fieldNames = new string[] { "FirstName", "SecondName" };
string[] fieldValues = new string[] { "James", "Bond" };

MailMergerContext context = new MailMergerContext();
context.SetSimpleDataSource(fieldNames, fieldValues);

MailMerger.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

The following example demonstrates how to execute mail merge with regions:

DataTable items = new DataTable("Items");
items.Columns.Add("Item");
items.Columns.Add("Quantity");
items.Columns.Add("Price");

items.Rows.Add("Apple", 10, 20);
items.Rows.Add("Carrot", 5, 15);
items.Rows.Add("Onion", 20, 10);

MailMergerContext context = new MailMergerContext();
context.SetRegionsDataSource(items);

MailMerger.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

If both simple mail merge data source and data source for mail merge with regions are specified, mail merge with regions is executed first and then simple mail merge is executed:

// Data for simple mail merge.
string[] fieldNames = new string[] { "FirstName", "SecondName" };
string[] fieldValues = new string[] { "James", "Bond" };

// Data for mail merge with regions.
DataTable items = new DataTable("Items");
items.Columns.Add("Item");
items.Columns.Add("Quantity");
items.Columns.Add("Price");

items.Rows.Add("Apple", 10, 20);
items.Rows.Add("Carrot", 5, 15);
items.Rows.Add("Onion", 20, 10);

MailMergerContext context = new MailMergerContext();
context.SetRegionsDataSource(items);
context.SetSimpleDataSource(fieldNames, fieldValues);

MailMerger.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Mail merge process can be configured by setting the appropriate options in MailMergerContext.MailMergeOptions:

DataTable items = new DataTable("Items");
items.Columns.Add("Item");
items.Columns.Add("Quantity");
items.Columns.Add("Price");

items.Rows.Add("Apple", 10, 20);
items.Rows.Add(null, null, null);
items.Rows.Add("Onion", 20, 10);

MailMergerContext context = new MailMergerContext();
context.SetRegionsDataSource(items);
// Instruct Wordize to remove empty table rows produced upon executing mail merge with regions. 
context.MailMergeOptions.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyTableRows;

MailMerger.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Merge documents using C#

Wordize for .NET allows to merge several documents.

Merger.Merge(@"C:\Temp\out.docx", new string[] { @"C:\Temp\in1.docx", @"C:\Temp\in2.pdf", @"C:\Temp\in3.doc", @"C:\Temp\in4.rtf" });

The following example demonstrates how to merge multiple documents in different formats and save the result as DOCX and PDF using fluent API:

Merger.Create()
    .From(@"C:\Temp\inDocx.docx")
    .From(@"C:\Temp\inPdf.pdf")
    .From(@"C:\Temp\inDoc.doc")
    .From(@"C:\Temp\inRtf.rtf")
    .To(@"C:\Temp\out.docx")
    .To(@"C:\Temp\out.pdf")
    .Execute();

Merging process can be configured using MergerContext:

MergerContext context = new MergerContext();
context.MergeFormatMode = MergeFormatMode.KeepSourceLayout;

Merger.Create(context)
    .From(@"C:\Temp\inDocx.docx")
    .From(@"C:\Temp\inPdf.pdf")
    .From(@"C:\Temp\inDoc.doc")
    .From(@"C:\Temp\inRtf.rtf")
    .To(@"C:\Temp\out.docx")
    .Execute();

Replace text in documents using C#

Wordize for .NET allows to replace text in documents.

int occurrences = Replacer.Replace(@"C:\Temp\in.docx", @"C:\Temp\out.docx", "replace me", "my cool replacement");

Replacing text in the document can be performed using fluent API:

ReplacerContext context = new ReplacerContext();
context.SetReplacement("ReplaceMe", "Replacement");

Replacer.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

The replacement process can be configured using ReplacerContext. The following code demonstrates how to replace text matching a regular expression with markup-formatted text.

ReplacerContext context = new ReplacerContext();
context.SetReplacement(new Regex(@"oc[a-z]+e"), "**Text** *with* `formatting`");
context.FindReplaceOptions.ReplacementFormat = ReplacementFormat.Markdown;

Replacer.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Generate reports using LINQ Reporting Engine using C#

Wordize for .NET allows to generate reports using various data sources such as JSON, XML or Objects. Template is built using simple text placeholders of the following format <<[field_name_]>>. For example:

Name: <<[data.Name]>>
Position: <<[data.Position]>>

can be filled with the following JSON data:

{ 
    Name: "James Bond",
    Position: "Spy" 
}

using the following simple code:

ReportBuilder.BuildReport(@"C:\Temp\in.docx", @"C:\Temp\out.docx", new JsonDataSource(@"C:\Temp\data.json"), "data");

The following code demonstrates how to fill the above template with data from data class using fluent API:

ReportBuilderContext context = new ReportBuilderContext();
context.DataSources.Add(new DummyData() { Name = "James Bond", Position = "Spy" }, "data");

ReportBuilder.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();
public class DummyData
{
    public string Name { get; set; }
    public string Position { get; set; }
}

Report building process can be configured using ReportBuilderContext. The following example demonstrates how to configure the LINQ Reporting Engine to remove empty paragraphs generated during report building:

ReportBuilderContext context = new ReportBuilderContext();
context.DataSources.Add(new DummyData() { Name = "James Bond", Position = "Spy" }, "data");
context.ReportBuilderOptions.RemoveEmptyParagraphs = true;

ReportBuilder.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Split documents using C#

Wordize for .NET allows easily split documents.

Splitter.Split(@"C:\Temp\in.docx", @"C:\Temp\out.docx", new SplitOptions() { SplitCriteria = SplitCriteria.Page });

The same can be done using fluent API. The following code example demonstrates how to split a DOCX document into pages and return each page as a separate DOCX document in a list of streams:

SplitterContext context = new SplitterContext();
context.SplitOptions.SplitCriteria = SplitCriteria.Page;

List<Stream> pageStreams = new List<Stream>();

Splitter.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(pageStreams, SaveFormat.Docx)
    .Execute();

The document splitting process can be configured using SplitterContext. The following code demonstrates how to split a document by paragraphs that have the Heading 1 style applied.

Note: When saving the output to a file, if the splitting results is multiple files, an unique name for each part will be generated using the following rule: outputFile_partIndex.extension.

SplitterContext context = new SplitterContext();
context.SplitOptions.SplitCriteria = SplitCriteria.Style;
context.SplitOptions.SplitStyle = "Heading 1";

Splitter.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Add watermarks using C#

Wordize for .NET allows easily add watermark to documents.

Watermarker.SetText(@"C:\Temp\in.docx", @"C:\Temp\out.docx", SaveFormat.Docx, "My Cool Watermark");

Configure a text watermark and its appearance using WatermarkerContext. Specify the input and outputs to apply the text watermark to the document.

WatermarkerContext context = new WatermarkerContext();
context.TextWatermark = "Wordize";

Watermarker.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

The similar approach can be used for adding an image as a watermark:

WatermarkerContext context = new WatermarkerContext();
context.ImageWatermark = File.ReadAllBytes(@"C:\Temp\watermark.png");

Watermarker.Create(context)
    .From(@"C:\Temp\in.docx")
    .To(@"C:\Temp\out.docx")
    .Execute();

Product Page | Docs | Demos | Free Support | Temporary License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
25.4.0 247 5 days ago
25.3.0 345 a month ago
25.2.0 340 2 months ago
25.1.0 442 4 months ago