cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Looking for java code to convert word files to pdf

Former Member
0 Likes
1,897

Hello,

I am looking for a way to convert word files to pdf using Java. I am familiar with the jakarta POI project but unfortunally it doesn't contain this option. Does anyone have a sample code to do that?

Roy

View Entire Topic
detlev_beutner
Active Contributor
0 Likes

Hi Roy,

this is a hard task. The problem is not only reading Word (POI's word API is somewhere between alpha and beta, it's not as good as the XLS-API, and at the moment, not under further development).

Some good source to look out for libraries for reading/writing different file formats is http://schmidt.devlib.org/java/document-libraries.html

Anyhow, when I had to convert Word into pure txt, I used StarOffice and it's Java API (not very comfortable, but possible). This is a way I would think about (you'd need StarOffice installed on the server). Maybe extracting to RTF before would bring you further, don't know...

As said, a hard task...

Hope it helps

Detlev

Former Member
0 Likes

Hey Detlev,

I think I found good library to do that, it is called iText: http://www.lowagie.com/iText/docs.html.

I will investigate it and let you know...

Cheers,

Roy

detlev_beutner
Active Contributor
0 Likes

Hi Roy,

from the FAQ:

> Can I convert WORD doc-files or RTF to PDF using iText?

>

> No, iText is only able to generate RTF.

> It doesn't do RTF or Word-doc parsing. Try Apache POI.

At least, it would be a very hard task to support each Word feature manually into PDF creation.

I don't think that there is a comfortable way except really "printing" the PDF (of course, this should be done automatically, so this is the question if StarOffice or a third tool provide the API for this functionality).

Hope it helps

Detlev

Former Member
0 Likes

Yep, I just saw it 2.

Well, I'll try looking for a free web service which does that and than I'll simply pass it the word file and get the pdf. I found such web services but unfortunally not free ones...

Roy