SharePoint 2010

Mar 29, 2010 at 4:35 PM

Thanks. Looks very useful. What about working with SP 2010, will this port easily? I am also very interested in working the other way by writing to a PDF form from a list.

Ken

Coordinator
Mar 29, 2010 at 5:26 PM

Ken, 

I haven't ported it to SP2010, but I don't expect it to be much of a problem. I'll add it to my ToDos for this spring.

 

What's your concept? Is it to have a list item update a PDF whenever it's modified? Or is it to add the ability to view a list item in its PDF form? I'm guessing the latter ... hmmm, probably doable, I guess you would like that ability to hang off of the item's pop-up menu, for example? Just curious about what you're thinking.

Nov 21, 2012 at 3:35 PM

Hey,

I am probably far too late posting anything in this forum but hey ...you don't know if you don't try :).

Anyway, thanks a lot for this. I am currently using SharePoint 2010 too and am looking to see if I can get this working with it. I don't suppose you ever had chance to take a look at porting to 2010 did you? It would be super useful as I have only stumbled on 3 products that offer the ability in SharePoint to read from form fields. 

One is astronomically expensive and the other two only work for 2007 :)

Any help would be appreciated (I'm sure I cant be the only one who would benefit from this).

Thanks once again for what you have done so far. I only wish I knew more about c# to make the changes myself!

Cheers

Dave

 

Coordinator
Nov 21, 2012 at 3:57 PM

Dave,

I haven't tried to port it as the projects where we were using it took a different direction. Come to think of it, I could use this add-in for some other stuff; hmm, but I think I'd have it work a little differently. Basically, you want some PDF form fields to bubble up into the Content Type's properties, correct? So, for each content type field, there needs to be some sort of mapping into the PDF form field.

 

Nov 22, 2012 at 7:18 AM

Thanks for the reply!

Yes indeed that is exactly what I am looking for. The idea behind this is as a way of collecting information reliably from external sources that do not have access to either infopath or indeed the SP infrastructure. I downloaded a trial of VS2008 yesterday so I'm going to have a tinker with your source (not that I really know what I am doing) anyway, if anything goes too wrong ...that's what lab backups are for right :)

If you do ever do any work on it from your end you'd have one fan right here!

Thanks a lot

Dave

Nov 23, 2012 at 1:20 PM
Edited Nov 23, 2012 at 1:31 PM

Well after puzzling for a day and a bit I have figured it out - below is what I did. This forms a simple step by step that anyone should be able to follow without prior programming knowledge (basically where I was coming from). I am sure it will also help me in 6 months time when, once again parts of my brain drift away into the ether ...anyway on with the good stuff! I used:

  •  Visual Studio 2008 to modify the source and...
  • WSPBuilder (WSPBuilder Extensions 2010 BETA 1.4) to create the wsp. You can grab this from codeplex here
  • Oh and yeah make sure you have SharePoint installed on your the same computer as your VS install otherwise you will have difficulties :)

Here is what I did:

  • Open up the solution file in VS (.\PdfForm.sln)
  • Expand the References folder, right click and delete Microsoft.SharePoint (it will probably have a yellow warning triangle on it as it is trying to find the 2007 version of the file). Once removed right click on the References folder and click 'Add Reference'. In the box that pops up (on the .NET tab) browse for Microsoft.SharePoint (v 14.0.0.0). If you cant find it you did install SharePoint right? :)
  • In VS rename the '12' folder to '14'
  • Expand the now renamed 14>TEMPLATE>FEATURES>PdfForm and create a sub folder called 'ManageContentType'. Right click on the 'ManageContentType' folder and select Add>Existing Item. Browse for and select the 'PdfForm.aspx' file located in 14\TEMPLATE\LAYOUTS\PdfForm. Your folder structure should now read 14\TEMPLATE\FEATURES\PdfForm\ManageContentType\PdfForm.aspx
    • Just a small explanation for the above. I found that unless this ManageContentType folder and associated asp page were created then the PDF Form feature would not activate without barking that (guess what) it couldn't find the ManageContentType\PdfForm.aspx page.
  • Anyway ...moving on. Open up 'feature.xml' located in 14\TEMPLATE\FEATURES\PdfForm\ and modify the two sections identified in green in the XML below. You can locate the 'PublicKeyToken' for the PdfForm assembly by visiting this site. If things do go wrong later on (and if you're me they usually do) make sure that this PublicKeyToken is correct.

 

<?xml version="1.0" encoding="utf-8"?>
<Feature  Id="5e862cad-84ef-45dd-bd30-5a82f5564541"
          Title="PDF Forms"
          Description="Used to store PDF Forms within Sharepoint and to have fileds from the document displayed within Sharepoint."
          Version="14.0.0.0"
          Hidden="FALSE"
          Scope="Site"
          DefaultResourceFile="core"
          ReceiverAssembly="PdfForm, Version=0.5.0.0, Culture=neutral, PublicKeyToken=742bd6dd8e8cc30b"
          ReceiverClass="PdfForm.PdfForm"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="elements.xml"/>
  </ElementManifests>
</Feature>

 

  • Open up the 'elements.xml' file from 14\TEMPLATE\FEATURES\PdfForm\ and as above update the PublicKeyToken references to that of your PdfFormHandler assembly. Below is just a snip of the XML file to show you the TWO places that the PublicKeyToken pops up.

 

            <Assembly>PdfFormHandler, Version=0.5.0.0, Culture=neutral, PublicKeyToken=742bd6dd8e8cc30b</Assembly>
            <Class>PdfFormHandler.PdfForm</Class>
            <Data></Data>
            <Filter></Filter>
          </Receiver>
          <Receiver>
            <Name>PdfForm</Name>
            <Type>ItemUpdated</Type>
            <SequenceNumber>10000</SequenceNumber>
            <Assembly>PdfFormHandler, Version=0.5.0.0, Culture=neutral, PublicKeyToken=742bd6dd8e8cc30b</Assembly

 

  • Next browse to and open up 'PdfForm.aspx', 'PdfFormFields.aspx', and 'PdfForms.aspx' in 14\TEMPLATE\LAYOUTS\PdfForm. Search for and change all '12.0.0.0' references in the three files to '14.0.0.0' (changing the SharePoint version of course). You could always do a find and replace I suppose over the whole solution too.
  • In the PdfFormHandler project make sure the 'References' folder contains the right version of the Microsoft.SharePoint dll.
  • Finally open up PdfFormnHandler.cs (the very last file in the tree view) and change the 2 lines that read 'this.DisableEventFiring();' to 'this.EventFiringEnabled = false;' and then the 2 lines that read 'this.EnableEventFiring();' to 'this.EventFiringEnabled = true;' (snip shown with relevant lines in red below)

 

        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            //this.DisableEventFiring();
            this.EventFiringEnabled = false;
            UpdateItemProperties(properties);
            SetPermissions(properties);
            //this.EnableEventFiring();
            this.EventFiringEnabled = true;
        }
        /// CODE
        /// CODE
        /// GLORIOUS
        /// CODE

        public override void ItemUpdated(SPItemEventProperties properties)
        {
            // MORE
            // CODE
            if (approvalStatus != 0 && approvalStatus != 1)
            {
                //this.DisableEventFiring();
                this.EventFiringEnabled = false;
                UpdateItemProperties(properties);
                // SetPermissions(properties);
                //this.EnableEventFiring();
                this.EventFiringEnabled = true;
            }
        }

 

 

  • Finally make sure that both assemblies are signed otherwise when you try and install the wsp you'll probably end up getting warnings along the lines of 'You should use a strong name for any assembly that will be in the global assembly cache.' Do this by right clicking, in turn, on each project and then selecting properties. Click on the 'Signing' tab and click 'Sign the assembly'. Then in the drop down create a new Key name. I used the same key for both assemblies - created it once and then browsed to it for the second one.
  • Once this is all done build the solution (right click the root solution and click 'Build Solution')
  • Once built, in windows explorer navigate to the PdfFormHandler\bin\Release (or Debug) directory and locate the 'PdfFormHandler.dll' that youve just created. Copy this to the \PdfForm\GAC directory.
  • Then, back in VS, right click on the 'PdfForm' project in the Solution explorer. If you have installed WSP Builder, mentioned at the start there should be an option the 'Build WSP'
  • Select this, wait a few moments and you should have a shiny, 2010 compatible PdfForm.wsp file in the \PdfForm directory.
  • Install this with the usual Add-SPSolution mumbo and away you go
  • Thank hstaples for a fantastic solution

 

Disclaimer - this worked for me. Whether it works for you is an entirely different story lol!

Big smiley :D to the creator for making this in the first place! Thanks a lot!

Dave

Edit: Bad spelling!