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 pos开发者_如何学运维sible to do this without having to install Word.
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/
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!
You can use reportviewers save as pdf option.
I ended up using OpenOffice Portable...
http://portableapps.com/apps/office/openoffice_portable
精彩评论