Skip to content

Commit 1fde787

Browse files
committed
Workaround for dataurlnewwindow usage on Safari.
1 parent 140c979 commit 1fde787

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

jspdf.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ var jsPDF = (function(global) {
751751
* @name output
752752
*/
753753
output = SAFE(function(type, options) {
754+
var datauri = ('' + type).substr(0,6) === 'dataur'
755+
? 'data:application/pdf;base64,'+btoa(buildDocument()):0;
756+
754757
switch (type) {
755758
case undefined:
756759
return buildDocument();
@@ -778,13 +781,14 @@ var jsPDF = (function(global) {
778781
return global.URL && global.URL.createObjectURL(getBlob()) || void 0;
779782
case 'datauristring':
780783
case 'dataurlstring':
781-
return 'data:application/pdf;base64,' + btoa(buildDocument());
784+
return datauri;
785+
case 'dataurlnewwindow':
786+
var nW = global.open(datauri);
787+
if (nW || typeof safari === "undefined") return nW;
788+
/* pass through */
782789
case 'datauri':
783790
case 'dataurl':
784-
return global.document.location.href = 'data:application/pdf;base64,' + btoa(buildDocument());
785-
case 'dataurlnewwindow':
786-
return global.open('data:application/pdf;base64,' + btoa(buildDocument()));
787-
break;
791+
return global.document.location.href = datauri;
788792
default:
789793
throw new Error('Output type "' + type + '" is not supported.');
790794
}

0 commit comments

Comments
 (0)