@@ -47,7 +47,10 @@ source product.
47
47
using iText . Commons ;
48
48
using iText . Commons . Utils ;
49
49
using iText . Kernel . Font ;
50
+ using iText . Kernel . Geom ;
51
+ using iText . Kernel . Pdf ;
50
52
using iText . Kernel . Pdf . Tagging ;
53
+ using iText . Layout ;
51
54
using iText . Layout . Element ;
52
55
using iText . Layout . Layout ;
53
56
using iText . Layout . Properties ;
@@ -226,9 +229,11 @@ public override void Draw(DrawContext drawContext) {
226
229
else {
227
230
symbolRenderer . Move ( dxPosition , 0 ) ;
228
231
}
229
- if ( ! isRtl && symbolRenderer . GetOccupiedArea ( ) . GetBBox ( ) . GetRight ( ) > parent . GetOccupiedArea ( ) . GetBBox ( ) . GetLeft
230
- ( ) || isRtl && symbolRenderer . GetOccupiedArea ( ) . GetBBox ( ) . GetLeft ( ) < parent . GetOccupiedArea ( ) . GetBBox
231
- ( ) . GetRight ( ) ) {
232
+ // consider page area without margins
233
+ Rectangle effectiveArea = ObtainEffectiveArea ( drawContext ) ;
234
+ // symbols are not drawn here, because they are in page margins
235
+ if ( ! isRtl && symbolRenderer . GetOccupiedArea ( ) . GetBBox ( ) . GetRight ( ) > effectiveArea . GetLeft ( ) || isRtl &&
236
+ symbolRenderer . GetOccupiedArea ( ) . GetBBox ( ) . GetLeft ( ) < effectiveArea . GetRight ( ) ) {
232
237
BeginElementOpacityApplying ( drawContext ) ;
233
238
symbolRenderer . Draw ( drawContext ) ;
234
239
EndElementOpacityApplying ( drawContext ) ;
@@ -353,5 +358,24 @@ private float[] CalculateAscenderDescender() {
353
358
}
354
359
return new float [ ] { 0 , 0 } ;
355
360
}
361
+
362
+ private Rectangle ObtainEffectiveArea ( DrawContext drawContext ) {
363
+ PdfDocument pdfDocument = drawContext . GetDocument ( ) ;
364
+ // for the time being iText creates a single symbol renderer for a list.
365
+ // This renderer will be used for all the items across all the pages, which mean that it could
366
+ // be layouted at page i and used at page j, j>i.
367
+ int pageNumber = parent . GetOccupiedArea ( ) . GetPageNumber ( ) ;
368
+ Rectangle pageSize ;
369
+ if ( pageNumber != 0 ) {
370
+ PdfPage page = pdfDocument . GetPage ( pageNumber ) ;
371
+ pageSize = page . GetPageSize ( ) ;
372
+ }
373
+ else {
374
+ pageSize = pdfDocument . GetDefaultPageSize ( ) ;
375
+ }
376
+ Document document = new Document ( pdfDocument ) ;
377
+ return new Rectangle ( pageSize ) . ApplyMargins ( document . GetTopMargin ( ) , document . GetRightMargin ( ) , document . GetBottomMargin
378
+ ( ) , document . GetLeftMargin ( ) , false ) ;
379
+ }
356
380
}
357
381
}
0 commit comments