valerybokov commented on PR #440:
URL: https://github.com/apache/pdfbox/pull/440#issuecomment-4229275562
Here are some more things that look like bugs:
1. This is strange: drawRect uses the wrong Graphics object (line 305)
`graphics.drawRect(0, 0, (int)cropBox.getWidth(),
(int)cropBox.getHeight()); `
This calls graphics (the original parameter), not graphics2D. All the
configuration just set on graphics2D (transform,
clip, scale, color, stroke) is ignored, so the page border is drawn at
the wrong place with default color/stroke, and
the just-set transform is never used. Should be graphics2D.drawRect(...).
2. State leak on the printer Graphics2D. The method mutates graphics2D
(translate at line 255, translate at line 264, setBackground, setTransform,
setClip, scale, setColor, setStroke) but never saves/restores the original
state. print() may be called multiple times for the same Graphics; the next
page inherits the mangled transform/clip/stroke. Standard pattern is:
```
AffineTransform orig = graphics2D.getTransform();
try { ... } finally { graphics2D.setTransform(orig); }
```
3. Potential zero/negative-size BufferedImage (lines 279–281)
If imageableWidth * dpiScale / scale truncates to 0 (tiny imageable area,
or scale very large), new BufferedImage(0,
0, ...) throws IllegalArgumentException. Edge case, but not guarded.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]