Hello,
I'm trying to generate PDF from the docx. The images are not getting displayed in the generated PDF file.
I have also tried this solution, but no luck:
https://github.com/PHPOffice/PHPWord/issues/431#issuecomment-194815644
Here is my complete code:
Settings::setOutputEscapingEnabled(true);
Settings::setPdfRendererPath(base_path() . '/vendor/tecnickcom/tcpdf');
Settings::setPdfRendererName('TCPDF');
// Convert docx file into PDF file
$phpWord = IOFactory::load($exportFilePath);
$xmlWriter = IOFactory::createWriter($phpWord , 'PDF');
// Delete the docx file
unlink($exportFilePath);
// Save PDF file
$exportFilePath = $exportPath . '/' . time() . '_pdf.pdf';
$xmlWriter->save($exportFilePath);
PS: I'm using TCPDF.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Please, check what is pass on to the TCPDF library in that file /src/PhpWord/Writer/PDF/TCPDF.php
Is there your image?
with which version did you try? Could you please try with the latest development version? It should be fixed (fixed by #1074)
@troosan I'm sorry I tryied with the latest development release
it doesn't work :(
I use a template issued inside the word document (docx)
any clue ?
this fix was not for templates, only for "from scratch" document generation
wow you're fast @troosan
any clue to make it work from templates ?
That fix permits to make image templating works and - with that - it works with the pdf conversion
can we add that code in phpword ?
https://stackoverflow.com/a/48565596/584448
@psohm There a few TemplateProcessor improvements I need to merge to the main branch.
I'm planning on doing this the version after the current one.
I have my code. Image is not displaying while converting docx to pdf . Please suggest me
load('sa-report.docx'); $rendererName = \PhpOffice\PhpWord\Settings::PDF_RENDERER_TCPDF; $rendererLibrary = 'tcpdf'; $rendererLibraryPath = ''.$rendererLibrary; if(!\PhpOffice\PhpWord\Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) { die('please set renderer name'); } $rendererLibraryPath = ''.$rendererLibrary; $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF'); $objWriter->save('sa.pdf');**
Most helpful comment
I have my code. Image is not displaying while converting docx to pdf . Please suggest me
load('sa-report.docx'); $rendererName = \PhpOffice\PhpWord\Settings::PDF_RENDERER_TCPDF; $rendererLibrary = 'tcpdf'; $rendererLibraryPath = ''.$rendererLibrary; if(!\PhpOffice\PhpWord\Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) { die('please set renderer name'); } $rendererLibraryPath = ''.$rendererLibrary; $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF'); $objWriter->save('sa.pdf');**