Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.12 KB

creating-pdfs-with-multiple-pages.md

File metadata and controls

52 lines (35 loc) · 1.12 KB
title weight
Creating PDFs with multiple pages
2

This package offers a couple of Blade directives to help you create PDFs with multiple pages.

Setting a page break

To create a PDF with multiple pages, you can use the @pageBreak Blade directive in your view. Using this directive will result in a new page being created in the PDF document.

So if you have a view like this...

<div>
    Page 1
</div>

@pageBreak

<div>
    Page 2
</div>

... and you render this view using ...

Pdf::view('view-with-multiple-pages')->save($path);

... the resulting PDF will have two pages, one with "Page 1" and one with "Page 2".

Adding page numbers

To add page numbers to your PDF, you can use the @pageNumber and @totalPages Blade directive in your view.

Imagine you have this footer view...

<div>
    This is page @pageNumber of @totalPages
</div>

... and you render this view using ...

Pdf::view('view-with-multiple-pages')->footerView('footer-view')->save($path);

... the resulting PDF will have a footer on each page, with the page number and the total number of pages.