'Find the first page of a MuliPage in dart-pdf
I am creating PDF document using dart-pdf. It contains various sections that could be any number of pages in length. Each section starts on a new page. Currently I am adding a new MultiPage
to the document for each section. How can I place a heading on only the first page of a given MultiPage
...
myPdf.addPage(
MultiPage(
header: (Context context) {
//discover first page of this MultiPage here ???
if(isFirstPage) {
return Header()
}
}
)
)
myPdf.addPage(
MultiPage(
header: (Context context) {
//discover first page of this MultiPage here ???
if(isFirstPage) {
return Header()
}
}
)
)
...
Solution 1:[1]
In all cases, you can do something like:
var isFirstPage = true;
myPdf.addPage(
MultiPage(
header: (Context context) {
//discover first page of this MultiPage here ???
if(isFirstPage) {
isFirstPage = false;
return Header()
}
}
)
)
https://github.com/DavBfr/dart_pdf/issues/707#issuecomment-852458481
Solution 2:[2]
My solution (ho header on first page):
MultiPage(
header: (pw.Context context) {
if (context.pageNumber == 1) {
return pw.Container();
}
return ...},
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shannon |
Solution 2 | Ðиколай Ðевзоров |