chrome-php / chrome

Instrument headless chrome/chromium instances from PHP
MIT License
2.3k stars 279 forks source link

headerTemplate and footerTemplate #101

Closed daemon-byte closed 3 years ago

daemon-byte commented 5 years ago

Hi,

Is it possible to set these using the master version of this code? I tried this but it didn't seem to work.

        $options = [
            'headerTemplate' => 'holy headers batman',
            'footerTemplate' => 'footer bam',
            'displayHeaderFooter' => true,
        ];
        $pdf = $page->pdf($options);
Vimalsumanthran commented 5 years ago

got any solution??

daemon-byte commented 5 years ago

Not with this tool. We went to a different system based on puppeteer

Vimalsumanthran commented 5 years ago

Which One?

daemon-byte commented 5 years ago

I'm not at a computer but it was one of these. I think it was smalot's pdfparser but wouldn't swear on it

Smalot/pdfparser Spiritix/php-chrome-html2pdf

jonrmitchell commented 4 years ago

I had a similar issue, in the end I had to do 2 things:

  1. Give the page margins (I had set them to 0)
  2. Give the header/footer template a font-size: 'footerTemplate' => '<div style="font-size:10px">footer bam</div>',

I'm sure you've moved on, but hopefully this helps someone else, so they don't have to try to pivot to a whole different system based on puppeteer like I did, only to realize that the same issue exists (you need margins and styles there too!)

GrahamCampbell commented 3 years ago

Yes, that is supported by this package. @jonrmitchell has answered this. :)