1/*global ActiveXObject, window, console, define, module, jQuery */ 2//jshint unused:false, strict: false 3 4/* 5 PDFObject v2.0.201604172 6 https://github.com/pipwerks/PDFObject 7 Copyright (c) 2008-2016 Philip Hutchison 8 MIT-style license: http://pipwerks.mit-license.org/ 9 UMD module pattern from https://github.com/umdjs/umd/blob/master/templates/returnExports.js 10*/ 11 12(function (root, factory) { 13 if (typeof define === 'function' && define.amd) { 14 // AMD. Register as an anonymous module. 15 define([], factory); 16 } else if (typeof module === 'object' && module.exports) { 17 // Node. Does not work with strict CommonJS, but 18 // only CommonJS-like environments that support module.exports, 19 // like Node. 20 module.exports = factory(); 21 } else { 22 // Browser globals (root is window) 23 root.PDFObject = factory(); 24 } 25}(this, function () { 26 27 "use strict"; 28 //jshint unused:true 29 30 //PDFObject is designed for client-side (browsers), not server-side (node) 31 //Will choke on undefined navigator and window vars when run on server 32 //Return boolean false and exit function when running server-side 33 34 if(typeof window === "undefined" || typeof navigator === "undefined"){ return false; } 35 36 var pdfobjectversion = "2.0.201604172", 37 supportsPDFs, 38 39 //declare functions 40 createAXO, 41 isIE, 42 supportsPdfMimeType = (typeof navigator.mimeTypes['application/pdf'] !== "undefined"), 43 supportsPdfActiveX, 44 buildFragmentString, 45 log, 46 embedError, 47 embed, 48 getTargetElement, 49 generatePDFJSiframe, 50 isIOS = (function (){ return (/iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())); })(), 51 generateEmbedElement; 52 53 54 /* ---------------------------------------------------- 55 Supporting functions 56 ---------------------------------------------------- */ 57 58 createAXO = function (type){ 59 var ax; 60 try { 61 ax = new ActiveXObject(type); 62 } catch (e) { 63 ax = null; //ensure ax remains null 64 } 65 return ax; 66 }; 67 68 //IE11 still uses ActiveX for Adobe Reader, but IE 11 doesn't expose 69 //window.ActiveXObject the same way previous versions of IE did 70 //window.ActiveXObject will evaluate to false in IE 11, but "ActiveXObject" in window evaluates to true 71 //so check the first one for older IE, and the second for IE11 72 //FWIW, MS Edge (replacing IE11) does not support ActiveX at all, both will evaluate false 73 //Constructed as a method (not a prop) to avoid unneccesarry overhead -- will only be evaluated if needed 74 isIE = function (){ return !!(window.ActiveXObject || "ActiveXObject" in window); }; 75 76 //If either ActiveX support for "AcroPDF.PDF" or "PDF.PdfCtrl" are found, return true 77 //Constructed as a method (not a prop) to avoid unneccesarry overhead -- will only be evaluated if needed 78 supportsPdfActiveX = function (){ return !!(createAXO("AcroPDF.PDF") || createAXO("PDF.PdfCtrl")); }; 79 80 //Determines whether PDF support is available 81 supportsPDFs = (supportsPdfMimeType || (isIE() && supportsPdfActiveX())); 82 83 //Create a fragment identifier for using PDF Open parameters when embedding PDF 84 buildFragmentString = function(pdfParams){ 85 86 var string = "", 87 prop; 88 89 if(pdfParams){ 90 91 for (prop in pdfParams) { 92 if (pdfParams.hasOwnProperty(prop)) { 93 string += encodeURIComponent(prop) + "=" + encodeURIComponent(pdfParams[prop]) + "&"; 94 } 95 } 96 97 //The string will be empty if no PDF Params found 98 if(string){ 99 100 string = "#" + string; 101 102 //Remove last ampersand 103 string = string.slice(0, string.length - 1); 104 105 } 106 107 } 108 109 return string; 110 111 }; 112 113 log = function (msg){ 114 if(typeof console !== "undefined" && console.log){ 115 console.log("[PDFObject] " + msg); 116 } 117 }; 118 119 embedError = function (msg){ 120 log(msg); 121 return false;
122 }; 123 124 getTargetElement = function (targetSelector){ 125 126 //Default to body for full-browser PDF 127 var targetNode = document.body; 128 129 //If a targetSelector is specified, check to see whether 130 //it's passing a selector, jQuery object, or an HTML element 131 132 if(typeof targetSelector === "string"){ 133 134 //Is CSS selector 135 targetNode = document.querySelector(targetSelector); 136 137 } else if (typeof jQuery !== "undefined" && targetSelector instanceof jQuery && targetSelector.length) { 138 139 //Is jQuery element. Extract HTML node 140 targetNode = targetSelector.get(0); 141 142 } else if (typeof targetSelector.nodeType !== "undefined" && targetSelector.nodeType === 1){ 143 144 //Is HTML element 145 targetNode = targetSelector; 146 147 } 148 149 return targetNode; 150 151 }; 152 153 generatePDFJSiframe = function (targetNode, url, pdfOpenFragment, PDFJS_URL, id){ 154 155 var fullURL = PDFJS_URL + "?file=" + encodeURIComponent(url) + pdfOpenFragment; 156 var scrollfix = (isIOS) ? "-webkit-overflow-scrolling: touch; overflow-y: scroll; " : "overflow: hidden; "; 157 var iframe = "<div style='" + scrollfix + "position: absolute; top: 0; right: 0; bottom: 0; left: 0;'><iframe " + id + " src='" + fullURL + "' style='border: none; width: 100%; height: 100%;' frameborder='0'></iframe></div>"; 158 targetNode.className += " pdfobject-container"; 159 targetNode.style.position = "relative"; 160 targetNode.style.overflow = "auto"; 161 targetNode.innerHTML = iframe; 162 return targetNode.getElementsByTagName("iframe")[0]; 163 164 }; 165 166 generateEmbedElement = function (targetNode, targetSelector, url, pdfOpenFragment, width, height, id){ 167 168 var style = ""; 169 170 if(targetSelector && targetSelector !== document.body){ 171 style = "width: " + width + "; height: " + height + ";"; 172 } else { 173 style = "position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;"; 174 } 175 176 targetNode.className += " pdfobject-container"; 177 targetNode.innerHTML = "<embed " + id + " class='pdfobject' src='" + url + pdfOpenFragment + "' type='application/pdf' style='overflow: auto; " + style + "'/>"; 178 179 return targetNode.getElementsByTagName("embed")[0]; 180 181 }; 182 183 embed = function(url, targetSelector, options){ 184 185 //Ensure URL is available. If not, exit now. 186 if(typeof url !== "string"){ return embedError("URL is not valid"); } 187 188 //If targetSelector is not defined, convert to boolean 189 targetSelector = (typeof targetSelector !== "undefined") ? targetSelector : false; 190 191 //Ensure options object is not undefined -- enables easier error checking below 192 options = (typeof options !== "undefined") ? options : {}; 193 194 //Get passed options, or set reasonable defaults 195 var id = (options.id && typeof options.id === "string") ? "id='" + options.id + "'" : "", 196 page = (options.page) ? options.page : false, 197 pdfOpenParams = (options.pdfOpenParams) ? options.pdfOpenParams : {}, 198 fallbackLink = (typeof options.fallbackLink !== "undefined") ? options.fallbackLink : true, 199 width = (options.width) ? options.width : "100%", 200 height = (options.height) ? options.height : "100%", 201 forcePDFJS = (typeof options.forcePDFJS === "boolean") ? options.forcePDFJS : false, 202 PDFJS_URL = (options.PDFJS_URL) ? options.PDFJS_URL : false, 203 targetNode = getTargetElement(targetSelector), 204 fallbackHTML = "", 205 pdfOpenFragment = "", 206 fallbackHTML_default = "<p>This browser does not support inline PDFs. Please download the PDF to view it: <a href='[url]'>Download PDF</a></p>"; 207 208 //If target element is specified but is not valid, exit without doing anything 209 if(!targetNode){ return embedError("Target element cannot be determined"); } 210 211 212 //page option overrides pdfOpenParams, if found 213 if(page){ 214 pdfOpenParams.page = page; 215 } 216 217 //Stringify optional Adobe params for opening document (as fragment identifier) 218 pdfOpenFragment = buildFragmentString(pdfOpenParams); 219 220 //Do the dance 221 if(forcePDFJS && PDFJS_URL){ 222 223 return generatePDFJSiframe(targetNode, url, pdfOpenFragment, PDFJS_URL, id); 224 225 } else if(supportsPDFs){ 226 227 return generateEmbedElement(targetNode, targetSelector, url, pdfOpenFragment, width, height, id); 228 229 } else { 230 231 if(PDFJS_URL){ 232 233 return generatePDFJSiframe(targetNode, url, pdfOpenFragment, PDFJS_URL, id); 234 235 } else if(fallbackLink){ 236 237 fallbackHTML = (typeof fallbackLink === "string") ? fallbackLink : fallbackHTML_default; 238 targetNode.innerHTML = fallbackHTML.replace(/\[url\]/g, url); 239 240 } 241 242 return embedError("This browser does not support embedded PDFs"); 243 244 } 245 246 }; 247 248 return { 249 embed: function (a,b,c){ return embed(a,b,c); }, 250 pdfobjectversion: (function () { return pdfobjectversion; })(), 251 supportsPDFs: (function (){ return supportsPDFs; })() 252 }; 253 254}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.