Convert PDF to Word, Excel, and PowerPoint for Windows, Linux, and macOS: Sample Code in C#, Python,
Convert PDFs to MS Office (DOCX, XLSX, PPTX) without any external third party dependencies. PDF to Word, PDF to Excel, PDF to PowerPoint are all provided with support for C#, Python, C++, Java, PHP, Ruby, Go; on Windows, Linux and Mac.
The Structured Output module is an optional add-on
Only available on Desktop and Server (Windows, Linux, or Mac) You can find more details about how to install the Structured Output module here .
Setup
Download the Structured Output Module that allows PDF to Office conversion.
Place it in the directory of your project, in a folder called
liband then reference it in the below sample.
Convert PDF to Word
This sample demonstrates how to convert from a PDF to DOCX file.
Convert.WordOutputOptions wordOutputOptions = new Convert.WordOutputOptions();
// Optionally convert only the first page
wordOutputOptions.SetPages(1, 1);
// Requires the Structured Output module
Convert.ToWord(filename, output_filename, wordOutputOptions);Convert::WordOutputOptions wordOutputOptions;
// Optionally convert only the first page
wordOutputOptions.SetPages(1, 1);
// Requires the Structured Output module
Convert::ToWord(filename, output_filename, wordOutputOptions);wordOutputOptions := NewWordOutputOptions()
// Optionally convert only the first page
wordOutputOptions.SetPages(1, 1)
// Requires the Structured Output module
ConvertToWord(filename, output_filename, wordOutputOptions)Convert.WordOutputOptions wordOutputOptions = new Convert.WordOutputOptions();
// Optionally convert only the first page
wordOutputOptions.setPages(1, 1);
// Requires the Structured Output module
Convert.toWord(filename, output_filename, wordOutputOptions);Convert PDF to Word with Paddle OCR
For scanned or image-based PDFs, SetPreferredOCREngine() lets you choose the Paddle OCR engine instead of the default engine for improved accuracy on low-quality scans and complex layouts, at the cost of longer processing time (see Select OCR Engine for a full comparison). Since Paddle does not support automatic language detection, set the OCR language explicitly with SetCustomOCRLanguage().
Convert PDF to PowerPoint
This sample demonstrates how to convert from a PDF to PPTX file.
Convert PDF to Excel
This sample demonstrates how to convert from a PDF to XLSX file.
Full Sample Code
Convert PDF files to MS Office Full sample code which illustrates how to convert PDF to MS Office files (Word, Excel, PowerPoint). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.
Last updated
Was this helpful?