I have seen a couple threads about this, however am not getting very straight answers in my searching. I have a web application that requires to take in doc, docx, xls, xlsx files and transform them into PDF. Today we have a procedure that uses the Microsoft.Office.Interop.Word library which opens up the file, prints it to a PS file, then GPL GhostScript converts the PS file into a PDF.
This process works , however in general there are a number of actions in there, and this was initially developed years ago when it was even harder to discover a PDF print motorist and user interface it. In the spirit of upgrading, I am looking at trying to discover a possible much better method to manage this. The main reason is that in our application we use a web service call to perform the elevated operation of the conversion procedure, with more recent windows server and in particular for Window 7 for development, the capability to open the file even with impersonation is causing some issues with the Interop library.
All of this I make certain can be found out and settled, however I was questioning if there is a newer and much better method to tackle this. I have checked out PDF995, but am not finding a great method to programmatically enter and print a file straight to a PDF. The code they supply is in C++ and I am not discovering how to imitate the calls in C#.
The Office Interop code, and the Office applications it talks to, were designed for a single-user, interactive environment. That just plain doesn’t work properly in a multi-threaded, multi-user environment.
It’s great to work on a server, you just desire a background procedure that watches your data for documents that have to be transformed. the issue with running directly from asp pages is that several requests can both aim to invoke the com things at the very same time.
If you’re looking for a “complimentary” solution, I think you may have the only feasible option out there, but like John said, server-side interop is generally not a good concept. We have actually utilized the.NET Aspose parts with an excellent deal of success. This is a pure handled option with no interop or office required.
Here’s the code for transforming a Docx to PDF using Interop. Ideally you can figure out how to do the other files using this as a starting point.
Exists a business library (for c# WinForms) out there that I can use to View/Edit Microsoft Office files?
I require it for a business application which can edit and/or open Office files. The application requires an ingrained control not redirect the user to set up circumstances of Microsoft Office.
You can add ExcelObj, Workbork and Worksheet to your application. It’s all quite self explanatory. In the copying you check out content of a spreadsheet.
If you wish to do this with Office items, you have to install a copy of Microsoft Office and install the subprograms PIA (Main Interop Assemblies). Otherwise you need to look for alternatives like:
iDiTect.Excel – modify excel spreadsheet in c#.NET.
NPOI – Which is totally free and open source.
Spreadsheet XML – Essentially XML for producing spreadsheets.
OfficeWriter Application API
EPPlus, a.NET library that reads and composes Excel 2007/2010 files utilizing the Open Office XML format.