Wednesday, May 14, 2008

Open-Edit-Save PDF document into SharePoint library

Recently one of our clients had decided not to just preview PDF documents from the SharePoint library, but to edit it and save to the same location.

Because Adobe is not integrated with SharePoint, when you open a PDF file for editing and save it, it will not save to the source location (Document library), but instead it will save it to one of the folders on your hard drive depending on the preferences. In my case, client wanted to open these PDF's from tasks that were created through "Collect" action in SPD (they served to provide additional information on the approver's disposition) as you might know this action creates a content type and associates ASPX page used to collect information. Users expected to open up the task associated with approval of this PDF document, open up the document they were about to review from this Task, provide some comments within the document, save this PDF to the source location and state their disposition in the task Item as well. Through the addition of  XSL within the ASPX page associated with this Task content type I've achieved the desired functionality:

Before, the link to the document that triggered associated workflow to create a task looked something like this:

        Document: <a href="{substring-before(@WorkflowLink, ', ')}">
                        <xsl:value-of select="substring-after(@WorkflowLink, ', ')"></xsl:value-of>
                      </a>

This piece of code would output name of the document with link to the document.

I've modified it to open the location (folder) of this document through the Windows Explorer (WebDav interface), luckily I have only one document per folder:

Document: <a href="#" onclick="NavigateHttpFolder('{substring-before(substring-before(@WorkflowLink, ', '),substring-after(@WorkflowLink, ', '))}', '_blank');">                         <xsl:value-of select="substring-after(@WorkflowLink, ', ')"></xsl:value-of>
                       </a >

As soon as you open PDF Document through the WebDav Interface, by default Adobe will save this document after editing it in the same location.

...BUT... yeah, there is always a catch.

When you try to open Office document, such as word document, you will get an error "Your Client does not support opening this list in Windows Explorer".

Here is your answer:

http://support.microsoft.com/kb/923906/en-us even though it describes this error from the "Actions" menu, but when you dig dipper it all boils down to the problem described here, as limitation of characters in your URL to only 100 characters.

http://support.microsoft.com/kb/325355/

Yes, it is your answer, if you are running IE 6.0.2.8... or earlier, but what do you do if it is not the case and you are getting this error anyway. I have IE 7 and office 2007.

I personally tried almost every patch, and download, and IE settings out there. We opened a support ticket with Microsoft, no solution. NOTHING WORKED, I've stumbled upon some forum threads that were ended on a hopeless note.

In my case the answer was within the actual XSL, apparently the problem can be resolved by the reformatting the URL used within the onClick command.

if before the HTML output from this line :

Document: <a href="#" onclick="NavigateHttpFolder('{substring-before(substring-before(@WorkflowLink, ', '),substring-after(@WorkflowLink, ', '))}', '_blank');">                         <xsl:value-of select="substring-after(@WorkflowLink, ', ')"></xsl:value-of>
                       </a >

was

<a href="#" onclick="NavigateHttpFolder('', '_blank');"> as you can see no URL id being supplied here, what is even stranger is that the URL was always there for PDF documents, but not for the office documents.

If you replace each "/" with "\u002f" within your link variable (in my case it's @WorkflowLink) it will work just fine :-)Once I replaced the previous code it with:

Document: <a href="#" onclick="NavigateHttpFolder('{translate(substring-before(substring-before(@WorkflowLink, ', '),substring-after(@WorkflowLink, ', ')),'\','\u002f')}', '_blank');">                <xsl:value-of select="substring-after(@WorkflowLink, ', ')"></xsl:value-of>
                      </a>

The HTML output was the correct one, for all types of documents!

Document: <a href="#" onclick="NavigateHttpFolder('http://portal/Documentlibrary/FolderName/', '_blank');">

This work around allowed me to open WebDav for particular folders

lesson learned, before you start looking for patches even though your system should be fine, go into the source code and look at what actually happens there, are you providing all the right values?

This post should have been re-titled though, but....

Enjoy


Note: do not get hang up on this part "substring-before(substring-before(@WorkflowLink, ', '),substring-after(@WorkflowLink, ', '))" It's just a way (in my case) to extract the URL to location of the document. By the way in some instances you might not even need to replace "/" with "\u002f".

10 comments:

Tihomir Ignatov said...

Hi, Natalya.
I have the same problem with PDFs, but your approach doesn't work for me. I'm opening the file library through WebDav (Windows Explorer View) but when I try to save the PDF from Adobe Acrobat Pro - the result is the same - It saves the doc in local folder and this is all.
this is the link from my SPD

a href="#" onclick="NavigateHttpFolder('http://myportal/sites/library/client%20files/', '_blank');"

Natalya Voskresenskaya [SharePoint MVP] said...

You might want to try to update your Web Folder component. the link looks good. What version of Acrobat do you have?

Unknown said...

Hi Natalya,

Where would I look for the ASPX page that goes with my Task? My task being a Document Listing. MOS2007 WSS3. I have looked in %PROGRAM_FILES%/Common Files/Microsoft Shared/web server extensions/12/... I am having trouble finding one with the links to open a document. And I have Arobat 9. Thanks! Great Post!

Anonymous said...

Hello, from what I read quickly, you want to open, edit, and save pdf's in sharpoint. I've been trying to look for a solution to that as well. What seems to work, is usinf Firefox instead of IE. I've tried it briefly and it saves any edits. But then you have to worry about other issues that arise from not using IE. I am still trying to find a better solution. (I'm thinking of converting my pdf's to Infopath forms, we'll see.)

Cummings Family said...

There is a wizard in acrobat pro that allows you to do shared reviews from a sharepoint server. My problem is that i can see the sharepoint server from acrobat...it sees the workspace i created, but it does not see the document library that is in that workspace. Anyone has documentation on what needs to be in place on the sharepoint server? Stumped. Sharepoint 2007, acrobat 9 pro

Unknown said...

You guys need to look at Wisdom PDF SharePoint Save.....

http://www.macroview.com.au/MacroView_Adobe_Save_To_Sharepoint.htm

Mahmoud Ramzy said...

how to link to the related item in the document library ?

Ernesto Gaia said...

Hi Nat.

I have one client that open, saves and edit the pdf files from INTRANET, but when someone tries to execute the same actions from an external access, he found an error when eh tried to open, edit AND SAVE. It nevers save. Have you seen something like this?

Tks
Ernesto

Ernesto Gaia said...

Hi Nat, how are you?

I have on client that has this situation. He can ope, edit and save the pdf in a sharepoint library when he accesses the Sharepoint from Intranet. When he tries to execute the same actions from External access, he can´t save.

Have you seen something like this?

Tks
Ernesto

Natalya Voskresenskaya [SharePoint MVP] said...

No I have not, some wierd client integration issues?