PHPOffice / PHPWord

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

Export PDF with DomPDF / Margin #1559

Open psohm opened 5 years ago

psohm commented 5 years ago

This is:

Expected Behavior

I'd like to have a clean PDF export. I would like to export also the margin properties.

Current Behavior

The PDF is exported with the default margin

How to Reproduce

Please provide a code sample that reproduces the issue.

<?php
        $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
        $xmlWriter->save($fileName.'.pdf');

As far I understood, the docx generate a HTML and then a PDF with another library. I think it is a bit complicated to reproduce word settings so we should only have a way to manipulate HTML before exporting to PDF. adding more css properties for example

<style type="text/css">
    body { margin: 40px; }
</style
kaystrobach commented 5 years ago

you could use the html writer to get the html, modify it and then mpdf to convert html to pdf