HOME     SITEMAP     RSS     TWITTER     EMAIL    
Search:   

FollowSteph Follow Steph as he posts Blog Blazer Friday
 
 

Printing is Broken on Mac OS X with Java 7

Confused Programmer

Printing on the Mac OS with Java 7 has been broken for a long time, months in fact. I don’t understand how this can possibly happen. After all printing isn’t exactly a small issue, and the Mac isn’t exactly a small market. So how can this be? For months? I don’t get it…

Specifically the font attributes are not honored on the Mac OS. Java seems to make the proper OS calls but for whatever reason the Mac OS just ignores those calls. Here’s the official bug report. To quote:

“Call to MacOS native function CTTypesetterCreateWithAttributedStringAndOptions did not produce the expected result.  Although the font dictionary was passed in options, for unknown reason, it is ignored.  Fix is to add the font dictionary in the attributed string and use CTTypesetterCreateWithAttributedString.”

And this only affects the Mac, it works fine in Windows or with Linux. The following code shows how to replicate the Java 7 printing bug on the Mac OS:

Font font = new Font("Times", Font.BOLD, 24);
Graphics2D g = (Graphics2D)graphics;
g.setFont(font);
g.drawString("Hello World", 10, 10);
// Increase font by 10 - Mac OS ignores this next line of code.
g.setFont(font.deriveFont(font.getSize2D()+10));
g.drawString("Hello World in a bigger font", 10, 100);

The weirdest part of this whole issue is that it’s really only broken in Java 7!! Of course it’s the only stable release of Java. How does that make any sense? It still works on Java 6 which is no longer supported (past it’s End of Life). For Java 8, which is still in beta and does NOT have a stable release, it seems to be working. However for Java 7, nope. Nothing. Nada. Huh???

In case you want to read further information from the better links I found on the issue, they are here, here, here, here, here, here, here, here, here, here, and here. Just a few links. So it’s not exactly an unknown issue. Many people are struggling with it.

That being said, several people have found workaround solutions, including us here at LandlordMax Property Management Software. A common solution I’ve heard is to create an image of what you want to print and print that image. It makes sense and it will work because you’re bypassing the font attributes. I’m not a big fan of this solution, especially since it doesn’t really scale well to multi-page report printouts that we need in LandlordMax.

So what we’ve been forced to do is create a temporary PDF file of the report, ask the Mac OS to print the file using the system command lp filename.pdf, and then delete the temporary file. This works pretty well, the only downside is that the Page Setup and printer setting options that comes along with most programs are not available because we’re not really printing from the software itself, nor can we pass them on to the system command. It’s not ideal, but it’s the only way to print within Java 7 on the Mac OS.

We added this workaround in the software with Java 7 Update 17. Unfortunately s far as we can tell the bug has been around at least since Update 9, but probably earlier. I just checked and we’re now at Java 7 Update 25, and guess what. Still no fix! No mention of the issue either.

The big question now is whether this is a Java (Oracle) issue or a Mac (Apple) issue? In either case, I would think both companies should want to fix this issue right away. It’s not exactly a minor issue. I don’t understand what’s holding up a resolution to this issue. It makes absolutely no sense to me. This is core functionality that affects both their users in a big way. It’s not a little bug, it’s huge! Printing is important, even in today’s digital world.

Hopefully Apple and Oracle can put their differences aside for a little bit and resolve this issue. It’s affecting a lot of people and we don’t deserve to be the collateral damage to their war against each other.



 
Like this article?

Comments:

  •     Josep Llodrà
    · August 28th, 2013  · 11:12 am  · Permalink

    This 7u40 seems to fix font printing issues. Still having problems printing with a printer other than default here.

  •     Josep Llodrà
    · August 28th, 2013  · 11:13 am  · Permalink

    JDK 7 Update 40 Early Access Release
    Link here: https://jdk7.java.net/download.html

  •     followsteph
    · August 28th, 2013  · 4:46 pm  · Permalink

    Hopefully that fixes it. That being said, we have to wait until it’s an official release, we can’t use an early access release because of the potential for issues.

    Also it’s odd that you’re seeing it work since that bug is nowhere in the release notes: https://jdk7.java.net/EA_features_changes.html Is it possible there’s another release between 25 and 40 that will have this fixed? I didn’t see one but maybe I missed something…

Write a reply:





 


SOFTWARE AND BOOKS BY STEPHANE GRENIER:

LandlordMax Property Management Software

LandlordMax is the EASIEST
Property Management
Software available!
Try it for free!

Real Estate Pigeon

Real Estate Pigeon
The place to ask and answer
all your real estate questions

Blog Blazers: 40 Top Bloggers Share Their Secrets to Creating a High-Profile, High-Traffic, and High-Profit Blog!

Blog Blazers is a book that
features secrets from the
Top 40 Bloggers on the web

How to Generate Traffic to Your Website ebook

How to Generate Traffic to
Your Website
is an ebook for
to you achieve success


 

FollowSteph
More resources from Stephane Grenier:
PUBLICATIONS
For people who work on the web
Blog Blazers
How to Generate Traffic to Your Website
 
SOFTWARE
The EASIEST Property Management Software available!
LandlordMax


Copyright @2003-2024
LandlordMax Property Management Software

Disclaimer: This is a personal blog about my thoughts, experiences and ideas. The contents of this blog are for informational purposes only. No content should be construed as financial, business, personal, or any other type of advice. Commenters, advertisers and linked sites are entirely responsible for their own content and do not represent the views of myself. All decisions involve risks and results are not guaranteed. Always do your own research, due diligence, and consult your own professional advisors before making any decision. This blog (including myself) assumes no liability with regard to results based on use of information from this blog. If this blog contains any errors, misrepresentations, or omissions, please contact me or leave a comment to have the content corrected.