Skip to content

Commit b5d2438

Browse files
SnipxiText-CI
authored andcommitted
Add a comment explaning necessity of page removal during #relayout
Autoported commit. Original commit hash: [cc0f55342]
1 parent f930026 commit b5d2438

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

itext/itext.layout/itext/layout/Document.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ public virtual void Relayout() {
212212
if (nextRelayoutRenderer == null || !(nextRelayoutRenderer is RootRenderer)) {
213213
nextRelayoutRenderer = new DocumentRenderer(this, immediateFlush);
214214
}
215+
// Even though #relayout() only makes sense when immediateFlush=false and therefore no elements
216+
// should have been written to document, still empty pages are created during layout process
217+
// because we need to know the effective page size which may differ from page to page.
218+
// Therefore, we remove all the pages that might have been created before proceeding to relayout elements.
215219
while (pdfDocument.GetNumberOfPages() > 0) {
216220
pdfDocument.RemovePage(pdfDocument.GetNumberOfPages());
217221
}

itext/itext.layout/itext/layout/renderer/DocumentRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ protected internal virtual PageSize AddNewPage(PageSize customPageSize) {
181181

182182
/// <summary>Ensures that PDF document has n pages.</summary>
183183
/// <remarks>
184-
/// Ensures that PDF document has n pages. If document has less pages,
184+
/// Ensures that PDF document has n pages. If document has fewer pages,
185185
/// adds new pages by calling
186186
/// <see cref="AddNewPage(iText.Kernel.Geom.PageSize)"/>
187187
/// method.

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bbabbfd61feab7ef47a538e9f0f4248255ff138a
1+
cc0f553429cb077f8d86c93ec0c56a0b9f0d19ce

0 commit comments

Comments
 (0)