tags:

views:

1085

answers:

4

Does anyone know of an easily available library or SDK which can be used to convert a PDF document to RTF in Java?

A: 

You could try looking at iText, which is primarily a PDF library, but it has an RTF package addon available.

RodeoClown
It looks like iText doesn't support conversion in this direction - http://itext.ugent.be/library/question.php?id=651 (unless it's changed since then..?)
Dexter
Fair enough - I haven't used the RTF addon, just saw it existed.
RodeoClown
+1  A: 

Try checking this link.

Directly from adobe.

Pedro Ghilardi
I had a look at that, but it seems to rely upon having a LiveCycle server already installed, which seems like a bit of overkill to me!
Dexter
A: 

What is your primary priority - identical layout, or editability?

Thorbjørn Ravn Andersen
Honestly.. the priority is to minimise development effort! Beyond that, identical layout is next most important.
Dexter
+2  A: 

Take another look at iText (I know that direct PDF -> RTF conversion isn't supported - but read on for spine tingling possibilities!).

  1. We added a PDF text parsing module to iText last year. Right now, this is somewhat rudimentary, but it does work, and is pretty easy to expand.

  2. iText is good at generating RTF.

So... It should be relatively straightforward (not easy, but straightforward) to parse text from a PDF and create an RTF based on the parsing.

If you have to preserve things like font, it will take a little bit more work (the PDF parser does provide font info, as well as page location for each piece of text), but I suspect that iText's RTF generator will simplify a lot of that.

If your PDFs contain embedded images that you need to bring over to the RTF, the current PDF parser doesn't really do much with that - but it has sufficient hooks to allow it to happen with a bit of elbow grease.

So I would say that iText can most likely do what you are looking for, and will help you achieve a local minimum of development effort, but I wouldn't put this in the class of super easy... Sounds like a nice challenge, actually.

If you do wind up implementing something like this, feel free to ping me with questions/thoughts after you've had a chance to play a bit. If you wind up with a decent bit of converting code, we might want to get it added to iText.

If you are wanting to just get this out the door, and you have money to spend, I'm sure that there are a number of commercial converters that do what you are looking for. Probably won't be cheap, but may be cheaper than your development time.

Kevin Day