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

header and footer aren't visible #9

Closed
daemon-byte opened this issue Aug 13, 2019 · 3 comments
Closed

header and footer aren't visible #9

daemon-byte opened this issue Aug 13, 2019 · 3 comments

Comments

@daemon-byte
Copy link

daemon-byte commented Aug 13, 2019

I'm using the code below and it's generating the pdf file with the margins. However it's not displaying any header or footer. Neither my custom or chrome's standard. I even tried removing the headerTemplate option and nothing. Is there a bug or am I doing something wrong? I'm using the latest version.
$input = new StringInput(); $input->setHtml($html); $converter = new Converter($input, new StringOutput()); $converter->setOptions([ 'landscape' => false, 'printBackground' => true, 'displayHeaderFooter' => true, 'headerTemplate' => '<p>I am a header</p>', 'margin' => ['top' => '5px', 'bottom' => '5px', 'left' => '5px', 'right' => '5px'] ]); $output = $converter->convert(); $binary = $output->get(); if ($binary) { $this->getLogger()->logUserActivity('result_download'); $filename = 'result.pdf'; return new Response($binary, 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $filename . '"' ]); }

@daemon-byte
Copy link
Author

Ok it seems I needed bigger margins and to explicitly set a font size. Might be worth putting that in the readme file?


        $converter->setOptions([
            'landscape' => false,
            'printBackground' => true,
            'displayHeaderFooter' => true,
            'headerTemplate' => '<div style="font-size:10px !important;">I am a header</div>',
            'footerTemplate' => '<div style="font-size:10px !important;">I am a footer</div>',
            'margin' => ['top' => '40px', 'bottom' => '40px', 'left' => '40px', 'right' => '40px']
        ]);

@spiritix
Copy link
Owner

The problem is that page styles are not visible inside header and footer templates. This is a limitation of Chromium. Therefore, without setting any styles inside the templates, a default font size is being used which can be very small. Will update the documentation accordingly.

@Ankur2720
Copy link

im also using same liberary on codeigniter when im parsing the url the fucntion get the content for the url but its stills return null
can you help me with that

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

No branches or pull requests

3 participants