AlexanderScherbatiy opened a new pull request, #173: URL: https://github.com/apache/pdfbox/pull/173
This a fix for the [PDFBOX-5715](https://issues.apache.org/jira/browse/PDFBOX-5715) `Lines vanish when printing on MacOS`. PageDrawer class sets clip the same as drawn path on line https://github.com/apache/pdfbox/blob/6441a8b6117c7ac9963491de79c8c5f07e4a52df/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java#L998 When the graphics scale is less than 1.0 and the path stroke width is less than 1.0 then the clip width or height is less than 1.0 and it can be rounded in the device space to have a zero area. The issue with the fop project is reproduced on MacOS because CPrinterJob sets graphics scale to 1 for Printable, PDFBox adds scale `0.4842` in code: https://github.com/apache/pdfbox/blob/2b60e17e1db7bfc29d32ba33530d305c6441aaa1/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrintable.java#L213 where imageable area is `[288, 432]`, crop box area: `[0.0,0.0,594.72,792.0]` and the scaleX is `288/594.72 = 0.4842`, and the linePath stroke is `0.283`. On Linux RasterPrinterJob sets the graphics scale to `4.16` which is enough to properly draw the line path in the device space. The RasterPrinterJob calculates `x/yScale` as [ getX/YRes() / 72.0](https://github.com/openjdk/jdk/blob/4d50df63b6ea76fd6a6c387593c3d6bc9429007b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#L2175) where the default [getX/YRes is 300](https://github.com/openjdk/jdk/blob/4d50df63b6ea76fd6a6c387593c3d6bc9429007b/src/java.desktop/share/classes/sun/print/PSPrinterJob.java#L147). The fix checks if the graphics scale is less than 1.0 and the scaled linePath bounds width or height is less than 1.0 and then enlarges the clip bounds to cover at least 1 point plus 0.5 on one and another side in the device space to allow to draw the linePath inside the clip. The linePath can consists from different lines but when its bounds width or height is less than 1.0 it seems safe to use a rectangle as a clip instead of the real path. For performance reasons the fix first checks if the graphics scale is less than 1.0 and if it is not the case the initial clip is used. It still can be the case that the scale is larger than 1.0 but the line stroke width is less than 1.0 so the total stroke width in the device space is less than 1.0. The tests passes on Linux with the fix. There are failing tests on MacOS but as I can see the same tests fail on MacOS even without the fix: The only test which uses the graphics scale less than 1.0 on Linux is `org.apache.pdfbox.tools.imageio.TestImageIOUtils` but its linePath bounds widht and height are greater than 1.0. -- 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]
