TPPDF
TPPDF copied to clipboard
Customizing header/pagination for specific page
Is it possible to set custom for a header or hide part of the header on the first page? Is it possible to hide pagination when I have one page in pdf and show when there is more than one page?
Is it possible to hide pagination when I have one page in pdf and show when there is more than one page?
If I understood correctly you can use next approach
let pagination = PDFPagination(container: .footerRight, style: .customClosure({ page, total in
if total > 1 {
return "\(page)/\(total)"
}
return ""
}))
Is it possible to set custom for a header or hide part of the header on the first page?
For now it is not possible to change the header or footer on a per-page basis. Instead you could consider creating two PDFDocument
and use the multi-document generator
Is it possible to hide pagination when I have one page in pdf and show when there is more than one page?
As TPPDF is a static PDF document generator (with PDFPagniation being one of the few exceptions), there is currently no real support for conditional rendering based on the page count, because every added or removed element changes the content of the document, therefore changing the layout, e.g. with a header on the first page the content needs to pages, but without a header on the first page, it does not etc.
Therefore I would say the approach of @tarasChernysh is probably the most realistic one right now.
I will close this issue for now, but feel free to reopen if this should be discussed as an enhancement