Hi,

I'm looking for an java api which can convert .doc file into .pdf file... i need this solution to work without any intervention of MS Office/Windows.

If anyone have any idea about such api , please reply.

Thanks ahead

Daniel

Recommended Answers

All 40 Replies

Davisor Publisher is a Java API that can convert from a DOC, PPT or PDF to PDF, XHTML, PNG, JPEG, TXT or XML formats. I haven't actually used it before but it seems to be a good one.

Thx darkagn!

gonna check it it

Another solution:

import officetools.OfficeFile;
...
FileInputStream fis = new FileInputStream(new File("test.doc")); // works with xls also
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");

All possible convertions:
html --> pdf
doc --> pdf, html, txt, rtf
xls --> pdf, html, csv
ppt --> pdf, swf
from dancrintea.ro/html-to-pdf/

commented: Reviving an Old thread, and on top of that providing an incomplete and sub standard solution -1

iText is a free, open source Java to PDF converter and it offers much more.

Verruckt24, I guess the O.P. by now must have already figured out how to accomplish this task.
"bertt" is the culprit who revived this thread older than almost 6 months and whats worse he doesn't even provide a decent answer, let alone use code tags or anything else.

I did not look into iText for last 2 years. Did they extend the scope of documents that can be converted? As far I can remember it was only images gif, png, bmp, tiff, wmf and jpeg (there was problem with JPEG2000 - type of grey colour), html, txt, rtf, xml. Are you sure you can convert office formats like doc, ppt or xls to pdf?

Verruckt24, I guess the O.P. by now must have already figured out how to accomplish this task.
"bertt" is the culprit who revived this thread older than almost 6 months and whats worse he doesn't even provide a decent answer, let alone use code tags or anything else.

Yes you are correct, I don't how but the post date somehow skipped my attention here.

Actually to convert from .doc to .pdf via Java I could not find a direct method, But I found a two step process,

  1. Access your Microsoft Format files using Apache POI, You can read more about it here.
  2. Next use iText to convert the data you have into a PDF.
commented: I missed the first step ;) +2

I tried the convertion method that bertt's described . bt I can't get the jar that contain the ' import officetools.OfficeFile' can any one please suggest a method to convert HTML to PDF

I tried the convertion method that bertt's described . bt I can't get the jar that contain the ' import officetools.OfficeFile' can any one please suggest a method to convert HTML to PDF

Thats the reason why his post has received a Bad Rep (RED Mark) and my post which was the actual answer received a Good Rep (Green Mark) if you had cared to observe.

Can anyone please help me ?????

I want to convert HTML to PDF using java code.... please give me a solution.......

Whats wrong with you the answer has already been given here

i don't want to use iTex ... most of the methods described above are not working :(

Which methods ? Have you even cared to go through the iText library and the Apache POI ? They both are stable production quality libraries.
Do your homework before posting blindly.

commented: Exactly the tone to use for such posts +6

i don't want to use iTex ... most of the methods described above are not working :(

iText is working fine as long you know how to use it not like brett.
iText tutorials, don't forget to download the library file and store it in your project folder

You can try JasperReports, but i think that´s for web develop only, anyway you can find something.

Hi,

Iam facing the same issue, have to convert any file come (e.g xls/doc/text...) into pdf for an urgent requrement. i have started with apache poi and itext but succeed. can you please help me with sample code that have both apache POI and itext used say for eample reading an excel and converting it into pdf. please hurry ....


Thanks,
Rajni

Actually to convert from .doc to .pdf via Java I could not find a direct method, But I found a two step process,

  1. Access your Microsoft Format files using Apache POI, You can read more about it here.
  2. Next use iText to convert the data you have into a PDF.

Hi,

Iam facing the same issue, have to convert any file come (e.g xls/doc/text...) into pdf for an urgent requrement. i have started with apache poi and itext but didnt succeed. can you please help me with sample code that have both apache POI and itext used say for eample reading an excel and converting it into pdf. please hurry ....


Thanks,
Rajni

can you please help me with sample code that have both apache POI and itext used say for eample reading an excel and converting it into pdf. please hurry ....

Yeah before that transfer a million dollars to my account !!!

Yeah before that transfer a million dollars to my account !!!

Please dnt joke .... u r from mumbai?? me tooo.. we can talk on the issue if u dnt mind ... please send the code sample.

Please dnt joke .... u r from mumbai?? me tooo.. we can talk on the issue if u dnt mind ... please send the code sample.

You're from Bombay that nice to know, but that does not mean I am going to spoon feed you any code. My first post in the thread links to the iText library and the Apache POI site, go visit them and you will find quite a few code samples there.

You're from Bombay that nice to know, but that does not mean I am going to spoon feed you any code. My first post in the thread links to the iText library and the Apache POI site, go visit them and you will find quite a few code samples there.

its nothing like spoon feed .... i have gone though the code alrady even can able to write the code on apache but didnt knw how to access that file whicg apache has made which itext may used to transfer in pdf code.

my undersatnding :

Excel/doc/txt... using (apache POI ) get transfered in some intermidiate file then itext convert that intermidiate file into pdf :

is that undersatnding is correct?? i just need the help ... m not telling u to write my code ... if u dnt saw on mails i have written i need some sample code not extact code since i dont knw how apache and itext work together .....i have written separate code for both :( please reply if u want to help else thanks :)

Guess what I found a direct API which does this conversion, although I do not know how it works :-
http://www.artofsolving.com/opensource/jodconverter

That need to install office org sdk ... which is not possible on my client machince .... can u provide the answers of Qs i posted on previous msg. Please explian the useage of apache and itext together???

You say you don't need spoon feeding, but what else are you asking for then, when you say "Please explian the useage of apache and itext together???". You have been given the links, you can go read the contents there, which I am sure would be more better in explaining the usage than anyone over here. What do you think we are going to do when we would be explaining you the stuff, we would read the contents on the site as well, why then do you need our interpretation for that.
If you are not aware of the customs here, let me tell you that we would be giving you only pointers in the right direction, which you have already been given, we aren't your tutors to do the explaining part for you as well.

You say you don't need spoon feeding, but what else are you asking for then, when you say "Please explian the useage of apache and itext together???". You have been given the links, you can go read the contents there, which I am sure would be more better in explaining the usage than anyone over here. What do you think we are going to do when we would be explaining you the stuff, we would read the contents on the site as well, why then do you need our interpretation for that.
If you are not aware of the customs here, let me tell you that we would be giving you only pointers in the right direction, which you have already been given, we aren't your tutors to do the explaining part for you as well.

i have alrady gone though the code on the specified links ... as it is not solving my problem and thought he has alrady implemented the same... so asked help and since i didnt find any link where we can use apache poi and itext together so asked... can u able to provide me link where apache poi and itext has been used together?

i guess this forum is there to explain the things .... sometime just posting the links wont help ...and if somebody has alrady implemeneted the things is really helpful. i guess u guys wont implemet anything and just post the link...

i have alrady gone though the code on the specified links

You haven't gone through anything, if you would have gone through, your questions would have changed, but you keep asking the same, lame questions again and again.

i didnt find any link where we can use apache poi and itext together so asked... can u able to provide me link where apache poi and itext has been used together?

You are still asking for spoon feeding like a baby.

i guess this forum is there to explain the things

Have you gone through the forum rules, if not go through them, if yes, still go through them again and try to understand them this time. We aren't in anyway obligated to help you.

and if somebody has alrady implemeneted the things is really helpful

Translation : I would be happy biting on ready made food than to cook it myself.

i guess u guys wont implemet anything and just post the link

Yes, rare enough but you are right this time.

Giving you one last hint, if you have the smarts to take it.
Go read how to read content of an excel file with Apache POI. Once you know how to obtain the content, go read how to transfer it to a pdf file using the iText library. That's all that you are going to get from me.

Hi! sorry if i'm bringing up this old topic but i'm trying to do exactly this method to convert from .doc to .pdf but can't get it! i've extracted the .doc text with POI then I tried to create a pdf file with that output using iText but it doesn't works for me; have any of you done this? i mean where could i find an example of this two things working together? it's the first time i use POI or iText and i've made test of both separately and works fine; i really appreciate your help!

Sorry guys! i saw a really old post of this topic and didn't read the hole fight with Rajni05 about the "spoon feeding", and is just exactly what i asked, i've been reading and testing a lot, i don't know if there is a sort of incompatibility with POI's output (FileOutputStream) and iText input stream; i've finally made a short example that works at half: the final pdf contains all the text from the original file (.doc,.xls,.ppt) and a bunch of garbage characters at the end; i'm working to make it right (and i dont want to think on images yet!), if i get a decent example of POI and iText together i'll post it.. thanks any way.. by the way, i'm from venezuela and i'm a new member.. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.