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

Footer/Header in PDF #843

Open buchmayr opened 8 years ago

buchmayr commented 8 years ago

Is it possible to render Footer and Header from Word using the PDF writer? Seems like it skips the parts created with: $section->createHeader(); $section->createFooter();

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36396934-footer-header-in-pdf?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github).
zdimension commented 3 years ago

Any news on this? Ended up inserting custom html code with a position: fixed style

vkurlenko commented 1 year ago

Any news on this? Ended up inserting custom html code with a position: fixed style

Can you show some example of your code?

FabianKoestring commented 3 months ago
Settings::setPdfRendererName(Settings::PDF_RENDERER_DOMPDF);
Settings::setPdfRendererPath('/vendor/dompdf/dompdf');

$phpWord = new \PhpOffice\PhpWord\PhpWord();

$section = $phpWord->addSection();

$section->addHeader()->addImage('my-image.png');

$section->addTitle("HELLO WORLD!");
$section->addText('Lorem ipsum dolor sit amet, consetetur sadipscing elitr');

$footer = $section->addFooter();
$footer->addText('FOOTER');

$pdfWriter = IOFactory::createWriter($phpWord, 'PDF');
$pdfWriter->save('sample.pdf');

$docxWriter = IOFactory::createWriter($phpWord, 'Word2007');
$docxWriter->save('sample.docx');

The resulting .docx has header and footer but the .pdf has not. Why? I tested dompdf and mpdf.

Progi1984 commented 1 month ago

Note : https://github.com/dompdf/dompdf/wiki/Common-Use-Cases#header-and-footer

https://mpdf.github.io/headers-footers/headers-footers.html