Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docx to PDF images and styles lost #1684

Closed
shedh opened this issue Aug 5, 2019 · 6 comments
Closed

Docx to PDF images and styles lost #1684

shedh opened this issue Aug 5, 2019 · 6 comments

Comments

@shedh
Copy link

shedh commented Aug 5, 2019

Hi,

Using the following code the temp file has images and the styles but once converted to pdf images and styles are lost

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$rendererLibraryPath = '../composer/vendor/tecnickcom/tcpdf';
\PhpOffice\PhpWord\Settings::setPdfRendererPath($rendererLibraryPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('./docs/PurchaseOrderTemplate.docx');
$templateProcessor->setImageValue('logo', './docs/sigtext.png');
$templateProcessor->saveAs('./docs/temp/temp2.docx');

$temp = \PhpOffice\PhpWord\IOFactory::load('./docs/temp/temp2.docx');

$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($temp , 'PDF');
$xmlWriter->save('./docs/results/sampledocument.pdf', TRUE);

@geoffwasham
Copy link

I am also experiencing this issue. I started using PHPWord specifically because the documentation indicated I could use it to hydrate Word docs and then convert them to PDF.

Please update/comment as to the status of this feature.

@gpstiip88
Copy link

@geoffwasham try use unoconv to convert docx to pdf.
I'm using phpword to parse template and the results seems nice, but can't convert to pdf.

@geoffwasham
Copy link

@gpstiip88 Thanks for the suggestion. I've looked into that one, just not a good fit for my web server.

Would love to hear a response from PhpOffice/PhpWord developers.

@m1stermanager
Copy link

also experiencing this issue. absolutely cannot/will not run word on my servers for something like unoconv to work. not awesome that this is the "standard" php word/office lib?

@AlanHdz
Copy link

AlanHdz commented Mar 2, 2022

also experiencing this issue, any updates?

@m1stermanager
Copy link

m1stermanager commented Mar 3, 2022

our solution was to make sure that openoffice was available to the app, write the docx, convert to pdf, do whatever w/ the pdf bytes, cleanup temp docx and pdf

(so not using this particular library... which I'm sure is great for other things)

@shedh shedh closed this as completed Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants