Submitting data from an PDF Form to MS SharePoint

I have heard a few of our customers mention that they have SharePoint and LiveCycle ES but there seems to be a knowledge gap in how the two can be used together. Recently, we posted a whitepaper on Devnet. This whitepaper provides an excellent overview of the integration possibilities and added-value touch points. But the bottom line is that samples are what make the IT world turn. So, I decided that I would create a couple of quick samples that would demonstrate some of the low hanging fruit available. The problem is, where to start??? As if it was a sign, I stumbled on an Adobe forums post where someone was trying to submit data from a PDF form to SharePoint.

The key to handle a custom submission in SharePoint is to create a custom handler. Sounds worse than it actually is. It’s actually very simple to get this working. Here is a link to a good MSDN article on how to create custom handlers (ashx) for Sharepoint 3.0:
http://msdn.microsoft.com/en-us/library/bb457204.aspx. From this article, I was able to create a custom handler that accepts an XML post from a PDF form. The handler then parses the submitted XML and extract some key values. Since this is a sample, I took the liberty to hard-code some of the logic to keep things simple :). Using the SPList API, I create a new list entry (A custom list I created in SharePoint called ‘Purchase Order’). Since the list I created had custom columns (Total, date, ordered by), I pump the data extracted from the XML submission into the desired columns. Finally, I attach the submitted XML document to the list entry.

As for the PDF Form, all you have to do is edit the form in Adobe Designer, configure the submit button on your form to submit XML or XDP data, and point the submission to your custom handler (ex: http://mysharepointserver/_layouts/SP_PDFSubmitHandler.ashx).

Get the Custom SharePoint Handler Sample Here

The screenshot below shows what the result of the submission looks like.

This is a snapshot of the the Custom List:

Sharepoint_list

This is a snapshot of the item detail of a submission

Sharepoint_list_item_detail

Comments Closed

9 Responses to Submitting data from an PDF Form to MS SharePoint

  1. Trudy Hutzler says:

    Help!!!! Mycompany uses LiveCycle forms. We also have a sharepoint site. The development for both has fallen to me. 🙂 I have been searching and searching for information on how to populate sharepoint lists from adobe forms. So I was excited to find this blog. When I tried to create my own handler I get an error that a root element is missing. Here is my code:using System;using System.Web;using Microsoft.SharePoint;using System.Xml;public class HelloHttpHandler : 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 Documentweb.AllowUnsafeUpdates = true;SPList list = web.Lists[“Campaign Status Tracker”];SPListItem item = list.Items.Add();item[“Campaign Name”] = xmlDoc.GetElementsByTagName(“txtCampName”).Item(0).InnerText;item[“Campaign Owner”] = xmlDoc.GetElementsByTagName(“txtCampOwner”).Item(0).InnerText;item[“Product Line”] = xmlDoc.GetElementsByTagName(“cboProdLine”).Item(0).InnerText;item[“Start Date”] = xmlDoc.GetElementsByTagName(“dteStart”).Item(0).InnerText;item[“Duration”] = xmlDoc.GetElementsByTagName(“numDur”).Item(0).InnerText;item[“Target End Date”] = xmlDoc.GetElementsByTagName(“dteTarEndr”).Item(0).InnerText;item[“Exposure”] = xmlDoc.GetElementsByTagName(“numExp”).Item(0).InnerText;item[“Actual End Date”] = xmlDoc.GetElementsByTagName(“dteActEnd”).Item(0).InnerText;item[“Campaign Vehicle”] = xmlDoc.GetElementsByTagName(“cboCampVeh”).Item(0).InnerText;item[“Campaign Budget”] = xmlDoc.GetElementsByTagName(“numCampBud”).Item(0).InnerText;item[“Balance”] = xmlDoc.GetElementsByTagName(“numBal”).Item(0).InnerText;item[“Budget Spent”] = xmlDoc.GetElementsByTagName(“numTotExp”).Item(0).InnerText;item[“Percent Spent”] = xmlDoc.GetElementsByTagName(“numPercentSpent”).Item(0).InnerText;item[“Total Responses”] = xmlDoc.GetElementsByTagName(“numTotResp”).Item(0).InnerText;item[“Total Actions”] = xmlDoc.GetElementsByTagName(“numTotAction”).Item(0).InnerText;item[“Total Sales”] = xmlDoc.GetElementsByTagName(“numTotSales”).Item(0).InnerText;item[“Total Amount Sales”] = xmlDoc.GetElementsByTagName(“numTotSaleAmt”).Item(0).InnerText;item[“Response Rate”] = xmlDoc.GetElementsByTagName(“numRespRate”).Item(0).InnerText;item[“Action Rate”] = xmlDoc.GetElementsByTagName(“numActRate”).Item(0).InnerText;item[“Conversion Rate”] = xmlDoc.GetElementsByTagName(“numConvRate”).Item(0).InnerText;item[“Cost p/Response”] = xmlDoc.GetElementsByTagName(“numCostResp”).Item(0).InnerText;item[“Cost p/Action”] = xmlDoc.GetElementsByTagName(“numCostAct”).Item(0).InnerText;item[“Avg Purchase Value”] = xmlDoc.GetElementsByTagName(“numAvgPurVal”).Item(0).InnerText;item.Update();//Redirect the browser to the Campaign Tracker list so we can see our submisison.context.Response.Redirect(“http://team.mysite.net/sales/marketing/Lists/Campaign%20Status%20Tracker/Allitemsg.aspx”);}catch (Exception ex){context.Response.Write(ex.Message);}}public bool IsReusable {get {return false;}}}My sharepoint runs on server 2008. Can you see what I am missing, or what I did wrong? I am learning by doing so I may have totally missed something.Any help is greatly appreciated!Trudy

  2. Barry Walls says:

    Hi, I would like to try the handler above, but I cannot find the “_layouts” folder to store the handler in.Am I missing the folder or is it something I create? Wouldn’t I want it in the folder where I want the form stored?thanks.

  3. Jesper Angelo says:

    Thank you for this article – just what I am looking for… however llink to sample is not working 😐

    • Marcel Boucher says:

      My apologies. When the blog server was updated some of the files did not follow.
      The link is fixed now.

  4. Lisa Stotelmyre says:

    Marcel, I am interested in locating and learning about customers who are moving forward with ES and SharePoint (either integration or simply using LC forms on the front end and SP on the back end). Are there any case studies written or projects in process that you are aware of?

  5. Dmitry says:

    If you need to integrate Pdf forms with SharePoint 2010 then you should take a look at http://www.pdfsharepoint.com. It contains a product that has the most natural integration:

    1. bi-directional column mapping to Pdf fields
    2. support of free Adobe Reader
    3. dynamic layout using XFA
    4. scripting using JavaScript for client event and C#.NET for server-side.

  6. Georges says:

    Link does not work

    • Marcel Boucher says:

      I just tested the link and it works. Please try again, if it still does not work, let me know and I can post on an alternate location.

  7. Steve Grusak says:

    Need some help on why I am unable to get this seemingly simple handler technology to work. I have a Windows 2003 Server, running WSS 3.0, under IIS 6. I have created two ashx files and placed them both under the _layouts folder (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS). I have verified that the web site has a mapping for ashx execution. I have verified that I have the proper Assembly reference at the top of the ashx files. One of the two ashx files does nothing more than this example:

    public void ProcessRequest(HttpContext context) {
    SPSite siteColl = SPContext.Current.Site;
    SPWeb site = SPContext.Current.Web;
    context.Response.ContentType = “text/plain”;
    context.Response.Write(“Hello HttpHandler from the site ” + site.Title + ” at ” + site.Url);
    }

    Both ASHX files are fired from Submit buttons in PDF Forms. The second ashx file is setup to process the XML output from a submit button. On the PDF form, created by Adobe Pro 9.0, I have a button, configured as “Submit a form” and XFDF format. The button points to the ashx file on the Sharepoint site – named “credit” – “http://spvm/credit/_layouts/BBD_PDFTestSubmitHandler.ashx”. While sitting on the server that is running WSS 3.0, I have tried submitting from a filled in form using Adobe Reader and also a 3rd party PDF reader. Neither will tool execute either of the two ashx files. The error I get from the latest version of Adobe Reader after submitting is: “Sorry, failed to submit your form. Please try again.” The guts of the code I have for the XFDF formatted XML output was initially tested in a simple windows app – so I know that it is OK. I have also tried “http://spvm/_layouts/BBD_PDFTestSubmitHandler.ashx”, and a few other URLs with no luck. I simply created the ashx file and copied it to the LAYOUT folder.

    What am I missing? Is there an issue with the filename? Do I need to use VS2008/2010 and deploy – creating some compiled DLL? I was under the impression that the code did not need to be compiled. Please help. Thanks.