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.
  • SizeSettings specifies the page size through a PageSizeOptions object: PageSize (Default, A3, A4, A5, Letter, Legal, Tabloid, …), or PageWidth and PageHeight in points (1 point = 1/72 inch). When a width or height is set, PageSize is automatically changed to Custom.
  • OrientationSettings 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.
  • MarginSettings specifies the desired page margins in points after conversion through a PageMarginOptions object (Top, Bottom, Left, Right).
  • 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,
        OrientationSettings = 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
    {
        SizeSettings = new PageSizeOptions { PageSize = PageSize.A4 },
        OrientationSettings = PageOrientation.Portrait
    };
    converter.Convert("a4-document.docx", options);
}

Using Custom Dimensions

using (Converter converter = new Converter("sample.pdf"))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions
    {
        SizeSettings = new PageSizeOptions
        {
            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
    {
        MarginSettings = new PageMarginOptions
        {
            Top = 72,     // 1 inch
            Bottom = 72,  // 1 inch
            Left = 90,    // 1.25 inches
            Right = 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);
}

Markdown output has dedicated options for controlling how images are handled — inlined as base64 (default) or routed through a custom callback. See Convert to Markdown with advanced 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.