Click here to Skip to main content
Licence CPOL
First Posted 17 Sep 2010
Views 6,333
Bookmarked 6 times

Using Solid Framework in ASP.NET

By | 17 Sep 2010 | Article
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

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.

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

    checkeditems.png

  2. Download PdfToText Project
    The sample application can be downloaded from here. Extract the zip file to any folder you would like.
  3. 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.

permissions.png

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:

appscreen.png

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.

/* The web service is running as Local Service on Vista X64.  
 * You have to grant Read/Write access to 
 * temp folder to save the uploaded file to and a subfolder 
 * for Solid Framework to extract its
 * assemblies to on first use.
 */
// LOCAL SERVICE has Read/Write/Execute on this folder.
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())
{
    // Set the converter options here:		
    // Add file to convert.
    converter.AddSourceFile(pdfFile);
    // Using Page Range.
    if (hasPageRange.Checked)
    {
        converter.PageRange = PageRange.Parse(PageRangeBox.Text);
    }

    ConversionStatus status = 
      converter.ConvertTo(outputFileName, true);  // true means overwrite if exists.

    // your error handling here.
    if (status != ConversionStatus.Success)
    {
        throw new Exception("unexpected converter result");
    }
	
    // Cleanup the converter: converter.Dispose() 
    // is called on exiting the using{..} block.
}

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.

  1. Right click on Computer, select Manage and navigate to Internet Information Services (IIS) Manager
  2. In Connections on the right, expand Local Computer, Sites and you should see Default Web Site
  3. Right click on Default Web Site and select Add Application.
  4. Alias: textbox, fill in any name you want for the subfolder in the URL. I used pdftotext.
  5. Physical path: Hit the browse button and navigate to the PdfToText project folder. The dialog should look like:

    applicationsetup.png

  6. Click OK.

History

  • 17th September, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

greggree

Software Developer
Solid Documents LLC
United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 17 Sep 2010
Article Copyright 2010 by greggree
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid