Convert to WordProcessing with advanced options

GroupDocs.Conversion provides the WordProcessingConvertOptions class to give you control over conversion result when convert to WordProcessing formats. Along with common convert options from base class WordProcessingConvertOptions has the following additional options:

  • Format specifies desired result document type. Available options are: Doc, Docm, Docx, Dot, Dotx, Rtf, Odt, Ott, Mobi, Txt, Md.
  • PageWidth specifies desired page width in points after conversion (1 point = 1/72 inch). When set, PageSize is automatically changed to Custom.
  • PageHeight specifies desired page height in points after conversion (1 point = 1/72 inch). When set, PageSize is automatically changed to Custom.
  • PageSize specifies page size. Available options are: Default, A3, A4, A5, Letter, Legal, Tabloid.
  • PageOrientation specifies page orientation. Available options are: Default, Landscape, Portrait.
  • FallbackPageSize specifies the fallback page size to use when the input document’s page size cannot be determined.
  • Dpi specifies desired page dpi after conversion. The default resolution is 96 dpi.
  • MarginTop specifies the desired page top margin in points after conversion.
  • MarginBottom specifies the desired page bottom margin in points after conversion.
  • MarginLeft specifies the desired page left margin in points after conversion.
  • MarginRight specifies the desired page right margin in points after conversion.
  • Password whether the converted document will be password protected with the specified password.
  • PdfRecognitionMode specifies the recognition mode when converting from PDF. Available options are: Textbox, Flow. Flow mode is recommended for maximum content editability.
  • RtfOptions specifies RTF specific options. See below.
  • MarkdownOptions specifies Markdown specific options when converting to Markdown format.
  • Zoom specifies the zoom level in percentage. Default is 100.

The following code snippet shows how to convert to WordProcessing with advanced options:

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        PageNumber = 2,
        PagesCount = 1,
        Format = WordProcessingFileType.Docx,
        PageOrientation = PageOrientation.Portrait
    };
    converter.Convert("converted.docx", options);
}

Page Size and Dimensions

You can control page size using either predefined sizes or custom dimensions:

Using Predefined Page Size

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        PageSize = PageSize.A4,
        PageOrientation = PageOrientation.Portrait
    };
    converter.Convert("a4-document.docx", options);
}

Using Custom Dimensions

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        PageWidth = 612,   // 8.5 inches × 72 points/inch
        PageHeight = 792   // 11 inches × 72 points/inch
    };
    converter.Convert("custom-size.docx", options);
}

Page Margins

Set custom margins for all four sides:

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        MarginTop = 72,     // 1 inch
        MarginBottom = 72,  // 1 inch
        MarginLeft = 90,    // 1.25 inches
        MarginRight = 90    // 1.25 inches
    };
    converter.Convert("margins-document.docx", options);
}

PDF Recognition Mode

When converting from PDF, control how content is interpreted:

using (Converter converter = new Converter("document.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        PdfRecognitionMode = PdfRecognitionMode.Flow  // Recommended for editable content
    };
    converter.Convert("editable-document.docx", options);
}

Available recognition modes:

  • Textbox - Preserves exact layout using textboxes (less editable)
  • Flow - Optimizes for content flow and editability (recommended)

RtfOptions

The RtfOptions class provides RTF-specific convert options:

  • ExportImagesForOldReaders - specifies whether the keywords for “old readers” are written to RTF or not. This can significantly affect the size of the RTF document.

The following code snippet shows how to convert to RTF with specific options:

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        Format = WordProcessingFileType.Rtf,
        RtfOptions = new RtfOptions
        {
            ExportImagesForOldReaders = true
        }
    };
    converter.Convert("converted.rtf", options);
}

Convert to Markdown

Convert documents to Markdown format:

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        Format = WordProcessingFileType.Md
    };
    converter.Convert("converted.md", options);
}

More Resources

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.