File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
layout/src/main/java/com/itextpdf/layout Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,10 @@ public void relayout() {
193
193
nextRelayoutRenderer = new DocumentRenderer (this , immediateFlush );
194
194
}
195
195
196
+ // Even though #relayout() only makes sense when immediateFlush=false and therefore no elements
197
+ // should have been written to document, still empty pages are created during layout process
198
+ // because we need to know the effective page size which may differ from page to page.
199
+ // Therefore, we remove all the pages that might have been created before proceeding to relayout elements.
196
200
while (pdfDocument .getNumberOfPages () > 0 ) {
197
201
pdfDocument .removePage (pdfDocument .getNumberOfPages ());
198
202
}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ protected PageSize addNewPage(PageSize customPageSize) {
195
195
}
196
196
197
197
/**
198
- * Ensures that PDF document has n pages. If document has less pages,
198
+ * Ensures that PDF document has n pages. If document has fewer pages,
199
199
* adds new pages by calling {@link #addNewPage(PageSize)} method.
200
200
*
201
201
* @param n the expected number of pages if document
You can’t perform that action at this time.
0 commit comments