{"version":3,"file":"jspdf.es.js","sources":["../src/libs/globalObject.js","../src/libs/console.js","../src/libs/FileSaver.js","../src/libs/rgbcolor.js","../src/libs/AtobBtoa.js","../src/libs/md5.js","../src/libs/rc4.js","../src/libs/pdfsecurity.js","../src/libs/pdfname.js","../src/jspdf.js","../src/modules/acroform.js","../src/modules/addimage.js","../src/modules/annotations.js","../src/modules/arabic.js","../src/modules/autoprint.js","../src/modules/canvas.js","../src/modules/cell.js","../src/libs/fontFace.js","../src/modules/context2d.js","../src/modules/filters.js","../src/modules/fileloading.js","../src/modules/html.js","../src/modules/javascript.js","../src/modules/outline.js","../src/modules/jpeg_support.js","../src/libs/png.js","../src/modules/png_support.js","../src/libs/omggif.js","../src/libs/JPEGEncoder.js","../src/modules/gif_support.js","../src/libs/BMPDecoder.js","../src/modules/bmp_support.js","../src/libs/WebPDecoder.js","../src/modules/webp_support.js","../src/modules/rgba_support.js","../src/modules/setlanguage.js","../src/modules/split_text_to_size.js","../src/modules/standard_fonts_metrics.js","../src/modules/ttfsupport.js","../src/modules/svg.js","../src/modules/total_pages.js","../src/modules/viewerpreferences.js","../src/modules/xmp_metadata.js","../src/modules/utf8.js","../src/modules/vfs.js","../src/libs/bidiEngine.js","../src/libs/ttffont.js"],"sourcesContent":["export var globalObject = (function() {\n return \"undefined\" !== typeof window\n ? window\n : \"undefined\" !== typeof global\n ? global\n : \"undefined\" !== typeof self\n ? self\n : this;\n})();\n","import { globalObject } from \"./globalObject.js\";\n\nfunction consoleLog() {\n if (globalObject.console && typeof globalObject.console.log === \"function\") {\n globalObject.console.log.apply(globalObject.console, arguments);\n }\n}\n\nfunction consoleWarn(str) {\n if (globalObject.console) {\n if (typeof globalObject.console.warn === \"function\") {\n globalObject.console.warn.apply(globalObject.console, arguments);\n } else {\n consoleLog.call(null, arguments);\n }\n }\n}\n\nfunction consoleError(str) {\n if (globalObject.console) {\n if (typeof globalObject.console.error === \"function\") {\n globalObject.console.error.apply(globalObject.console, arguments);\n } else {\n consoleLog(str);\n }\n }\n}\nexport var console = {\n log: consoleLog,\n warn: consoleWarn,\n error: consoleError\n};\n","/**\n * @license\n * FileSaver.js\n * A saveAs() FileSaver implementation.\n *\n * By Eli Grey, http://eligrey.com\n *\n * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)\n * source : http://purl.eligrey.com/github/FileSaver.js\n */\n\nimport { globalObject as _global } from \"./globalObject.js\";\nimport { console } from \"./console.js\";\n\nfunction bom(blob, opts) {\n if (typeof opts === \"undefined\") opts = { autoBom: false };\n else if (typeof opts !== \"object\") {\n console.warn(\"Deprecated: Expected third argument to be a object\");\n opts = { autoBom: !opts };\n }\n\n // prepend BOM for UTF-8 XML and text/* types (including HTML)\n // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF\n if (\n opts.autoBom &&\n /^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(\n blob.type\n )\n ) {\n return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type });\n }\n return blob;\n}\n\nfunction download(url, name, opts) {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url);\n xhr.responseType = \"blob\";\n xhr.onload = function() {\n saveAs(xhr.response, name, opts);\n };\n xhr.onerror = function() {\n console.error(\"could not download file\");\n };\n xhr.send();\n}\n\nfunction corsEnabled(url) {\n var xhr = new XMLHttpRequest();\n // use sync to avoid popup blocker\n xhr.open(\"HEAD\", url, false);\n try {\n xhr.send();\n } catch (e) {}\n return xhr.status >= 200 && xhr.status <= 299;\n}\n\n// `a.click()` doesn't work for all browsers (#465)\nfunction click(node) {\n try {\n node.dispatchEvent(new MouseEvent(\"click\"));\n } catch (e) {\n var evt = document.createEvent(\"MouseEvents\");\n evt.initMouseEvent(\n \"click\",\n true,\n true,\n window,\n 0,\n 0,\n 0,\n 80,\n 20,\n false,\n false,\n false,\n false,\n 0,\n null\n );\n node.dispatchEvent(evt);\n }\n}\n\nvar saveAs =\n _global.saveAs ||\n // probably in some web worker\n (typeof window !== \"object\" || window !== _global\n ? function saveAs() {\n /* noop */\n }\n : // Use download attribute first if possible (#193 Lumia mobile) unless this is a native app\n typeof HTMLAnchorElement !== \"undefined\" &&\n \"download\" in HTMLAnchorElement.prototype\n ? function saveAs(blob, name, opts) {\n var URL = _global.URL || _global.webkitURL;\n var a = document.createElement(\"a\");\n name = name || blob.name || \"download\";\n\n a.download = name;\n a.rel = \"noopener\"; // tabnabbing\n\n // TODO: detect chrome extensions & packaged apps\n // a.target = '_blank'\n\n if (typeof blob === \"string\") {\n // Support regular links\n a.href = blob;\n if (a.origin !== location.origin) {\n corsEnabled(a.href)\n ? download(blob, name, opts)\n : click(a, (a.target = \"_blank\"));\n } else {\n click(a);\n }\n } else {\n // Support blobs\n a.href = URL.createObjectURL(blob);\n setTimeout(function() {\n URL.revokeObjectURL(a.href);\n }, 4e4); // 40s\n setTimeout(function() {\n click(a);\n }, 0);\n }\n }\n : // Use msSaveOrOpenBlob as a second approach\n \"msSaveOrOpenBlob\" in navigator\n ? function saveAs(blob, name, opts) {\n name = name || blob.name || \"download\";\n\n if (typeof blob === \"string\") {\n if (corsEnabled(blob)) {\n download(blob, name, opts);\n } else {\n var a = document.createElement(\"a\");\n a.href = blob;\n a.target = \"_blank\";\n setTimeout(function() {\n click(a);\n });\n }\n } else {\n navigator.msSaveOrOpenBlob(bom(blob, opts), name);\n }\n }\n : // Fallback to using FileReader and a popup\n function saveAs(blob, name, opts, popup) {\n // Open a popup immediately do go around popup blocker\n // Mostly only available on user interaction and the fileReader is async so...\n popup = popup || open(\"\", \"_blank\");\n if (popup) {\n popup.document.title = popup.document.body.innerText =\n \"downloading...\";\n }\n\n if (typeof blob === \"string\") return download(blob, name, opts);\n\n var force = blob.type === \"application/octet-stream\";\n var isSafari =\n /constructor/i.test(_global.HTMLElement) || _global.safari;\n var isChromeIOS = /CriOS\\/[\\d]+/.test(navigator.userAgent);\n\n if (\n (isChromeIOS || (force && isSafari)) &&\n typeof FileReader === \"object\"\n ) {\n // Safari doesn't allow downloading of blob URLs\n var reader = new FileReader();\n reader.onloadend = function() {\n var url = reader.result;\n url = isChromeIOS\n ? url\n : url.replace(/^data:[^;]*;/, \"data:attachment/file;\");\n if (popup) popup.location.href = url;\n else location = url;\n popup = null; // reverse-tabnabbing #460\n };\n reader.readAsDataURL(blob);\n } else {\n var URL = _global.URL || _global.webkitURL;\n var url = URL.createObjectURL(blob);\n if (popup) popup.location = url;\n else location.href = url;\n popup = null; // reverse-tabnabbing #460\n setTimeout(function() {\n URL.revokeObjectURL(url);\n }, 4e4); // 40s\n }\n });\n\nexport { saveAs };\n","/**\n * A class to parse color values\n * @author Stoyan Stefanov
\r\n * @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.
\r\n * Possible values are \"pt\" (points), \"mm\", \"cm\", \"in\", \"px\", \"pc\", \"em\" or \"ex\". Note that in order to get the correct scaling for \"px\"\r\n * units, you need to enable the hotfix \"px_scaling\" by setting options.hotfixes = [\"px_scaling\"].\r\n * @param {string/Array} [options.format=a4] The format of the first page. Can be:
\r\n * 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]\r\n * @param {boolean} [options.putOnlyUsedFonts=false] Only put fonts into the PDF, which were used.\r\n * @param {boolean} [options.compress=false] Compress the generated PDF.\r\n * @param {number} [options.precision=16] Precision of the element-positions.\r\n * @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.\r\n * @param {string[]} [options.hotfixes] An array of strings to enable hotfixes such as correct pixel scaling.\r\n * @param {Object} [options.encryption]\r\n * @param {string} [options.encryption.userPassword] Password for the user bound by the given permissions list.\r\n * @param {string} [options.encryption.ownerPassword] Both userPassword and ownerPassword should be set for proper authentication.\r\n * @param {string[]} [options.encryption.userPermissions] Array of permissions \"print\", \"modify\", \"copy\", \"annot-forms\", accessible by the user.\r\n * @param {number|\"smart\"} [options.floatPrecision=16]\r\n * @returns {jsPDF} jsPDF-instance\r\n * @description\r\n * ```\r\n * {\r\n * orientation: 'p',\r\n * unit: 'mm',\r\n * format: 'a4',\r\n * putOnlyUsedFonts:true,\r\n * floatPrecision: 16 // or \"smart\", default is 16\r\n * }\r\n * ```\r\n *\r\n * @constructor\r\n */\r\nfunction jsPDF(options) {\r\n var orientation = typeof arguments[0] === \"string\" ? arguments[0] : \"p\";\r\n var unit = arguments[1];\r\n var format = arguments[2];\r\n var compressPdf = arguments[3];\r\n var filters = [];\r\n var userUnit = 1.0;\r\n var precision;\r\n var floatPrecision = 16;\r\n var defaultPathOperation = \"S\";\r\n var encryptionOptions = null;\r\n\r\n options = options || {};\r\n\r\n if (typeof options === \"object\") {\r\n orientation = options.orientation;\r\n unit = options.unit || unit;\r\n format = options.format || format;\r\n compressPdf = options.compress || options.compressPdf || compressPdf;\r\n encryptionOptions = options.encryption || null;\r\n if (encryptionOptions !== null) {\r\n encryptionOptions.userPassword = encryptionOptions.userPassword || \"\";\r\n encryptionOptions.ownerPassword = encryptionOptions.ownerPassword || \"\";\r\n encryptionOptions.userPermissions =\r\n encryptionOptions.userPermissions || [];\r\n }\r\n userUnit =\r\n typeof options.userUnit === \"number\" ? Math.abs(options.userUnit) : 1.0;\r\n if (typeof options.precision !== \"undefined\") {\r\n precision = options.precision;\r\n }\r\n if (typeof options.floatPrecision !== \"undefined\") {\r\n floatPrecision = options.floatPrecision;\r\n }\r\n defaultPathOperation = options.defaultPathOperation || \"S\";\r\n }\r\n\r\n filters =\r\n options.filters || (compressPdf === true ? [\"FlateEncode\"] : filters);\r\n\r\n unit = unit || \"mm\";\r\n orientation = (\"\" + (orientation || \"P\")).toLowerCase();\r\n var putOnlyUsedFonts = options.putOnlyUsedFonts || false;\r\n var usedFonts = {};\r\n\r\n var API = {\r\n internal: {},\r\n __private__: {}\r\n };\r\n\r\n API.__private__.PubSub = PubSub;\r\n\r\n var pdfVersion = \"1.3\";\r\n var getPdfVersion = (API.__private__.getPdfVersion = function() {\r\n return pdfVersion;\r\n });\r\n\r\n API.__private__.setPdfVersion = function(value) {\r\n pdfVersion = value;\r\n };\r\n\r\n // Size in pt of various paper formats\r\n var pageFormats = {\r\n a0: [2383.94, 3370.39],\r\n a1: [1683.78, 2383.94],\r\n a2: [1190.55, 1683.78],\r\n a3: [841.89, 1190.55],\r\n a4: [595.28, 841.89],\r\n a5: [419.53, 595.28],\r\n a6: [297.64, 419.53],\r\n a7: [209.76, 297.64],\r\n a8: [147.4, 209.76],\r\n a9: [104.88, 147.4],\r\n a10: [73.7, 104.88],\r\n b0: [2834.65, 4008.19],\r\n b1: [2004.09, 2834.65],\r\n b2: [1417.32, 2004.09],\r\n b3: [1000.63, 1417.32],\r\n b4: [708.66, 1000.63],\r\n b5: [498.9, 708.66],\r\n b6: [354.33, 498.9],\r\n b7: [249.45, 354.33],\r\n b8: [175.75, 249.45],\r\n b9: [124.72, 175.75],\r\n b10: [87.87, 124.72],\r\n c0: [2599.37, 3676.54],\r\n c1: [1836.85, 2599.37],\r\n c2: [1298.27, 1836.85],\r\n c3: [918.43, 1298.27],\r\n c4: [649.13, 918.43],\r\n c5: [459.21, 649.13],\r\n c6: [323.15, 459.21],\r\n c7: [229.61, 323.15],\r\n c8: [161.57, 229.61],\r\n c9: [113.39, 161.57],\r\n c10: [79.37, 113.39],\r\n dl: [311.81, 623.62],\r\n letter: [612, 792],\r\n \"government-letter\": [576, 756],\r\n legal: [612, 1008],\r\n \"junior-legal\": [576, 360],\r\n ledger: [1224, 792],\r\n tabloid: [792, 1224],\r\n \"credit-card\": [153, 243]\r\n };\r\n\r\n API.__private__.getPageFormats = function() {\r\n return pageFormats;\r\n };\r\n\r\n var getPageFormat = (API.__private__.getPageFormat = function(value) {\r\n return pageFormats[value];\r\n });\r\n\r\n format = format || \"a4\";\r\n\r\n var ApiMode = {\r\n COMPAT: \"compat\",\r\n ADVANCED: \"advanced\"\r\n };\r\n var apiMode = ApiMode.COMPAT;\r\n\r\n function advancedAPI() {\r\n // prepend global change of basis matrix\r\n // (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix\r\n // that does this job for us (however, texts, images and similar objects must be drawn bottom up))\r\n this.saveGraphicsState();\r\n out(\r\n new Matrix(\r\n scaleFactor,\r\n 0,\r\n 0,\r\n -scaleFactor,\r\n 0,\r\n getPageHeight() * scaleFactor\r\n ).toString() + \" cm\"\r\n );\r\n this.setFontSize(this.getFontSize() / scaleFactor);\r\n\r\n // The default in MrRio's implementation is \"S\" (stroke), whereas the default in the yWorks implementation\r\n // was \"n\" (none). Although this has nothing to do with transforms, we should use the API switch here.\r\n defaultPathOperation = \"n\";\r\n\r\n apiMode = ApiMode.ADVANCED;\r\n }\r\n\r\n function compatAPI() {\r\n this.restoreGraphicsState();\r\n defaultPathOperation = \"S\";\r\n apiMode = ApiMode.COMPAT;\r\n }\r\n\r\n /**\r\n * @function combineFontStyleAndFontWeight\r\n * @param {string} fontStyle Fontstyle or variant. Example: \"italic\".\r\n * @param {number | string} fontWeight Weight of the Font. Example: \"normal\" | 400\r\n * @returns {string}\r\n * @private\r\n */\r\n var combineFontStyleAndFontWeight = (API.__private__.combineFontStyleAndFontWeight = function(\r\n fontStyle,\r\n fontWeight\r\n ) {\r\n if (\r\n (fontStyle == \"bold\" && fontWeight == \"normal\") ||\r\n (fontStyle == \"bold\" && fontWeight == 400) ||\r\n (fontStyle == \"normal\" && fontWeight == \"italic\") ||\r\n (fontStyle == \"bold\" && fontWeight == \"italic\")\r\n ) {\r\n throw new Error(\"Invalid Combination of fontweight and fontstyle\");\r\n }\r\n if (fontWeight) {\r\n fontStyle =\r\n fontWeight == 400 || fontWeight === \"normal\"\r\n ? fontStyle === \"italic\"\r\n ? \"italic\"\r\n : \"normal\"\r\n : (fontWeight == 700 || fontWeight === \"bold\") &&\r\n fontStyle === \"normal\"\r\n ? \"bold\"\r\n : (fontWeight == 700 ? \"bold\" : fontWeight) + \"\" + fontStyle;\r\n }\r\n return fontStyle;\r\n });\r\n\r\n /**\r\n * @callback ApiSwitchBody\r\n * @param {jsPDF} pdf\r\n */\r\n\r\n /**\r\n * For compatibility reasons jsPDF offers two API modes which differ in the way they convert between the the usual\r\n * screen coordinates and the PDF coordinate system.\r\n * - \"compat\": Offers full compatibility across all plugins but does not allow arbitrary transforms\r\n * - \"advanced\": Allows arbitrary transforms and more advanced features like pattern fills. Some plugins might\r\n * not support this mode, though.\r\n * Initial mode is \"compat\".\r\n *\r\n * You can either provide a callback to the body argument, which means that jsPDF will automatically switch back to\r\n * the original API mode afterwards; or you can omit the callback and switch back manually using {@link compatAPI}.\r\n *\r\n * Note, that the calls to {@link saveGraphicsState} and {@link restoreGraphicsState} need to be balanced within the\r\n * callback or between calls of this method and its counterpart {@link compatAPI}. Calls to {@link beginFormObject}\r\n * or {@link beginTilingPattern} need to be closed by their counterparts before switching back to \"compat\" API mode.\r\n *\r\n * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.\r\n * The API mode will be switched back automatically afterwards.\r\n * @returns {jsPDF}\r\n * @memberof jsPDF#\r\n * @name advancedAPI\r\n */\r\n API.advancedAPI = function(body) {\r\n var doSwitch = apiMode === ApiMode.COMPAT;\r\n\r\n if (doSwitch) {\r\n advancedAPI.call(this);\r\n }\r\n\r\n if (typeof body !== \"function\") {\r\n return this;\r\n }\r\n\r\n body(this);\r\n\r\n if (doSwitch) {\r\n compatAPI.call(this);\r\n }\r\n\r\n return this;\r\n };\r\n\r\n /**\r\n * Switches to \"compat\" API mode. See {@link advancedAPI} for more details.\r\n *\r\n * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.\r\n * The API mode will be switched back automatically afterwards.\r\n * @return {jsPDF}\r\n * @memberof jsPDF#\r\n * @name compatApi\r\n */\r\n API.compatAPI = function(body) {\r\n var doSwitch = apiMode === ApiMode.ADVANCED;\r\n\r\n if (doSwitch) {\r\n compatAPI.call(this);\r\n }\r\n\r\n if (typeof body !== \"function\") {\r\n return this;\r\n }\r\n\r\n body(this);\r\n\r\n if (doSwitch) {\r\n advancedAPI.call(this);\r\n }\r\n\r\n return this;\r\n };\r\n\r\n /**\r\n * @return {boolean} True iff the current API mode is \"advanced\". See {@link advancedAPI}.\r\n * @memberof jsPDF#\r\n * @name isAdvancedAPI\r\n */\r\n API.isAdvancedAPI = function() {\r\n return apiMode === ApiMode.ADVANCED;\r\n };\r\n\r\n var advancedApiModeTrap = function(methodName) {\r\n if (apiMode !== ApiMode.ADVANCED) {\r\n throw new Error(\r\n methodName +\r\n \" is only available in 'advanced' API mode. \" +\r\n \"You need to call advancedAPI() first.\"\r\n );\r\n }\r\n };\r\n\r\n var roundToPrecision = (API.roundToPrecision = API.__private__.roundToPrecision = function(\r\n number,\r\n parmPrecision\r\n ) {\r\n var tmpPrecision = precision || parmPrecision;\r\n if (isNaN(number) || isNaN(tmpPrecision)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.roundToPrecision\");\r\n }\r\n return number.toFixed(tmpPrecision).replace(/0+$/, \"\");\r\n });\r\n\r\n // high precision float\r\n var hpf;\r\n if (typeof floatPrecision === \"number\") {\r\n hpf = API.hpf = API.__private__.hpf = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\r\n }\r\n return roundToPrecision(number, floatPrecision);\r\n };\r\n } else if (floatPrecision === \"smart\") {\r\n hpf = API.hpf = API.__private__.hpf = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\r\n }\r\n if (number > -1 && number < 1) {\r\n return roundToPrecision(number, 16);\r\n } else {\r\n return roundToPrecision(number, 5);\r\n }\r\n };\r\n } else {\r\n hpf = API.hpf = API.__private__.hpf = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\r\n }\r\n return roundToPrecision(number, 16);\r\n };\r\n }\r\n var f2 = (API.f2 = API.__private__.f2 = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.f2\");\r\n }\r\n return roundToPrecision(number, 2);\r\n });\r\n\r\n var f3 = (API.__private__.f3 = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.f3\");\r\n }\r\n return roundToPrecision(number, 3);\r\n });\r\n\r\n var scale = (API.scale = API.__private__.scale = function(number) {\r\n if (isNaN(number)) {\r\n throw new Error(\"Invalid argument passed to jsPDF.scale\");\r\n }\r\n if (apiMode === ApiMode.COMPAT) {\r\n return number * scaleFactor;\r\n } else if (apiMode === ApiMode.ADVANCED) {\r\n return number;\r\n }\r\n });\r\n\r\n var transformY = function(y) {\r\n if (apiMode === ApiMode.COMPAT) {\r\n return getPageHeight() - y;\r\n } else if (apiMode === ApiMode.ADVANCED) {\r\n return y;\r\n }\r\n };\r\n\r\n var transformScaleY = function(y) {\r\n return scale(transformY(y));\r\n };\r\n\r\n /**\r\n * @name setPrecision\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n * @param {string} precision\r\n * @returns {jsPDF}\r\n */\r\n API.__private__.setPrecision = API.setPrecision = function(value) {\r\n if (typeof parseInt(value, 10) === \"number\") {\r\n precision = parseInt(value, 10);\r\n }\r\n };\r\n\r\n var fileId = \"00000000000000000000000000000000\";\r\n\r\n var getFileId = (API.__private__.getFileId = function() {\r\n return fileId;\r\n });\r\n\r\n var setFileId = (API.__private__.setFileId = function(value) {\r\n if (typeof value !== \"undefined\" && /^[a-fA-F0-9]{32}$/.test(value)) {\r\n fileId = value.toUpperCase();\r\n } else {\r\n fileId = fileId\r\n .split(\"\")\r\n .map(function() {\r\n return \"ABCDEF0123456789\".charAt(Math.floor(Math.random() * 16));\r\n })\r\n .join(\"\");\r\n }\r\n\r\n if (encryptionOptions !== null) {\r\n encryption = new PDFSecurity(\r\n encryptionOptions.userPermissions,\r\n encryptionOptions.userPassword,\r\n encryptionOptions.ownerPassword,\r\n fileId\r\n );\r\n }\r\n return fileId;\r\n });\r\n\r\n /**\r\n * @name setFileId\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n * @param {string} value GUID.\r\n * @returns {jsPDF}\r\n */\r\n API.setFileId = function(value) {\r\n setFileId(value);\r\n return this;\r\n };\r\n\r\n /**\r\n * @name getFileId\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n *\r\n * @returns {string} GUID.\r\n */\r\n API.getFileId = function() {\r\n return getFileId();\r\n };\r\n\r\n var creationDate;\r\n\r\n var convertDateToPDFDate = (API.__private__.convertDateToPDFDate = function(\r\n parmDate\r\n ) {\r\n var result = \"\";\r\n var tzoffset = parmDate.getTimezoneOffset(),\r\n tzsign = tzoffset < 0 ? \"+\" : \"-\",\r\n tzhour = Math.floor(Math.abs(tzoffset / 60)),\r\n tzmin = Math.abs(tzoffset % 60),\r\n timeZoneString = [tzsign, padd2(tzhour), \"'\", padd2(tzmin), \"'\"].join(\"\");\r\n\r\n result = [\r\n \"D:\",\r\n parmDate.getFullYear(),\r\n padd2(parmDate.getMonth() + 1),\r\n padd2(parmDate.getDate()),\r\n padd2(parmDate.getHours()),\r\n padd2(parmDate.getMinutes()),\r\n padd2(parmDate.getSeconds()),\r\n timeZoneString\r\n ].join(\"\");\r\n return result;\r\n });\r\n\r\n var convertPDFDateToDate = (API.__private__.convertPDFDateToDate = function(\r\n parmPDFDate\r\n ) {\r\n var year = parseInt(parmPDFDate.substr(2, 4), 10);\r\n var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;\r\n var date = parseInt(parmPDFDate.substr(8, 2), 10);\r\n var hour = parseInt(parmPDFDate.substr(10, 2), 10);\r\n var minutes = parseInt(parmPDFDate.substr(12, 2), 10);\r\n var seconds = parseInt(parmPDFDate.substr(14, 2), 10);\r\n // var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);\r\n // var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);\r\n\r\n var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);\r\n return resultingDate;\r\n });\r\n\r\n var setCreationDate = (API.__private__.setCreationDate = function(date) {\r\n var tmpCreationDateString;\r\n 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])'?$/;\r\n if (typeof date === \"undefined\") {\r\n date = new Date();\r\n }\r\n\r\n if (date instanceof Date) {\r\n tmpCreationDateString = convertDateToPDFDate(date);\r\n } else if (regexPDFCreationDate.test(date)) {\r\n tmpCreationDateString = date;\r\n } else {\r\n throw new Error(\"Invalid argument passed to jsPDF.setCreationDate\");\r\n }\r\n creationDate = tmpCreationDateString;\r\n return creationDate;\r\n });\r\n\r\n var getCreationDate = (API.__private__.getCreationDate = function(type) {\r\n var result = creationDate;\r\n if (type === \"jsDate\") {\r\n result = convertPDFDateToDate(creationDate);\r\n }\r\n return result;\r\n });\r\n\r\n /**\r\n * @name setCreationDate\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n * @param {Object} date\r\n * @returns {jsPDF}\r\n */\r\n API.setCreationDate = function(date) {\r\n setCreationDate(date);\r\n return this;\r\n };\r\n\r\n /**\r\n * @name getCreationDate\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n * @param {Object} type\r\n * @returns {Object}\r\n */\r\n API.getCreationDate = function(type) {\r\n return getCreationDate(type);\r\n };\r\n\r\n var padd2 = (API.__private__.padd2 = function(number) {\r\n return (\"0\" + parseInt(number)).slice(-2);\r\n });\r\n\r\n var padd2Hex = (API.__private__.padd2Hex = function(hexString) {\r\n hexString = hexString.toString();\r\n return (\"00\" + hexString).substr(hexString.length);\r\n });\r\n\r\n var objectNumber = 0; // 'n' Current object number\r\n var offsets = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.\r\n var content = [];\r\n var contentLength = 0;\r\n var additionalObjects = [];\r\n\r\n var pages = [];\r\n var currentPage;\r\n var hasCustomDestination = false;\r\n var outputDestination = content;\r\n\r\n var resetDocument = function() {\r\n //reset fields relevant for objectNumber generation and xref.\r\n objectNumber = 0;\r\n contentLength = 0;\r\n content = [];\r\n offsets = [];\r\n additionalObjects = [];\r\n\r\n rootDictionaryObjId = newObjectDeferred();\r\n resourceDictionaryObjId = newObjectDeferred();\r\n };\r\n\r\n API.__private__.setCustomOutputDestination = function(destination) {\r\n hasCustomDestination = true;\r\n outputDestination = destination;\r\n };\r\n var setOutputDestination = function(destination) {\r\n if (!hasCustomDestination) {\r\n outputDestination = destination;\r\n }\r\n };\r\n\r\n API.__private__.resetCustomOutputDestination = function() {\r\n hasCustomDestination = false;\r\n outputDestination = content;\r\n };\r\n\r\n var out = (API.__private__.out = function(string) {\r\n string = string.toString();\r\n contentLength += string.length + 1;\r\n outputDestination.push(string);\r\n\r\n return outputDestination;\r\n });\r\n\r\n var write = (API.__private__.write = function(value) {\r\n return out(\r\n arguments.length === 1\r\n ? value.toString()\r\n : Array.prototype.join.call(arguments, \" \")\r\n );\r\n });\r\n\r\n var getArrayBuffer = (API.__private__.getArrayBuffer = function(data) {\r\n var len = data.length,\r\n ab = new ArrayBuffer(len),\r\n u8 = new Uint8Array(ab);\r\n\r\n while (len--) u8[len] = data.charCodeAt(len);\r\n return ab;\r\n });\r\n\r\n var standardFonts = [\r\n [\"Helvetica\", \"helvetica\", \"normal\", \"WinAnsiEncoding\"],\r\n [\"Helvetica-Bold\", \"helvetica\", \"bold\", \"WinAnsiEncoding\"],\r\n [\"Helvetica-Oblique\", \"helvetica\", \"italic\", \"WinAnsiEncoding\"],\r\n [\"Helvetica-BoldOblique\", \"helvetica\", \"bolditalic\", \"WinAnsiEncoding\"],\r\n [\"Courier\", \"courier\", \"normal\", \"WinAnsiEncoding\"],\r\n [\"Courier-Bold\", \"courier\", \"bold\", \"WinAnsiEncoding\"],\r\n [\"Courier-Oblique\", \"courier\", \"italic\", \"WinAnsiEncoding\"],\r\n [\"Courier-BoldOblique\", \"courier\", \"bolditalic\", \"WinAnsiEncoding\"],\r\n [\"Times-Roman\", \"times\", \"normal\", \"WinAnsiEncoding\"],\r\n [\"Times-Bold\", \"times\", \"bold\", \"WinAnsiEncoding\"],\r\n [\"Times-Italic\", \"times\", \"italic\", \"WinAnsiEncoding\"],\r\n [\"Times-BoldItalic\", \"times\", \"bolditalic\", \"WinAnsiEncoding\"],\r\n [\"ZapfDingbats\", \"zapfdingbats\", \"normal\", null],\r\n [\"Symbol\", \"symbol\", \"normal\", null]\r\n ];\r\n\r\n API.__private__.getStandardFonts = function() {\r\n return standardFonts;\r\n };\r\n\r\n var activeFontSize = options.fontSize || 16;\r\n\r\n /**\r\n * Sets font size for upcoming text elements.\r\n *\r\n * @param {number} size Font size in points.\r\n * @function\r\n * @instance\r\n * @returns {jsPDF}\r\n * @memberof jsPDF#\r\n * @name setFontSize\r\n */\r\n API.__private__.setFontSize = API.setFontSize = function(size) {\r\n if (apiMode === ApiMode.ADVANCED) {\r\n activeFontSize = size / scaleFactor;\r\n } else {\r\n activeFontSize = size;\r\n }\r\n return this;\r\n };\r\n\r\n /**\r\n * Gets the fontsize for upcoming text elements.\r\n *\r\n * @function\r\n * @instance\r\n * @returns {number}\r\n * @memberof jsPDF#\r\n * @name getFontSize\r\n */\r\n var getFontSize = (API.__private__.getFontSize = API.getFontSize = function() {\r\n if (apiMode === ApiMode.COMPAT) {\r\n return activeFontSize;\r\n } else {\r\n return activeFontSize * scaleFactor;\r\n }\r\n });\r\n\r\n var R2L = options.R2L || false;\r\n\r\n /**\r\n * Set value of R2L functionality.\r\n *\r\n * @param {boolean} value\r\n * @function\r\n * @instance\r\n * @returns {jsPDF} jsPDF-instance\r\n * @memberof jsPDF#\r\n * @name setR2L\r\n */\r\n API.__private__.setR2L = API.setR2L = function(value) {\r\n R2L = value;\r\n return this;\r\n };\r\n\r\n /**\r\n * Get value of R2L functionality.\r\n *\r\n * @function\r\n * @instance\r\n * @returns {boolean} jsPDF-instance\r\n * @memberof jsPDF#\r\n * @name getR2L\r\n */\r\n API.__private__.getR2L = API.getR2L = function() {\r\n return R2L;\r\n };\r\n\r\n var zoomMode; // default: 1;\r\n\r\n var setZoomMode = (API.__private__.setZoomMode = function(zoom) {\r\n var validZoomModes = [\r\n undefined,\r\n null,\r\n \"fullwidth\",\r\n \"fullheight\",\r\n \"fullpage\",\r\n \"original\"\r\n ];\r\n\r\n if (/^(?:\\d+\\.\\d*|\\d*\\.\\d+|\\d+)%$/.test(zoom)) {\r\n zoomMode = zoom;\r\n } else if (!isNaN(zoom)) {\r\n zoomMode = parseInt(zoom, 10);\r\n } else if (validZoomModes.indexOf(zoom) !== -1) {\r\n zoomMode = zoom;\r\n } else {\r\n throw new Error(\r\n 'zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. \"' +\r\n zoom +\r\n '\" is not recognized.'\r\n );\r\n }\r\n });\r\n\r\n API.__private__.getZoomMode = function() {\r\n return zoomMode;\r\n };\r\n\r\n var pageMode; // default: 'UseOutlines';\r\n var setPageMode = (API.__private__.setPageMode = function(pmode) {\r\n var validPageModes = [\r\n undefined,\r\n null,\r\n \"UseNone\",\r\n \"UseOutlines\",\r\n \"UseThumbs\",\r\n \"FullScreen\"\r\n ];\r\n\r\n if (validPageModes.indexOf(pmode) == -1) {\r\n throw new Error(\r\n 'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. \"' +\r\n pmode +\r\n '\" is not recognized.'\r\n );\r\n }\r\n pageMode = pmode;\r\n });\r\n\r\n API.__private__.getPageMode = function() {\r\n return pageMode;\r\n };\r\n\r\n var layoutMode; // default: 'continuous';\r\n var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {\r\n var validLayoutModes = [\r\n undefined,\r\n null,\r\n \"continuous\",\r\n \"single\",\r\n \"twoleft\",\r\n \"tworight\",\r\n \"two\"\r\n ];\r\n\r\n if (validLayoutModes.indexOf(layout) == -1) {\r\n throw new Error(\r\n 'Layout mode must be one of continuous, single, twoleft, tworight. \"' +\r\n layout +\r\n '\" is not recognized.'\r\n );\r\n }\r\n layoutMode = layout;\r\n });\r\n\r\n API.__private__.getLayoutMode = function() {\r\n return layoutMode;\r\n };\r\n\r\n /**\r\n * Set the display mode options of the page like zoom and layout.\r\n *\r\n * @name setDisplayMode\r\n * @memberof jsPDF#\r\n * @function\r\n * @instance\r\n * @param {integer|String} zoom You can pass an integer or percentage as\r\n * a string. 2 will scale the document up 2x, '200%' will scale up by the\r\n * same amount. You can also set it to 'fullwidth', 'fullheight',\r\n * 'fullpage', or 'original'.\r\n *\r\n * Only certain PDF readers support this, such as Adobe Acrobat.\r\n *\r\n * @param {string} layout Layout mode can be: 'continuous' - this is the\r\n * default continuous scroll. 'single' - the single page mode only shows one\r\n * page at a time. 'twoleft' - two column left mode, first page starts on\r\n * the left, and 'tworight' - pages are laid out in two columns, with the\r\n * first page on the right. This would be used for books.\r\n * @param {string} pmode 'UseOutlines' - it shows the\r\n * outline of the document on the left. 'UseThumbs' - shows thumbnails along\r\n * the left. 'FullScreen' - prompts the user to enter fullscreen mode.\r\n *\r\n * @returns {jsPDF}\r\n */\r\n API.__private__.setDisplayMode = API.setDisplayMode = function(\r\n zoom,\r\n layout,\r\n pmode\r\n ) {\r\n setZoomMode(zoom);\r\n setLayoutMode(layout);\r\n setPageMode(pmode);\r\n return this;\r\n };\r\n\r\n var documentProperties = {\r\n title: \"\",\r\n subject: \"\",\r\n author: \"\",\r\n keywords: \"\",\r\n creator: \"\"\r\n };\r\n\r\n API.__private__.getDocumentProperty = function(key) {\r\n if (Object.keys(documentProperties).indexOf(key) === -1) {\r\n throw new Error(\"Invalid argument passed to jsPDF.getDocumentProperty\");\r\n }\r\n return documentProperties[key];\r\n };\r\n\r\n API.__private__.getDocumentProperties = function() {\r\n return documentProperties;\r\n };\r\n\r\n /**\r\n * Adds a properties to the PDF document.\r\n *\r\n * @param {Object} A property_name-to-property_value object structure.\r\n * @function\r\n * @instance\r\n * @returns {jsPDF}\r\n * @memberof jsPDF#\r\n * @name setDocumentProperties\r\n */\r\n API.__private__.setDocumentProperties = API.setProperties = API.setDocumentProperties = function(\r\n properties\r\n ) {\r\n // copying only those properties we can render.\r\n for (var property in documentProperties) {\r\n if (documentProperties.hasOwnProperty(property) && properties[property]) {\r\n documentProperties[property] = properties[property];\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n API.__private__.setDocumentProperty = function(key, value) {\r\n if (Object.keys(documentProperties).indexOf(key) === -1) {\r\n throw new Error(\"Invalid arguments passed to jsPDF.setDocumentProperty\");\r\n }\r\n return (documentProperties[key] = value);\r\n };\r\n\r\n var fonts = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font.\r\n var fontmap = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont()\r\n var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle\r\n var fontStateStack = []; //\r\n var patterns = {}; // collection of pattern objects\r\n var patternMap = {}; // see fonts\r\n var gStates = {}; // collection of graphic state objects\r\n var gStatesMap = {}; // see fonts\r\n var activeGState = null;\r\n var scaleFactor; // Scale factor\r\n var page = 0;\r\n var pagesContext = [];\r\n var events = new PubSub(API);\r\n var hotfixes = options.hotfixes || [];\r\n\r\n var renderTargets = {};\r\n var renderTargetMap = {};\r\n var renderTargetStack = [];\r\n var pageX;\r\n var pageY;\r\n var pageMatrix; // only used for FormObjects\r\n\r\n /**\r\n * A matrix object for 2D homogenous transformations:
\r\n * | a b 0 |
\r\n * | c d 0 |
\r\n * | e f 1 |
\r\n * pdf multiplies matrices righthand: v' = v x m1 x m2 x ...\r\n *\r\n * @class\r\n * @name Matrix\r\n * @param {number} sx\r\n * @param {number} shy\r\n * @param {number} shx\r\n * @param {number} sy\r\n * @param {number} tx\r\n * @param {number} ty\r\n * @constructor\r\n */\r\n var Matrix = function(sx, shy, shx, sy, tx, ty) {\r\n if (!(this instanceof Matrix)) {\r\n return new Matrix(sx, shy, shx, sy, tx, ty);\r\n }\r\n\r\n if (isNaN(sx)) sx = 1;\r\n if (isNaN(shy)) shy = 0;\r\n if (isNaN(shx)) shx = 0;\r\n if (isNaN(sy)) sy = 1;\r\n if (isNaN(tx)) tx = 0;\r\n if (isNaN(ty)) ty = 0;\r\n\r\n this._matrix = [sx, shy, shx, sy, tx, ty];\r\n };\r\n\r\n /**\r\n * @name sx\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"sx\", {\r\n get: function() {\r\n return this._matrix[0];\r\n },\r\n set: function(value) {\r\n this._matrix[0] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name shy\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"shy\", {\r\n get: function() {\r\n return this._matrix[1];\r\n },\r\n set: function(value) {\r\n this._matrix[1] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name shx\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"shx\", {\r\n get: function() {\r\n return this._matrix[2];\r\n },\r\n set: function(value) {\r\n this._matrix[2] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name sy\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"sy\", {\r\n get: function() {\r\n return this._matrix[3];\r\n },\r\n set: function(value) {\r\n this._matrix[3] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name tx\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"tx\", {\r\n get: function() {\r\n return this._matrix[4];\r\n },\r\n set: function(value) {\r\n this._matrix[4] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name ty\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"ty\", {\r\n get: function() {\r\n return this._matrix[5];\r\n },\r\n set: function(value) {\r\n this._matrix[5] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"a\", {\r\n get: function() {\r\n return this._matrix[0];\r\n },\r\n set: function(value) {\r\n this._matrix[0] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"b\", {\r\n get: function() {\r\n return this._matrix[1];\r\n },\r\n set: function(value) {\r\n this._matrix[1] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"c\", {\r\n get: function() {\r\n return this._matrix[2];\r\n },\r\n set: function(value) {\r\n this._matrix[2] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"d\", {\r\n get: function() {\r\n return this._matrix[3];\r\n },\r\n set: function(value) {\r\n this._matrix[3] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"e\", {\r\n get: function() {\r\n return this._matrix[4];\r\n },\r\n set: function(value) {\r\n this._matrix[4] = value;\r\n }\r\n });\r\n\r\n Object.defineProperty(Matrix.prototype, \"f\", {\r\n get: function() {\r\n return this._matrix[5];\r\n },\r\n set: function(value) {\r\n this._matrix[5] = value;\r\n }\r\n });\r\n\r\n /**\r\n * @name rotation\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"rotation\", {\r\n get: function() {\r\n return Math.atan2(this.shx, this.sx);\r\n }\r\n });\r\n\r\n /**\r\n * @name scaleX\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"scaleX\", {\r\n get: function() {\r\n return this.decompose().scale.sx;\r\n }\r\n });\r\n\r\n /**\r\n * @name scaleY\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"scaleY\", {\r\n get: function() {\r\n return this.decompose().scale.sy;\r\n }\r\n });\r\n\r\n /**\r\n * @name isIdentity\r\n * @memberof Matrix#\r\n */\r\n Object.defineProperty(Matrix.prototype, \"isIdentity\", {\r\n get: function() {\r\n if (this.sx !== 1) {\r\n return false;\r\n }\r\n if (this.shy !== 0) {\r\n return false;\r\n }\r\n if (this.shx !== 0) {\r\n return false;\r\n }\r\n if (this.sy !== 1) {\r\n return false;\r\n }\r\n if (this.tx !== 0) {\r\n return false;\r\n }\r\n if (this.ty !== 0) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n });\r\n\r\n /**\r\n * Join the Matrix Values to a String\r\n *\r\n * @function join\r\n * @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.\r\n * @returns {string} A string with all array elements joined.\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.join = function(separator) {\r\n return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty]\r\n .map(hpf)\r\n .join(separator);\r\n };\r\n\r\n /**\r\n * Multiply the matrix with given Matrix\r\n *\r\n * @function multiply\r\n * @param matrix\r\n * @returns {Matrix}\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.multiply = function(matrix) {\r\n var sx = matrix.sx * this.sx + matrix.shy * this.shx;\r\n var shy = matrix.sx * this.shy + matrix.shy * this.sy;\r\n var shx = matrix.shx * this.sx + matrix.sy * this.shx;\r\n var sy = matrix.shx * this.shy + matrix.sy * this.sy;\r\n var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx;\r\n var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty;\r\n\r\n return new Matrix(sx, shy, shx, sy, tx, ty);\r\n };\r\n\r\n /**\r\n * @function decompose\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.decompose = function() {\r\n var a = this.sx;\r\n var b = this.shy;\r\n var c = this.shx;\r\n var d = this.sy;\r\n var e = this.tx;\r\n var f = this.ty;\r\n\r\n var scaleX = Math.sqrt(a * a + b * b);\r\n a /= scaleX;\r\n b /= scaleX;\r\n\r\n var shear = a * c + b * d;\r\n c -= a * shear;\r\n d -= b * shear;\r\n\r\n var scaleY = Math.sqrt(c * c + d * d);\r\n c /= scaleY;\r\n d /= scaleY;\r\n shear /= scaleY;\r\n\r\n if (a * d < b * c) {\r\n a = -a;\r\n b = -b;\r\n shear = -shear;\r\n scaleX = -scaleX;\r\n }\r\n\r\n return {\r\n scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),\r\n translate: new Matrix(1, 0, 0, 1, e, f),\r\n rotate: new Matrix(a, b, -b, a, 0, 0),\r\n skew: new Matrix(1, 0, shear, 1, 0, 0)\r\n };\r\n };\r\n\r\n /**\r\n * @function toString\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.toString = function(parmPrecision) {\r\n return this.join(\" \");\r\n };\r\n\r\n /**\r\n * @function inversed\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.inversed = function() {\r\n var a = this.sx,\r\n b = this.shy,\r\n c = this.shx,\r\n d = this.sy,\r\n e = this.tx,\r\n f = this.ty;\r\n\r\n var quot = 1 / (a * d - b * c);\r\n\r\n var aInv = d * quot;\r\n var bInv = -b * quot;\r\n var cInv = -c * quot;\r\n var dInv = a * quot;\r\n var eInv = -aInv * e - cInv * f;\r\n var fInv = -bInv * e - dInv * f;\r\n\r\n return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);\r\n };\r\n\r\n /**\r\n * @function applyToPoint\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.applyToPoint = function(pt) {\r\n var x = pt.x * this.sx + pt.y * this.shx + this.tx;\r\n var y = pt.x * this.shy + pt.y * this.sy + this.ty;\r\n return new Point(x, y);\r\n };\r\n\r\n /**\r\n * @function applyToRectangle\r\n * @memberof Matrix#\r\n */\r\n Matrix.prototype.applyToRectangle = function(rect) {\r\n var pt1 = this.applyToPoint(rect);\r\n var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));\r\n return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);\r\n };\r\n\r\n /**\r\n * Clone the Matrix\r\n *\r\n * @function clone\r\n * @memberof Matrix#\r\n * @name clone\r\n * @instance\r\n */\r\n Matrix.prototype.clone = function() {\r\n var sx = this.sx;\r\n var shy = this.shy;\r\n var shx = this.shx;\r\n var sy = this.sy;\r\n var tx = this.tx;\r\n var ty = this.ty;\r\n\r\n return new Matrix(sx, shy, shx, sy, tx, ty);\r\n };\r\n\r\n API.Matrix = Matrix;\r\n\r\n /**\r\n * Multiplies two matrices. (see {@link Matrix})\r\n * @param {Matrix} m1\r\n * @param {Matrix} m2\r\n * @memberof jsPDF#\r\n * @name matrixMult\r\n */\r\n var matrixMult = (API.matrixMult = function(m1, m2) {\r\n return m2.multiply(m1);\r\n });\r\n\r\n /**\r\n * The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)).\r\n * @type {Matrix}\r\n * @memberof! jsPDF#\r\n * @name identityMatrix\r\n */\r\n var identityMatrix = new Matrix(1, 0, 0, 1, 0, 0);\r\n API.unitMatrix = API.identityMatrix = identityMatrix;\r\n\r\n /**\r\n * Adds a new pattern for later use.\r\n * @param {String} key The key by it can be referenced later. The keys must be unique!\r\n * @param {API.Pattern} pattern The pattern\r\n */\r\n var addPattern = function(key, pattern) {\r\n // only add it if it is not already present (the keys provided by the user must be unique!)\r\n if (patternMap[key]) return;\r\n\r\n var prefix = pattern instanceof ShadingPattern ? \"Sh\" : \"P\";\r\n var patternKey = prefix + (Object.keys(patterns).length + 1).toString(10);\r\n pattern.id = patternKey;\r\n\r\n patternMap[key] = patternKey;\r\n patterns[patternKey] = pattern;\r\n\r\n events.publish(\"addPattern\", pattern);\r\n };\r\n\r\n /**\r\n * A pattern describing a shading pattern.\r\n *\r\n * Only available in \"advanced\" API mode.\r\n *\r\n * @param {String} type One of \"axial\" or \"radial\"\r\n * @param {Array
If pageNumber is specified, top and zoom may also be specified
\n * @name link\n * @function\n * @param {number} x\n * @param {number} y\n * @param {number} w\n * @param {number} h\n * @param {Object} options\n */\n jsPDFAPI.link = function(x, y, w, h, options) {\n var pageInfo = this.internal.getCurrentPageInfo();\n var getHorizontalCoordinateString = this.internal.getCoordinateString;\n var getVerticalCoordinateString = this.internal.getVerticalCoordinateString;\n\n pageInfo.pageContext.annotations.push({\n finalBounds: {\n x: getHorizontalCoordinateString(x),\n y: getVerticalCoordinateString(y),\n w: getHorizontalCoordinateString(x + w),\n h: getVerticalCoordinateString(y + h)\n },\n options: options,\n type: \"link\"\n });\n };\n\n /**\n * Currently only supports single line text.\n * Returns the width of the text/link\n *\n * @name textWithLink\n * @function\n * @param {string} text\n * @param {number} x\n * @param {number} y\n * @param {Object} options\n * @returns {number} width the width of the text/link\n */\n jsPDFAPI.textWithLink = function(text, x, y, options) {\n var totalLineWidth = this.getTextWidth(text);\n var lineHeight = this.internal.getLineHeight() / this.internal.scaleFactor;\n var linkHeight, linkWidth;\n\n // Checking if maxWidth option is passed to determine lineWidth and number of lines for each line\n if (options.maxWidth !== undefined) {\n var { maxWidth } = options;\n linkWidth = maxWidth;\n var numOfLines = this.splitTextToSize(text, linkWidth).length;\n linkHeight = Math.ceil(lineHeight * numOfLines);\n } else {\n linkWidth = totalLineWidth;\n linkHeight = lineHeight;\n }\n\n this.text(text, x, y, options);\n\n //TODO We really need the text baseline height to do this correctly.\n // Or ability to draw text on top, bottom, center, or baseline.\n y += lineHeight * 0.2;\n //handle x position based on the align option\n if (options.align === \"center\") {\n x = x - totalLineWidth / 2; //since starting from center move the x position by half of text width\n }\n if (options.align === \"right\") {\n x = x - totalLineWidth;\n }\n this.link(x, y - lineHeight, linkWidth, linkHeight, options);\n return totalLineWidth;\n };\n\n //TODO move into external library\n /**\n * @name getTextWidth\n * @function\n * @param {string} text\n * @returns {number} txtWidth\n */\n jsPDFAPI.getTextWidth = function(text) {\n var fontSize = this.internal.getFontSize();\n var txtWidth =\n (this.getStringUnitWidth(text) * fontSize) / this.internal.scaleFactor;\n return txtWidth;\n };\n\n return this;\n})(jsPDF.API);\n","/**\n * @license\n * Copyright (c) 2017 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\n\nimport { jsPDF } from \"../jspdf.js\";\n\n/**\n * jsPDF arabic parser PlugIn\n *\n * @name arabic\n * @module\n */\n(function(jsPDFAPI) {\n \"use strict\";\n\n /**\n * Arabic shape substitutions: char code => (isolated, final, initial, medial).\n * Arabic Substition A\n */\n var arabicSubstitionA = {\n 0x0621: [0xfe80], // ARABIC LETTER HAMZA\n 0x0622: [0xfe81, 0xfe82], // ARABIC LETTER ALEF WITH MADDA ABOVE\n 0x0623: [0xfe83, 0xfe84], // ARABIC LETTER ALEF WITH HAMZA ABOVE\n 0x0624: [0xfe85, 0xfe86], // ARABIC LETTER WAW WITH HAMZA ABOVE\n 0x0625: [0xfe87, 0xfe88], // ARABIC LETTER ALEF WITH HAMZA BELOW\n 0x0626: [0xfe89, 0xfe8a, 0xfe8b, 0xfe8c], // ARABIC LETTER YEH WITH HAMZA ABOVE\n 0x0627: [0xfe8d, 0xfe8e], // ARABIC LETTER ALEF\n 0x0628: [0xfe8f, 0xfe90, 0xfe91, 0xfe92], // ARABIC LETTER BEH\n 0x0629: [0xfe93, 0xfe94], // ARABIC LETTER TEH MARBUTA\n 0x062a: [0xfe95, 0xfe96, 0xfe97, 0xfe98], // ARABIC LETTER TEH\n 0x062b: [0xfe99, 0xfe9a, 0xfe9b, 0xfe9c], // ARABIC LETTER THEH\n 0x062c: [0xfe9d, 0xfe9e, 0xfe9f, 0xfea0], // ARABIC LETTER JEEM\n 0x062d: [0xfea1, 0xfea2, 0xfea3, 0xfea4], // ARABIC LETTER HAH\n 0x062e: [0xfea5, 0xfea6, 0xfea7, 0xfea8], // ARABIC LETTER KHAH\n 0x062f: [0xfea9, 0xfeaa], // ARABIC LETTER DAL\n 0x0630: [0xfeab, 0xfeac], // ARABIC LETTER THAL\n 0x0631: [0xfead, 0xfeae], // ARABIC LETTER REH\n 0x0632: [0xfeaf, 0xfeb0], // ARABIC LETTER ZAIN\n 0x0633: [0xfeb1, 0xfeb2, 0xfeb3, 0xfeb4], // ARABIC LETTER SEEN\n 0x0634: [0xfeb5, 0xfeb6, 0xfeb7, 0xfeb8], // ARABIC LETTER SHEEN\n 0x0635: [0xfeb9, 0xfeba, 0xfebb, 0xfebc], // ARABIC LETTER SAD\n 0x0636: [0xfebd, 0xfebe, 0xfebf, 0xfec0], // ARABIC LETTER DAD\n 0x0637: [0xfec1, 0xfec2, 0xfec3, 0xfec4], // ARABIC LETTER TAH\n 0x0638: [0xfec5, 0xfec6, 0xfec7, 0xfec8], // ARABIC LETTER ZAH\n 0x0639: [0xfec9, 0xfeca, 0xfecb, 0xfecc], // ARABIC LETTER AIN\n 0x063a: [0xfecd, 0xfece, 0xfecf, 0xfed0], // ARABIC LETTER GHAIN\n 0x0641: [0xfed1, 0xfed2, 0xfed3, 0xfed4], // ARABIC LETTER FEH\n 0x0642: [0xfed5, 0xfed6, 0xfed7, 0xfed8], // ARABIC LETTER QAF\n 0x0643: [0xfed9, 0xfeda, 0xfedb, 0xfedc], // ARABIC LETTER KAF\n 0x0644: [0xfedd, 0xfede, 0xfedf, 0xfee0], // ARABIC LETTER LAM\n 0x0645: [0xfee1, 0xfee2, 0xfee3, 0xfee4], // ARABIC LETTER MEEM\n 0x0646: [0xfee5, 0xfee6, 0xfee7, 0xfee8], // ARABIC LETTER NOON\n 0x0647: [0xfee9, 0xfeea, 0xfeeb, 0xfeec], // ARABIC LETTER HEH\n 0x0648: [0xfeed, 0xfeee], // ARABIC LETTER WAW\n 0x0649: [0xfeef, 0xfef0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA\n 0x064a: [0xfef1, 0xfef2, 0xfef3, 0xfef4], // ARABIC LETTER YEH\n 0x0671: [0xfb50, 0xfb51], // ARABIC LETTER ALEF WASLA\n 0x0677: [0xfbdd], // ARABIC LETTER U WITH HAMZA ABOVE\n 0x0679: [0xfb66, 0xfb67, 0xfb68, 0xfb69], // ARABIC LETTER TTEH\n 0x067a: [0xfb5e, 0xfb5f, 0xfb60, 0xfb61], // ARABIC LETTER TTEHEH\n 0x067b: [0xfb52, 0xfb53, 0xfb54, 0xfb55], // ARABIC LETTER BEEH\n 0x067e: [0xfb56, 0xfb57, 0xfb58, 0xfb59], // ARABIC LETTER PEH\n 0x067f: [0xfb62, 0xfb63, 0xfb64, 0xfb65], // ARABIC LETTER TEHEH\n 0x0680: [0xfb5a, 0xfb5b, 0xfb5c, 0xfb5d], // ARABIC LETTER BEHEH\n 0x0683: [0xfb76, 0xfb77, 0xfb78, 0xfb79], // ARABIC LETTER NYEH\n 0x0684: [0xfb72, 0xfb73, 0xfb74, 0xfb75], // ARABIC LETTER DYEH\n 0x0686: [0xfb7a, 0xfb7b, 0xfb7c, 0xfb7d], // ARABIC LETTER TCHEH\n 0x0687: [0xfb7e, 0xfb7f, 0xfb80, 0xfb81], // ARABIC LETTER TCHEHEH\n 0x0688: [0xfb88, 0xfb89], // ARABIC LETTER DDAL\n 0x068c: [0xfb84, 0xfb85], // ARABIC LETTER DAHAL\n 0x068d: [0xfb82, 0xfb83], // ARABIC LETTER DDAHAL\n 0x068e: [0xfb86, 0xfb87], // ARABIC LETTER DUL\n 0x0691: [0xfb8c, 0xfb8d], // ARABIC LETTER RREH\n 0x0698: [0xfb8a, 0xfb8b], // ARABIC LETTER JEH\n 0x06a4: [0xfb6a, 0xfb6b, 0xfb6c, 0xfb6d], // ARABIC LETTER VEH\n 0x06a6: [0xfb6e, 0xfb6f, 0xfb70, 0xfb71], // ARABIC LETTER PEHEH\n 0x06a9: [0xfb8e, 0xfb8f, 0xfb90, 0xfb91], // ARABIC LETTER KEHEH\n 0x06ad: [0xfbd3, 0xfbd4, 0xfbd5, 0xfbd6], // ARABIC LETTER NG\n 0x06af: [0xfb92, 0xfb93, 0xfb94, 0xfb95], // ARABIC LETTER GAF\n 0x06b1: [0xfb9a, 0xfb9b, 0xfb9c, 0xfb9d], // ARABIC LETTER NGOEH\n 0x06b3: [0xfb96, 0xfb97, 0xfb98, 0xfb99], // ARABIC LETTER GUEH\n 0x06ba: [0xfb9e, 0xfb9f], // ARABIC LETTER NOON GHUNNA\n 0x06bb: [0xfba0, 0xfba1, 0xfba2, 0xfba3], // ARABIC LETTER RNOON\n 0x06be: [0xfbaa, 0xfbab, 0xfbac, 0xfbad], // ARABIC LETTER HEH DOACHASHMEE\n 0x06c0: [0xfba4, 0xfba5], // ARABIC LETTER HEH WITH YEH ABOVE\n 0x06c1: [0xfba6, 0xfba7, 0xfba8, 0xfba9], // ARABIC LETTER HEH GOAL\n 0x06c5: [0xfbe0, 0xfbe1], // ARABIC LETTER KIRGHIZ OE\n 0x06c6: [0xfbd9, 0xfbda], // ARABIC LETTER OE\n 0x06c7: [0xfbd7, 0xfbd8], // ARABIC LETTER U\n 0x06c8: [0xfbdb, 0xfbdc], // ARABIC LETTER YU\n 0x06c9: [0xfbe2, 0xfbe3], // ARABIC LETTER KIRGHIZ YU\n 0x06cb: [0xfbde, 0xfbdf], // ARABIC LETTER VE\n 0x06cc: [0xfbfc, 0xfbfd, 0xfbfe, 0xfbff], // ARABIC LETTER FARSI YEH\n 0x06d0: [0xfbe4, 0xfbe5, 0xfbe6, 0xfbe7], //ARABIC LETTER E\n 0x06d2: [0xfbae, 0xfbaf], // ARABIC LETTER YEH BARREE\n 0x06d3: [0xfbb0, 0xfbb1] // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE\n };\n\n /*\n var ligaturesSubstitutionA = {\n 0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM\n };\n */\n\n var ligatures = {\n 0xfedf: {\n 0xfe82: 0xfef5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM\n 0xfe84: 0xfef7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM\n 0xfe88: 0xfef9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM\n 0xfe8e: 0xfefb // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM\n },\n 0xfee0: {\n 0xfe82: 0xfef6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM\n 0xfe84: 0xfef8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM\n 0xfe88: 0xfefa, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM\n 0xfe8e: 0xfefc // ARABIC LIGATURE LAM WITH ALEF FINAL FORM\n },\n 0xfe8d: { 0xfedf: { 0xfee0: { 0xfeea: 0xfdf2 } } }, // ALLAH\n 0x0651: {\n 0x064c: 0xfc5e, // Shadda + Dammatan\n 0x064d: 0xfc5f, // Shadda + Kasratan\n 0x064e: 0xfc60, // Shadda + Fatha\n 0x064f: 0xfc61, // Shadda + Damma\n 0x0650: 0xfc62 // Shadda + Kasra\n }\n };\n\n var arabic_diacritics = {\n 1612: 64606, // Shadda + Dammatan\n 1613: 64607, // Shadda + Kasratan\n 1614: 64608, // Shadda + Fatha\n 1615: 64609, // Shadda + Damma\n 1616: 64610 // Shadda + Kasra\n };\n\n var alfletter = [1570, 1571, 1573, 1575];\n\n var noChangeInForm = -1;\n var isolatedForm = 0;\n var finalForm = 1;\n var initialForm = 2;\n var medialForm = 3;\n\n jsPDFAPI.__arabicParser__ = {};\n\n //private\n var isInArabicSubstitutionA = (jsPDFAPI.__arabicParser__.isInArabicSubstitutionA = function(\n letter\n ) {\n return typeof arabicSubstitionA[letter.charCodeAt(0)] !== \"undefined\";\n });\n\n var isArabicLetter = (jsPDFAPI.__arabicParser__.isArabicLetter = function(\n letter\n ) {\n return (\n typeof letter === \"string\" &&\n /^[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\uFB50-\\uFDFF\\uFE70-\\uFEFF]+$/.test(\n letter\n )\n );\n });\n\n var isArabicEndLetter = (jsPDFAPI.__arabicParser__.isArabicEndLetter = function(\n letter\n ) {\n return (\n isArabicLetter(letter) &&\n isInArabicSubstitutionA(letter) &&\n arabicSubstitionA[letter.charCodeAt(0)].length <= 2\n );\n });\n\n var isArabicAlfLetter = (jsPDFAPI.__arabicParser__.isArabicAlfLetter = function(\n letter\n ) {\n return (\n isArabicLetter(letter) && alfletter.indexOf(letter.charCodeAt(0)) >= 0\n );\n });\n\n jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm = function(letter) {\n return (\n isArabicLetter(letter) &&\n isInArabicSubstitutionA(letter) &&\n arabicSubstitionA[letter.charCodeAt(0)].length >= 1\n );\n };\n\n var arabicLetterHasFinalForm = (jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm = function(\n letter\n ) {\n return (\n isArabicLetter(letter) &&\n isInArabicSubstitutionA(letter) &&\n arabicSubstitionA[letter.charCodeAt(0)].length >= 2\n );\n });\n\n jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm = function(letter) {\n return (\n isArabicLetter(letter) &&\n isInArabicSubstitutionA(letter) &&\n arabicSubstitionA[letter.charCodeAt(0)].length >= 3\n );\n };\n\n var arabicLetterHasMedialForm = (jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm = function(\n letter\n ) {\n return (\n isArabicLetter(letter) &&\n isInArabicSubstitutionA(letter) &&\n arabicSubstitionA[letter.charCodeAt(0)].length == 4\n );\n });\n\n var resolveLigatures = (jsPDFAPI.__arabicParser__.resolveLigatures = function(\n letters\n ) {\n var i = 0;\n var tmpLigatures = ligatures;\n var result = \"\";\n var effectedLetters = 0;\n\n for (i = 0; i < letters.length; i += 1) {\n if (typeof tmpLigatures[letters.charCodeAt(i)] !== \"undefined\") {\n effectedLetters++;\n tmpLigatures = tmpLigatures[letters.charCodeAt(i)];\n\n if (typeof tmpLigatures === \"number\") {\n result += String.fromCharCode(tmpLigatures);\n tmpLigatures = ligatures;\n effectedLetters = 0;\n }\n if (i === letters.length - 1) {\n tmpLigatures = ligatures;\n result += letters.charAt(i - (effectedLetters - 1));\n i = i - (effectedLetters - 1);\n effectedLetters = 0;\n }\n } else {\n tmpLigatures = ligatures;\n result += letters.charAt(i - effectedLetters);\n i = i - effectedLetters;\n effectedLetters = 0;\n }\n }\n\n return result;\n });\n\n jsPDFAPI.__arabicParser__.isArabicDiacritic = function(letter) {\n return (\n letter !== undefined &&\n arabic_diacritics[letter.charCodeAt(0)] !== undefined\n );\n };\n\n var getCorrectForm = (jsPDFAPI.__arabicParser__.getCorrectForm = function(\n currentChar,\n beforeChar,\n nextChar\n ) {\n if (!isArabicLetter(currentChar)) {\n return -1;\n }\n\n if (isInArabicSubstitutionA(currentChar) === false) {\n return noChangeInForm;\n }\n if (\n !arabicLetterHasFinalForm(currentChar) ||\n (!isArabicLetter(beforeChar) && !isArabicLetter(nextChar)) ||\n (!isArabicLetter(nextChar) && isArabicEndLetter(beforeChar)) ||\n (isArabicEndLetter(currentChar) && !isArabicLetter(beforeChar)) ||\n (isArabicEndLetter(currentChar) && isArabicAlfLetter(beforeChar)) ||\n (isArabicEndLetter(currentChar) && isArabicEndLetter(beforeChar))\n ) {\n return isolatedForm;\n }\n\n if (\n arabicLetterHasMedialForm(currentChar) &&\n isArabicLetter(beforeChar) &&\n !isArabicEndLetter(beforeChar) &&\n isArabicLetter(nextChar) &&\n arabicLetterHasFinalForm(nextChar)\n ) {\n return medialForm;\n }\n\n if (isArabicEndLetter(currentChar) || !isArabicLetter(nextChar)) {\n return finalForm;\n }\n return initialForm;\n });\n\n /**\n * @name processArabic\n * @function\n * @param {string} text\n * @returns {string}\n */\n var parseArabic = function(text) {\n text = text || \"\";\n\n var result = \"\";\n var i = 0;\n var j = 0;\n var position = 0;\n var currentLetter = \"\";\n var prevLetter = \"\";\n var nextLetter = \"\";\n\n var words = text.split(\"\\\\s+\");\n var newWords = [];\n for (i = 0; i < words.length; i += 1) {\n newWords.push(\"\");\n for (j = 0; j < words[i].length; j += 1) {\n currentLetter = words[i][j];\n prevLetter = words[i][j - 1];\n nextLetter = words[i][j + 1];\n if (isArabicLetter(currentLetter)) {\n position = getCorrectForm(currentLetter, prevLetter, nextLetter);\n if (position !== -1) {\n newWords[i] += String.fromCharCode(\n arabicSubstitionA[currentLetter.charCodeAt(0)][position]\n );\n } else {\n newWords[i] += currentLetter;\n }\n } else {\n newWords[i] += currentLetter;\n }\n }\n\n newWords[i] = resolveLigatures(newWords[i]);\n }\n result = newWords.join(\" \");\n\n return result;\n };\n\n var processArabic = (jsPDFAPI.__arabicParser__.processArabic = jsPDFAPI.processArabic = function() {\n var text =\n typeof arguments[0] === \"string\" ? arguments[0] : arguments[0].text;\n var tmpText = [];\n var result;\n\n if (Array.isArray(text)) {\n var i = 0;\n tmpText = [];\n for (i = 0; i < text.length; i += 1) {\n if (Array.isArray(text[i])) {\n tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]);\n } else {\n tmpText.push([parseArabic(text[i])]);\n }\n }\n result = tmpText;\n } else {\n result = parseArabic(text);\n }\n if (typeof arguments[0] === \"string\") {\n return result;\n } else {\n arguments[0].text = result;\n return arguments[0];\n }\n });\n\n jsPDFAPI.events.push([\"preProcessText\", processArabic]);\n})(jsPDF.API);\n","/** @license\n * jsPDF Autoprint Plugin\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\n\nimport { jsPDF } from \"../jspdf.js\";\n\n/**\n * @name autoprint\n * @module\n */\n(function(jsPDFAPI) {\n \"use strict\";\n\n /**\n * Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer.\n *\n * @name autoPrint\n * @function\n * @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 .\n * @returns {jsPDF}\n * @example\n * var doc = new jsPDF();\n * doc.text(10, 10, 'This is a test');\n * doc.autoPrint({variant: 'non-conform'});\n * doc.save('autoprint.pdf');\n */\n jsPDFAPI.autoPrint = function(options) {\n \"use strict\";\n var refAutoPrintTag;\n options = options || {};\n options.variant = options.variant || \"non-conform\";\n\n switch (options.variant) {\n case \"javascript\":\n //https://github.com/Rob--W/pdf.js/commit/c676ecb5a0f54677b9f3340c3ef2cf42225453bb\n this.addJS(\"print({});\");\n break;\n case \"non-conform\":\n default:\n this.internal.events.subscribe(\"postPutResources\", function() {\n refAutoPrintTag = this.internal.newObject();\n this.internal.out(\"<<\");\n this.internal.out(\"/S /Named\");\n this.internal.out(\"/Type /Action\");\n this.internal.out(\"/N /Print\");\n this.internal.out(\">>\");\n this.internal.out(\"endobj\");\n });\n\n this.internal.events.subscribe(\"putCatalog\", function() {\n this.internal.out(\"/OpenAction \" + refAutoPrintTag + \" 0 R\");\n });\n break;\n }\n return this;\n };\n})(jsPDF.API);\n","/**\n * @license\n * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\n\nimport { jsPDF } from \"../jspdf.js\";\n\n/**\n * jsPDF Canvas PlugIn\n * This plugin mimics the HTML5 Canvas\n *\n * The goal is to provide a way for current canvas users to print directly to a PDF.\n * @name canvas\n * @module\n */\n(function(jsPDFAPI) {\n \"use strict\";\n\n /**\n * @class Canvas\n * @classdesc A Canvas Wrapper for jsPDF\n */\n var Canvas = function() {\n var jsPdfInstance = undefined;\n Object.defineProperty(this, \"pdf\", {\n get: function() {\n return jsPdfInstance;\n },\n set: function(value) {\n jsPdfInstance = value;\n }\n });\n\n var _width = 150;\n /**\n * The height property is a positive integer reflecting the height HTML attribute of the