Convert PDF to Word in .NET Smart Data Extractor

30 Nov 202611 minutes to read

Word (DOCX) is a widely used format for creating and editing professional documents. The Syncfusion® Smart Data Extractor library supports PDF and Images into Word conversion in .NET, enabling seamless transformation of PDF files into fully editable Word documents while preserving the original layout, barcodes, tables and images. This feature makes it easier to reuse content, improve accessibility, and integrate document data into .NET applications and business workflows.

Assemblies and NuGet packages required

Refer to the following links for the assemblies and NuGet packages required based on your target platform to convert PDF or Image as a Word file using the Syncfusion® Smart Data Extractor library.

Conversion Processing Modes

The Smart Data Extractor library automatically analyzes each PDF page and selects the most appropriate conversion approach to achieve the best balance between editing capability and layout preservation. The detected document type determines whether the content is processed using the selectable PDF workflow or the OCR-based workflow.

Selectable PDF Conversion

When all pages in a PDF contain selectable text, vector content, tables, colors, or other structural elements, the document is treated as a selectable PDF. In this scenario, Smart Data Extractor directly analyzes the PDF content using the native PDF structure without performing OCR and ONNX-based layout detection.

This approach provides:

  • Better text accuracy and editing capability.
  • Preservation of text colors and formatting.
  • Preservation of tables and cell structures.
  • Preservation of images, charts, and page layout.
  • Faster processing because OCR is not required.

Hybrid PDF Conversion

A PDF page is considered hybrid when it contains both selectable text and images on the same page. In this case, Smart Data Extractor uses the OCR-based workflow and intelligently combines OCR results with existing PDF content. Existing selectable content is preserved, while additional OCR text outside image regions is incorporated into the output.

Scanned PDF Conversion

If any page in the document contains only image content without a selectable text layer, the document is treated as a scanned PDF. This includes documents where:

  • All pages are scanned images.
  • One page is scanned and the remaining pages are selectable.
  • A page contains only an image and no selectable text.

In these scenarios, Smart Data Extractor automatically performs OCR and ONNX-based layout analysis to recognize text, tables, and document structure before generating the word document.

Note: Even if most pages contain selectable text, the presence of a single scanned page causes the entire document to be processed using the OCR-based workflow to ensure consistent conversion results.

Convert PDF or Image to Word Document

To convert a PDF document or Image into a Word using the ExtractDataAsWordDocument method of the DataExtractor class, refer to the following code example:

using Syncfusion.SmartDataExtractor;
using Syncfusion.DocIO.DLS;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
  //Initialize the Data Extractor.
  DataExtractor extractor = new DataExtractor();
  //Extract data as WordDocument.
  WordDocument document = extractor.ExtractDataAsWordDocument(stream);
  using MemoryStream saveStream = new MemoryStream();
  //Save the extracted Word data into an output file.
  document.Save(saveStream, FormatType.Docx);
  document.Close();
}
using Syncfusion.SmartDataExtractor;
using Syncfusion.DocIO.DLS;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
  //Initialize the Data Extractor.
  DataExtractor extractor = new DataExtractor();
  //Extract data as WordDocument.
  WordDocument document = extractor.ExtractDataAsWordDocument(stream);
  using MemoryStream saveStream = new MemoryStream();
  //Save the extracted Word data into an output file.
  document.Save(saveStream, FormatType.Docx);
  document.Close();
}

If you want to convert an image instead of a PDF, replace the input stream with the image file (for example, Input.jpg or Input.png). The rest of the code remains unchanged.

You can download a complete working sample from GitHub.

Convert a range of PDF pages to Word

To convert a specific range of PDF pages from the PDF document into Word by using the ExtractDataAsWordDocument method of the DataExtractor class, refer to the following code example:

using System.IO;
using Syncfusion.SmartDataExtractor;
using Syncfusion.DocIO.DLS;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
    //Initialize the Data Extractor.
    DataExtractor extractor = new DataExtractor();
    //Set the page range for conversion (example: pages 2 to 4).
    extractor.PageRange = new int[,] { { 2, 4 } };
    //Convert the selected pages into a Word document.
    WordDocument document = extractor.ExtractDataAsWordDocument(stream);
    using MemoryStream saveStream = new MemoryStream();
    //Save the extracted Word data into an output file.
	document.Save(saveStream, FormatType.Docx);
    document.Close();
}
using System.IO;
using Syncfusion.SmartDataExtractor;
using Syncfusion.DocIO.DLS;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
    //Initialize the Data Extractor.
    DataExtractor extractor = new DataExtractor();
    //Set the page range for conversion (example: pages 2 to 4).
    extractor.PageRange = new int[,] { { 2, 4 } };
    //Convert the selected pages to a Word document.
    WordDocument document = extractor.ExtractDataAsWordDocument(stream);
    //Save the Word document.
    using MemoryStream saveStream = new MemoryStream();
    //Save the extracted Word data into an output file.
	document.Save(saveStream, FormatType.Docx);
    document.Close();
}

If you want to convert an image instead of a PDF, replace the input stream with the image file (for example, Input.jpg or Input.png). The rest of the code remains unchanged.

Preserve Scanned Pages as Images

You can use the PreserveScannedPagesAsImages property to preserve the original visual appearance of scanned PDFs and image files during Word conversion. When enabled, scanned pages are rendered as images and inserted directly into the output document instead of being processed through OCR.

Convert Scanned PDF Pages as Images

The following example preserves scanned PDF pages as images while converting them to a Word document:

using Syncfusion.SmartDataExtractor;
using Syncfusion.DocIO.DLS;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
    //Initialize the Data Extractor.
    DataExtractor extractor = new DataExtractor();
    //Preserve scanned pages as images.
    extractor.PreserveScannedPagesAsImages = true;
    //Extract data as WordDocument.
    WordDocument document = extractor.ExtractDataAsWordDocument(stream);
    //Save the extracted Word data into an output file.
    using MemoryStream outputStream = new MemoryStream();
    document.Save(outputStream, FormatType.Docx);
    document.Close();
}

This property is applicable only to scanned PDFs and image inputs. It is ignored for selectable PDFs because selectable PDFs are converted directly into editable Word content while preserving layout, text, tables, images, and formatting.

PDF Classification Summary

Document Type Processing Approach
All pages contain selectable text and structure Direct selectable PDF conversion (No OCR)
Any page contains only image content OCR + ONNX workflow
PDF contains both selectable and scanned pages OCR + ONNX workflow
Page contains both image and selectable text Hybrid processing with OCR enhancement
Scanned PDF/Image with PreserveScannedPagesAsImages = true Pages exported as images without OCR

Supported and Unsupported PDF Elements

The following table lists the PDF elements and their preservation details for selectable and scanned PDFs in the Word document.

PDF Elements Selectable PDF Scanned PDF
Paragraph Title, Document Title Yes Yes
Header, Footer No (Preserved at the original page position and layout) Yes
Image Yes Yes
Table Yes Yes
Nested Table No No
Text Inline Styles Yes (Bold and Italic) No
Subscript, Superscript Partial (Visual appearance preserved) No
Underline, Strikethrough Partial (Visual appearance preserved as lines) No
List No (Converted as line-by-line text) No (Converted as line-by-line text)
Charts and Barcodes Yes (Preserved as images) Yes (Preserved as images)
Code blocks, Page Number Yes (Preserved as text) Yes (Preserved as text)
Link No (Preserved as plain text with color) No (Preserved as plain text)
Text color and Background color Yes No
Logo in page header or footer Yes No