Open DulanNB opened 3 years ago
@DulanNB I did some research on this topic last year and found out that it is almost impossible to convert DOCX to PDF without corrupting the layout.
There is a possibility to convert a DOCX file to PDF using LibreOffice CLI - but the result will be like if you did it in the LibreOffice (which might be suitable for you, 90% layout will be exactly the same)
But in my case, I needed PDF that would look 100% exactly the same as DOCX file, so I ended up using third party service CloudConvert (I am sure there are other variants too)
Hope this helps
@DulanNB I did some research on this topic last year and found out that it is almost impossible to convert DOCX to PDF without corrupting the layout. There is a possibility to convert a DOCX file to PDF using LibreOffice CLI - but the result will be like if you did it in the LibreOffice (which might be suitable for you, 90% layout will be exactly the same) But in my case, I needed PDF that would look 100% exactly the same as DOCX file, so I ended up using third party service CloudConvert (I am sure there are other variants too) Hope this helps
thank's this help me a lot. i developing app that must to convert document such as word to pdf, try many ways and always fail. desperate can't find the answers finally theres an option to make it trough.
your answer really helpfull
@4unkur Your Research saved me, i spent several hours in trying different PDF Libraries, and no one work for DOCX to PDF conversion, Your suggestion for CloudCovert help me a lot, They have very good API. Thanks for Sharing.
public function convertWordToPDF() { $domPdfPath = base_path('vendor/dompdf/dompdf'); \PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath); \PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
Description
This function is converting to pdf losing data, images, and structure layout.