PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.26k stars 2.69k forks source link

Word to PDF with MPDF: Missing paragraph/gap #2394

Open marcoheine opened 1 year ago

marcoheine commented 1 year ago

I use PHPWord with MPDF to convert Word to PDF.

This is my code:

    `Settings::setPdfRendererName( Settings::PDF_RENDERER_MPDF );
Settings::setPdfRendererPath( '.' );
     $phpWord = IOFactory::load( $_FILES["fileToUpload"]["tmp_name"], 'Word2007' );
$phpWord->save( 'document.pdf', 'PDF' );

header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); 
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize('document.pdf'));
@readfile( 'document.pdf' );`

It is working, but there are no gaps between the paragraphs. The gaps are in the original Word-File but in the PDF all lines are directly below each other with no spacing. Is there a setting for this?

allestaire commented 1 year ago

There is an existing issue when converting to PDF, either DomPDF or MPDF, most of it loses their style, still there are no solutions to this.

Progi1984 commented 2 months ago

@marcoheine Hi, Could you send me the docx file with error, for analyzing it, please ?