Open xErik opened 1 month ago
I found out how to get the current page count.
I'll leave this feature request open, as I am not sure if this new feature is still a good idea or not.
This code will inject an empty page and push the next page with content to an odd page (right hand):
final pageCount = doc.document.pdfPageList.pages.length;
final isNextEven = (pageCount + 1) % 2 == 0;
if (isNextEven) {
doc.addPage(
pw.Page(
pageFormat: format.copyWith(marginBottom: 1.5 * PdfPageFormat.cm),
orientation: pw.PageOrientation.portrait,
build: (context) => pw.NewPage(),
),
);
Is your feature request related to a problem? Please describe.
Consider a book where:
addPage()
does not allow to force the start of the chapter page to the next odd page number.Describe the solution you'd like
Here,
addPage
injects blank pages as needed to achieve the desired effect.Describe alternatives you've considered
I tried to get the current page count before inserting a new page. But the document hasn't been rendered yet. Thus, the actual page count is not accessible. And whether an additionally injected blank page is needed cannot be determined at coding time.
I may have overlooked an obvious solution to this problem, or an already existing API parameter.