10

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.

JeremyWeir
  • 24,118
  • 10
  • 92
  • 107
  • 7
    Good idea. Can you call all my clients for me too :) – JeremyWeir Jun 04 '10 at 23:52
  • you're invoking Word-code, how on earth would you even remotely be able to that if Word is not installed !? – Pauli Østerø Jan 19 '11 at 05:01
  • 1
    Pauli - I was hoping for assembly references or some other programmable interface that didn't require actual installation. Existence of dlls or exes is not the same thing as installation. – JeremyWeir Jan 22 '11 at 03:46

4 Answers4

4

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
  • 11,194
  • 5
  • 43
  • 56
  • Do you know for sure that itextsharp can simply convert a Word doc accurately? – JeremyWeir Jun 04 '10 at 23:00
  • 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-programmatically Much 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 Jun 04 '10 at 23:03
1

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
  • 15,219
  • 3
  • 51
  • 63
  • 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. – JeremyWeir Jun 04 '10 at 23:51
0

You can use reportviewers save as pdf option.

Efe Kaptan
  • 465
  • 2
  • 11
0

I ended up using OpenOffice Portable...

http://portableapps.com/apps/office/openoffice_portable

JeremyWeir
  • 24,118
  • 10
  • 92
  • 107