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

pageNumber and totalPages are not displayed in footerTemplate #66

Closed
riatw opened this issue Mar 25, 2024 · 3 comments
Closed

pageNumber and totalPages are not displayed in footerTemplate #66

riatw opened this issue Mar 25, 2024 · 3 comments

Comments

@riatw
Copy link

riatw commented Mar 25, 2024

Please check the title.
How can I resolve this?

code

use Spiritix\Html2Pdf\Converter;
use Spiritix\Html2Pdf\Input\UrlInput;
use Spiritix\Html2Pdf\Output\EmbedOutput;

$input = new UrlInput();
$input->setUrl($requestTmplUrl);

$converter = new Converter($input, new EmbedOutput());

$footerTemplate = <<<END
<div style="font-family: '游ゴシック体', 'Yu Gothic', YuGothic, 'ヒラギノ角ゴ Pro', 'Hiragino Kaku Gothic Pro', 'メイリオ', 'Meiryo', sans-serif; position: relative; margin: 0.5cm 1cm; font-size: 9px; width: 100%;">
  <div style="position: absolute; left: 0; top: 0.5cm;">Site Title</div>
  <div style="position: absolute; width: 100%; top: 0.5cm; text-align: center;">
    <span class="pageNumber"></span> / <span class="totalPages"></span>
  </div>
  <div style="position: absolute; right: 0; top: 0.5cm;">$footerRight</div>
</div>
END;

$converter->setOptions([
    'printBackground' => true,
    'displayHeaderFooter' => true,
    'margin' => array('top' => '1cm','right' => '1cm','bottom' => '0cm','left' => '1cm',),
    'footerTemplate' => $footerTemplate,
]);

$output = $converter->convert();
$output->embed($title . ".pdf");
@SmurfVal
Copy link

SmurfVal commented Apr 8, 2024

We ran into the same issue:
Turns out our default size was so small, we thought it wasn't rendering.
Also had to increase the bottom margin as maybe there isn't enough space inside of it to render the html
Screenshot 2024-04-08 at 12 27 48

@spiritix
Copy link
Owner

spiritix commented Apr 9, 2024

Thanks guys. I will add that to the manual.

@spiritix spiritix closed this as completed Apr 9, 2024
@riatw
Copy link
Author

riatw commented Apr 10, 2024

@SmurfVal
@spiritix
thank you for your reply.

Increasing the font size did not solve the problem here.
Is it possible for you to tell me which version and settings you tried?

Only pageNumber and totalPages are not drawn, but normal text is drawn.

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