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.
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.
<?php
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$textInfo = $content;
$paramsTextInfo = array(
'val' => 1,
'i' => 'single',
'sz' => 8
);
$docx->addText($textInfo, $paramsTextInfo);
$docx->createDocx('report.docx');
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With