7

On some printers, for whatever reason, the printouts are automatically enlarged with what seems to be default settings when printing through the Java JVM (Java 7). This seems to be with older printers, and it's pretty rare, but it is happening with more than one printer model. Also upgrading the drivers doesn't resolve the issue.

The software uses the JFreeReport (classic engine) library, and when using the library to export as a PDF, everything is great. As well the Print Preview using the library is perfect. However when it comes to printing, and this is only with a very very small number of printers, the printouts are enlarged. They aren't zoomed in, but the fonts are much much bigger and improperly spaced so that they overlap over each others.

These same printers with JDK 6 seem to work fine. Seem, I'm still trying to isolate the issue. My thinking is that possibly these printers do not correctly support Java 7

Update: I found this thread which seems to indicate that there are some issues with JDK 7u21. I didn't see anything in the release notes to address this. In addition here is another example of the a similar bug report.

Update2: For anyone interested, I wrote a blog post called Printing is Broken on Mac OS X with Java 7 about this issue which contains more details and what I discovered.

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192
  • For now I'm creating a temporary file and then calling "lp tempFile.pdf" but this isn't ideal because it assumes the default printer is the correct one. There has to be a solution. I can't believe that Oracle and Apple have left this major glaring bug for months. This is something critical for a lot of applications!!! – Stephane Grenier May 27 '13 at 02:12

3 Answers3

2

This is a known bug sadly. While there are a few workarounds (the symmetrical print resolution mentioned in your links, converting to a bufferedimage then printing that) I'm not aware of any fix as yet.

MrB
  • 818
  • 8
  • 28
0

Apparently there is no solution. The issue is that the font attributes set by the JVM are ignored by the Mac OS as reported in this bug report and this bug report.

The only workaround is to create a temporary file and then print it by using:

try
{
    Process process = Runtime.getRuntime().exec(new String[]{"lp", tempFileFullPath});
    process.waitFor();
} catch (Exception e) {
    // error handling
}

Of course this can be fired off in a thread or through SwingUtils depending if you have a GUI application, but it's the only way possible at this time.

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192
0

This is a known bug - if you don't want to use the PDF-print workaround, you can check out this answer:

https://stackoverflow.com/a/17345102/456837

Community
  • 1
  • 1
user456837
  • 183
  • 7