Search code examples
c#.netasp.netoffice-interoppdf-conversion

Office documents to PDF


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#.


Solution

  • 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.