Skip to content

Commit

Permalink
Build with reduced jsPDF
Browse files Browse the repository at this point in the history
Let inject jsroot.js into batch canvas file
  • Loading branch information
linev committed Oct 9, 2024
1 parent 1afb54e commit 4680b89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 102 deletions.
102 changes: 1 addition & 101 deletions build/jsroot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const version_id = 'dev',

/** @summary version date
* @desc Release date in format day/month/year like '14/04/2022' */
version_date = '8/10/2024',
version_date = '9/10/2024',

/** @summary version id and date
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
Expand Down Expand Up @@ -107755,9 +107755,6 @@ function jsPDF(options) {
* 'bloburi'/'bloburl' -> (string)<br/>
* 'datauristring'/'dataurlstring' -> (string)<br/>
* 'datauri'/'dataurl' -> (undefined) -> change location to generated datauristring/dataurlstring<br/>
* 'dataurlnewwindow' -> (window | null | undefined) throws error if global isn't a window object(node)<br/>
* 'pdfobjectnewwindow' -> (window | null) throws error if global isn't a window object(node)<br/>
* 'pdfjsnewwindow' -> (wind | null)
* @param {Object|string} options An object providing some additional signalling to PDF generator.<br/>
* Possible options are 'filename'.<br/>
* A string can be passed instead of {filename:string} and defaults to 'generated.pdf'
Expand Down Expand Up @@ -107824,103 +107821,6 @@ function jsPDF(options) {
";base64," +
dataURI
);
case "pdfobjectnewwindow":
if (
Object.prototype.toString.call(globalObject) === "[object Window]"
) {
var pdfObjectUrl =
"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js";
var integrity =
' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';

if (options.pdfObjectUrl) {
pdfObjectUrl = options.pdfObjectUrl;
integrity = "";
}

var htmlForNewWindow =
"<html>" +
'<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><script src="' +
pdfObjectUrl +
'"' +
integrity +
'></script><script >PDFObject.embed("' +
this.output("dataurlstring") +
'", ' +
JSON.stringify(options) +
");</script></body></html>";
var nW = globalObject.open();

if (nW !== null) {
nW.document.write(htmlForNewWindow);
}
return nW;
} else {
throw new Error(
"The option pdfobjectnewwindow just works in a browser-environment."
);
}
case "pdfjsnewwindow":
if (
Object.prototype.toString.call(globalObject) === "[object Window]"
) {
var pdfJsUrl = options.pdfJsUrl || "examples/PDF.js/web/viewer.html";
var htmlForPDFjsNewWindow =
"<html>" +
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style>" +
'<body><iframe id="pdfViewer" src="' +
pdfJsUrl +
"?file=&downloadName=" +
options.filename +
'" width="500px" height="400px" />' +
"</body></html>";
var PDFjsNewWindow = globalObject.open();

if (PDFjsNewWindow !== null) {
PDFjsNewWindow.document.write(htmlForPDFjsNewWindow);
var scope = this;
PDFjsNewWindow.document.documentElement.querySelector(
"#pdfViewer"
).onload = function() {
PDFjsNewWindow.document.title = options.filename;
PDFjsNewWindow.document.documentElement
.querySelector("#pdfViewer")
.contentWindow.PDFViewerApplication.open(
scope.output("bloburl")
);
};
}
return PDFjsNewWindow;
} else {
throw new Error(
"The option pdfjsnewwindow just works in a browser-environment."
);
}
case "dataurlnewwindow":
if (
Object.prototype.toString.call(globalObject) === "[object Window]"
) {
var htmlForDataURLNewWindow =
"<html>" +
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style>" +
"<body>" +
'<iframe src="' +
this.output("datauristring", options) +
'"></iframe>' +
"</body></html>";
var dataURLNewWindow = globalObject.open();
if (dataURLNewWindow !== null) {
dataURLNewWindow.document.write(htmlForDataURLNewWindow);
dataURLNewWindow.document.title = options.filename;
}
if (dataURLNewWindow || typeof safari === "undefined")
return dataURLNewWindow;
} else {
throw new Error(
"The option dataurlnewwindow just works in a browser-environment."
);
}
break;
case "datauri":
case "dataurl":
return (globalObject.document.location.href = this.output(
Expand Down
2 changes: 1 addition & 1 deletion modules/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const version_id = 'dev',

/** @summary version date
* @desc Release date in format day/month/year like '14/04/2022' */
version_date = '8/10/2024',
version_date = '9/10/2024',

/** @summary version id and date
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
Expand Down

0 comments on commit 4680b89

Please sign in to comment.