-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Milestone
Description
Describe the Bug
I'm not sure how to describe it, but the generated document is broken (literally not looks like the source document (.docx).
Steps to Reproduce
Please provide a code sample that reproduces the issue.
$reader = \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpWord = $reader->load(Storage::disk('document-request')->path($filePath));
// Docx to Docx
\PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007')->save(Storage::disk('document request')->path($documentRequest->id . '/requirements/') . $filename . '.docx');
// To PDF (dompdf and tcpdf)
\PhpOffice\PhpWord\Settings::setPdfRenderer(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF, base_path('vendor/dompdf/dompdf'));
\PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF')->save(Storage::disk('document-request')->path($documentRequest->id . '/requirements/') . $filename . '.pdf');
Expected Behavior
Generated looks like the source file.
Current Behavior
Generated files broken-structured.
Context
Please fill in your environment information:
- PHP Version: 8.1
- PHPWord Version: 1.1
- Laravel Version: 10
- Dompdf Version: *Latest
- TCPDF Version: 6.6.5
Compared file
-
Docx to Docx (This is just a try, and looks like PHPWord cannot read the document even without any change correctly)
-
Docx to PDF (DomPDF and TCPDF return the same-broken structured-result)
The source file was only 1 pages, but pdf resulted in 3 pages. The other file is 2 pages and turn into 5 pages.
Here's the example file I used