Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

footerTemplate and header #659

Open
seyfcom opened this issue Oct 30, 2024 · 3 comments
Open

footerTemplate and header #659

seyfcom opened this issue Oct 30, 2024 · 3 comments

Comments

@seyfcom
Copy link

seyfcom commented Oct 30, 2024

Hi ! thanks for all, great code.
I need to know if it is possible to make a html for the footer and maybe header templates, so we can have a text at le left part, then another in the center, and for example the page count at the far right.
I don't succeed, I've tried with float, text align, and so on but not great...

@enricodias
Copy link
Member

You mean when printing the page?
The rest of the page's html and css will likely change the way your footer renders. You'll have to tweak it for every website or save it separately and append it to the generated pdf after printing.

@seyfcom
Copy link
Author

seyfcom commented Nov 5, 2024

Sorry, out of context it is difficult to understand.
I use Chrome-php with symfony framework, with a simple bundle to use chrome-php in symfony, and I print a page that has a specific CSS for the printing page. But anyhow, it seems that it doesn't want to use the style I put in the HTML.
It looks like the part of headerTemplate and footerTemplate HTML givent to the Chrome -PHP is treated another way than the rest of the page taht is rendered in Chromium. But not the headerTemplate and footerTemplate, no?

$options = [
    'landscape'           => true,
    'printBackground'     => true,
    'displayHeaderFooter' => true,
    'preferCSSPageSize'   => true, 
   ...
    'headerTemplate'      => '<div>foo</div>', // HOW IS THAT PART PROCESSED ? 
    'footerTemplate'      => '<div>foo</div>', // HOW IS THAT PART PROCESSED ?
    'scale'               => 1.2, 
];

I need to have rich headerTemplate and footerTemplates, with design, images. Is it possible ?

@enricodias
Copy link
Member

Those header and footer templates will be added to the page when printing it to pdf, but they won't load external resources like images or styles. I commented this issue on #347. Using images encoded in base64 or inline styles will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants