Open all PDF files in Maximum Dialog Box

This code grabs any PDF file on the page and rather have them opening in the same window or a new window, they open conveniently in a SharePoint modal pop up dialog window.

All you need to do is:

1: Place the code below into a TXT or HTML file,

2: Upload it to a Document Library

3: Your could edit the file and change the path of JQuery to a local copy of JQuery1.9.1.min.js if required.

4: You could either reference the file path in a Content Editor Web Part.  eg: \sharepointserver\sites\sitecollection\subsite\scripts\pdfmaxdialogcode.html

or add the code to your Master Page in a .JS file . (Need help with this, post a comment below)

5: Open up a page where PDF files are located and test it out.

Fullscreen SharePoint Dialog

To see a preview of the result, refer to my previous post:

This script was created by Alexander Bautz from

His post is located here:

For redundancy, I’ll post the code here as well.

* After you Paste the code, you will need to remove the < code > < / code > tags from the script below, it’s the only way I can paste the code in WordPress without the Object tags being stripped out.
<!-- Put this code below the list view web part -->
<script type="text/javascript" src="//"></script>
<script type="text/javascript">
function openPDFinDlg(href){
var o;
$("body").append("<div id='pdfTemp' style='min-height:600px;min-width:800px;height:100%;overflow:hidden'><<code>object</code> data='"+href+"' width='100%' height='100%' type='application/pdf' ></<code>object</code>></div>");
o = {};
o.html = $("#pdfTemp")[0];
o.showMaximized = true;
o.title = href.substring(href.lastIndexOf("/")+1);
o.dialogReturnValueCallback = openPDFinDlgCallback;

function openPDFinDlgCallback(){
// do something here when the dialog closes
// ]]></script>

To enhance the display of PDF files to your site vistors

When dealing with PDF files, you can also add parameters from Adobe’s PDF Open Parameters documentation to the +href+ variable to present the PDF to your users.

Some examples of Adobe PDF Open Parameters:

The following table lists and describes the available PDF open parameters. Italics indicate user-specified variables.

Specifies a numbered page in the document, using an integer value. The document’s first page has a pagenum value of 1.

Use the page command before this command.
pagemode=none (default)
Displays bookmarks or thumbnails.
Turns scrollbars on or off.
Turns the toolbar on or off.
Turns the status bar on or off.
Turns the document message bar on or off.
Turns the navigation panes and tabs on or off.

for example: Within line 11, you can change this portion:

 data='"+href+"' width='100%' height='100%' type='application/pdf' 

to this

 data='"+href+"#page=1&view=fitV&pagemode=thumbs' width='100%' height='100%' type='application/pdf' 

For further documentation on Adobe Open Parameters see this link:

* Possible issues: If the PDF link is located outside of your SharePoint server, the dialog window will display but the PDF may not.

Hope the code is useful for your site, thanks for reading.

Post a Comment

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s