tags:

views:

372

answers:

2

Okay, so here's my problem:

We use FOP for creating "pretty" report output. We use the pdf option if the user wants a file, AWT for previewing, and the -print option for printing them. We are using FOP 0.25.x, which I fully recognize is not the newest version, but upgrading to 0.95 appears to be a non-trivial task that I don't necessarily want to undertake.

Anyway, it was noticed by one of our users that when printing ID cards (generated via FOP -print option) to the id card printer, the images on the cards (pictures of the employees) had some corruption in them...sort of like like green and reds dots and lines. We also discovered that if we sent the exact same print request to one of our HP color laserjets, it printed fine. To add to the strangeness, if we use FOP to create a PDF of the ID card and then print it via acrobat reader on the card printer, it prints fine.

I eventually discovered that it had something to do with the scaling of the images...we were scaling 600px high images down to something like 120px. If I presized the images down, even just halfing them, the corruption went down noticeably. Similarly, when I upsized the images, the corruption went up.

So my question: anybody have ANY idea what is going on here? Or has ever run into such a thing?

Since I don't know why this is happening, I don't know how to fix the root cause, but I've been working through some various workarounds:

1) Use FOP to create a pdf of the image and then print that via Java. This seems like an obvious answer, but some Googling around showed that printing a PDF via Java is not trivial. I've seen the PDF Renderer project on java.net, but seems pretty bulky for a single very specific application.

2) Try to resize the images before giving it to FOP. This also seemed pretty straightforward, however our various users can setup stylesheets for these id cards however they want and using "pt" and "in" sizing in them seems to be pretty common...I don't know of any good way to map that to a pixel resizing.

If anybody has any insight into the root cause, ways to make these work arounds work, and/or another idea, you'd be in my debt.

A: 

Most certain explanation:
image corruption? it's a bug.

Why not use 0.95? Sooner or later you have to upgrade, Apache consortium won't fix bugs in 0.25.x versions.

You can't hope to find workarounds for every bugs which might occur in future.

ivan_ivanovich_ivanoff
The reason to not upgrade is that in the newer versions of the software we use a different tool entirely (C# based, can't remember which one), so we really won't ever need to upgrade this...especially due to how much got changed from 0.25 to 0.95.
Morinar
A: 

I ended up doing the second thing I mention in the original question...i.e. resizing it before giving it to FOP. I found that I could retrieve the dpi of the printer I was printing to and do some math on it to get pixel sizing. Seems to work perfectly in all my testing...not a real solution but an adequate workaround.

Morinar