I have found several open-source/freeware programs that allow you to convert .doc files to .pdf files, but they're all of the application/printer driver variety, with no SDK attached.
I have found several programs that do have an SDK allowing you to convert .doc files to .pdf files, but they're all of the proprietary type, $2,000 a license or thereabouts.
Does anyone know of any clean, inexpensive (preferably free) programmatic solution to my problem, using C# or VB.NET?
Thanks!
For programmers who are in a situation where they cannot install Office on their server, or operating in some cloud environment -- an inexpensive alternative to the other answers is Api2Pdf which supports converting Word files to PDF as well as any other MS Office file. It is a web API and uses LibreOffice under the hood.
Seems to be some relevent info here:
Converting MS Word Documents to PDF in ASP.NET
Also, with Office 2007 having publish to PDF functionality, I guess you could use office automation to open the *.DOC file in Word 2007 and Save as PDF. I'm not too keen on office automation as it's slow and prone to hanging, but just throwing that out there...
Use a foreach loop instead of a for loop - it solved my problem.
Here is a modification of a program that worked for me. It uses Word 2007 with the Save As PDF add-in installed. It searches a directory for .doc files, opens them in Word and then saves them as a PDF. Note that you'll need to add a reference to Microsoft.Office.Interop.Word to the solution.
When I stumbled upon some problems with server side office automation we looked into the technique described here on codeproject. It uses the portable version (which can be deployed via xcopy) of OpenOffice in combination with a macro. Although we haven't done the switch ourselves yet, it looks very promissing.
PDFCreator has a COM component, callable from .NET or VBScript (samples included in the download).
But, it seems to me that a printer is just what you need - just mix that with Word's automation, and you should be good to go.
To sum it up for vb.net users, the free option (must have office installed):
Microsoft office assembies download:
pia for office 2007
Add reference to Microsoft.Office.Interop.Word.Application
Add using or import (vb.net) statement to Microsoft.Office.Interop.Word.Application
VB.NET example: