Skip to content

Commit c3a379d

Browse files
fixed basic.html and update 'pdfjsnewwindow' (#2855)
Co-authored-by: Lukas Holländer <[email protected]>
1 parent 07d682a commit c3a379d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

examples/PDF.js/web/viewer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4886,10 +4886,11 @@
48864886
}
48874887

48884888
function getPDFFileNameFromURL(url) {
4889-
var defaultFilename =
4890-
arguments.length > 1 && arguments[1] !== undefined
4891-
? arguments[1]
4892-
: "document.pdf";
4889+
let downloadName = (window.location.search).split('=')[2];
4890+
var defaultFilename = downloadName || "document.pdf";
4891+
// arguments.length > 1 && arguments[1] !== undefined
4892+
// ? arguments[1]
4893+
// : "document.pdf";
48934894

48944895
if (typeof url !== "string") {
48954896
return defaultFilename;

examples/basic.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

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

1616
<script>
17+
window.jsPDF = window.jspdf.jsPDF;
18+
1719
$(function () {
1820
$("#accordion-basic, #accordion-text, #accordion-graphic, #accordion-font").accordion({
1921
autoHeight: false,

src/jspdf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ function jsPDF(options) {
30263026
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style>" +
30273027
'<body><iframe id="pdfViewer" src="' +
30283028
pdfJsUrl +
3029-
'?file=" width="500px" height="400px" />' +
3029+
'?file=&downloadName=' + options.filename + '" width="500px" height="400px" />' +
30303030
"</body></html>";
30313031
var PDFjsNewWindow = globalObject.open();
30323032

@@ -3036,6 +3036,7 @@ function jsPDF(options) {
30363036
PDFjsNewWindow.document.documentElement.querySelector(
30373037
"#pdfViewer"
30383038
).onload = function() {
3039+
PDFjsNewWindow.document.title = options.filename;
30393040
PDFjsNewWindow.document.documentElement
30403041
.querySelector("#pdfViewer")
30413042
.contentWindow.PDFViewerApplication.open(

0 commit comments

Comments
 (0)