Introduction
In this article, I will show you how to setup IIS 7.0 to run an ASP.NET application that uses Solid Framework SDK to convert a PDF document to a TXT file. The application will use SMTP to email the converted document as an attachment.
Setup
To run the ASP.NET application, I will use Windows Vista with IIS 7.0 installed. I want to run it in IIS to show you what you need to do in Solid Framework to get permissions to work correctly.
- Installing IIS
Navigate to Control Panel\Programs\Programs and Features\Turn Window Features on or off.
Check Internet Information Services. Make sure World Wide Web Services, Application Development Features, .NET Extensibility and ASP.NET are selected as well.
- Download PdfToText Project
The sample application can be downloaded from here. Extract the zip file to any folder you would like.
- Download Solid Framework SDK
You can download Solid Framework from this link. Download the DLL to the root folder of the extracted PdfToText project. This is the same location as the .sln file.
Setting Up the Working Directory
Since the ASP.NET application is going to be run as Local Service, you need to setup a directory that Solid Framework will use during conversion.
I'll guide you through the default directories that are used in the ASP.NET application code. Later, I will show you where the code is, and you can change this directory to your liking.
In explorer, navigate to
C:\ and create a folder called
working. Right click on this folder and select properties. Under the Security tab, select edit and add Local Service to the list. Select the Local Service user and give this user Read & execute, Read and Write permissions.
During conversion, Solid Framework uses the current user's temp directory as the location to create a temp file for the conversion. In IIS 7, this was changed for Local Service to c:\Windows\Temp directory. Server 2008 and Vista default read\write permission to Local Service for this directory. You should verify that this has not been changed.
About PdfToText Code
PdfToText is a simple ASP.NET application that asks the user for a PDF file to convert to a text file. The main page is as follows:
Once the file is converted, it will be emailed as an attachment to the email address specified in the Email text box. As I mentioned earlier, the following code snippet shows the setup for the working folder Solid Framework will use. To move this folder, just change the full path for GrantedTempDirectory. This folder must have the Local Service permissions described above.
string GrantedTempDirectory = "c:\\working\\";
// LOCAL SERVICE will create if it does not exist.
string GrantedUploadDirectory = Path.Combine(GrantedTempDirectory, "uploaded");
// Framework assembly folder. Created.
string GrantedFrameworkDirectory = Path.Combine(GrantedTempDirectory, "SolidDocuments");
if (!Directory.Exists(GrantedUploadDirectory))
{
Directory.CreateDirectory(GrantedUploadDirectory);
}
Everything to do the conversion happens in the following few lines of code:
using (PdfToTextConverter converter = new PdfToTextConverter())
{
converter.AddSourceFile(pdfFile);
if (hasPageRange.Checked)
{
converter.PageRange = PageRange.Parse(PageRangeBox.Text);
}
ConversionStatus status =
converter.ConvertTo(outputFileName, true);
if (status != ConversionStatus.Success)
{
throw new Exception("unexpected converter result");
}
}
Files to be converted will be uploaded from the client and placed in a folder called uploaded in the GrantedTempDirectory. On first use, Solid Framework will extract its needed assemblies to the SolidDocuments folder under GrantedTempDirectory. These assemblies will either be the 32 or 64 bit assemblies depending on which bitness the .NET framework is running at.
Adding the PdfToText application to IIS
Adding PdfToText to the web server is straightforward.
- Right click on Computer, select Manage and navigate to Internet Information Services (IIS) Manager
- In Connections on the right, expand Local Computer, Sites and you should see Default Web Site
- Right click on Default Web Site and select Add Application.
- Alias: textbox, fill in any name you want for the subfolder in the URL. I used pdftotext.
- Physical path: Hit the browse button and navigate to the PdfToText project folder. The dialog should look like:

- Click OK.
History
- 17th September, 2010: Initial post