Laravel-snappy: How to add page number in footer in PDF generating file

Created on 23 Nov 2016  路  8Comments  路  Source: barryvdh/laravel-snappy

$pdf = PDF::loadView('resume.resume',array('resumeData' => $resumeData))->setOption('page-width', 200)->setOption('page-height', 287)->setOption('page-offset', 2);

with page-offset option page number is not display in pdf file

stale

Most helpful comment

I solved this by appending setOption('footer-right','[page]') to the code line. You can place the page number where you like it, just change the 'fotter-right' for other position. The important point is to add the [page] to the option, so the page number is printed.

All 8 comments

I solved this by appending setOption('footer-right','[page]') to the code line. You can place the page number where you like it, just change the 'fotter-right' for other position. The important point is to add the [page] to the option, so the page number is printed.

By any chance do you know how to set the footer to something like "Page 1 from 2" or something like that?

Yes, just do setOption("footer-right", "Page [page] from [topage]"), where [topage] is the total number of pages of the document.

  • [page] Replaced by the number of the pages currently being printed

    • [frompage] Replaced by the number of the first page to be printed

    • [topage] Replaced by the number of the last page to be printed

    • [webpage] Replaced by the URL of the page being printed

    • [section] Replaced by the name of the current section

    • [subsection] Replaced by the name of the current subsection

    • [date] Replaced by the current date in system local format

    • [isodate] Replaced by the current date in ISO 8601 extended format

    • [time] Replaced by the current time in system local format

    • [title] Replaced by the title of the of the current page object

    • [doctitle] Replaced by the title of the output document

    • [sitepage] Replaced by the number of the page in the current site being converted

    • [sitepages] Replaced by the number of pages in the current site being converted

can [topage] be used in the blade template?

I think that it not possible to use it on blade, since it is a variable managed by wkhtmtopdf during the conversion to pdf, so it is not visible to blade during the preparation of the view that is rendered to a pdf.

How do I get the page numbers in the footer on the right?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy.
If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

larsemil picture larsemil  路  5Comments

krtorio picture krtorio  路  5Comments

samsoft00 picture samsoft00  路  3Comments

leonardosapiras picture leonardosapiras  路  3Comments

jerearaujo03 picture jerearaujo03  路  5Comments