Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround to avoid calls to contentStream.moveTo with NaN arguments. #12

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,22 +829,25 @@ private void walkShape(Shape clip) throws IOException {
PathIterator pi = clip.getPathIterator(tf);
float[] coords = new float[6];
while (!pi.isDone()) {
switch (pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
contentStream.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
contentStream.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_QUADTO:
contentStream.curveTo1(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
contentStream.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
case PathIterator.SEG_CLOSE:
contentStream.closePath();
break;
int segment = pi.currentSegment(coords);
if(Float.isFinite(coords[0])) {
switch (segment) {
case PathIterator.SEG_MOVETO:
contentStream.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
contentStream.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_QUADTO:
contentStream.curveTo1(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
contentStream.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
case PathIterator.SEG_CLOSE:
contentStream.closePath();
break;
}
}
pi.next();
}
Expand Down