diff --git a/.eslintrc.js b/.eslintrc.js
index 0263497d0..ae77f4a0c 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,18 +1,21 @@
module.exports = {
- "env": {
- "browser": true,
- "commonjs": true,
- "es6": true,
- "node": true
- },
- "extends": "eslint:recommended",
- "globals": {
- "Atomics": "readonly",
- "SharedArrayBuffer": "readonly"
- },
- "parserOptions": {
- "ecmaVersion": 2018
- },
- "rules": {
- }
-};
\ No newline at end of file
+ parser: "@typescript-eslint/parser",
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
+ env: {
+ browser: true,
+ commonjs: true,
+ es6: true,
+ node: true,
+ jasmine: true
+ },
+ plugins: ["@typescript-eslint", "jasmine"],
+ globals: {
+ Atomics: "readonly",
+ SharedArrayBuffer: "readonly"
+ },
+ parserOptions: {
+ ecmaVersion: 2018,
+ sourceType: "module"
+ },
+ rules: {}
+};
diff --git a/bower.json b/bower.json
index 948445d8f..05557659a 100644
--- a/bower.json
+++ b/bower.json
@@ -1,70 +1,76 @@
{
- "name": "jspdf-yworks",
- "version": "2.1.1",
- "homepage": "https://github.com/yWorks/jsPDF",
+ "name": "jspdf",
+ "version": "1.5.3",
+ "homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": [
- "dist/jspdf.debug.js",
- "dist/jspdf.min.js",
- "dist/jspdf.node.debug.js",
+ "dist/jspdf.umd.js",
+ "dist/jspdf.umd.min.js",
+ "dist/jspdf.es.js",
+ "dist/jspdf.es.min.js",
+ "dist/jspdf.node.js",
"dist/jspdf.node.min.js"
],
- "moduleType": [
- "amd",
- "globals"
- ],
- "keywords": [
- "pdf"
- ],
+ "moduleType": ["amd", "globals", "node", "es6"],
+ "keywords": ["pdf"],
"dependencies": {
"atob": "^2.1.2",
- "btoa": "^1.2.1",
- "canvg": "1.5.3",
- "es6-promise": "^4.2.6",
- "file-saver": "2.0.1",
- "html2canvas": "^1.0.0-rc.1",
- "omggif": "1.0.9",
- "stackblur-canvas": "2.2.0"
+ "btoa": "^1.2.1"
+ },
+ "optionalDependencies": {
+ "canvg": "^3.0.6",
+ "core-js": "^3.6.0",
+ "html2canvas": "^1.0.0-rc.5"
},
"devDependencies": {
- "@babel/core": "^7.4.3",
+ "@babel/core": "^7.8.4",
"@babel/plugin-external-helpers": "7.2.0",
- "@babel/preset-env": "^7.4.3",
- "acorn": "^6.1.1",
- "babel-plugin-rewire-exports": "1.0.1",
+ "@babel/preset-env": "^7.8.4",
+ "@rollup/plugin-replace": "^2.3.3",
+ "@types/jasmine": "^3.5.11",
+ "@types/node": "^14.0.18",
+ "@typescript-eslint/parser": "^3.6.0",
+ "@typescript-eslint/eslint-plugin": "^3.6.0",
+ "chalk": "^4.1.0",
"codeclimate-test-reporter": "0.5.1",
+ "core-js": "^3.6.5",
"diff": "4.0.1",
"docdash": "1.1.0",
- "eslint": "^5.16.0",
+ "eslint": "^7.4.0",
+ "eslint-plugin-jasmine": "^4.1.1",
"folder-delete": "1.0.4",
- "gulp-babel": "^8.0.0",
- "inquirer": "^6.2.2",
- "jasmine": "^3.4.0",
- "jasmine-core": "3.4.0",
- "jasmine-expect": "^4.0.1",
+ "inquirer": "^6.5.2",
+ "jasmine": "3.5.0",
+ "jasmine-core": "3.5.0",
+ "jasmine-expect": "4.0.3",
"js-yaml": "3.13.1",
- "jsdoc": "3.6.0",
- "karma": "4.0.1",
- "karma-babel-preprocessor": "^8.0.0",
- "karma-chrome-launcher": "2.2.0",
- "karma-coverage": "1.1.2",
- "karma-firefox-launcher": "1.1.0",
+ "jsdoc": "^3.6.3",
+ "karma": "5.1.0",
+ "karma-babel-preprocessor": "8.0.1",
+ "karma-chrome-launcher": "3.1.0",
+ "karma-coverage": "2.0.2",
+ "karma-firefox-launcher": "1.3.0",
"karma-ie-launcher": "1.0.0",
- "karma-jasmine": "^2.0.1",
- "karma-jasmine-matchers": "^4.0.1",
+ "karma-jasmine": "3.3.1",
+ "karma-jasmine-matchers": "4.0.2",
"karma-mocha-reporter": "2.2.5",
- "karma-sauce-launcher": "2.0.2",
+ "karma-sauce-launcher": "4.1.5",
+ "karma-typescript": "^5.0.3",
"karma-verbose-reporter": "0.0.6",
"local-web-server": "2.6.1",
+ "log-utils": "^1.0.0",
"markdown": "0.5.0",
- "prettier": "^1.13.7",
- "promise-polyfill": "8.1.1",
- "rollup": "1.12.1",
- "rollup-plugin-babel": "4.3.2",
- "rollup-plugin-buble": "^0.19.6",
+ "preprocess": "^3.2.0",
+ "prettier": "^1.19.1",
+ "regenerator-runtime": "^0.13.5",
+ "requirejs": "^2.3.6",
+ "rollup": "^2.18.2",
+ "rollup-plugin-commonjs": "^10.1.0",
+ "rollup-plugin-license": "^2.1.0",
"rollup-plugin-node-resolve": "4.2.3",
- "rollup-plugin-sizes": "^0.5.1",
- "uglify-js": "3.5.8"
+ "rollup-plugin-preprocess": "0.0.4",
+ "rollup-plugin-terser": "^6.1.0",
+ "typescript": "^3.9.6"
},
"license": "MIT",
"ignore": [
@@ -74,6 +80,8 @@
"examples",
"node_modules",
"bower_components",
- "tests"
+ "test",
+ "coverage",
+ "docs"
]
}
diff --git a/build.browser.conf.js b/build.browser.conf.js
deleted file mode 100644
index 7c71a7765..000000000
--- a/build.browser.conf.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import './src/license.js';
-import './src/libs/polyfill.js';
-import './src/jspdf.js';
-
-import './src/modules/acroform';
-import './src/modules/addimage';
-import './src/modules/annotations';
-import './src/modules/arabic';
-import './src/modules/autoprint';
-import './src/modules/canvas';
-import './src/modules/cell';
-import './src/modules/context2d';
-import './src/modules/filters';
-import './src/modules/fileloading';
-import './src/modules/html';
-import './src/modules/javascript';
-import './src/modules/outline';
-import './src/modules/jpeg_support';
-import './src/modules/png_support';
-import './src/modules/gif_support';
-import './src/modules/bmp_support';
-import './src/modules/webp_support';
-import './src/modules/setlanguage';
-import './src/modules/split_text_to_size';
-import './src/modules/standard_fonts_metrics';
-import './src/modules/ttfsupport';
-import './src/modules/svg';
-import './src/modules/total_pages';
-import './src/modules/viewerpreferences';
-import './src/modules/xmp_metadata';
-import './src/modules/utf8';
-import './src/modules/vfs';
-
-import './src/deprecated/addhtml.js';
-import './src/deprecated/from_html.js';
-import './src/deprecated/html2pdf.js';
-
-import './src/libs/Blob.js';
-import './src/libs/omggif.js';
-import './src/libs/adler32cs.js';
-import './src/libs/bidiEngine.js';
-import './src/libs/JPEGEncoder.js';
-import './src/libs/BMPDecoder.js';
-import './src/libs/WebPDecoder.js';
-import './src/libs/Deflater.js';
-import './src/libs/rgbcolor.js';
-import './src/libs/ttffont.js';
-import './src/libs/png.js';
-import './src/libs/zlib.js';
-import './src/libs/FileSaver.js';
diff --git a/build.js b/build.js
deleted file mode 100644
index dc0c888e8..000000000
--- a/build.js
+++ /dev/null
@@ -1,150 +0,0 @@
-/* eslint-disable no-empty */
-/* eslint-disable no-console */
-"use strict";
-
-var fs = require("fs");
-const rollup = require("rollup");
-const rollupConfig = require("./rollup.config");
-var uglify = require("uglify-js");
-var execSync = require("child_process").execSync;
-
-const args = process.argv
- .slice(2)
- .map(arg => arg.split("="))
- .reduce((args, [value, key]) => {
- args[value] = key;
- return args;
- }, {});
-
-switch (args.type) {
- case "worker":
- bundle({
- type: args.type,
- distFolder: "dist",
- config: "./build.worker.conf.js",
- context: "global",
- minify: args.minify || true,
- format: "cjs",
- filename: "jspdf.worker"
- });
- break;
- case "node":
- bundle({
- type: args.type,
- distFolder: "dist",
- config: "./build.node.conf.js",
- context: "global",
- minify: args.minify || true,
- format: "cjs",
- filename: "jspdf.node"
- });
- break;
- case "browser":
- default:
- bundle({
- type: args.type,
- distFolder: "dist",
- config: "./build.browser.conf.js",
- minify: args.minify || true,
- format: "umd",
- context: "window",
- filename: "jspdf"
- });
- break;
-}
-
-function bundle(options) {
- console.log(
- "Start Bundling " +
- options.distFolder +
- "/" +
- options.filename +
- ".debug.js"
- );
- const plugins =
- options.type === "node" ? rollupConfig.nodePlugins : rollupConfig.plugins;
- rollup
- .rollup({
- input: options.config,
- context: options.context,
- plugins: plugins
- })
- .then(bundle => {
- return bundle.generate({
- format: options.format,
- name: "jsPDF"
- });
- })
- .then(output => {
- let code = output["output"][0].code;
- code = code.replace(
- /Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./,
- "Licensed under the MIT License"
- );
- code = code.replace(
- /Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./g,
- ""
- );
-
- code = renew(code);
-
- code = code.replace(/}\)\);\s*$/, "return jsPDF;\n$&");
- code = code + "\ntry {\nmodule.exports = jsPDF;\n}\ncatch (e) {}\n"; // inserted by build.js make require('jspdf.debug') work in node\n
- fs.writeFileSync(
- options.distFolder + "/" + options.filename + ".debug.js",
- code
- );
-
- console.log(
- "Finish Bundling " +
- options.distFolder +
- "/" +
- options.filename +
- ".debug.js"
- );
- if (options.minify === true) {
- console.log(
- "Minifiying " +
- options.distFolder +
- "/" +
- options.filename +
- ".debug.js to " +
- options.filename +
- ".min.js"
- );
- var minified = uglify.minify(code, {
- output: {
- comments: /@preserve|@license|copyright/i
- }
- });
- fs.writeFileSync(
- options.distFolder + "/" + options.filename + ".min.js",
- minified.code
- );
- }
- })
- .catch(err => {
- console.error(err);
- });
-}
-
-function renew(code) {
- var date = new Date().toISOString();
- var version = require("./package.json").version;
- var commit = "00000000";
- try {
- commit = execSync("git rev-parse --short=10 HEAD")
- .toString()
- .trim();
- } catch (e) {}
- code = code.replace(
- /jsPDF\.version\s*=\s*['"]0\.0\.0['"]/g,
- `jsPDF.version = '${version}'`
- );
- code = code.replace(/\$\{versionID\}/g, version);
- code = code.replace(/\$\{builtOn\}/g, date);
- code = code.replace("${commitID}", commit);
- code = code.replace(/1\.0\.0-trunk/, version + " " + date);
-
- return code;
-}
diff --git a/build.node.conf.js b/build.node.conf.js
deleted file mode 100644
index f76437d77..000000000
--- a/build.node.conf.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import './src/license.js';
-import './src/jspdf.js';
-
-import './src/modules/acroform';
-import './src/modules/addimage';
-import './src/modules/annotations';
-import './src/modules/arabic';
-import './src/modules/autoprint';
-import './src/modules/canvas';
-import './src/modules/cell';
-import './src/modules/context2d';
-import './src/modules/filters';
-import './src/modules/fileloading';
-import './src/modules/html';
-import './src/modules/javascript';
-import './src/modules/outline';
-import './src/modules/jpeg_support';
-import './src/modules/png_support';
-import './src/modules/gif_support';
-import './src/modules/bmp_support';
-import './src/modules/webp_support';
-import './src/modules/setlanguage';
-import './src/modules/split_text_to_size';
-import './src/modules/standard_fonts_metrics';
-import './src/modules/ttfsupport';
-import './src/modules/svg';
-import './src/modules/total_pages';
-import './src/modules/viewerpreferences';
-import './src/modules/xmp_metadata';
-import './src/modules/utf8';
-import './src/modules/vfs';
-
-import './src/node.js';
-
-import './src/libs/adler32cs.js';
-import './src/libs/bidiEngine.js';
-import './src/libs/JPEGEncoder.js';
-import './src/libs/BMPDecoder.js';
-import './src/libs/WebPDecoder.js';
-import './src/libs/Deflater.js';
-import './src/libs/rgbcolor.js';
-import './src/libs/ttffont.js';
-import './src/libs/png.js';
-import './src/libs/zlib.js';
diff --git a/build.worker.conf.js b/build.worker.conf.js
deleted file mode 100644
index ddfa489f0..000000000
--- a/build.worker.conf.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import './src/license.js';
-import './src/worker.polyfill.js';
-import './src/jspdf.js';
-
-//import './src/modules/acroform';
-import './src/modules/addimage';
-import './src/modules/annotations';
-import './src/modules/arabic';
-import './src/modules/autoprint';
-import './src/modules/canvas';
-import './src/modules/cell';
-import './src/modules/context2d';
-import './src/modules/filters';
-import './src/modules/fileloading';
-import './src/modules/html';
-import './src/modules/javascript';
-import './src/modules/outline';
-import './src/modules/jpeg_support';
-import './src/modules/png_support';
-import './src/modules/gif_support';
-import './src/modules/bmp_support';
-import './src/modules/webp_support';
-import './src/modules/setlanguage';
-import './src/modules/split_text_to_size';
-import './src/modules/standard_fonts_metrics';
-//import './src/modules/ttfsupport';
-import './src/modules/svg';
-import './src/modules/total_pages';
-import './src/modules/viewerpreferences';
-import './src/modules/xmp_metadata';
-import './src/modules/utf8';
-//import './src/modules/vfs';
-
-//import './src/node.js';
-
-import './src/libs/adler32cs.js';
-import './src/libs/bidiEngine.js';
-import './src/libs/JPEGEncoder.js';
-import './src/libs/BMPDecoder.js';
-import './src/libs/WebPDecoder.js';
-import './src/libs/Deflater.js';
-import './src/libs/rgbcolor.js';
-import './src/libs/ttffont.js';
-import './src/libs/png.js';
-import './src/libs/zlib.js';
diff --git a/dist/jspdf.debug.js b/dist/jspdf.debug.js
deleted file mode 100644
index e6761e49a..000000000
--- a/dist/jspdf.debug.js
+++ /dev/null
@@ -1,31906 +0,0 @@
-(function (factory) {
- typeof define === 'function' && define.amd ? define(factory) :
- factory();
-}(function () { 'use strict';
-
- /** @license
- *
- * jsPDF - PDF Document creation from JavaScript
- * Version 2.1.1 Built on 2019-10-11T08:56:17.234Z
- * CommitID 0dd01f177e
- *
- * Copyright (c) 2010-2018 James Hall , https://github.com/MrRio/jsPDF
- * 2015-2018 yWorks GmbH, http://www.yworks.com
- * 2015-2018 Lukas Holländer , https://github.com/HackbrettXXX
- * 2016-2018 Aras Abbasi
- * 2010 Aaron Spike, https://github.com/acspike
- * 2012 Willow Systems Corporation, willow-systems.com
- * 2012 Pablo Hess, https://github.com/pablohess
- * 2012 Florian Jenett, https://github.com/fjenett
- * 2013 Warren Weckesser, https://github.com/warrenweckesser
- * 2013 Youssef Beddad, https://github.com/lifof
- * 2013 Lee Driscoll, https://github.com/lsdriscoll
- * 2013 Stefan Slonevskiy, https://github.com/stefslon
- * 2013 Jeremy Morel, https://github.com/jmorel
- * 2013 Christoph Hartmann, https://github.com/chris-rock
- * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
- * 2014 James Makes, https://github.com/dollaruw
- * 2014 Diego Casorran, https://github.com/diegocr
- * 2014 Steven Spungin, https://github.com/Flamenco
- * 2014 Kenneth Glassey, https://github.com/Gavvers
- *
- * Licensed under the MIT License
- *
- * Contributor(s):
- * siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
- * kim3er, mfo, alnorth, Flamenco
- */
-
- function _typeof(obj) {
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
-
- return _typeof(obj);
- }
-
- /**
- * JavaScript Polyfill functions for jsPDF
- * Collected from public resources by
- * https://github.com/diegocr
- */
- (function (global) {
- if (_typeof(global.console) !== "object") {
- // Console-polyfill. MIT license.
- // https://github.com/paulmillr/console-polyfill
- // Make it safe to do console.log() always.
- global.console = {};
- var con = global.console;
- var prop, method;
-
- var dummy = function dummy() {};
-
- var properties = ["memory"];
- var methods = ("assert,clear,count,debug,dir,dirxml,error,exception,group," + "groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd," + "show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn").split(","); // eslint-disable-next-line no-cond-assign
-
- while (prop = properties.pop()) {
- if (!con[prop]) { con[prop] = {}; }
- } // eslint-disable-next-line no-cond-assign
-
-
- while (method = methods.pop()) {
- if (!con[method]) { con[method] = dummy; }
- }
- }
-
- var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
- if (typeof global.btoa === "undefined") {
- global.btoa = function (data) {
- // discuss at: http://phpjs.org/functions/base64_encode/
- // original by: Tyler Akins (http://rumkin.com)
- // improved by: Bayron Guevara
- // improved by: Thunder.m
- // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // improved by: Rafal Kukawski (http://kukawski.pl)
- // bugfixed by: Pellentesque Malesuada
- // example 1: base64_encode('Kevin van Zonneveld');
- // returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
- var o1,
- o2,
- o3,
- h1,
- h2,
- h3,
- h4,
- bits,
- i = 0,
- ac = 0,
- enc = "",
- tmp_arr = [];
-
- if (!data) {
- return data;
- }
-
- do {
- // pack three octets into four hexets
- o1 = data.charCodeAt(i++);
- o2 = data.charCodeAt(i++);
- o3 = data.charCodeAt(i++);
- bits = o1 << 16 | o2 << 8 | o3;
- h1 = bits >> 18 & 0x3f;
- h2 = bits >> 12 & 0x3f;
- h3 = bits >> 6 & 0x3f;
- h4 = bits & 0x3f; // use hexets to index into b64, and append result to encoded string
-
- tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
- } while (i < data.length);
-
- enc = tmp_arr.join("");
- var r = data.length % 3;
- return (r ? enc.slice(0, r - 3) : enc) + "===".slice(r || 3);
- };
- }
-
- if (typeof global.atob === "undefined") {
- global.atob = function (data) {
- // discuss at: http://phpjs.org/functions/base64_decode/
- // original by: Tyler Akins (http://rumkin.com)
- // improved by: Thunder.m
- // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // input by: Aman Gupta
- // input by: Brett Zamir (http://brett-zamir.me)
- // bugfixed by: Onno Marsman
- // bugfixed by: Pellentesque Malesuada
- // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
- // returns 1: 'Kevin van Zonneveld'
- var o1,
- o2,
- o3,
- h1,
- h2,
- h3,
- h4,
- bits,
- i = 0,
- ac = 0,
- dec = "",
- tmp_arr = [];
-
- if (!data) {
- return data;
- }
-
- data += "";
-
- do {
- // unpack four hexets into three octets using index points in b64
- h1 = b64.indexOf(data.charAt(i++));
- h2 = b64.indexOf(data.charAt(i++));
- h3 = b64.indexOf(data.charAt(i++));
- h4 = b64.indexOf(data.charAt(i++));
- bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
- o1 = bits >> 16 & 0xff;
- o2 = bits >> 8 & 0xff;
- o3 = bits & 0xff;
-
- if (h3 == 64) {
- tmp_arr[ac++] = String.fromCharCode(o1);
- } else if (h4 == 64) {
- tmp_arr[ac++] = String.fromCharCode(o1, o2);
- } else {
- tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
- }
- } while (i < data.length);
-
- dec = tmp_arr.join("");
- return dec;
- };
- }
-
- if (!Array.prototype.map) {
- Array.prototype.map = function (fun
- /*, thisArg */
- ) {
- if (this === void 0 || this === null || typeof fun !== "function") { throw new TypeError(); }
- var t = Object(this),
- len = t.length >>> 0,
- res = new Array(len);
- var thisArg = arguments.length > 1 ? arguments[1] : void 0;
-
- for (var i = 0; i < len; i++) {
- // NOTE: Absolute correctness would demand Object.defineProperty
- // be used. But this method is fairly new, and failure is
- // possible only if Object.prototype or Array.prototype
- // has a property |i| (very unlikely), so use a less-correct
- // but more portable alternative.
- if (i in t) { res[i] = fun.call(thisArg, t[i], i, t); }
- }
-
- return res;
- };
- }
-
- if (!Array.isArray) {
- Array.isArray = function (arg) {
- return Object.prototype.toString.call(arg) === "[object Array]";
- };
- } // Production steps of ECMA-262, Edition 5, 15.4.4.21
- // Reference: http://es5.github.io/#x15.4.4.21
- // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
-
-
- if (!Array.prototype.reduce) {
- Object.defineProperty(Array.prototype, "reduce", {
- value: function value(callback
- /*, initialValue*/
- ) {
- if (this === null) {
- throw new TypeError("Array.prototype.reduce " + "called on null or undefined");
- }
-
- if (typeof callback !== "function") {
- throw new TypeError(callback + " is not a function");
- } // 1. Let O be ? ToObject(this value).
-
-
- var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
-
- var len = o.length >>> 0; // Steps 3, 4, 5, 6, 7
-
- var k = 0;
- var value;
-
- if (arguments.length >= 2) {
- value = arguments[1];
- } else {
- while (k < len && !(k in o)) {
- k++;
- } // 3. If len is 0 and initialValue is not present,
- // throw a TypeError exception.
-
-
- if (k >= len) {
- throw new TypeError("Reduce of empty array " + "with no initial value");
- }
-
- value = o[k++];
- } // 8. Repeat, while k < len
-
-
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- // b. Let kPresent be ? HasProperty(O, Pk).
- // c. If kPresent is true, then
- // i. Let kValue be ? Get(O, Pk).
- // ii. Let accumulator be ? Call(
- // callbackfn, undefined,
- // « accumulator, kValue, k, O »).
- if (k in o) {
- value = callback(value, o[k], k, o);
- } // d. Increase k by 1.
-
-
- k++;
- } // 9. Return accumulator.
-
-
- return value;
- }
- });
- }
-
- if (!Uint8Array.prototype.reduce) {
- Object.defineProperty(Uint8Array.prototype, "reduce", {
- value: function value(callback
- /*, initialValue*/
- ) {
- if (this === null) {
- throw new TypeError("Array.prototype.reduce " + "called on null or undefined");
- }
-
- if (typeof callback !== "function") {
- throw new TypeError(callback + " is not a function");
- } // 1. Let O be ? ToObject(this value).
-
-
- var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
-
- var len = o.length >>> 0; // Steps 3, 4, 5, 6, 7
-
- var k = 0;
- var value;
-
- if (arguments.length >= 2) {
- value = arguments[1];
- } else {
- while (k < len && !(k in o)) {
- k++;
- } // 3. If len is 0 and initialValue is not present,
- // throw a TypeError exception.
-
-
- if (k >= len) {
- throw new TypeError("Reduce of empty array " + "with no initial value");
- }
-
- value = o[k++];
- } // 8. Repeat, while k < len
-
-
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- // b. Let kPresent be ? HasProperty(O, Pk).
- // c. If kPresent is true, then
- // i. Let kValue be ? Get(O, Pk).
- // ii. Let accumulator be ? Call(
- // callbackfn, undefined,
- // « accumulator, kValue, k, O »).
- if (k in o) {
- value = callback(value, o[k], k, o);
- } // d. Increase k by 1.
-
-
- k++;
- } // 9. Return accumulator.
-
-
- return value;
- }
- });
- }
-
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function (fun, thisArg) {
-
- if (this === void 0 || this === null || typeof fun !== "function") { throw new TypeError(); }
- var t = Object(this),
- len = t.length >>> 0;
-
- for (var i = 0; i < len; i++) {
- if (i in t) { fun.call(thisArg, t[i], i, t); }
- }
- };
- } // https://tc39.github.io/ecma262/#sec-array.prototype.find
-
-
- if (!Array.prototype.find) {
- Object.defineProperty(Array.prototype, "find", {
- value: function value(predicate) {
- // 1. Let O be ? ToObject(this value).
- if (this == null) {
- throw new TypeError('"this" is null or not defined');
- }
-
- var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
-
- var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception.
-
- if (typeof predicate !== "function") {
- throw new TypeError("predicate must be a function");
- } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
-
-
- var thisArg = arguments[1]; // 5. Let k be 0.
-
- var k = 0; // 6. Repeat, while k < len
-
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- // b. Let kValue be ? Get(O, Pk).
- // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
- // d. If testResult is true, return kValue.
- var kValue = o[k];
-
- if (predicate.call(thisArg, kValue, k, o)) {
- return kValue;
- } // e. Increase k by 1.
-
-
- k++;
- } // 7. Return undefined.
-
-
- return undefined;
- },
- configurable: true,
- writable: true
- });
- }
-
- if (typeof Object.create != "function") {
- Object.create = function (undefined$1) {
- var Temp = function Temp() {};
-
- return function (prototype, propertiesObject) {
- if (prototype !== Object(prototype) && prototype !== null) {
- throw TypeError("Argument must be an object, or null");
- }
-
- Temp.prototype = prototype || {};
-
- if (propertiesObject !== undefined$1) {
- Object.defineProperties(Temp.prototype, propertiesObject);
- }
-
- var result = new Temp();
- Temp.prototype = null; // to imitate the case of Object.create(null)
-
- if (prototype === null) {
- result.__proto__ = null;
- }
-
- return result;
- };
- }();
- }
-
- if (!Object.keys) {
- Object.keys = function () {
-
- var hasOwnProperty = Object.prototype.hasOwnProperty,
- hasDontEnumBug = !{
- toString: null
- }.propertyIsEnumerable("toString"),
- dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"],
- dontEnumsLength = dontEnums.length;
- return function (obj) {
- if (_typeof(obj) !== "object" && (typeof obj !== "function" || obj === null)) {
- throw new TypeError();
- }
-
- var result = [],
- prop,
- i;
-
- for (prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- result.push(prop);
- }
- }
-
- if (hasDontEnumBug) {
- for (i = 0; i < dontEnumsLength; i++) {
- if (hasOwnProperty.call(obj, dontEnums[i])) {
- result.push(dontEnums[i]);
- }
- }
- }
-
- return result;
- };
- }();
- }
-
- if (!Object.values) {
- Object.values = function (obj) {
- var vals = [];
-
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && obj.propertyIsEnumerable(key)) {
- vals.push(obj[key]);
- }
- }
-
- return vals;
- };
- }
-
- if (typeof Object.assign != "function") {
- Object.assign = function (target) {
- var arguments$1 = arguments;
-
-
- if (target == null) {
- throw new TypeError("Cannot convert undefined or null to object");
- }
-
- target = Object(target);
-
- for (var index = 1; index < arguments.length; index++) {
- var source = arguments$1[index];
-
- if (source != null) {
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- }
-
- return target;
- };
- }
-
- if (!String.prototype.trim) {
- String.prototype.trim = function () {
- return this.replace(/^\s+|\s+$/g, "");
- };
- }
-
- if (!String.prototype.trimLeft) {
- String.prototype.trimLeft = function () {
- return this.replace(/^\s+/g, "");
- };
- }
-
- if (!String.prototype.trimRight) {
- String.prototype.trimRight = function () {
- return this.replace(/\s+$/g, "");
- };
- }
-
- Number.isInteger = Number.isInteger || function (value) {
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
- };
- })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || typeof global !== "undefined" && global || Function('return typeof this === "object" && this.content')() || Function("return this")()); // `self` is undefined in Firefox for Android content script context
- // while `this` is nsIContentFrameMessageManager
- // with an attribute `content` that corresponds to the window
-
- /* eslint-disable no-console */
-
- /* global saveAs, define, RGBColor */
- // eslint-disable-next-line no-unused-vars
- var jsPDF = function (global) {
- /**
- * jsPDF's Internal PubSub Implementation.
- * Backward compatible rewritten on 2014 by
- * Diego Casorran, https://github.com/diegocr
- *
- * @class
- * @name PubSub
- * @ignore
- */
-
- function PubSub(context) {
- if (_typeof(context) !== "object") {
- throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");
- }
-
- var topics = {};
-
- this.subscribe = function (topic, callback, once) {
- once = once || false;
-
- if (typeof topic !== "string" || typeof callback !== "function" || typeof once !== "boolean") {
- throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");
- }
-
- if (!topics.hasOwnProperty(topic)) {
- topics[topic] = {};
- }
-
- var token = Math.random().toString(35);
- topics[topic][token] = [callback, !!once];
- return token;
- };
-
- this.unsubscribe = function (token) {
- for (var topic in topics) {
- if (topics[topic][token]) {
- delete topics[topic][token];
-
- if (Object.keys(topics[topic]).length === 0) {
- delete topics[topic];
- }
-
- return true;
- }
- }
-
- return false;
- };
-
- this.publish = function (topic) {
- if (topics.hasOwnProperty(topic)) {
- var args = Array.prototype.slice.call(arguments, 1),
- tokens = [];
-
- for (var token in topics[topic]) {
- var sub = topics[topic][token];
-
- try {
- sub[0].apply(context, args);
- } catch (ex) {
- if (global.console) {
- console.error("jsPDF PubSub Error", ex.message, ex);
- }
- }
-
- if (sub[1]) { tokens.push(token); }
- }
-
- if (tokens.length) { tokens.forEach(this.unsubscribe); }
- }
- };
-
- this.getTopics = function () {
- return topics;
- };
- }
- /**
- * Creates new jsPDF document object instance.
- * @name jsPDF
- * @class
- * @param {Object} [options] - Collection of settings initializing the jsPDF-instance
- * @param {string} [options.orientation=portrait] - Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" or "l").
- * @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.
- * Possible values are "pt" (points), "mm", "cm", "m", "in" or "px".
- * @param {string/Array} [options.format=a4] The format of the first page. Can be:- a0 - a10
- b0 - b10
- c0 - c10
- dl
- letter
- government-letter
- legal
- junior-legal
- ledger
- tabloid
- credit-card
- * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
- * @param {boolean} [options.putOnlyUsedFonts=false] Only put fonts into the PDF, which were used.
- * @param {boolean} [options.compress=false] Compress the generated PDF.
- * @param {number} [options.precision=16] Precision of the element-positions.
- * @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.
- * @param {number|"smart"} [options.floatPrecision=16]
- * @returns {jsPDF} jsPDF-instance
- * @description
- * ```
- * {
- * orientation: 'p',
- * unit: 'mm',
- * format: 'a4',
- * putOnlyUsedFonts:true,
- * floatPrecision: 16 // or "smart", default is 16
- * }
- * ```
- *
- * @constructor
- */
-
-
- function jsPDF(options) {
- var orientation = typeof arguments[0] === "string" ? arguments[0] : "p";
- var unit = arguments[1];
- var format = arguments[2];
- var compressPdf = arguments[3];
- var filters = [];
- var userUnit = 1.0;
- var precision;
- var floatPrecision = 16;
- var defaultPathOperation = "S";
- options = options || {};
-
- if (_typeof(options) === "object") {
- orientation = options.orientation;
- unit = options.unit || unit;
- format = options.format || format;
- compressPdf = options.compress || options.compressPdf || compressPdf;
- userUnit = typeof options.userUnit === "number" ? Math.abs(options.userUnit) : 1.0;
-
- if (typeof options.precision !== "undefined") {
- precision = options.precision;
- }
-
- if (typeof options.floatPrecision !== "undefined") {
- floatPrecision = options.floatPrecision;
- }
-
- defaultPathOperation = options.defaultPathOperation || "S";
- }
-
- filters = options.filters || (compressPdf === true ? ["FlateEncode"] : filters);
- unit = unit || "mm";
- orientation = ("" + (orientation || "P")).toLowerCase();
- var putOnlyUsedFonts = options.putOnlyUsedFonts || false;
- var usedFonts = {};
- var API = {
- internal: {},
- __private__: {}
- };
- API.__private__.PubSub = PubSub;
- var pdfVersion = "1.3";
-
- var getPdfVersion = API.__private__.getPdfVersion = function () {
- return pdfVersion;
- };
-
- API.__private__.setPdfVersion = function (value) {
- pdfVersion = value;
- }; // Size in pt of various paper formats
-
-
- var pageFormats = {
- a0: [2383.94, 3370.39],
- a1: [1683.78, 2383.94],
- a2: [1190.55, 1683.78],
- a3: [841.89, 1190.55],
- a4: [595.28, 841.89],
- a5: [419.53, 595.28],
- a6: [297.64, 419.53],
- a7: [209.76, 297.64],
- a8: [147.4, 209.76],
- a9: [104.88, 147.4],
- a10: [73.7, 104.88],
- b0: [2834.65, 4008.19],
- b1: [2004.09, 2834.65],
- b2: [1417.32, 2004.09],
- b3: [1000.63, 1417.32],
- b4: [708.66, 1000.63],
- b5: [498.9, 708.66],
- b6: [354.33, 498.9],
- b7: [249.45, 354.33],
- b8: [175.75, 249.45],
- b9: [124.72, 175.75],
- b10: [87.87, 124.72],
- c0: [2599.37, 3676.54],
- c1: [1836.85, 2599.37],
- c2: [1298.27, 1836.85],
- c3: [918.43, 1298.27],
- c4: [649.13, 918.43],
- c5: [459.21, 649.13],
- c6: [323.15, 459.21],
- c7: [229.61, 323.15],
- c8: [161.57, 229.61],
- c9: [113.39, 161.57],
- c10: [79.37, 113.39],
- dl: [311.81, 623.62],
- letter: [612, 792],
- "government-letter": [576, 756],
- legal: [612, 1008],
- "junior-legal": [576, 360],
- ledger: [1224, 792],
- tabloid: [792, 1224],
- "credit-card": [153, 243]
- };
-
- API.__private__.getPageFormats = function () {
- return pageFormats;
- };
-
- var getPageFormat = API.__private__.getPageFormat = function (value) {
- return pageFormats[value];
- };
-
- format = format || "a4";
- var ApiMode = {
- COMPAT: "compat",
- ADVANCED: "advanced"
- };
- var apiMode = ApiMode.COMPAT;
-
- function advancedAPI() {
- // prepend global change of basis matrix
- // (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix
- // that does this job for us (however, texts, images and similar objects must be drawn bottom up))
- this.saveGraphicsState();
- out(new Matrix(scaleFactor, 0, 0, -scaleFactor, 0, getPageHeight() * scaleFactor).toString() + " cm");
- this.setFontSize(this.getFontSize() / scaleFactor); // The default in MrRio's implementation is "S" (stroke), whereas the default in the yWorks implementation
- // was "n" (none). Although this has nothing to do with transforms, we should use the API switch here.
-
- defaultPathOperation = "n";
- apiMode = ApiMode.ADVANCED;
- }
-
- function compatAPI() {
- this.restoreGraphicsState();
- defaultPathOperation = "S";
- apiMode = ApiMode.COMPAT;
- }
- /**
- * @callback ApiSwitchBody
- * @param {jsPDF} pdf
- */
-
- /**
- * For compatibility reasons jsPDF offers two API modes which differ in the way they convert between the the usual
- * screen coordinates and the PDF coordinate system.
- * - "compat": Offers full compatibility across all plugins but does not allow arbitrary transforms
- * - "advanced": Allows arbitrary transforms and more advanced features like pattern fills. Some plugins might
- * not support this mode, though.
- * Initial mode is "compat".
- *
- * You can either provide a callback to the body argument, which means that jsPDF will automatically switch back to
- * the original API mode afterwards; or you can omit the callback and switch back manually using {@link compatAPI}.
- *
- * Note, that the calls to {@link saveGraphicsState} and {@link restoreGraphicsState} need to be balanced within the
- * callback or between calls of this method and its counterpart {@link compatAPI}. Calls to {@link beginFormObject}
- * or {@link beginTilingPattern} need to be closed by their counterparts before switching back to "compat" API mode.
- *
- * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.
- * The API mode will be switched back automatically afterwards.
- * @returns {jsPDF}
- * @memberof jsPDF#
- * @name advancedAPI
- */
-
-
- API.advancedAPI = function (body) {
- var doSwitch = apiMode === ApiMode.COMPAT;
-
- if (doSwitch) {
- advancedAPI.call(this);
- }
-
- if (typeof body !== "function") {
- return this;
- }
-
- body(this);
-
- if (doSwitch) {
- compatAPI.call(this);
- }
-
- return this;
- };
- /**
- * Switches to "compat" API mode. See {@link advancedAPI} for more details.
- *
- * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.
- * The API mode will be switched back automatically afterwards.
- * @return {jsPDF}
- * @memberof jsPDF#
- * @name compatApi
- */
-
-
- API.compatAPI = function (body) {
- var doSwitch = apiMode === ApiMode.ADVANCED;
-
- if (doSwitch) {
- compatAPI.call(this);
- }
-
- if (typeof body !== "function") {
- return this;
- }
-
- body(this);
-
- if (doSwitch) {
- advancedAPI.call(this);
- }
-
- return this;
- };
- /**
- * @return {boolean} True iff the current API mode is "advanced". See {@link advancedAPI}.
- * @memberof jsPDF#
- * @name isAdvancedAPI
- */
-
-
- API.isAdvancedAPI = function () {
- return apiMode === ApiMode.ADVANCED;
- };
-
- var advancedApiModeTrap = function advancedApiModeTrap(methodName) {
- if (apiMode !== ApiMode.ADVANCED) {
- throw new Error(methodName + " is only available in 'advanced' API mode. " + "You need to call advancedAPI() first.");
- }
- };
-
- var roundToPrecision = API.roundToPrecision = API.__private__.roundToPrecision = function (number, parmPrecision) {
- var tmpPrecision = precision || parmPrecision;
-
- if (isNaN(number) || isNaN(tmpPrecision)) {
- throw new Error("Invalid argument passed to jsPDF.roundToPrecision");
- }
-
- return number.toFixed(tmpPrecision).replace(/0+$/, "");
- }; // high precision float
-
-
- var hpf;
-
- if (typeof floatPrecision === "number") {
- hpf = API.hpf = API.__private__.hpf = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.hpf");
- }
-
- return roundToPrecision(number, floatPrecision);
- };
- } else if (floatPrecision === "smart") {
- hpf = API.hpf = API.__private__.hpf = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.hpf");
- }
-
- if (number > -1 && number < 1) {
- return roundToPrecision(number, 16);
- } else {
- return roundToPrecision(number, 5);
- }
- };
- } else {
- hpf = API.hpf = API.__private__.hpf = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.hpf");
- }
-
- return roundToPrecision(number, 16);
- };
- }
-
- var f2 = API.f2 = API.__private__.f2 = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.f2");
- }
-
- return roundToPrecision(number, 2);
- };
-
- var f3 = API.__private__.f3 = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.f3");
- }
-
- return roundToPrecision(number, 3);
- };
-
- var scale = API.scale = API.__private__.scale = function (number) {
- if (isNaN(number)) {
- throw new Error("Invalid argument passed to jsPDF.scale");
- }
-
- if (apiMode === ApiMode.COMPAT) {
- return number * scaleFactor;
- } else if (apiMode === ApiMode.ADVANCED) {
- return number;
- }
- };
-
- var transformY = function transformY(y) {
- if (apiMode === ApiMode.COMPAT) {
- return getPageHeight() - y;
- } else if (apiMode === ApiMode.ADVANCED) {
- return y;
- }
- };
-
- var transformScaleY = function transformScaleY(y) {
- return scale(transformY(y));
- };
- /**
- * @name setPrecision
- * @memberof jsPDF#
- * @function
- * @instance
- * @param {string} precision
- * @returns {jsPDF}
- */
-
-
- API.__private__.setPrecision = API.setPrecision = function (value) {
- if (typeof parseInt(value, 10) === "number") {
- precision = parseInt(value, 10);
- }
- };
-
- var fileId = "00000000000000000000000000000000";
-
- var getFileId = API.__private__.getFileId = function () {
- return fileId;
- };
-
- var setFileId = API.__private__.setFileId = function (value) {
- if (typeof value !== "undefined" && /^[a-fA-F0-9]{32}$/.test(value)) {
- fileId = value.toUpperCase();
- } else {
- fileId = fileId.split("").map(function () {
- return "ABCDEF0123456789".charAt(Math.floor(Math.random() * 16));
- }).join("");
- }
-
- return fileId;
- };
- /**
- * @name setFileId
- * @memberof jsPDF#
- * @function
- * @instance
- * @param {string} value GUID.
- * @returns {jsPDF}
- */
-
-
- API.setFileId = function (value) {
- setFileId(value);
- return this;
- };
- /**
- * @name getFileId
- * @memberof jsPDF#
- * @function
- * @instance
- *
- * @returns {string} GUID.
- */
-
-
- API.getFileId = function () {
- return getFileId();
- };
-
- var creationDate;
-
- var convertDateToPDFDate = API.__private__.convertDateToPDFDate = function (parmDate) {
- var result = "";
- var tzoffset = parmDate.getTimezoneOffset(),
- tzsign = tzoffset < 0 ? "+" : "-",
- tzhour = Math.floor(Math.abs(tzoffset / 60)),
- tzmin = Math.abs(tzoffset % 60),
- timeZoneString = [tzsign, padd2(tzhour), "'", padd2(tzmin), "'"].join("");
- result = ["D:", parmDate.getFullYear(), padd2(parmDate.getMonth() + 1), padd2(parmDate.getDate()), padd2(parmDate.getHours()), padd2(parmDate.getMinutes()), padd2(parmDate.getSeconds()), timeZoneString].join("");
- return result;
- };
-
- var convertPDFDateToDate = API.__private__.convertPDFDateToDate = function (parmPDFDate) {
- var year = parseInt(parmPDFDate.substr(2, 4), 10);
- var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;
- var date = parseInt(parmPDFDate.substr(8, 2), 10);
- var hour = parseInt(parmPDFDate.substr(10, 2), 10);
- var minutes = parseInt(parmPDFDate.substr(12, 2), 10);
- var seconds = parseInt(parmPDFDate.substr(14, 2), 10); // var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);
- // var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);
-
- var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);
- return resultingDate;
- };
-
- var setCreationDate = API.__private__.setCreationDate = function (date) {
- var tmpCreationDateString;
- var regexPDFCreationDate = /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/;
-
- if (typeof date === "undefined") {
- date = new Date();
- }
-
- if (date instanceof Date) {
- tmpCreationDateString = convertDateToPDFDate(date);
- } else if (regexPDFCreationDate.test(date)) {
- tmpCreationDateString = date;
- } else {
- throw new Error("Invalid argument passed to jsPDF.setCreationDate");
- }
-
- creationDate = tmpCreationDateString;
- return creationDate;
- };
-
- var getCreationDate = API.__private__.getCreationDate = function (type) {
- var result = creationDate;
-
- if (type === "jsDate") {
- result = convertPDFDateToDate(creationDate);
- }
-
- return result;
- };
- /**
- * @name setCreationDate
- * @memberof jsPDF#
- * @function
- * @instance
- * @param {Object} date
- * @returns {jsPDF}
- */
-
-
- API.setCreationDate = function (date) {
- setCreationDate(date);
- return this;
- };
- /**
- * @name getCreationDate
- * @memberof jsPDF#
- * @function
- * @instance
- * @param {Object} type
- * @returns {Object}
- */
-
-
- API.getCreationDate = function (type) {
- return getCreationDate(type);
- };
-
- var padd2 = API.__private__.padd2 = function (number) {
- return ("0" + parseInt(number)).slice(-2);
- };
-
- var padd2Hex = API.__private__.padd2Hex = function (hexString) {
- hexString = hexString.toString();
- return ("00" + hexString).substr(hexString.length);
- };
-
- var objectNumber = 0; // 'n' Current object number
-
- var offsets = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.
-
- var content = [];
- var contentLength = 0;
- var additionalObjects = [];
- var pages = [];
- var currentPage;
- var hasCustomDestination = false;
- var outputDestination = content;
-
- var resetDocument = function resetDocument() {
- //reset fields relevant for objectNumber generation and xref.
- objectNumber = 0;
- contentLength = 0;
- content = [];
- offsets = [];
- additionalObjects = [];
- rootDictionaryObjId = newObjectDeferred();
- resourceDictionaryObjId = newObjectDeferred();
- };
-
- API.__private__.setCustomOutputDestination = function (destination) {
- hasCustomDestination = true;
- outputDestination = destination;
- };
-
- var setOutputDestination = function setOutputDestination(destination) {
- if (!hasCustomDestination) {
- outputDestination = destination;
- }
- };
-
- API.__private__.resetCustomOutputDestination = function () {
- hasCustomDestination = false;
- outputDestination = content;
- };
-
- var out = API.__private__.out = function (string) {
- string = string.toString();
- contentLength += string.length + 1;
- outputDestination.push(string);
- return outputDestination;
- };
-
- var write = API.__private__.write = function (value) {
- return out(arguments.length === 1 ? value.toString() : Array.prototype.join.call(arguments, " "));
- };
-
- var getArrayBuffer = API.__private__.getArrayBuffer = function (data) {
- var len = data.length,
- ab = new ArrayBuffer(len),
- u8 = new Uint8Array(ab);
-
- while (len--) {
- u8[len] = data.charCodeAt(len);
- }
-
- return ab;
- };
-
- var standardFonts = [["Helvetica", "helvetica", "normal", "WinAnsiEncoding"], ["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"], ["Helvetica-Oblique", "helvetica", "italic", "WinAnsiEncoding"], ["Helvetica-BoldOblique", "helvetica", "bolditalic", "WinAnsiEncoding"], ["Courier", "courier", "normal", "WinAnsiEncoding"], ["Courier-Bold", "courier", "bold", "WinAnsiEncoding"], ["Courier-Oblique", "courier", "italic", "WinAnsiEncoding"], ["Courier-BoldOblique", "courier", "bolditalic", "WinAnsiEncoding"], ["Times-Roman", "times", "normal", "WinAnsiEncoding"], ["Times-Bold", "times", "bold", "WinAnsiEncoding"], ["Times-Italic", "times", "italic", "WinAnsiEncoding"], ["Times-BoldItalic", "times", "bolditalic", "WinAnsiEncoding"], ["ZapfDingbats", "zapfdingbats", "normal", null], ["Symbol", "symbol", "normal", null]];
-
- API.__private__.getStandardFonts = function () {
- return standardFonts;
- };
-
- var activeFontSize = options.fontSize || 16;
- /**
- * Sets font size for upcoming text elements.
- *
- * @param {number} size Font size in points.
- * @function
- * @instance
- * @returns {jsPDF}
- * @memberof jsPDF#
- * @name setFontSize
- */
-
- API.__private__.setFontSize = API.setFontSize = function (size) {
- if (apiMode === ApiMode.ADVANCED) {
- activeFontSize = size / scaleFactor;
- } else {
- activeFontSize = size;
- }
-
- return this;
- };
- /**
- * Gets the fontsize for upcoming text elements.
- *
- * @function
- * @instance
- * @returns {number}
- * @memberof jsPDF#
- * @name getFontSize
- */
-
-
- var getFontSize = API.__private__.getFontSize = API.getFontSize = function () {
- if (apiMode === ApiMode.COMPAT) {
- return activeFontSize;
- } else {
- return activeFontSize * scaleFactor;
- }
- };
-
- var R2L = options.R2L || false;
- /**
- * Set value of R2L functionality.
- *
- * @param {boolean} value
- * @function
- * @instance
- * @returns {jsPDF} jsPDF-instance
- * @memberof jsPDF#
- * @name setR2L
- */
-
- API.__private__.setR2L = API.setR2L = function (value) {
- R2L = value;
- return this;
- };
- /**
- * Get value of R2L functionality.
- *
- * @function
- * @instance
- * @returns {boolean} jsPDF-instance
- * @memberof jsPDF#
- * @name getR2L
- */
-
-
- API.__private__.getR2L = API.getR2L = function () {
- return R2L;
- };
-
- var zoomMode; // default: 1;
-
- var setZoomMode = API.__private__.setZoomMode = function (zoom) {
- var validZoomModes = [undefined, null, "fullwidth", "fullheight", "fullpage", "original"];
-
- if (/^\d*\.?\d*%$/.test(zoom)) {
- zoomMode = zoom;
- } else if (!isNaN(zoom)) {
- zoomMode = parseInt(zoom, 10);
- } else if (validZoomModes.indexOf(zoom) !== -1) {
- zoomMode = zoom;
- } else {
- throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "' + zoom + '" is not recognized.');
- }
- };
-
- API.__private__.getZoomMode = function () {
- return zoomMode;
- };
-
- var pageMode; // default: 'UseOutlines';
-
- var setPageMode = API.__private__.setPageMode = function (pmode) {
- var validPageModes = [undefined, null, "UseNone", "UseOutlines", "UseThumbs", "FullScreen"];
-
- if (validPageModes.indexOf(pmode) == -1) {
- throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' + pmode + '" is not recognized.');
- }
-
- pageMode = pmode;
- };
-
- API.__private__.getPageMode = function () {
- return pageMode;
- };
-
- var layoutMode; // default: 'continuous';
-
- var setLayoutMode = API.__private__.setLayoutMode = function (layout) {
- var validLayoutModes = [undefined, null, "continuous", "single", "twoleft", "tworight", "two"];
-
- if (validLayoutModes.indexOf(layout) == -1) {
- throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "' + layout + '" is not recognized.');
- }
-
- layoutMode = layout;
- };
-
- API.__private__.getLayoutMode = function () {
- return layoutMode;
- };
- /**
- * Set the display mode options of the page like zoom and layout.
- *
- * @name setDisplayMode
- * @memberof jsPDF#
- * @function
- * @instance
- * @param {integer|String} zoom You can pass an integer or percentage as
- * a string. 2 will scale the document up 2x, '200%' will scale up by the
- * same amount. You can also set it to 'fullwidth', 'fullheight',
- * 'fullpage', or 'original'.
- *
- * Only certain PDF readers support this, such as Adobe Acrobat.
- *
- * @param {string} layout Layout mode can be: 'continuous' - this is the
- * default continuous scroll. 'single' - the single page mode only shows one
- * page at a time. 'twoleft' - two column left mode, first page starts on
- * the left, and 'tworight' - pages are laid out in two columns, with the
- * first page on the right. This would be used for books.
- * @param {string} pmode 'UseOutlines' - it shows the
- * outline of the document on the left. 'UseThumbs' - shows thumbnails along
- * the left. 'FullScreen' - prompts the user to enter fullscreen mode.
- *
- * @returns {jsPDF}
- */
-
-
- API.__private__.setDisplayMode = API.setDisplayMode = function (zoom, layout, pmode) {
- setZoomMode(zoom);
- setLayoutMode(layout);
- setPageMode(pmode);
- return this;
- };
-
- var documentProperties = {
- title: "",
- subject: "",
- author: "",
- keywords: "",
- creator: ""
- };
-
- API.__private__.getDocumentProperty = function (key) {
- if (Object.keys(documentProperties).indexOf(key) === -1) {
- throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");
- }
-
- return documentProperties[key];
- };
-
- API.__private__.getDocumentProperties = function () {
- return documentProperties;
- };
- /**
- * Adds a properties to the PDF document.
- *
- * @param {Object} A property_name-to-property_value object structure.
- * @function
- * @instance
- * @returns {jsPDF}
- * @memberof jsPDF#
- * @name setDocumentProperties
- */
-
-
- API.__private__.setDocumentProperties = API.setProperties = API.setDocumentProperties = function (properties) {
- // copying only those properties we can render.
- for (var property in documentProperties) {
- if (documentProperties.hasOwnProperty(property) && properties[property]) {
- documentProperties[property] = properties[property];
- }
- }
-
- return this;
- };
-
- API.__private__.setDocumentProperty = function (key, value) {
- if (Object.keys(documentProperties).indexOf(key) === -1) {
- throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");
- }
-
- return documentProperties[key] = value;
- };
-
- var fonts = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font.
-
- var fontmap = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont()
-
- var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle
-
- var fontStateStack = []; //
-
- var patterns = {}; // collection of pattern objects
-
- var patternMap = {}; // see fonts
-
- var gStates = {}; // collection of graphic state objects
-
- var gStatesMap = {}; // see fonts
-
- var activeGState = null;
- var scaleFactor; // Scale factor
-
- var page = 0;
- var pagesContext = [];
- var events = new PubSub(API);
- var hotfixes = options.hotfixes || [];
- var renderTargets = {};
- var renderTargetMap = {};
- var renderTargetStack = [];
- var pageX;
- var pageY;
- var pageMatrix; // only used for FormObjects
-
- /**
- * A matrix object for 2D homogenous transformations:
- * | a b 0 |
- * | c d 0 |
- * | e f 1 |
- * pdf multiplies matrices righthand: v' = v x m1 x m2 x ...
- *
- * @class
- * @name Matrix
- * @param {number} sx
- * @param {number} shy
- * @param {number} shx
- * @param {number} sy
- * @param {number} tx
- * @param {number} ty
- * @constructor
- */
-
- var Matrix = function Matrix(sx, shy, shx, sy, tx, ty) {
- var _matrix = [];
- /**
- * @name sx
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "sx", {
- get: function get() {
- return _matrix[0];
- },
- set: function set(value) {
- _matrix[0] = value;
- }
- });
- /**
- * @name shy
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "shy", {
- get: function get() {
- return _matrix[1];
- },
- set: function set(value) {
- _matrix[1] = value;
- }
- });
- /**
- * @name shx
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "shx", {
- get: function get() {
- return _matrix[2];
- },
- set: function set(value) {
- _matrix[2] = value;
- }
- });
- /**
- * @name sy
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "sy", {
- get: function get() {
- return _matrix[3];
- },
- set: function set(value) {
- _matrix[3] = value;
- }
- });
- /**
- * @name tx
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "tx", {
- get: function get() {
- return _matrix[4];
- },
- set: function set(value) {
- _matrix[4] = value;
- }
- });
- /**
- * @name ty
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "ty", {
- get: function get() {
- return _matrix[5];
- },
- set: function set(value) {
- _matrix[5] = value;
- }
- });
- Object.defineProperty(this, "a", {
- get: function get() {
- return _matrix[0];
- },
- set: function set(value) {
- _matrix[0] = value;
- }
- });
- Object.defineProperty(this, "b", {
- get: function get() {
- return _matrix[1];
- },
- set: function set(value) {
- _matrix[1] = value;
- }
- });
- Object.defineProperty(this, "c", {
- get: function get() {
- return _matrix[2];
- },
- set: function set(value) {
- _matrix[2] = value;
- }
- });
- Object.defineProperty(this, "d", {
- get: function get() {
- return _matrix[3];
- },
- set: function set(value) {
- _matrix[3] = value;
- }
- });
- Object.defineProperty(this, "e", {
- get: function get() {
- return _matrix[4];
- },
- set: function set(value) {
- _matrix[4] = value;
- }
- });
- Object.defineProperty(this, "f", {
- get: function get() {
- return _matrix[5];
- },
- set: function set(value) {
- _matrix[5] = value;
- }
- });
- /**
- * @name rotation
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "rotation", {
- get: function get() {
- return Math.atan2(this.shx, this.sx);
- }
- });
- /**
- * @name scaleX
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "scaleX", {
- get: function get() {
- return this.decompose().scale.sx;
- }
- });
- /**
- * @name scaleY
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "scaleY", {
- get: function get() {
- return this.decompose().scale.sy;
- }
- });
- /**
- * @name isIdentity
- * @memberof Matrix#
- */
-
- Object.defineProperty(this, "isIdentity", {
- get: function get() {
- if (this.sx !== 1) {
- return false;
- }
-
- if (this.shy !== 0) {
- return false;
- }
-
- if (this.shx !== 0) {
- return false;
- }
-
- if (this.sy !== 1) {
- return false;
- }
-
- if (this.tx !== 0) {
- return false;
- }
-
- if (this.ty !== 0) {
- return false;
- }
-
- return true;
- }
- });
- this.sx = !isNaN(sx) ? sx : 1;
- this.shy = !isNaN(shy) ? shy : 0;
- this.shx = !isNaN(shx) ? shx : 0;
- this.sy = !isNaN(sy) ? sy : 1;
- this.tx = !isNaN(tx) ? tx : 0;
- this.ty = !isNaN(ty) ? ty : 0;
- return this;
- };
- /**
- * Join the Matrix Values to a String
- *
- * @function join
- * @param {string} separator Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them.
- * @returns {string} A string with all array elements joined.
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.join = function (separator) {
- return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty].map(hpf).join(separator);
- };
- /**
- * Multiply the matrix with given Matrix
- *
- * @function multiply
- * @param matrix
- * @returns {Matrix}
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.multiply = function (matrix) {
- var sx = matrix.sx * this.sx + matrix.shy * this.shx;
- var shy = matrix.sx * this.shy + matrix.shy * this.sy;
- var shx = matrix.shx * this.sx + matrix.sy * this.shx;
- var sy = matrix.shx * this.shy + matrix.sy * this.sy;
- var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx;
- var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty;
- return new Matrix(sx, shy, shx, sy, tx, ty);
- };
- /**
- * @function decompose
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.decompose = function () {
- var a = this.sx;
- var b = this.shy;
- var c = this.shx;
- var d = this.sy;
- var e = this.tx;
- var f = this.ty;
- var scaleX = Math.sqrt(a * a + b * b);
- a /= scaleX;
- b /= scaleX;
- var shear = a * c + b * d;
- c -= a * shear;
- d -= b * shear;
- var scaleY = Math.sqrt(c * c + d * d);
- c /= scaleY;
- d /= scaleY;
- shear /= scaleY;
-
- if (a * d < b * c) {
- a = -a;
- b = -b;
- shear = -shear;
- scaleX = -scaleX;
- }
-
- return {
- scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),
- translate: new Matrix(1, 0, 0, 1, e, f),
- rotate: new Matrix(a, b, -b, a, 0, 0),
- skew: new Matrix(1, 0, shear, 1, 0, 0)
- };
- };
- /**
- * @function toString
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.toString = function (parmPrecision) {
- return this.join(" ");
- };
- /**
- * @function inversed
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.inversed = function () {
- var a = this.sx,
- b = this.shy,
- c = this.shx,
- d = this.sy,
- e = this.tx,
- f = this.ty;
- var quot = 1 / (a * d - b * c);
- var aInv = d * quot;
- var bInv = -b * quot;
- var cInv = -c * quot;
- var dInv = a * quot;
- var eInv = -aInv * e - cInv * f;
- var fInv = -bInv * e - dInv * f;
- return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);
- };
- /**
- * @function applyToPoint
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.applyToPoint = function (pt) {
- var x = pt.x * this.sx + pt.y * this.shx + this.tx;
- var y = pt.x * this.shy + pt.y * this.sy + this.ty;
- return new Point(x, y);
- };
- /**
- * @function applyToRectangle
- * @memberof Matrix#
- */
-
-
- Matrix.prototype.applyToRectangle = function (rect) {
- var pt1 = this.applyToPoint(rect);
- var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));
- return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);
- };
- /**
- * Clone the Matrix
- *
- * @function clone
- * @memberof Matrix#
- * @name clone
- * @instance
- */
-
-
- Matrix.prototype.clone = function () {
- var sx = this.sx;
- var shy = this.shy;
- var shx = this.shx;
- var sy = this.sy;
- var tx = this.tx;
- var ty = this.ty;
- return new Matrix(sx, shy, shx, sy, tx, ty);
- };
-
- API.Matrix = Matrix;
- /**
- * Multiplies two matrices. (see {@link Matrix})
- * @param {Matrix} m1
- * @param {Matrix} m2
- * @memberof jsPDF#
- * @name matrixMult
- */
-
- var matrixMult = API.matrixMult = function (m1, m2) {
- return m2.multiply(m1);
- };
- /**
- * The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)).
- * @type {Matrix}
- * @memberof! jsPDF#
- * @name identityMatrix
- */
-
-
- var identityMatrix = new Matrix(1, 0, 0, 1, 0, 0);
- API.unitMatrix = API.identityMatrix = identityMatrix;
-
- var Pattern = function Pattern(gState, matrix) {
- this.gState = gState;
- this.matrix = matrix;
- this.id = ""; // set by addPattern()
-
- this.objectNumber = -1; // will be set by putPattern()
- };
- /**
- * Adds a new pattern for later use.
- * @param {String} key The key by it can be referenced later. The keys must be unique!
- * @param {API.Pattern} pattern The pattern
- */
-
-
- var addPattern = function addPattern(key, pattern) {
- // only add it if it is not already present (the keys provided by the user must be unique!)
- if (patternMap[key]) { return; }
- var prefix = pattern instanceof API.ShadingPattern ? "Sh" : "P";
- var patternKey = prefix + (Object.keys(patterns).length + 1).toString(10);
- pattern.id = patternKey;
- patternMap[key] = patternKey;
- patterns[patternKey] = pattern;
- events.publish("addPattern", pattern);
- };
- /**
- * A pattern describing a shading pattern.
- *
- * Only available in "advanced" API mode.
- *
- * @param {String} type One of "axial" or "radial"
- * @param {Array} coords Either [x1, y1, x2, y2] for "axial" type describing the two interpolation points
- * or [x1, y1, r, x2, y2, r2] for "radial" describing inner and the outer circle.
- * @param {Array
- * @name annotations
- * @module
- */
-
- /*
- Destination Magnification Factors
- See PDF 1.3 Page 386 for meanings and options
-
- [supported]
- XYZ (options; left top zoom)
- Fit (no options)
- FitH (options: top)
- FitV (options: left)
-
- [not supported]
- FitR
- FitB
- FitBH
- FitBV
- */
- (function (jsPDFAPI) {
-
- var notEmpty = function notEmpty(obj) {
- if (typeof obj != "undefined") {
- if (obj != "") {
- return true;
- }
- }
- };
-
- jsPDF.API.events.push(["addPage", function (addPageData) {
- var pageInfo = this.internal.getPageInfo(addPageData.pageNumber);
- pageInfo.pageContext.annotations = [];
- }]);
- jsPDFAPI.events.push(["putPage", function (putPageData) {
- var getHorizontalCoordinateString = this.internal.getCoordinateString;
- var getVerticalCoordinateString = this.internal.getVerticalCoordinateString;
- var pageInfo = this.internal.getPageInfoByObjId(putPageData.objId);
- var pageAnnos = putPageData.pageContext.annotations;
- var anno, rect, line;
- var found = false;
-
- for (var a = 0; a < pageAnnos.length && !found; a++) {
- anno = pageAnnos[a];
-
- switch (anno.type) {
- case "link":
- if (notEmpty(anno.options.url) || notEmpty(anno.options.pageNumber)) {
- found = true;
- }
-
- break;
-
- case "reference":
- case "text":
- case "freetext":
- found = true;
- break;
- }
- }
-
- if (found == false) {
- return;
- }
-
- this.internal.write("/Annots [");
-
- for (var i = 0; i < pageAnnos.length; i++) {
- anno = pageAnnos[i];
-
- switch (anno.type) {
- case "reference":
- // References to Widget Annotations (for AcroForm Fields)
- this.internal.write(" " + anno.object.objId + " 0 R ");
- break;
-
- case "text":
- // Create a an object for both the text and the popup
- var objText = this.internal.newAdditionalObject();
- var objPopup = this.internal.newAdditionalObject();
- var title = anno.title || "Note";
- rect = "/Rect [" + getHorizontalCoordinateString(anno.bounds.x) + " " + getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) + " " + getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w) + " " + getVerticalCoordinateString(anno.bounds.y) + "] ";
- line = "<>";
- objText.content = line;
- var parent = objText.objId + " 0 R";
- var popoff = 30;
- rect = "/Rect [" + getHorizontalCoordinateString(anno.bounds.x + popoff) + " " + getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) + " " + getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w + popoff) + " " + getVerticalCoordinateString(anno.bounds.y) + "] ";
- line = "<>";
- objPopup.content = line;
- this.internal.write(objText.objId, "0 R", objPopup.objId, "0 R");
- break;
-
- case "freetext":
- rect = "/Rect [" + getHorizontalCoordinateString(anno.bounds.x) + " " + getVerticalCoordinateString(anno.bounds.y) + " " + getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w) + " " + getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) + "] ";
- var color = anno.color || "#000000";
- line = "<>";
- this.internal.write(line);
- break;
-
- case "link":
- if (anno.options.name) {
- var loc = this.annotations._nameMap[anno.options.name];
- anno.options.pageNumber = loc.page;
- anno.options.top = loc.y;
- } else {
- if (!anno.options.top) {
- anno.options.top = 0;
- }
- }
-
- rect = "/Rect [" + getHorizontalCoordinateString(anno.x) + " " + getVerticalCoordinateString(anno.y) + " " + getHorizontalCoordinateString(anno.x + anno.w) + " " + getVerticalCoordinateString(anno.y + anno.h) + "] ";
- line = "";
-
- if (anno.options.url) {
- line = "<>";
- } else if (anno.options.pageNumber) {
- // first page is 0
- var info = this.internal.getPageInfo(anno.options.pageNumber);
- line = "<>";
- this.internal.write(line);
- }
-
- break;
- }
- }
-
- this.internal.write("]");
- }]);
- /**
- * @name createAnnotation
- * @function
- * @param {Object} options
- */
-
- jsPDFAPI.createAnnotation = function (options) {
- var pageInfo = this.internal.getCurrentPageInfo();
-
- switch (options.type) {
- case "link":
- this.link(options.bounds.x, options.bounds.y, options.bounds.w, options.bounds.h, options);
- break;
-
- case "text":
- case "freetext":
- pageInfo.pageContext.annotations.push(options);
- break;
- }
- };
- /**
- * Create a link
- *
- * valid options
- * pageNumber or url [required]
- * If pageNumber is specified, top and zoom may also be specified
- * @name link
- * @function
- * @param {number} x
- * @param {number} y
- * @param {number} w
- * @param {number} h
- * @param {Object} options
- */
-
-
- jsPDFAPI.link = function (x, y, w, h, options) {
- var pageInfo = this.internal.getCurrentPageInfo();
- pageInfo.pageContext.annotations.push({
- x: x,
- y: y,
- w: w,
- h: h,
- options: options,
- type: "link"
- });
- };
- /**
- * Currently only supports single line text.
- * Returns the width of the text/link
- *
- * @name textWithLink
- * @function
- * @param {string} text
- * @param {number} x
- * @param {number} y
- * @param {Object} options
- * @returns {number} width the width of the text/link
- */
-
-
- jsPDFAPI.textWithLink = function (text, x, y, options) {
- var width = this.getTextWidth(text);
- var height = this.internal.getLineHeight() / this.internal.scaleFactor;
- this.text(text, x, y, options); //TODO We really need the text baseline height to do this correctly.
- // Or ability to draw text on top, bottom, center, or baseline.
-
- y += height * 0.2;
- this.link(x, y - height, width, height, options);
- return width;
- }; //TODO move into external library
-
- /**
- * @name getTextWidth
- * @function
- * @param {string} text
- * @returns {number} txtWidth
- */
-
-
- jsPDFAPI.getTextWidth = function (text) {
- var fontSize = this.internal.getFontSize();
- var txtWidth = this.getStringUnitWidth(text) * fontSize / this.internal.scaleFactor;
- return txtWidth;
- };
-
- return this;
- })(jsPDF.API);
-
- /* global jsPDF */
-
- /**
- * @license
- * Copyright (c) 2017 Aras Abbasi
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
- */
-
- /**
- * jsPDF arabic parser PlugIn
- *
- * @name arabic
- * @module
- */
- (function (jsPDFAPI) {
- /**
- * Arabic shape substitutions: char code => (isolated, final, initial, medial).
- * Arabic Substition A
- */
-
- var arabicSubstitionA = {
- 0x0621: [0xfe80],
- // ARABIC LETTER HAMZA
- 0x0622: [0xfe81, 0xfe82],
- // ARABIC LETTER ALEF WITH MADDA ABOVE
- 0x0623: [0xfe83, 0xfe84],
- // ARABIC LETTER ALEF WITH HAMZA ABOVE
- 0x0624: [0xfe85, 0xfe86],
- // ARABIC LETTER WAW WITH HAMZA ABOVE
- 0x0625: [0xfe87, 0xfe88],
- // ARABIC LETTER ALEF WITH HAMZA BELOW
- 0x0626: [0xfe89, 0xfe8a, 0xfe8b, 0xfe8c],
- // ARABIC LETTER YEH WITH HAMZA ABOVE
- 0x0627: [0xfe8d, 0xfe8e],
- // ARABIC LETTER ALEF
- 0x0628: [0xfe8f, 0xfe90, 0xfe91, 0xfe92],
- // ARABIC LETTER BEH
- 0x0629: [0xfe93, 0xfe94],
- // ARABIC LETTER TEH MARBUTA
- 0x062a: [0xfe95, 0xfe96, 0xfe97, 0xfe98],
- // ARABIC LETTER TEH
- 0x062b: [0xfe99, 0xfe9a, 0xfe9b, 0xfe9c],
- // ARABIC LETTER THEH
- 0x062c: [0xfe9d, 0xfe9e, 0xfe9f, 0xfea0],
- // ARABIC LETTER JEEM
- 0x062d: [0xfea1, 0xfea2, 0xfea3, 0xfea4],
- // ARABIC LETTER HAH
- 0x062e: [0xfea5, 0xfea6, 0xfea7, 0xfea8],
- // ARABIC LETTER KHAH
- 0x062f: [0xfea9, 0xfeaa],
- // ARABIC LETTER DAL
- 0x0630: [0xfeab, 0xfeac],
- // ARABIC LETTER THAL
- 0x0631: [0xfead, 0xfeae],
- // ARABIC LETTER REH
- 0x0632: [0xfeaf, 0xfeb0],
- // ARABIC LETTER ZAIN
- 0x0633: [0xfeb1, 0xfeb2, 0xfeb3, 0xfeb4],
- // ARABIC LETTER SEEN
- 0x0634: [0xfeb5, 0xfeb6, 0xfeb7, 0xfeb8],
- // ARABIC LETTER SHEEN
- 0x0635: [0xfeb9, 0xfeba, 0xfebb, 0xfebc],
- // ARABIC LETTER SAD
- 0x0636: [0xfebd, 0xfebe, 0xfebf, 0xfec0],
- // ARABIC LETTER DAD
- 0x0637: [0xfec1, 0xfec2, 0xfec3, 0xfec4],
- // ARABIC LETTER TAH
- 0x0638: [0xfec5, 0xfec6, 0xfec7, 0xfec8],
- // ARABIC LETTER ZAH
- 0x0639: [0xfec9, 0xfeca, 0xfecb, 0xfecc],
- // ARABIC LETTER AIN
- 0x063a: [0xfecd, 0xfece, 0xfecf, 0xfed0],
- // ARABIC LETTER GHAIN
- 0x0641: [0xfed1, 0xfed2, 0xfed3, 0xfed4],
- // ARABIC LETTER FEH
- 0x0642: [0xfed5, 0xfed6, 0xfed7, 0xfed8],
- // ARABIC LETTER QAF
- 0x0643: [0xfed9, 0xfeda, 0xfedb, 0xfedc],
- // ARABIC LETTER KAF
- 0x0644: [0xfedd, 0xfede, 0xfedf, 0xfee0],
- // ARABIC LETTER LAM
- 0x0645: [0xfee1, 0xfee2, 0xfee3, 0xfee4],
- // ARABIC LETTER MEEM
- 0x0646: [0xfee5, 0xfee6, 0xfee7, 0xfee8],
- // ARABIC LETTER NOON
- 0x0647: [0xfee9, 0xfeea, 0xfeeb, 0xfeec],
- // ARABIC LETTER HEH
- 0x0648: [0xfeed, 0xfeee],
- // ARABIC LETTER WAW
- 0x0649: [0xfeef, 0xfef0, 64488, 64489],
- // ARABIC LETTER ALEF MAKSURA
- 0x064a: [0xfef1, 0xfef2, 0xfef3, 0xfef4],
- // ARABIC LETTER YEH
- 0x0671: [0xfb50, 0xfb51],
- // ARABIC LETTER ALEF WASLA
- 0x0677: [0xfbdd],
- // ARABIC LETTER U WITH HAMZA ABOVE
- 0x0679: [0xfb66, 0xfb67, 0xfb68, 0xfb69],
- // ARABIC LETTER TTEH
- 0x067a: [0xfb5e, 0xfb5f, 0xfb60, 0xfb61],
- // ARABIC LETTER TTEHEH
- 0x067b: [0xfb52, 0xfb53, 0xfb54, 0xfb55],
- // ARABIC LETTER BEEH
- 0x067e: [0xfb56, 0xfb57, 0xfb58, 0xfb59],
- // ARABIC LETTER PEH
- 0x067f: [0xfb62, 0xfb63, 0xfb64, 0xfb65],
- // ARABIC LETTER TEHEH
- 0x0680: [0xfb5a, 0xfb5b, 0xfb5c, 0xfb5d],
- // ARABIC LETTER BEHEH
- 0x0683: [0xfb76, 0xfb77, 0xfb78, 0xfb79],
- // ARABIC LETTER NYEH
- 0x0684: [0xfb72, 0xfb73, 0xfb74, 0xfb75],
- // ARABIC LETTER DYEH
- 0x0686: [0xfb7a, 0xfb7b, 0xfb7c, 0xfb7d],
- // ARABIC LETTER TCHEH
- 0x0687: [0xfb7e, 0xfb7f, 0xfb80, 0xfb81],
- // ARABIC LETTER TCHEHEH
- 0x0688: [0xfb88, 0xfb89],
- // ARABIC LETTER DDAL
- 0x068c: [0xfb84, 0xfb85],
- // ARABIC LETTER DAHAL
- 0x068d: [0xfb82, 0xfb83],
- // ARABIC LETTER DDAHAL
- 0x068e: [0xfb86, 0xfb87],
- // ARABIC LETTER DUL
- 0x0691: [0xfb8c, 0xfb8d],
- // ARABIC LETTER RREH
- 0x0698: [0xfb8a, 0xfb8b],
- // ARABIC LETTER JEH
- 0x06a4: [0xfb6a, 0xfb6b, 0xfb6c, 0xfb6d],
- // ARABIC LETTER VEH
- 0x06a6: [0xfb6e, 0xfb6f, 0xfb70, 0xfb71],
- // ARABIC LETTER PEHEH
- 0x06a9: [0xfb8e, 0xfb8f, 0xfb90, 0xfb91],
- // ARABIC LETTER KEHEH
- 0x06ad: [0xfbd3, 0xfbd4, 0xfbd5, 0xfbd6],
- // ARABIC LETTER NG
- 0x06af: [0xfb92, 0xfb93, 0xfb94, 0xfb95],
- // ARABIC LETTER GAF
- 0x06b1: [0xfb9a, 0xfb9b, 0xfb9c, 0xfb9d],
- // ARABIC LETTER NGOEH
- 0x06b3: [0xfb96, 0xfb97, 0xfb98, 0xfb99],
- // ARABIC LETTER GUEH
- 0x06ba: [0xfb9e, 0xfb9f],
- // ARABIC LETTER NOON GHUNNA
- 0x06bb: [0xfba0, 0xfba1, 0xfba2, 0xfba3],
- // ARABIC LETTER RNOON
- 0x06be: [0xfbaa, 0xfbab, 0xfbac, 0xfbad],
- // ARABIC LETTER HEH DOACHASHMEE
- 0x06c0: [0xfba4, 0xfba5],
- // ARABIC LETTER HEH WITH YEH ABOVE
- 0x06c1: [0xfba6, 0xfba7, 0xfba8, 0xfba9],
- // ARABIC LETTER HEH GOAL
- 0x06c5: [0xfbe0, 0xfbe1],
- // ARABIC LETTER KIRGHIZ OE
- 0x06c6: [0xfbd9, 0xfbda],
- // ARABIC LETTER OE
- 0x06c7: [0xfbd7, 0xfbd8],
- // ARABIC LETTER U
- 0x06c8: [0xfbdb, 0xfbdc],
- // ARABIC LETTER YU
- 0x06c9: [0xfbe2, 0xfbe3],
- // ARABIC LETTER KIRGHIZ YU
- 0x06cb: [0xfbde, 0xfbdf],
- // ARABIC LETTER VE
- 0x06cc: [0xfbfc, 0xfbfd, 0xfbfe, 0xfbff],
- // ARABIC LETTER FARSI YEH
- 0x06d0: [0xfbe4, 0xfbe5, 0xfbe6, 0xfbe7],
- //ARABIC LETTER E
- 0x06d2: [0xfbae, 0xfbaf],
- // ARABIC LETTER YEH BARREE
- 0x06d3: [0xfbb0, 0xfbb1] // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
-
- };
- /*
- var ligaturesSubstitutionA = {
- 0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM
- };
- */
-
- var ligatures = {
- 0xfedf: {
- 0xfe82: 0xfef5,
- // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
- 0xfe84: 0xfef7,
- // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
- 0xfe88: 0xfef9,
- // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM
- 0xfe8e: 0xfefb // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
-
- },
- 0xfee0: {
- 0xfe82: 0xfef6,
- // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
- 0xfe84: 0xfef8,
- // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
- 0xfe88: 0xfefa,
- // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM
- 0xfe8e: 0xfefc // ARABIC LIGATURE LAM WITH ALEF FINAL FORM
-
- },
- 0xfe8d: {
- 0xfedf: {
- 0xfee0: {
- 0xfeea: 0xfdf2
- }
- }
- },
- // ALLAH
- 0x0651: {
- 0x064c: 0xfc5e,
- // Shadda + Dammatan
- 0x064d: 0xfc5f,
- // Shadda + Kasratan
- 0x064e: 0xfc60,
- // Shadda + Fatha
- 0x064f: 0xfc61,
- // Shadda + Damma
- 0x0650: 0xfc62 // Shadda + Kasra
-
- }
- };
- var arabic_diacritics = {
- 1612: 64606,
- // Shadda + Dammatan
- 1613: 64607,
- // Shadda + Kasratan
- 1614: 64608,
- // Shadda + Fatha
- 1615: 64609,
- // Shadda + Damma
- 1616: 64610 // Shadda + Kasra
-
- };
- var alfletter = [1570, 1571, 1573, 1575];
- var noChangeInForm = -1;
- var isolatedForm = 0;
- var finalForm = 1;
- var initialForm = 2;
- var medialForm = 3;
- jsPDFAPI.__arabicParser__ = {}; //private
-
- var isInArabicSubstitutionA = jsPDFAPI.__arabicParser__.isInArabicSubstitutionA = function (letter) {
- return typeof arabicSubstitionA[letter.charCodeAt(0)] !== "undefined";
- };
-
- var isArabicLetter = jsPDFAPI.__arabicParser__.isArabicLetter = function (letter) {
- return typeof letter === "string" && /^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(letter);
- };
-
- var isArabicEndLetter = jsPDFAPI.__arabicParser__.isArabicEndLetter = function (letter) {
- return isArabicLetter(letter) && isInArabicSubstitutionA(letter) && arabicSubstitionA[letter.charCodeAt(0)].length <= 2;
- };
-
- var isArabicAlfLetter = jsPDFAPI.__arabicParser__.isArabicAlfLetter = function (letter) {
- return isArabicLetter(letter) && alfletter.indexOf(letter.charCodeAt(0)) >= 0;
- };
-
- jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm = function (letter) {
- return isArabicLetter(letter) && isInArabicSubstitutionA(letter) && arabicSubstitionA[letter.charCodeAt(0)].length >= 1;
- };
-
- var arabicLetterHasFinalForm = jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm = function (letter) {
- return isArabicLetter(letter) && isInArabicSubstitutionA(letter) && arabicSubstitionA[letter.charCodeAt(0)].length >= 2;
- };
-
- jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm = function (letter) {
- return isArabicLetter(letter) && isInArabicSubstitutionA(letter) && arabicSubstitionA[letter.charCodeAt(0)].length >= 3;
- };
-
- var arabicLetterHasMedialForm = jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm = function (letter) {
- return isArabicLetter(letter) && isInArabicSubstitutionA(letter) && arabicSubstitionA[letter.charCodeAt(0)].length == 4;
- };
-
- var resolveLigatures = jsPDFAPI.__arabicParser__.resolveLigatures = function (letters) {
- var i = 0;
- var tmpLigatures = ligatures;
- var result = "";
- var effectedLetters = 0;
-
- for (i = 0; i < letters.length; i += 1) {
- if (typeof tmpLigatures[letters.charCodeAt(i)] !== "undefined") {
- effectedLetters++;
- tmpLigatures = tmpLigatures[letters.charCodeAt(i)];
-
- if (typeof tmpLigatures === "number") {
- result += String.fromCharCode(tmpLigatures);
- tmpLigatures = ligatures;
- effectedLetters = 0;
- }
-
- if (i === letters.length - 1) {
- tmpLigatures = ligatures;
- result += letters.charAt(i - (effectedLetters - 1));
- i = i - (effectedLetters - 1);
- effectedLetters = 0;
- }
- } else {
- tmpLigatures = ligatures;
- result += letters.charAt(i - effectedLetters);
- i = i - effectedLetters;
- effectedLetters = 0;
- }
- }
-
- return result;
- };
-
- jsPDFAPI.__arabicParser__.isArabicDiacritic = function (letter) {
- return letter !== undefined && arabic_diacritics[letter.charCodeAt(0)] !== undefined;
- };
-
- var getCorrectForm = jsPDFAPI.__arabicParser__.getCorrectForm = function (currentChar, beforeChar, nextChar) {
- if (!isArabicLetter(currentChar)) {
- return -1;
- }
-
- if (isInArabicSubstitutionA(currentChar) === false) {
- return noChangeInForm;
- }
-
- if (!arabicLetterHasFinalForm(currentChar) || !isArabicLetter(beforeChar) && !isArabicLetter(nextChar) || !isArabicLetter(nextChar) && isArabicEndLetter(beforeChar) || isArabicEndLetter(currentChar) && !isArabicLetter(beforeChar) || isArabicEndLetter(currentChar) && isArabicAlfLetter(beforeChar) || isArabicEndLetter(currentChar) && isArabicEndLetter(beforeChar)) {
- return isolatedForm;
- }
-
- if (arabicLetterHasMedialForm(currentChar) && isArabicLetter(beforeChar) && !isArabicEndLetter(beforeChar) && isArabicLetter(nextChar) && arabicLetterHasFinalForm(nextChar)) {
- return medialForm;
- }
-
- if (isArabicEndLetter(currentChar) || !isArabicLetter(nextChar)) {
- return finalForm;
- }
-
- return initialForm;
- };
- /**
- * @name processArabic
- * @function
- * @param {string} text
- * @returns {string}
- */
-
-
- var parseArabic = function parseArabic(text) {
- text = text || "";
- var result = "";
- var i = 0;
- var j = 0;
- var position = 0;
- var currentLetter = "";
- var prevLetter = "";
- var nextLetter = "";
- var words = text.split("\\s+");
- var newWords = [];
-
- for (i = 0; i < words.length; i += 1) {
- newWords.push("");
-
- for (j = 0; j < words[i].length; j += 1) {
- currentLetter = words[i][j];
- prevLetter = words[i][j - 1];
- nextLetter = words[i][j + 1];
-
- if (isArabicLetter(currentLetter)) {
- position = getCorrectForm(currentLetter, prevLetter, nextLetter);
-
- if (position !== -1) {
- newWords[i] += String.fromCharCode(arabicSubstitionA[currentLetter.charCodeAt(0)][position]);
- } else {
- newWords[i] += currentLetter;
- }
- } else {
- newWords[i] += currentLetter;
- }
- }
-
- newWords[i] = resolveLigatures(newWords[i]);
- }
-
- result = newWords.join(" ");
- return result;
- };
-
- var processArabic = jsPDFAPI.__arabicParser__.processArabic = jsPDFAPI.processArabic = function () {
- var text = typeof arguments[0] === "string" ? arguments[0] : arguments[0].text;
- var tmpText = [];
- var result;
-
- if (Array.isArray(text)) {
- var i = 0;
- tmpText = [];
-
- for (i = 0; i < text.length; i += 1) {
- if (Array.isArray(text[i])) {
- tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]);
- } else {
- tmpText.push([parseArabic(text[i])]);
- }
- }
-
- result = tmpText;
- } else {
- result = parseArabic(text);
- }
-
- if (typeof arguments[0] === "string") {
- return result;
- } else {
- arguments[0].text = result;
- return arguments[0];
- }
- };
-
- jsPDFAPI.events.push(["preProcessText", processArabic]);
- })(jsPDF.API);
-
- /* global jsPDF */
-
- /** @license
- * jsPDF Autoprint Plugin
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
- */
-
- /**
- * @name autoprint
- * @module
- */
- (function (jsPDFAPI) {
- /**
- * Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer.
- *
- * @name autoPrint
- * @function
- * @param {Object} options (optional) Set the attribute variant to 'non-conform' (default) or 'javascript' to activate different methods of automatic printing when opening in a PDF-viewer .
- * @returns {jsPDF}
- * @example
- * var doc = new jsPDF();
- * doc.text(10, 10, 'This is a test');
- * doc.autoPrint({variant: 'non-conform'});
- * doc.save('autoprint.pdf');
- */
-
- jsPDFAPI.autoPrint = function (options) {
-
- var refAutoPrintTag;
- options = options || {};
- options.variant = options.variant || "non-conform";
-
- switch (options.variant) {
- case "javascript":
- //https://github.com/Rob--W/pdf.js/commit/c676ecb5a0f54677b9f3340c3ef2cf42225453bb
- this.addJS("print({});");
- break;
-
- case "non-conform":
- default:
- this.internal.events.subscribe("postPutResources", function () {
- refAutoPrintTag = this.internal.newObject();
- this.internal.out("<<");
- this.internal.out("/S /Named");
- this.internal.out("/Type /Action");
- this.internal.out("/N /Print");
- this.internal.out(">>");
- this.internal.out("endobj");
- });
- this.internal.events.subscribe("putCatalog", function () {
- this.internal.out("/OpenAction " + refAutoPrintTag + " 0 R");
- });
- break;
- }
-
- return this;
- };
- })(jsPDF.API);
-
- /* global jsPDF */
-
- /**
- * @license
- * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
- */
-
- /**
- * jsPDF Canvas PlugIn
- * This plugin mimics the HTML5 Canvas
- *
- * The goal is to provide a way for current canvas users to print directly to a PDF.
- * @name canvas
- * @module
- */
- (function (jsPDFAPI) {
- /**
- * @class Canvas
- * @classdesc A Canvas Wrapper for jsPDF
- */
-
- var Canvas = function Canvas() {
- var jsPdfInstance = undefined;
- Object.defineProperty(this, "pdf", {
- get: function get() {
- return jsPdfInstance;
- },
- set: function set(value) {
- jsPdfInstance = value;
- }
- });
- var _width = 150;
- /**
- * The height property is a positive integer reflecting the height HTML attribute of the