Skip to content

Commit 6679ebe

Browse files
Benoit LagaeSamuel Huylebroeck
authored andcommitted
SVG: Use actual closePath operator in PDF syntax
Update cmp files DEVSIX-2718 also solves DEVSIX-2583
1 parent f426323 commit 6679ebe

30 files changed

+7
-6
lines changed

svg/src/main/java/com/itextpdf/svg/renderers/impl/AbstractSvgNodeRenderer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ void postDraw(SvgDrawContext context) {
252252
} else if (doStroke) {
253253
currentCanvas.stroke();
254254
}
255-
currentCanvas.closePath(); // TODO: see if this is necessary DEVSIX-2583
256255
}
257256
}
258257
}

svg/src/main/java/com/itextpdf/svg/renderers/path/impl/ClosePath.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.svg.renderers.path.impl;
4444

45+
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
46+
4547
/***
4648
* Implements closePath(Z) attribute of SVG's path element
4749
* */
@@ -56,4 +58,8 @@ public ClosePath(boolean relative) {
5658
super(relative);
5759
}
5860

61+
@Override
62+
public void draw(PdfCanvas canvas) {
63+
canvas.closePath();
64+
}
5965
}

svg/src/test/java/com/itextpdf/svg/renderers/TransformationApplicationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class TransformationApplicationTest {
6363

6464
@Test
6565
public void normalDrawTest() {
66-
byte[] expected = "1 0 0 1 7.5 0 cm\n0 0 0 rg\nf\nh\n".getBytes(StandardCharsets.UTF_8);
66+
byte[] expected = "1 0 0 1 7.5 0 cm\n0 0 0 rg\nf\n".getBytes(StandardCharsets.UTF_8);
6767

6868
ISvgNodeRenderer nodeRenderer = new AbstractSvgNodeRenderer() {
6969

svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererLowLevelIntegrationTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public void testAppliedClipPathRenderer() {
172172
"-63 -34.79 -34.79 -63 0 -63 c\n" +
173173
"34.79 -63 63 -34.79 63 0 c\n" +
174174
"f\n" +
175-
"h\n" +
176175
"Q\n";
177176
Assert.assertEquals(expected, new String(cv.getContentStream().getBytes()));
178177
}
@@ -211,7 +210,6 @@ public void testAppliedGroupClipPathRenderer() {
211210
"-63 -34.79 -34.79 -63 0 -63 c\n" +
212211
"34.79 -63 63 -34.79 63 0 c\n" +
213212
"f\n" +
214-
"h\n" +
215213
"Q\n" +
216214
"Q\n";
217215
Assert.assertEquals(expected, new String(cv.getContentStream().getBytes()));
@@ -258,7 +256,6 @@ public void testEoAppliedGroupClipPathRenderer() {
258256
"-63 -34.79 -34.79 -63 0 -63 c\n" +
259257
"34.79 -63 63 -34.79 63 0 c\n" +
260258
"f\n" +
261-
"h\n" +
262259
"Q\n" +
263260
"q\n" +
264261
"% rect\n" +
@@ -272,7 +269,6 @@ public void testEoAppliedGroupClipPathRenderer() {
272269
"-63 -34.79 -34.79 -63 0 -63 c\n" +
273270
"34.79 -63 63 -34.79 63 0 c\n" +
274271
"f\n" +
275-
"h\n" +
276272
"Q\n" +
277273
"Q\n";
278274
Assert.assertEquals(expected, new String(cv.getContentStream().getBytes()));
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)