Office documents to PDF

Justin Rassier picture Justin Rassier · Oct 5, 2011 · Viewed 7.4k times · Source

I have seen a couple threads about this, but am not getting very straight answers in my searching. I have a web application that needs to take in doc, docx, xls, xlsx files and convert them into PDF. Right now we have a process that uses the Microsoft.Office.Interop.Word library which opens up the document, prints it to a PS file, then GPL GhostScript converts the PS file into a PDF.

This process works OKish, but overall there are several steps in there, and this was originally developed years ago when it was even harder to find a PDF print driver and interface it. In the spirit of updating, I am looking at trying to find a possible better way to handle this. The main reason is that in our application we use a web service call to perform the elevated operation of the conversion process, with newer windows server and in particular for Window 7 for development, the ability to open the file even with impersonation is causing some issues with the Interop library.

All of this I'm sure can be figured out and ironed out, but I was wondering if there is a newer and better way to go about this. I have looked into PDF995, but am not finding a great way to programmatically go in and print a file directly to a PDF. The code they provide is in C++ and I am not finding how to mimic the calls in C#.

Answer

Steve Danner picture Steve Danner · Oct 5, 2011

If you're looking for a "free" solution, I think you might have the only viable option out there, but like John said, server-side interop is typically not a good idea. We've used the .NET Aspose components with a great deal of success. This is a pure managed solution with no interop or office required.