Skip to content

Commit 9aec0c4

Browse files
Evgeniy PrudnikoviText-CI
authored andcommitted
Fixed bullet drawing when changing direction
DEVSIX-6085 Autoported commit. Original commit hash: [7b938f237]
1 parent 93899a0 commit 9aec0c4

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

itext/itext.layout/itext/layout/renderer/ListItemRenderer.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ source product.
4747
using iText.Commons;
4848
using iText.Commons.Utils;
4949
using iText.Kernel.Font;
50+
using iText.Kernel.Geom;
51+
using iText.Kernel.Pdf;
5052
using iText.Kernel.Pdf.Tagging;
53+
using iText.Layout;
5154
using iText.Layout.Element;
5255
using iText.Layout.Layout;
5356
using iText.Layout.Properties;
@@ -226,9 +229,11 @@ public override void Draw(DrawContext drawContext) {
226229
else {
227230
symbolRenderer.Move(dxPosition, 0);
228231
}
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()) {
232237
BeginElementOpacityApplying(drawContext);
233238
symbolRenderer.Draw(drawContext);
234239
EndElementOpacityApplying(drawContext);
@@ -353,5 +358,24 @@ private float[] CalculateAscenderDescender() {
353358
}
354359
return new float[] { 0, 0 };
355360
}
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+
}
356380
}
357381
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0847044410e8b1c1eb0f1536d1ff2e282bc9d62d
1+
7b938f237aeae83feb5920bacbfa04947205ffbf

0 commit comments

Comments
 (0)