This post applies to Microsoft Office SharePoint Server 2007, WSS 3.0, Adobe LiveCycle, and PDF Forms

Scenario: Many organizations use Adobe PDF forms for employees to submit organizational forms for various business processes. It’s easy to configure these forms to submit the data in an e-mail message or send it to a SQL Server database. Submitting data is usually not the only thing required in the business process of the form. Once the data gets submitted via e-mail or database, there is usually some type of workflow involved in the business process. Adobe has a product called Adobe LiveCylcle ES that has a workflow engine that can be used to process information within an organization via Adobe Forms. Adobe LiveCycle ES is an incredible product but it is very expensive and you may not have it available within your organization. As an alternative, it is possible to post data from an Adobe PDF form and submit it to a SharePoint List. It is actually a very easy process. So….. How do you solve this?

Solution: First of all, I’m not sure why – but there is not much to find out there on this problem. I’m not sure exactly why. If you learn this technique, you could easily create very dynamic forms using Adobe LiveCycle Designer that can meet difficult requirements and leverage the use of SharePoint for data storage and Workflow processes. This Adobe blog post helped me with this process: Click Here to Read an Adobe Blog Post

You could easily read the post from the link above, so I’m going to explain it to you from my perspective.

Basically, to get Adobe PDF forms to communicate with a SharePoint List you need a 3 layer architecture.

LAYER 1: Adobe Form with a Submit button that is configured to submit data as XML and send the XML data to the http path of an .ashx file that is stored in the 12 hive (or another location) on a SharePoint server

LAYER 2: An .ashx file is created using Visual Studio  (or any text editor) and stored in the 12 hive (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\Whatever_You_Want_To_Call_This_Subdirectory) of the SharePoint Server.

LAYER 3: A Custom SharePoint List is created that has fields that match the fields of the Adobe Form.

Now I will explain each of these 3 Layers in more detail.

LAYER 1 (The Adobe Form):

First, you will want to use Adobe LiveCycle Designer to design the fields for your form. Just create a simple Text field called “Title” and a “Submit” button on the form. Then configure the Submit button to submit the data as XML. When configuring the submit button for XML, it will ask you for a desination URL to post your data. This is where you will paste the http: path from SharePoint to locate the .ashx file.  If you stored the file in a subdirectory of the LAYOUTS directory of the 12 hive, it would be something like:  http://servername/sites/sitecollectionname/_layouts/whatever_subdirectory/whatever.ashx

Now your form is prepared for data submission to a SharePoint List using an HttpHandler. Now lets keep going here.

LAYER 2 (The HTTPHandler – .ashx file)

You will need to create an HTTPHandler (.ashx) file with Visual Studio to handle accepting XML data from the Adobe PDF form and send it to the SharePoint List. The HTTPHandler will basically be used as the “middle man” to handle the exchange of the data. The file can be stored in the 12 hive of the SharePoint server so that it can be visible by all site collections within the SharePoint Farm. To use the 12 hive, you will need to create a subdirectory in the following path:  C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\Whatever_Subdirectory

You could easily just store .ashx file in the LAYOUTS directory, but its best practice not to do this so that you don’t risk replacing a file with the same name which could cause your SharePoint farm to become unstable.

The easiest way to create an .ashx file in Visual Studio is just to create a Web Application project using C#/ASP.NET. Then add a “New Item” as a basical HTML page. Then just rename the HTML Page with a .ashx file extension. There are other ways but this is easy enough.

Now let’s take a look at the anatomy of this .ashx file. First of all, you will be programming against SharePoint Services to get the data to the SharePoint list. So let’s look at a sample ASP.NET/C# script:

CODE ::
<%@ Assembly Name=”Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c” %>
<%@ WebHandler Language=”C#” Class=”put_data_in_sp_list” %>

using System;
using System.Web;
using Microsoft.SharePoint;
using System.Xml;

public class put_data_in_sp_list : IHttpHandler {

public void ProcessRequest (HttpContext context) {
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();

try
{
string rawXML = “”;
XmlTextReader reader = new XmlTextReader(context.Request.InputStream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(reader);
string _xmlString = xmlDoc.InnerXml;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string _fileTime = DateTime.Now.ToFileTime().ToString();

byte[] docAsBytes = encoding.GetBytes(_xmlString);

//Insert Document
web.AllowUnsafeUpdates = true;
// Here is the name of your Custom SharePoint List
SPList list = web.Lists["TestList"];
SPListItem item = list.Items.Add();

// Here is the name of your SharePoint Field that you will be sending the data from the first field of your Adobe Form
item["Title"] = xmlDoc.GetElementsByTagName(”Title”).Item(0).InnerText;
// Now Update the SharePoint List with the Data
item.Update();

}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}

}
// The HTTPHandler must have these lines
public bool IsReusable {
get {
return false;
}
}

}

:: END OF CODE

Notice that this script is using a single text field in an Adobe form then sending the XML data to a Custom SharePoint list called “TestList” in the “Title” field using SharePoint Services. If you have ever programmed C# scripts against SharePoint Services, you can see how this technique is EXTREMELY powerful. Since the referenced class above is “put_data_in_sp_list”, then obviously your .ashx file will be called put_data_in_sp_list.ashx .

LAYER 3 (Custom SharePoint List):

The final piece of this architecture is the Custom SharePoint List. If you are working off of the example above, obviously you will need to create a Custom SharePoint List called “TestList” and just use the “Title” field.

Conclusion:

Now that you have all 3 layers in place, you can now Preview your Adobe PDF form in Adobe LiveCycle Designer and enter some text in the text field. Then hit the Submit button. Your data will now be sent to the HTTPHandler, then added as a new item in the SharePoint “TestList”.

Once you have successfully tested data going from the Adobe PDF form to the custom SharePoint List, you are now ready to create your custom workflow on the SharePoint list. Just use SharePoint Designer to create the workflow to meet your business process needs and set it to kick off when a new item is added to the “TestList”. Install the worklfow on the “TestList” and now you have an end-to-end business solution using an Adobe PDF form to submit data to a SharePoint list while leveraging the Workflow capabilities of SharePoint.

Tags Categories: SharePoint, WSS Services Development Posted By: Clinton Daniel
Last Edit: 20 Jun 2009 @ 10 54 PM

E-mailPermalinkComments (18)
\/ More Options ...
Change Theme...
  • Users » 2
  • Posts/Pages » 16
  • Comments » 41
Change Theme...
  • VoidVoid
  • LifeLife « Default
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LiteLight
  • No Child Pages.