Monday, September 15, 2008

Convert PDF files to DOC Programmatically using ASP.NET

One common topic in e-mails we receive is whether Solid Framework can be used in a web application or not.

Solid Framework can be integrated into an ASP.NET project. A simple example how this might work is below:


(screen shot from the sample project)

This page provides the means for the end user to select a PDF file they wish to convert to DOC, select several conversion options and then type in their contact details so that the result may be e-mailed back to them. Clicking the Convert PDF to DOC button starts the upload and conversion process.

You can download the sample ASP.NET project [zip file] to see this in action for yourself. Those without Microsoft Visual Studio 2008 can use Microsoft Visual Web Developer 2008 for free to work with the sample project.

Most of the project is implementation and doesn't require careful study. Two sections you'll likely want to look at in the C# code-behind file are below:


This creates a new PdfToWordConverter object that you'll use to convert the PDF file to DOC. It checks the properties of several server controls on the page and sets the converter object's properties based on their values and then converts the file.


This code creates a new MailMessage, attached the converted DOC file, creates a new SmtpClient, attaches the message and sends it. Those wanting to modify this should look at the MSDN documentation for the System.Net.Mail namespace.

Configuration of the outgoing mail server settings (among other things) can be done in the web.config file in the project.

Assuming that you're using the default syntax highlighting in Microsoft Visual Web Developer just look for the friendly green comments in the web.config file for instructions. If you've configured the syntax highlighting to use an unfriendly color for comments we apologize in advance.

Note: Solid Framework is sold and licensed as a royalty-free SDK. Please review the Solid Framework licensing conditions and contact us if you need clarification.

Have any thoughts that you'd like to share? Please contact us with your feedback.