diff --git a/dev/index.html b/dev/index.html index d0c60c5..49972a3 100644 --- a/dev/index.html +++ b/dev/index.html @@ -72,7 +72,7 @@
The following pages are test cases for PDF embeds. They are configured to use the beta version of PDFObject (currently 2.2.12).
+The following pages are test cases for PDF embeds. They are configured to use the beta version of PDFObject (currently 2.3).
This browser does not support inline PDFs. Please download the PDF to view it: Download PDF
"; + + //Ensure URL is available. If not, exit now. + if(typeof url !== "string"){ return embedError("URL is not valid", suppressConsole); } + + //If target element is specified but is not valid, exit without doing anything + if(!targetNode){ return embedError("Target element cannot be determined", suppressConsole); } + + //page option overrides pdfOpenParams, if found + if(page){ pdfOpenParams.page = page; } + + //Stringify optional Adobe params for opening document (as fragment identifier) + pdfOpenFragment = buildURLFragmentString(pdfOpenParams); + + + // --== Do the dance: Embed attempt #1 ==-- + + //If the forcePDFJS option is invoked, skip everything else and embed as directed + if(forcePDFJS && PDFJS_URL){ + return generatePDFObjectMarkup("pdfjs", targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL); + } + + // --== Embed attempt #2 ==-- + + //Embed PDF if support is detected, or if this is a relatively modern browser + if(supportsPDFs){ + return generatePDFObjectMarkup("iframe", targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute); + } + + // --== Embed attempt #3 ==-- + + //If everything else has failed and a PDFJS fallback is provided, try to use it + if(PDFJS_URL){ + return generatePDFObjectMarkup("pdfjs", targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL); + } + + // --== PDF embed not supported! Use fallback ==-- + + //Display the fallback link if available + if(fallbackLink){ + fallbackHTML = (typeof fallbackLink === "string") ? fallbackLink : fallbackHTML_default; + targetNode.innerHTML = fallbackHTML.replace(/\[url\]/g, url); + } + + return embedError("This browser does not support embedded PDFs", suppressConsole); + + }; + + return { + embed: function (a,b,c){ return embed(a,b,c); }, + pdfobjectversion: (function () { return pdfobjectversion; })(), + supportsPDFs: (function (){ return supportsPDFs; })() + }; + +})); diff --git a/dev/tests/apostrophe-in-filename.html b/dev/tests/apostrophe-in-filename.html index c6d0a8d..558da62 100644 --- a/dev/tests/apostrophe-in-filename.html +++ b/dev/tests/apostrophe-in-filename.html @@ -56,7 +56,7 @@