Load WordProcessing document with options

GroupDocs.Conversion provides WordProcessingLoadOptions to give you control over how original Microsoft Word document will be converted. The following options could be set: 

  • Format - the document type is auto detected during load, however you can specify explicitly the type of the source WordProcessing document. Available options are: Doc, Docm, Docx, Dot, Dotm, Dotx, Rtf, Odt, Ott, Mobi, Txt
  • AutoFontSubstitution - if false, GroupDocs.Conversion uses the DefaultFont for the substitution of missing fonts. If true, GroupDocs.Conversion evaluates all the related fields in FontInfo (Panose, Sig etc) for the missing font and finds the closest match among the available font sources
    Note: that font substitution mechanism will override the DefaultFont in cases when FontInfo for the missing font is available in the document
  • DefaultFont - default font. The following font will be used if a document font is missing
  • FontSubstitutes - substitute specific fonts from the source document
  • Password -  password to unlock protected document
  • HideWordTrackedChanges - specifies that tracked changes should not included in converted document
  • HideComments - specifies that comments from source document must be hidden during conversion

Hide comments

Microsoft Word provides a Comment feature that allows multiple authors or reviewers to discuss a document when they are not working at it simultaneously. All added comments are displayed in an area from the right of document text. After DOCX document with comments is converted to another format Comments pane is also present in a resultant document. If it’s required to hide comments in a converted document programmatically you can use the following code sample that shows how to do this in a couple lines of C# code:

Contracts.Func<LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
{
    HideComments = true
};
using (Converter converter = new Converter("sample.docx", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

Hide tracked changes

Track Changes is another feature of Microsoft Word that provides a handy way to collaborate during document proofread and review - it’s like you’re marking errors with a pen and making some notes in the margins. All changes made by coworkers are highlighted and may be rejected or accepted and become permanent. By default Track Changes panel will also be displayed when converting a DOCX document to another format, however there is an option to hide it completely using GroupDocs.Conversion for .NET API. 

The following code sample shows how to convert DOCX document to PDF and hide tracked changes pane:

Contracts.Func<LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
{
    HideWordTrackedChanges = true
};
using (Converter converter = new Converter("sample.docx", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

Specify font substitution

Microsoft Word document content is often formatted with different fonts like Arial, Calibri, Times New Roman etc., and these fonts are usually stored at the computer where the document is originally created or edited. Sometimes it happens that during DOCX document conversion to another format some fonts used by a particular document are not present at the computer where conversion is performed. So the resulting converted document may look too different from the original file.

Of course GroupDocs.Conversion for .NET will try to select the most appropriate font substitution from available font sources and fonts embedded in the original document, but it also has an ability to specify font substitution explicitly. For doing this it is just needed to call the Create method of FontSubstitute class and provide names for original and substitute fonts.

The following code sample shows how to convert DOCX document with font substitution for missing fonts:

Contracts.Func<LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
{
    AutoFontSubstitution = false,
	DefaultFont = "Helvetica",
    FontSubstitutes = new List<FontSubstitute>
    {
        FontSubstitute.Create("Tahoma", "Arial"),
        FontSubstitute.Create("Times New Roman", "Arial"),
    }
};
using (Converter converter = new Converter("sample.docx", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

More resources

Examples and Demos

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!