PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.29k stars 2.7k forks source link

PHPWord and tcpdf retrieves an empty pdf #1030

Open 50l3r opened 7 years ago

50l3r commented 7 years ago

I execute this code to convert doc to pdf and recieve this empty pdf: LINK TO PDF

$FilePath = APPPATH."media/Documentos/Facturas/Factura ".$FacturaId.".docx";
$FilePathPdf` = APPPATH."media/Documentos/Facturas/Factura ".$FacturaId.".pdf";

//DOCX TO PDF
 require_once APPPATH.'third_party/phpword/bootstrap.php';

$rendererLibraryPath = PHPWORD_BASE_DIR . '/vendor/tecnickcom/tcpdf';
\PhpOffice\PhpWord\Settings::setPdfRendererPath($rendererLibraryPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');

$phpWord` = new \PhpOffice\PhpWord\PhpWord();

//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load($FilePath);

//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save($FilePathPdf);

Paths are correct

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/43440080-phpword-and-tcpdf-retrieves-an-empty-pdf?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github).
50l3r commented 7 years ago

I try whit DOMPDF without results: LINK TO 2ND PDF

$FilePath = APPPATH."media/Documentos/Facturas/Factura ".$FacturaId.".docx";
$FilePathPdf = APPPATH."media/Documentos/Facturas/Factura ".$FacturaId.".pdf";

//DOCX TO PDF
require_once APPPATH.'third_party/phpword/bootstrap.php';

$rendererLibraryPath = PHPWORD_BASE_DIR . '/vendor/dompdf/dompdf';
\PhpOffice\PhpWord\Settings::setPdfRendererPath($rendererLibraryPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');

$phpWord = new \PhpOffice\PhpWord\PhpWord();

//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load($FilePath);

//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save($FilePathPdf,);