views:

371

answers:

4

The sample code in this article for creating a PDF from a Word doc works great if you have word installed on the machine.

http://msdn.microsoft.com/en-us/library/bb412305.aspx

I'm curious if it is possible to do this without having to install Word.

+3  A: 

I think Word Interop around the 2000s allowed us to redistribute Word DLLs with our application, such that it worked even without Word being installed. However, this may no longer be the case.

One other option, depending on your use case, would be to generate the PDF directly: http://itextsharp.sourceforge.net/

drharris
Do you know for sure that itextsharp can simply convert a Word doc accurately?
jayrdub
No, it likely will not. ITextSharp is for the creation of PDF documents. That's why I specified "depending on your use case", because I didn't know if you were creating or converting. Since you're converting, have a gander at this old SO thread: http://stackoverflow.com/questions/607669/how-do-i-convert-word-files-to-pdf-programmaticallyMuch of it still remains true. In the end you're going to have to either pay some money or use the Save As PDF add-in.
drharris
A: 

I'm curious if it is possible to [create a PDF] without having to install Word.

Install OpenOffice.org.

amphetamachine
A: 

Yes, you can automate Word using interop and presumably print the docx to pdf that way. But MSDN explicitly says Office Interop can be naughty in terms of potentially breaking your web server scalability. I would trust its words and avoid it by finding a third party doc to pdf renderer - though I know many whom have not.

Be sure that you understand all the considerations for server-side Automation of Office.

Just by googling you should find many doc to pdf conversion libraries - inded there may even be a remote webservice you could call!

Reddog
Yes, there are lots of options (they are are either really crappy or really expensive), but using Word's interop gives really good results with not a lot of code. So I was just wondering if there have been any advances in getting it to work on a machine without installing Word.
jayrdub
A: 

You can use reportviewers save as pdf option.

Efe Kaptan