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

Is it possible to use this lib to convert docx files to pdf? #2411

Closed
insinfo opened this issue Jun 16, 2023 · 2 comments
Closed

Is it possible to use this lib to convert docx files to pdf? #2411

insinfo opened this issue Jun 16, 2023 · 2 comments

Comments

@insinfo
Copy link

insinfo commented Jun 16, 2023

Is it possible to use this lib to convert docx files to pdf?

@cavasinf
Copy link

Using domPDF

// Locate DomPDF vendor
$dompdfPath = $vendorDirPath . '/dompdf/dompdf';

// Set renderer settings
\PhpOffice\PhpWord\Settings::setPdfRenderer(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF, $domPdfPath);

// Load docx
$phpWord = \PhpOffice\PhpWord\IOFactory::load($docxPath);

// Write into PDF
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');

For better result you can use unoserve that use libreoffice libs directly

@insinfo
Copy link
Author

insinfo commented Jul 11, 2023

in the end I ended up installing libreoffice on the production debian server and using headless to convert docx to PDF, having to install libreoffice on the server for that is pretty bad but at the moment I haven't seen another library that does this in order to preserve the layout, do this without needing libre office just with pure php would be wonderful

@Progi1984 Progi1984 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2023
@Progi1984 Progi1984 reopened this Sep 24, 2023
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

3 participants