[ 
https://issues.apache.org/jira/browse/PDFBOX-5971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17953737#comment-17953737
 ] 

Tres Finocchiaro commented on PDFBOX-5971:
------------------------------------------

{quote}> Please post an URL or a JDK-XXX number if you get one.
{quote}
I don't have an upstream bug report or patch to provide yet... however... the 
JDK work on this has been fruitful. Here's an example of the before/after:

[^jdk23_patch.jpg]

I'll reference the upstream PR once I have it.  In addition to the quality 
issues there's also some DPI properties missing on macOS which I believe to be 
influencing this... quoting:
{quote}I reproduced the bug using {{{}pdfbox-app{}}}. When I print an image 
using the Ubuntu 24 on Brother DCP-720 then the image is printed using 300 DPI, 
but when I print the same image using MacOS then the image is printed using 72 
DPI.

 

The root cause of this is missed printer’s scale factor in the Graphics on the 
MacOS so the PDFBOX uses the default value - 72 points per inch during the 
printing.

We are proceeding to work with it.
{quote}
... 
{quote}We identified an option with macOS {{CGContextScaleCTM}} as the most 
acceptable, the JDK should handle printer DPI, calculate scaling factor and 
pass it to the macOS printer job [...]
{quote}
...
{quote}[...] I am not sure that we can use the Graphics' transformation matrix 
from the print method to determine printer’s DPI, I need to investigate this 
deeper.
{quote}
In the latest tests, the barcode is still less-clear than other OSs, so there's 
definitely some room for improvement, but we'll accept the upstream patch if it 
makes the barcodes scannable, which is what we'd consider reasonable acceptance 
criteria.

Due to the nature of bug reporting in JDK, the attached tests results are 
against JDK23.   We'll request a backport to at least JDK21 so that it lands on 
an LTS release.

> Degraded quality on macOS when dpi is not provided
> --------------------------------------------------
>
>                 Key: PDFBOX-5971
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5971
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.33, 3.0.4 PDFBox
>         Environment: openjdk 11.0.26
> macOS 15.3.1
>            Reporter: Tres Finocchiaro
>            Priority: Major
>         Attachments: image-2025-03-07-13-34-55-860.png, 
> image-2025-03-07-16-07-14-939.png, jdk23_patch.jpg, 
> minimal_example_TYPE_INT_RGB.png, pb_usps_sample-1.pdf
>
>
> When providing a `-dpi` to PDFBOX:
> {quote}Render into intermediate image with specific dpi and then print. Use 
> -1 for automatic detection of printer resolution.
> {quote}
> When printing to a 203 DPI printer on macOS, the quality differences are 
> quite different, with `-dpi 203` being significantly better quality.  This 
> issue was originally discovered in PDFBOX-5967 due to a downstream usage 
> preferring `-dpi 203` for some older JDK versions due to a hard-crash 
> (PDFBOX-2682).
>  
> Good: (with DPI)
> {quote}{{java -jar ~/Downloads/pdfbox-app-2.0.33.jar PrintPDF -dpi 203 
> -noColorOpt ~/Downloads/pb_usps_sample.pdf}}
> {quote}
> Not as good: (without DPI)
> {quote}{{java -jar ~/Downloads/pdfbox-app-2.0.33.jar PrintPDF -noColorOpt 
> ~/Downloads/pb_usps_sample.pdf}}
> {quote}
>  * I understand that this may be a result of something happening at the 
> OS-level.  If this is the case, any guidance as to how to isolate and provide 
> a bug report for openjdk is greatly appreciated.
>  * If there's a workaround that can be used as a stop-gap leveraging the 
> PDFBOX API, that would also be greatly appreciated.
>  
> [^pb_usps_sample.pdf]
> !image-2025-03-07-13-34-55-860.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to