What's the best way of converting PDF docs to Microsoft Word format in PHP? This can be either as a PHP script or calling a (Linux) executable (with proc_open()). It just needs to be relatively fast and produce quality Word documents (in 97/2000/2003 format).

Commercial software is OK.

No correct solution


To read PDF files, you will need to install the XPDF package, which includes "pdftotext." Once you have XPDF/pdftotext installed, you run the following PHP statement to get the PDF text:

content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');

After getting the content, Download PHPDOCX Community version, try like this.

require_once '../../classes/';

$docx = new CreateDocx();
$textInfo = $content;

$paramsTextInfo = array(
    'val' => 1,
    'i' => 'single',
    'sz' => 8

$docx->addText($textInfo, $paramsTextInfo);


Openoffice has a PDF import extension. Most of OpenOffice is scriptable, so you should be able to write a command line interface to perform the conversion. There are many examples on the official UNO wiki.

By far the easiest way is with phpLiveDocx. It can load DOC, DOCX and RTF and save to PDF. It can be downloaded from The download file contains a large number of sample applications, which illustrate all aspects of the PHP5 library. Leo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow