Author: tilman Date: Mon Jan 8 04:19:18 2024 New Revision: 1915122 URL: http://svn.apache.org/viewvc?rev=1915122&view=rev Log: PDFBOX-5749: catch WPathGraphics bug reported by Viktor Merkel; closes #175
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1915122&r1=1915121&r2=1915122&view=diff ============================================================================== --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Mon Jan 8 04:19:18 2024 @@ -1410,7 +1410,15 @@ public class PageDrawer extends PDFGraph int h = Math.round(image.getHeight() * scaleY); if (w < 1 || h < 1) { - graphics.drawImage(image, imageTransform, null); + try + { + graphics.drawImage(image, imageTransform, null); + } + catch (NegativeArraySizeException e) + { + // PDFBOX-5749 / JDK-8314112 catch WPathGraphics bug + LOG.debug(e.getMessage(), e); + } return; } Image imageToDraw = image.getScaledInstance(w, h, Image.SCALE_SMOOTH); @@ -1420,7 +1428,15 @@ public class PageDrawer extends PDFGraph imageTransform.scale(1f / w * image.getWidth(), 1f / h * image.getHeight()); imageTransform.preConcatenate(originalTransform); graphics.setTransform(new AffineTransform()); - graphics.drawImage(imageToDraw, imageTransform, null); + try + { + graphics.drawImage(imageToDraw, imageTransform, null); + } + catch (NegativeArraySizeException e) + { + // PDFBOX-5749 / JDK-8314112 catch WPathGraphics bug + LOG.debug(e.getMessage(), e); + } graphics.setTransform(originalTransform); } else @@ -1448,7 +1464,15 @@ public class PageDrawer extends PDFGraph g.dispose(); image = bim; } - graphics.drawImage(image, imageTransform, null); + try + { + graphics.drawImage(image, imageTransform, null); + } + catch (NegativeArraySizeException e) + { + // PDFBOX-5749 / JDK-8314112 catch WPathGraphics bug + LOG.debug(e.getMessage(), e); + } } } }