Author: tilman
Date: Sun Nov 9 09:49:20 2025
New Revision: 1929609
Log:
PDFBOX-6095: avoid empty transformedBBox
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
==============================================================================
---
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Sun Nov 9 08:30:17 2025 (r1929608)
+++
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Sun Nov 9 09:49:20 2025 (r1929609)
@@ -323,17 +323,19 @@ public abstract class PDFStreamEngine
PDRectangle bbox = appearance.getBBox();
PDRectangle rect = annotation.getRectangle();
- // zero-sized rectangles are not valid
+ // PDFBOX-4783: zero-sized rectangles are not valid
if (rect != null && rect.getWidth() > 0 && rect.getHeight() > 0 &&
bbox != null && bbox.getWidth() > 0 && bbox.getHeight() > 0)
{
- PDResources parent = pushResources(appearance);
- Deque<PDGraphicsState> savedStack = saveGraphicsStack();
-
Matrix matrix = appearance.getMatrix();
// transformed appearance box fixme: may be an arbitrary shape
Rectangle2D transformedBox = bbox.transform(matrix).getBounds2D();
+ if (transformedBox.isEmpty())
+ {
+ // PDFBOX-6095: zero-sized rectangles are not valid
+ return;
+ }
// compute a matrix which scales and translates the transformed
appearance box to align
// with the edges of the annotation's rectangle
@@ -350,6 +352,9 @@ public abstract class PDFStreamEngine
// filled fields / annotations that have a matrix in the
appearance stream, see PDFBOX-3083
Matrix aa = Matrix.concatenate(a, matrix);
+ PDResources parent = pushResources(appearance);
+ Deque<PDGraphicsState> savedStack = saveGraphicsStack();
+
// make matrix AA the CTM
getGraphicsState().setCurrentTransformationMatrix(aa);