tags:

views:

231

answers:

4

I am trying to link some user docs to my Java Swing application. The user docs are pdf and I would like to be able to click on a button in my application which opens up some sort of pdf renderer to display my userdoc.pdf.

I do not want to use the runtime exec command

I have tried the following with not much success --

pdfRenderer -- this seems to not work for the current version of pdfs (seems to want older pdfs)

acrobat viewer -- I keep getting font errors (the document is displayed but everytime I go to a new page, I get an error)

JPedal pdfHelp - This sounds cool and if it will work, it would be the best for me. But for some reason, I am unable to open any file here. No pdf file that I have loads in the window (The pdfHelp panel comes up with a list of pdfs as promised, but when I right click one of them and say "OpenPDF", I just get a progress bar and the file does not load, I have tried a few files on this and checked file permissions)

JPedal SimpleViewer -- So far this one seems to be the most promising. I would like to remove some of the functionality of this viewer though and am not able to edit the xml to do this. When I edit the xml, then I seem to get xml parsing errors.

Has anybody done anything similar that worked? Help please

PS. I need this to work on Linux machines (IcePDF seems to works only for Windows). I would very much prefer something that is free!

A: 

Would Java's Desktop API meet your requirements? It does launch another process, but it's not through you calling Runtime.exec().

The Desktop API uses your host operating system's file associations to launch applications associated with specific file types.

Steve K
I would like my app to be able to run on different user environments. With the desktop API, what happens if the user's machine does not support the desktop API? (Having user download anything is not an option )
Anu
A: 

I chose pdfbox for a similar use case - it's not perfect with every PDF, but works pretty well and is under active development. From the PDDocument you can get a list of PDPage objects, which have a convertToImage() method that gives you a BufferedImage you can draw on screen. I switched to this from pdf-renderer because I felt it gave better results in general.

Alex Vigdor
A: 

PdfHelp has moved to its own domain at http://www.pdfhelp.org and have been updated to fix your issues and add some other improvements...

mark stephens
Thanks Mark. This works great! There are a few minor bugs but in my research this is the best product out there for viewing pdf files from Java. It is also quite easy to implement!
Anu
A: 

Update: pdfHelp from IDR solutions (creators of JPedal) works now. The latest version (4.0) has fixed the bug and it reads my pdf files (and I am sure more of the latest pdf files). Just playing around with the product today and it is great! There are few minor bugs but I really appreciate how quickly Mark Stephens(?) responded to the first bug. Good work guys!

Anu
Update: IDR solutions has fixed the bugs that I mentioned in my previous post and so far this is the best product that fits my needs for a pdf online help solution
Anu