@@ -45,7 +45,11 @@ This file is part of the iText (R) project.
45
45
46
46
import com .itextpdf .io .logs .IoLogMessageConstant ;
47
47
import com .itextpdf .kernel .font .PdfFont ;
48
+ import com .itextpdf .kernel .geom .Rectangle ;
49
+ import com .itextpdf .kernel .pdf .PdfDocument ;
50
+ import com .itextpdf .kernel .pdf .PdfPage ;
48
51
import com .itextpdf .kernel .pdf .tagging .StandardRoles ;
52
+ import com .itextpdf .layout .Document ;
49
53
import com .itextpdf .layout .element .ListItem ;
50
54
import com .itextpdf .layout .element .Paragraph ;
51
55
import com .itextpdf .layout .layout .LayoutContext ;
@@ -223,8 +227,12 @@ public void draw(DrawContext drawContext) {
223
227
symbolRenderer .move (dxPosition , 0 );
224
228
}
225
229
226
- if (!isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getRight () > parent .getOccupiedArea ().getBBox ().getLeft ()
227
- || isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getLeft () < parent .getOccupiedArea ().getBBox ().getRight ()) {
230
+ // consider page area without margins
231
+ Rectangle effectiveArea = obtainEffectiveArea (drawContext );
232
+
233
+ // symbols are not drawn here, because they are in page margins
234
+ if (!isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getRight () > effectiveArea .getLeft ()
235
+ || isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getLeft () < effectiveArea .getRight ()) {
228
236
beginElementOpacityApplying (drawContext );
229
237
symbolRenderer .draw (drawContext );
230
238
endElementOpacityApplying (drawContext );
@@ -341,4 +349,23 @@ private float[] calculateAscenderDescender() {
341
349
return new float [] {0 , 0 };
342
350
}
343
351
352
+ private Rectangle obtainEffectiveArea (DrawContext drawContext ) {
353
+ PdfDocument pdfDocument = drawContext .getDocument ();
354
+
355
+ // for the time being iText creates a single symbol renderer for a list.
356
+ // This renderer will be used for all the items across all the pages, which mean that it could
357
+ // be layouted at page i and used at page j, j>i.
358
+ int pageNumber = parent .getOccupiedArea ().getPageNumber ();
359
+ Rectangle pageSize ;
360
+ if (pageNumber != 0 ) {
361
+ PdfPage page = pdfDocument .getPage (pageNumber );
362
+ pageSize = page .getPageSize ();
363
+ } else {
364
+ pageSize = pdfDocument .getDefaultPageSize ();
365
+ }
366
+
367
+ Document document = new Document (pdfDocument );
368
+ return new Rectangle (pageSize ).applyMargins (document .getTopMargin (), document .getRightMargin (), document .getBottomMargin (),
369
+ document .getLeftMargin (), false );
370
+ }
344
371
}
0 commit comments