Skip to content

Commit 6b38c9e

Browse files
committed
Store Property.TRANSFORM as List<String[]> in case of multiple-function declaration
DEVSIX-1310
1 parent ee1d5a0 commit 6b38c9e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,8 +1522,7 @@ protected Rectangle calculateAbsolutePdfBBox() {
15221522
}
15231523
}
15241524

1525-
String[] transform = renderer.<String[]>getProperty(Property.TRANSFORM);
1526-
if (transform != null) {
1525+
if (renderer.<List<String[]>>getProperty(Property.TRANSFORM) != null) {
15271526
if (renderer instanceof BlockRenderer) {
15281527
BlockRenderer blockRenderer = (BlockRenderer) renderer;
15291528
AffineTransform rotationTransform = blockRenderer.createTransformationInsideOccupiedArea();
@@ -1850,19 +1849,24 @@ protected void endTranformationIfApplied(PdfCanvas canvas) {
18501849
}
18511850
}
18521851

1853-
private float[] getCssTransformMatrix(float width, float height) {
1854-
String[] strings = this.<String[]>getProperty(Property.TRANSFORM);
1855-
float[] floats = new float[6];
1856-
for (int i = 0; i < 6; i++)
1857-
if (i == 4 || i == 5) {
1858-
int indexOfPercent = strings[i].indexOf('%');
1859-
if (indexOfPercent > 0)
1860-
floats[i] = Float.parseFloat(strings[i].substring(0, indexOfPercent)) / 100 * (i == 4 ? width : height);
1852+
private AffineTransform getCssTransformMatrix(float width, float height) {
1853+
List<String[]> multipleTransform = this.<List<String[]>>getProperty(Property.TRANSFORM);
1854+
AffineTransform affineTransform = new AffineTransform();
1855+
for (int k = multipleTransform.size() - 1; k >=0; k--) {
1856+
String[] transform = multipleTransform.get(k);
1857+
float[] floats = new float[6];
1858+
for (int i = 0; i < 6; i++)
1859+
if (i == 4 || i == 5) {
1860+
int indexOfPercent = transform[i].indexOf('%');
1861+
if (indexOfPercent > 0)
1862+
floats[i] = Float.parseFloat(transform[i].substring(0, indexOfPercent)) / 100 * (i == 4 ? width : height);
1863+
else
1864+
floats[i] = Float.parseFloat(transform[i]);
1865+
}
18611866
else
1862-
floats[i] = Float.parseFloat(strings[i]);
1863-
}
1864-
else
1865-
floats[i] = Float.parseFloat(strings[i]);
1866-
return floats;
1867+
floats[i] = Float.parseFloat(transform[i]);
1868+
affineTransform.preConcatenate(new AffineTransform(floats));
1869+
}
1870+
return affineTransform;
18671871
}
18681872
}

0 commit comments

Comments
 (0)