Skip to content

Commit 3b10cf4

Browse files
committed
PDFBOX-6095: avoid empty transformedBBox
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929611 13f79535-47bb-0310-9956-ffa450edef68
1 parent 69f82a1 commit 3b10cf4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,19 @@ protected void processAnnotation(PDAnnotation annotation, PDAppearanceStream app
324324
PDRectangle bbox = appearance.getBBox();
325325
PDRectangle rect = annotation.getRectangle();
326326

327-
// zero-sized rectangles are not valid
327+
// PDFBOX-4783: zero-sized rectangles are not valid
328328
if (rect != null && rect.getWidth() > 0 && rect.getHeight() > 0 &&
329329
bbox != null && bbox.getWidth() > 0 && bbox.getHeight() > 0)
330330
{
331-
PDResources parent = pushResources(appearance);
332-
Deque<PDGraphicsState> savedStack = saveGraphicsStack();
333-
334331
Matrix matrix = appearance.getMatrix();
335332

336333
// transformed appearance box fixme: may be an arbitrary shape
337334
Rectangle2D transformedBox = bbox.transform(matrix).getBounds2D();
335+
if (transformedBox.isEmpty())
336+
{
337+
// PDFBOX-6095: zero-sized rectangles are not valid
338+
return;
339+
}
338340

339341
// compute a matrix which scales and translates the transformed appearance box to align
340342
// with the edges of the annotation's rectangle
@@ -350,6 +352,9 @@ protected void processAnnotation(PDAnnotation annotation, PDAppearanceStream app
350352
// filled fields / annotations that have a matrix in the appearance stream, see PDFBOX-3083
351353
Matrix aa = Matrix.concatenate(a, matrix);
352354

355+
PDResources parent = pushResources(appearance);
356+
Deque<PDGraphicsState> savedStack = saveGraphicsStack();
357+
353358
// make matrix AA the CTM
354359
getGraphicsState().setCurrentTransformationMatrix(aa);
355360

0 commit comments

Comments
 (0)