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:
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:
Highlighted you'll notice the href we are targeting.
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.
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:
The page should look something like this:
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:
4- Check Hidden box
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
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!