Skip to content

Commit

Permalink
fixed basic.html and update 'pdfjsnewwindow' (#2855)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Holländer <[email protected]>
  • Loading branch information
kakugiki and HackbrettXXX authored Aug 21, 2020
1 parent 07d682a commit c3a379d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions examples/PDF.js/web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4886,10 +4886,11 @@
}

function getPDFFileNameFromURL(url) {
var defaultFilename =
arguments.length > 1 && arguments[1] !== undefined
? arguments[1]
: "document.pdf";
let downloadName = (window.location.search).split('=')[2];
var defaultFilename = downloadName || "document.pdf";
// arguments.length > 1 && arguments[1] !== undefined
// ? arguments[1]
// : "document.pdf";

if (typeof url !== "string") {
return defaultFilename;
Expand Down
4 changes: 3 additions & 1 deletion examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

<script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="../dist/jspdf.debug.js"></script>
<script type="text/javascript" src="../dist/jspdf.umd.js"></script>
<script type="text/javascript" src="js/basic.js"></script>

<script>
window.jsPDF = window.jspdf.jsPDF;

$(function () {
$("#accordion-basic, #accordion-text, #accordion-graphic, #accordion-font").accordion({
autoHeight: false,
Expand Down
3 changes: 2 additions & 1 deletion src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3026,7 +3026,7 @@ function jsPDF(options) {
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style>" +
'<body><iframe id="pdfViewer" src="' +
pdfJsUrl +
'?file=" width="500px" height="400px" />' +
'?file=&downloadName=' + options.filename + '" width="500px" height="400px" />' +
"</body></html>";
var PDFjsNewWindow = globalObject.open();

Expand All @@ -3036,6 +3036,7 @@ function jsPDF(options) {
PDFjsNewWindow.document.documentElement.querySelector(
"#pdfViewer"
).onload = function() {
PDFjsNewWindow.document.title = options.filename;
PDFjsNewWindow.document.documentElement
.querySelector("#pdfViewer")
.contentWindow.PDFViewerApplication.open(
Expand Down

0 comments on commit c3a379d

Please sign in to comment.