Skip Ribbon Commands Skip to main content
Help (new window)
Sign In
Navigate Up

PDF Attachment Links

 Open PDF Attachments in Browser for Office365 Form Pages.
 
I've had a few requests to enable browser viewing of PDF files attached to list items on form pages.  I worked a script that will do so and here's how to implement it. 
 
This is an example of what we're talking about:
CalEdit2.PNG
This is a calendar item with a PDF file attached.  To get the link to open in the browser we need to alter the href to use the PDF viewer page.
 
This is the HTML output:
 
CalEditCode.PNG

Highlighted you'll notice the href we are targeting.
 
This is the javascript that replaces the link:
 
‚Äč

pdf_forms.PNG

This is how to implement:

(we're assuming you've implemented the complete solution here http://joshuabooker.com/Pages/PDF-CompleteSolution.aspx)

1) Save this file to your Utilities document library. 

http://joshuabooker.com/utilities/pdf_forms.js

2) Open the list or library where you want to enable viewing attachments and change the URL to get the display form in edit mode like so:

<yoursite>/YourListName/Forms/DispForm.aspx?ToolPaneView=2&PageView=shared

The page should look something like this:

CalDispFormEditMode.PNG

3) Add a Content Editor Webpart to the page and set it up like so:

1- Move it to below the Form Web Part

2- Select Edit Web Part Properties

3- Set the file link to the following:

/utilities/pdf_forms.js

4- Check Hidden box

CalDispForm_CEWP2.PNG

4) Click Apply, Save and Close the page.  Goto an item with PDF attachment and test the link.

5) Repeat these steps for the EditForm.aspx page 

<yoursite>/YourListName/Forms/EditForm.aspx?ToolPaneView=2&PageView=shared
 
Also this will add browser viewing for attachments for only this one list.  You have to repeat these steps for Display and Edit forms of other lists to get it to work on those lists respectively.  I've tried adding this script to the master page, but it seems to interfere with the PDF solution for Document Library Views and I haven't worked through that yet.
 
Have a great Day!