Friday, May 28, 2010

In Reponse To...

This blog post is in response to Mark Stephens who wrote a comment to my JPedal LGPL Direct Links blog post. Thank you Mark for your comment. I'd like to reply to it here, since I'm likely going longer than a traditional comment block would support.

Here is Mark's comment:
Adam,

Its done automatically and you are taken straight to the page with the download links on. As you say, you don't even need to post a valid email address if you are paranoid.

We just ask for an email address so we can get an idea where the software is being downloaded from. IS that so unreasonable?

We go to a lot of trouble to make a version of the software freely available, we spend our lives updating it and answering questions on the forums and wonder why we bother when we see your comments...

Thanks again Mark, I appreciate the dialog.

First, you're right, currently the download link to the LGPL JPedal viewer is available on the page after submitting the 'name and email' form (I just tried it out). However, this was NOT the case when I wrote the blog post originally. I had to wait for an email to be sent to me in order receive the download link location.

So, kudos to you guys for changing your form. If it had been this way originally, I wouldn't have written my post. I think it's perfectly acceptable for you to ask for name and email, if you choose. According to the LGPL, you can even charge for downloads of your Free Software.

With the previous procedure, I had to post a valid email address, so being paranoid was not an option. This was because, again, the links were not present on the page following the form submission. I even tried an @mailinator.com email address waiting for the links that way, again with no luck. This gave rise to my suspicion that a manual process was in place, since Mailinator email addresses tend to get through otherwise.

So no, in my opinion, what you're doing (now) is not unreasonable to ask. What is unreasonable, in the spirit of Open Source Software, is to expect valid data to download your software (in this case, valid email). Though, of course, not required by most (all?) open source licenses, many Free Software advocates tend also to be privacy minded and expect to be able to download anonymously and for free. And if we can't, we assert the rights which you gave us, to legally distribute your Open software (for free) or, at the very least, do what I did and provide the direct download links.

This is all, therefore, water under the bridge. Your new procedure changes the need for me to provide direct download links to your software. Like I said, I wouldn't have written my original post if it had been the case.

Your second argument, however, doesn't hold water. You seem to suggest that you are going out of your way to make your software available to the open source software community for some benevolent cause. That you are heavy burdened by your LGPL initiatives.

The fact is that releasing an Open Source version of your software benefits you and supports your business model, because otherwise, you wouldn't have done it to begin with. In your case, you are hoping to provide an upgrade path from LGPL users to commercially licensed users, by removing support for printing and extraction in your LGPL product. In your business model, you are releasing your software as LGPL somewhat as a taste of the full package, almost like a limited trial edition. What you're doing is no more about Free Software (capital F) than what a "freeware" publisher is doing.

If you are "spending your lives" supporting your free software version without any direct or indirect benefit, then if I were you, I would be questioning your involvement. If you are so burdened by your support of the LGPL version, since you are obviously strictly motivated to this release for financial reasons, then I am just not seeing that the math is working out for you.

I have no idea why you took such offense at my original post, but if Open Source is not benefiting your business model (now or in the future), then honestly we (the Open Source Community) really don't want your code. If you are strictly in this to support your bottom line, and you are so bothered by posts like mine or support/complaints in your forums, then maybe you should just stop. It would be sad to lose your contributions, but it's better this way.

We, the OSS community, want partners and contributors who are supportive and happy about our cause. And, if you are able to make a buck in the process, even better. We have no problem with that either.

However, to imply that you are somehow burdened by the support of your software without rewards, or that you expect some sort of kissing of your backside because of your contributions, well, maybe it's time to say goodbye. We'd hate to see you leave, but rather that than to know that you are somehow dissatisfied with the Open Software Value Proposition. It's no skin off our backs, either way.

Friday, April 23, 2010

Open Source Java PDF Viewing Library Review

Here's a quick review of three open source Java based PDF libraries which can be used to view PDF documents in a Swing application. While there are some very good PDF generation libraries (iText and friends), there are fewer libraries which help render a PDF document into a type suitable for viewing in Swing.

JPedal
http://www.jpedal.org/

I've used JPedal in previous projects. It seems to work decently, but looking at the source code, the project is very disorganized and likely prone to bugs.

In my previous project, I had always exited my application by calling System.exit() or using the EXIT_ON_CLOSE parameter to the default close operation on a JFrame. It wasn't until playing with JPedal in a new project that I realized JPedal is hanging my swing app and preventing it from shutting down if my frames are simply disposed of. That is, if after having rendered a PDF document using JPedal, an application won't shutdown without having issued a System.exit().

I couldn't even find a single JPedal example where they used anything but System.exit(), so it seems they're probably aware of the problem and possibly hiding it? Don't know. I tried every combination I could find to cleanly close and dispose the JPedal resources to no avail. After looking at the source code, it doesn't necessarily surprise me.

I gave up on JPedal and was forced to move onto other choices.

PDF Renderer
https://pdf-renderer.dev.java.net/

This is/was a Sun sponsored open source project started by a few key Swing developers. I have met Richard Bair in person and he's a real great guy. So, this seemed like a logical next project to take a look at.

The API is by far the easiest to use. It's very simple to get a Swing based view of a PDF document up. However, the library currently only supports older PDF document versions. I have read that there is a patch available to allow rendering of new PDF. *bah* I was hoping for a solution that didn't require building the code myself. And, it somewhat looks like the project has stalled, which shouldn't be surprising given Sun's push on JavaFX and now Oracle.

Onto the next project.

Apache PDFBox
http://pdfbox.apache.org/

This turned out to be a good working solution. The API is a bit more confusing than the other two, and I couldn't seem to find an existing Swing component to render a PDF. But, the PDPage class of PDFBox has a convertToImage() method which returns a BufferedImage. So, it was fairly easy to take the generated image and draw onto the canvas of a JComponent.

My conversion code looks something like:
PDDocument doc = null;
try {
doc = PDDocument.load(inputStream);
final PDPage page = (PDPage) doc.getDocumentCatalog().getAllPages().get(0);

PipedInputStream pis = new PipedInputStream();
final PipedOutputStream pos = new PipedOutputStream(pis);

new Thread(new Runnable() {
@Override
public void run() {
try {
ImageIO.write(page.convertToImage(), "png", pos);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();

// create image panel
JPanel panel = new ImagePanel(pis);

} finally {
if (doc != null) {
doc.close();
}
}
My ImagePanel requires an InputStream (for reasons specific to the application), thus why the use of the I/O pipes. I also wish I knew a better way to get just the first page of the PDF document (without a call to getAllPage()), since this is all I was interested in (the application is generating a preview of the first PDF page).

PDFBox renders the newest PDF documents (from what I can tell), so this is good. Like I said, the API is a bit more difficult to learn, though it's now seemingly straight forward (as can be seen from the above). PDFBox is also in the Maven central repository, which is great for Maven development. All in all, I'm pretty happy with PDFBox.

jPodRenderer
http://opensource.intarsys.de/home/en/index.php?n=JPodRenderer.HomePage

I just found jPod tonight, having skipped over it a few times when searching. It actually looks pretty promising, especially since they have a specific renderer which will render to both AWT and SWT. So, that's cool. Looks like they have dependency on quite a few jars, though, and they don't seem to be in the central Maven repository, which stinks because of the dependencies. Anyway, if anyone has a review of jPod, send a link my way; I'd like to read about it.

Updated May 28th, 2010.
ICEpdf
http://www.icepdf.org/

Thanks to Mark Stephens at JPedal for providing this link. I wasn't aware of the project.

Friday, April 16, 2010

JPedal LGPL Direct Links

I get tired of the hoops some companies expect you to go through to download the Free Software versions of their products. JPedal, a PDF viewing library for Java, is one such example. They have an LGPL version of their library, but you must fill out a form asking for email and name in order to get it. Big deal, right? Just make something up, right? Seems like they have someone manually processing these requests, which means delays in getting what you need.

This is Free Software, isn't it? So, here are the direct links to the JPedal LGPL licensed software:

Binary: http://www.jpedal.org/download/lgpl/jpedal_lgpl.jar

Source: http://www.jpedal.org/download/lgpl/jpedal_lgpl_src.zip

p.s. According to the source, the latest version (as of this writing) is: 4.11b76

Monday, February 15, 2010

Simple Java Event Bus

I've just released some code that has come in handy for quite a few projects I've worked on. It's called the Simple Java Event Bus and is released under the New BSD license. You can download the code here: http://code.google.com/p/simpleeventbus/

An event bus is a useful pattern for decoupling the components of a highly meshed application. Event bus is a substitute for the Observer pattern, useful when too many observers/observables exist to keep a clean design. Components can couple directly to the EventBus instead of to each other, allowing events or messages to be published to the bus. Listeners to the bus will then be notified about the event if they have interest in the event type.

I have used other event bus implementations in live code. However, I have found that the above library to be the most simple to use and to get started quickly with. Hope you can benefit from the code as well.

Tuesday, November 3, 2009

Economics in One Lesson

This is one of those links you tuck away and revisit when you need a fresh perspective or a reset of values when things are hazy...
Economics is haunted by more fallacies than any other study known to man. This is no accident. The inherent difficulties of the subject would be great enough in any case, but they are multiplied a thousandfold by a factor that is insignificant in, say, physics, mathematics or medicine-the special pleading of selfish interests. While every group has certain economic interests identical with those of all groups, every group has also, as we shall see, interests antagonistic to those of all other groups. ...
Economics in One Lesson

Tuesday, October 13, 2009

So You Want to Learn Japanese

You’ve eaten at a few Japanese restaurants, seen some anime, hosted an exchange student, and had a Japanese girlfriend. And now, somewhere in the back of your tiny brain, you think that Japanese would be a good language to learn…

http://pepper.idge.net/japanese/