{"version":3,"file":"jspdf.umd.min.js","sources":["../src/libs/globalObject.js","../src/libs/console.js","../src/libs/FileSaver.js","../src/libs/AtobBtoa.js","../src/libs/rgbcolor.js","../src/libs/md5.js","../src/libs/rc4.js","../src/libs/pdfsecurity.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/modules/context2d.js","../node_modules/pako/lib/utils/common.js","../node_modules/pako/lib/zlib/trees.js","../node_modules/pako/lib/zlib/adler32.js","../node_modules/pako/lib/zlib/crc32.js","../node_modules/pako/lib/zlib/deflate.js","../node_modules/pako/lib/zlib/messages.js","../node_modules/pako/lib/utils/strings.js","../node_modules/pako/lib/zlib/zstream.js","../node_modules/pako/lib/deflate.js","../node_modules/pako/lib/zlib/inffast.js","../node_modules/pako/lib/zlib/inftrees.js","../node_modules/pako/lib/zlib/inflate.js","../node_modules/pako/lib/zlib/constants.js","../node_modules/pako/lib/zlib/gzheader.js","../node_modules/pako/lib/inflate.js","../node_modules/pako/index.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/zlib.js","../src/modules/split_text_to_size.js","../src/libs/png.js","../src/libs/omggif.js","../src/libs/JPEGEncoder.js","../src/libs/BMPDecoder.js","../src/libs/WebPDecoder.js","../src/modules/png_support.js","../src/modules/gif_support.js","../src/modules/bmp_support.js","../src/modules/webp_support.js","../src/modules/setlanguage.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","../src/libs/adler32cs.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)\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","import { globalObject } from \"./globalObject.js\";\n\nvar atob, btoa;\n\n(function() {\n atob = globalObject.atob.bind(globalObject);\n btoa = globalObject.btoa.bind(globalObject);\n return;\n\n})();\n\nexport { atob, btoa };\n","/**\n * A class to parse color values\n * @author Stoyan Stefanov
\n * @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.
\n * Possible values are \"pt\" (points), \"mm\", \"cm\", \"m\", \"in\" or \"px\". Note that in order to get the correct scaling for \"px\"\n * units, you need to enable the hotfix \"px_scaling\" by setting options.hotfixes = [\"px_scaling\"].\n * @param {string/Array} [options.format=a4] The format of the first page. Can be:
\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]\n * @param {boolean} [options.putOnlyUsedFonts=false] Only put fonts into the PDF, which were used.\n * @param {boolean} [options.compress=false] Compress the generated PDF.\n * @param {number} [options.precision=16] Precision of the element-positions.\n * @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.\n * @param {string[]} [options.hotfixes] An array of strings to enable hotfixes such as correct pixel scaling.\n * @param {Object} [options.encryption]\n * @param {string} [options.encryption.userPassword] Password for the user bound by the given permissions list.\n * @param {string} [options.encryption.ownerPassword] Both userPassword and ownerPassword should be set for proper authentication.\n * @param {string[]} [options.encryption.userPermissions] Array of permissions \"print\", \"modify\", \"copy\", \"annot-forms\", accessible by the user.\n * @param {number|\"smart\"} [options.floatPrecision=16]\n * @returns {jsPDF} jsPDF-instance\n * @description\n * ```\n * {\n * orientation: 'p',\n * unit: 'mm',\n * format: 'a4',\n * putOnlyUsedFonts:true,\n * floatPrecision: 16 // or \"smart\", default is 16\n * }\n * ```\n *\n * @constructor\n */\nfunction jsPDF(options) {\n var orientation = typeof arguments[0] === \"string\" ? arguments[0] : \"p\";\n var unit = arguments[1];\n var format = arguments[2];\n var compressPdf = arguments[3];\n var filters = [];\n var userUnit = 1.0;\n var precision;\n var floatPrecision = 16;\n var defaultPathOperation = \"S\";\n var encryptionOptions = null;\n\n options = options || {};\n\n if (typeof options === \"object\") {\n orientation = options.orientation;\n unit = options.unit || unit;\n format = options.format || format;\n compressPdf = options.compress || options.compressPdf || compressPdf;\n encryptionOptions = options.encryption || null;\n if (encryptionOptions !== null) {\n encryptionOptions.userPassword = encryptionOptions.userPassword || \"\";\n encryptionOptions.ownerPassword = encryptionOptions.ownerPassword || \"\";\n encryptionOptions.userPermissions =\n encryptionOptions.userPermissions || [];\n }\n userUnit =\n typeof options.userUnit === \"number\" ? Math.abs(options.userUnit) : 1.0;\n if (typeof options.precision !== \"undefined\") {\n precision = options.precision;\n }\n if (typeof options.floatPrecision !== \"undefined\") {\n floatPrecision = options.floatPrecision;\n }\n defaultPathOperation = options.defaultPathOperation || \"S\";\n }\n\n filters =\n options.filters || (compressPdf === true ? [\"FlateEncode\"] : filters);\n\n unit = unit || \"mm\";\n orientation = (\"\" + (orientation || \"P\")).toLowerCase();\n var putOnlyUsedFonts = options.putOnlyUsedFonts || false;\n var usedFonts = {};\n\n var API = {\n internal: {},\n __private__: {}\n };\n\n API.__private__.PubSub = PubSub;\n\n var pdfVersion = \"1.3\";\n var getPdfVersion = (API.__private__.getPdfVersion = function() {\n return pdfVersion;\n });\n\n API.__private__.setPdfVersion = function(value) {\n pdfVersion = value;\n };\n\n // Size in pt of various paper formats\n var pageFormats = {\n a0: [2383.94, 3370.39],\n a1: [1683.78, 2383.94],\n a2: [1190.55, 1683.78],\n a3: [841.89, 1190.55],\n a4: [595.28, 841.89],\n a5: [419.53, 595.28],\n a6: [297.64, 419.53],\n a7: [209.76, 297.64],\n a8: [147.4, 209.76],\n a9: [104.88, 147.4],\n a10: [73.7, 104.88],\n b0: [2834.65, 4008.19],\n b1: [2004.09, 2834.65],\n b2: [1417.32, 2004.09],\n b3: [1000.63, 1417.32],\n b4: [708.66, 1000.63],\n b5: [498.9, 708.66],\n b6: [354.33, 498.9],\n b7: [249.45, 354.33],\n b8: [175.75, 249.45],\n b9: [124.72, 175.75],\n b10: [87.87, 124.72],\n c0: [2599.37, 3676.54],\n c1: [1836.85, 2599.37],\n c2: [1298.27, 1836.85],\n c3: [918.43, 1298.27],\n c4: [649.13, 918.43],\n c5: [459.21, 649.13],\n c6: [323.15, 459.21],\n c7: [229.61, 323.15],\n c8: [161.57, 229.61],\n c9: [113.39, 161.57],\n c10: [79.37, 113.39],\n dl: [311.81, 623.62],\n letter: [612, 792],\n \"government-letter\": [576, 756],\n legal: [612, 1008],\n \"junior-legal\": [576, 360],\n ledger: [1224, 792],\n tabloid: [792, 1224],\n \"credit-card\": [153, 243]\n };\n\n API.__private__.getPageFormats = function() {\n return pageFormats;\n };\n\n var getPageFormat = (API.__private__.getPageFormat = function(value) {\n return pageFormats[value];\n });\n\n format = format || \"a4\";\n\n var ApiMode = {\n COMPAT: \"compat\",\n ADVANCED: \"advanced\"\n };\n var apiMode = ApiMode.COMPAT;\n\n function advancedAPI() {\n // prepend global change of basis matrix\n // (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix\n // that does this job for us (however, texts, images and similar objects must be drawn bottom up))\n this.saveGraphicsState();\n out(\n new Matrix(\n scaleFactor,\n 0,\n 0,\n -scaleFactor,\n 0,\n getPageHeight() * scaleFactor\n ).toString() + \" cm\"\n );\n this.setFontSize(this.getFontSize() / scaleFactor);\n\n // The default in MrRio's implementation is \"S\" (stroke), whereas the default in the yWorks implementation\n // was \"n\" (none). Although this has nothing to do with transforms, we should use the API switch here.\n defaultPathOperation = \"n\";\n\n apiMode = ApiMode.ADVANCED;\n }\n\n function compatAPI() {\n this.restoreGraphicsState();\n defaultPathOperation = \"S\";\n apiMode = ApiMode.COMPAT;\n }\n\n /**\n * @callback ApiSwitchBody\n * @param {jsPDF} pdf\n */\n\n /**\n * For compatibility reasons jsPDF offers two API modes which differ in the way they convert between the the usual\n * screen coordinates and the PDF coordinate system.\n * - \"compat\": Offers full compatibility across all plugins but does not allow arbitrary transforms\n * - \"advanced\": Allows arbitrary transforms and more advanced features like pattern fills. Some plugins might\n * not support this mode, though.\n * Initial mode is \"compat\".\n *\n * You can either provide a callback to the body argument, which means that jsPDF will automatically switch back to\n * the original API mode afterwards; or you can omit the callback and switch back manually using {@link compatAPI}.\n *\n * Note, that the calls to {@link saveGraphicsState} and {@link restoreGraphicsState} need to be balanced within the\n * callback or between calls of this method and its counterpart {@link compatAPI}. Calls to {@link beginFormObject}\n * or {@link beginTilingPattern} need to be closed by their counterparts before switching back to \"compat\" API mode.\n *\n * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.\n * The API mode will be switched back automatically afterwards.\n * @returns {jsPDF}\n * @memberof jsPDF#\n * @name advancedAPI\n */\n API.advancedAPI = function(body) {\n var doSwitch = apiMode === ApiMode.COMPAT;\n\n if (doSwitch) {\n advancedAPI.call(this);\n }\n\n if (typeof body !== \"function\") {\n return this;\n }\n\n body(this);\n\n if (doSwitch) {\n compatAPI.call(this);\n }\n\n return this;\n };\n\n /**\n * Switches to \"compat\" API mode. See {@link advancedAPI} for more details.\n *\n * @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.\n * The API mode will be switched back automatically afterwards.\n * @return {jsPDF}\n * @memberof jsPDF#\n * @name compatApi\n */\n API.compatAPI = function(body) {\n var doSwitch = apiMode === ApiMode.ADVANCED;\n\n if (doSwitch) {\n compatAPI.call(this);\n }\n\n if (typeof body !== \"function\") {\n return this;\n }\n\n body(this);\n\n if (doSwitch) {\n advancedAPI.call(this);\n }\n\n return this;\n };\n\n /**\n * @return {boolean} True iff the current API mode is \"advanced\". See {@link advancedAPI}.\n * @memberof jsPDF#\n * @name isAdvancedAPI\n */\n API.isAdvancedAPI = function() {\n return apiMode === ApiMode.ADVANCED;\n };\n\n var advancedApiModeTrap = function(methodName) {\n if (apiMode !== ApiMode.ADVANCED) {\n throw new Error(\n methodName +\n \" is only available in 'advanced' API mode. \" +\n \"You need to call advancedAPI() first.\"\n );\n }\n };\n\n var roundToPrecision = (API.roundToPrecision = API.__private__.roundToPrecision = function(\n number,\n parmPrecision\n ) {\n var tmpPrecision = precision || parmPrecision;\n if (isNaN(number) || isNaN(tmpPrecision)) {\n throw new Error(\"Invalid argument passed to jsPDF.roundToPrecision\");\n }\n return number.toFixed(tmpPrecision).replace(/0+$/, \"\");\n });\n\n // high precision float\n var hpf;\n if (typeof floatPrecision === \"number\") {\n hpf = API.hpf = API.__private__.hpf = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\n }\n return roundToPrecision(number, floatPrecision);\n };\n } else if (floatPrecision === \"smart\") {\n hpf = API.hpf = API.__private__.hpf = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\n }\n if (number > -1 && number < 1) {\n return roundToPrecision(number, 16);\n } else {\n return roundToPrecision(number, 5);\n }\n };\n } else {\n hpf = API.hpf = API.__private__.hpf = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.hpf\");\n }\n return roundToPrecision(number, 16);\n };\n }\n var f2 = (API.f2 = API.__private__.f2 = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.f2\");\n }\n return roundToPrecision(number, 2);\n });\n\n var f3 = (API.__private__.f3 = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.f3\");\n }\n return roundToPrecision(number, 3);\n });\n\n var scale = (API.scale = API.__private__.scale = function(number) {\n if (isNaN(number)) {\n throw new Error(\"Invalid argument passed to jsPDF.scale\");\n }\n if (apiMode === ApiMode.COMPAT) {\n return number * scaleFactor;\n } else if (apiMode === ApiMode.ADVANCED) {\n return number;\n }\n });\n\n var transformY = function(y) {\n if (apiMode === ApiMode.COMPAT) {\n return getPageHeight() - y;\n } else if (apiMode === ApiMode.ADVANCED) {\n return y;\n }\n };\n\n var transformScaleY = function(y) {\n return scale(transformY(y));\n };\n\n /**\n * @name setPrecision\n * @memberof jsPDF#\n * @function\n * @instance\n * @param {string} precision\n * @returns {jsPDF}\n */\n API.__private__.setPrecision = API.setPrecision = function(value) {\n if (typeof parseInt(value, 10) === \"number\") {\n precision = parseInt(value, 10);\n }\n };\n\n var fileId = \"00000000000000000000000000000000\";\n\n var getFileId = (API.__private__.getFileId = function() {\n return fileId;\n });\n\n var setFileId = (API.__private__.setFileId = function(value) {\n if (typeof value !== \"undefined\" && /^[a-fA-F0-9]{32}$/.test(value)) {\n fileId = value.toUpperCase();\n } else {\n fileId = fileId\n .split(\"\")\n .map(function() {\n return \"ABCDEF0123456789\".charAt(Math.floor(Math.random() * 16));\n })\n .join(\"\");\n }\n\n if (encryptionOptions !== null) {\n encryption = new PDFSecurity(\n encryptionOptions.userPermissions,\n encryptionOptions.userPassword,\n encryptionOptions.ownerPassword,\n fileId\n );\n }\n return fileId;\n });\n\n /**\n * @name setFileId\n * @memberof jsPDF#\n * @function\n * @instance\n * @param {string} value GUID.\n * @returns {jsPDF}\n */\n API.setFileId = function(value) {\n setFileId(value);\n return this;\n };\n\n /**\n * @name getFileId\n * @memberof jsPDF#\n * @function\n * @instance\n *\n * @returns {string} GUID.\n */\n API.getFileId = function() {\n return getFileId();\n };\n\n var creationDate;\n\n var convertDateToPDFDate = (API.__private__.convertDateToPDFDate = function(\n parmDate\n ) {\n var result = \"\";\n var tzoffset = parmDate.getTimezoneOffset(),\n tzsign = tzoffset < 0 ? \"+\" : \"-\",\n tzhour = Math.floor(Math.abs(tzoffset / 60)),\n tzmin = Math.abs(tzoffset % 60),\n timeZoneString = [tzsign, padd2(tzhour), \"'\", padd2(tzmin), \"'\"].join(\"\");\n\n result = [\n \"D:\",\n parmDate.getFullYear(),\n padd2(parmDate.getMonth() + 1),\n padd2(parmDate.getDate()),\n padd2(parmDate.getHours()),\n padd2(parmDate.getMinutes()),\n padd2(parmDate.getSeconds()),\n timeZoneString\n ].join(\"\");\n return result;\n });\n\n var convertPDFDateToDate = (API.__private__.convertPDFDateToDate = function(\n parmPDFDate\n ) {\n var year = parseInt(parmPDFDate.substr(2, 4), 10);\n var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;\n var date = parseInt(parmPDFDate.substr(8, 2), 10);\n var hour = parseInt(parmPDFDate.substr(10, 2), 10);\n var minutes = parseInt(parmPDFDate.substr(12, 2), 10);\n var seconds = parseInt(parmPDFDate.substr(14, 2), 10);\n // var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);\n // var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);\n\n var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);\n return resultingDate;\n });\n\n var setCreationDate = (API.__private__.setCreationDate = function(date) {\n var tmpCreationDateString;\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])'?$/;\n if (typeof date === \"undefined\") {\n date = new Date();\n }\n\n if (date instanceof Date) {\n tmpCreationDateString = convertDateToPDFDate(date);\n } else if (regexPDFCreationDate.test(date)) {\n tmpCreationDateString = date;\n } else {\n throw new Error(\"Invalid argument passed to jsPDF.setCreationDate\");\n }\n creationDate = tmpCreationDateString;\n return creationDate;\n });\n\n var getCreationDate = (API.__private__.getCreationDate = function(type) {\n var result = creationDate;\n if (type === \"jsDate\") {\n result = convertPDFDateToDate(creationDate);\n }\n return result;\n });\n\n /**\n * @name setCreationDate\n * @memberof jsPDF#\n * @function\n * @instance\n * @param {Object} date\n * @returns {jsPDF}\n */\n API.setCreationDate = function(date) {\n setCreationDate(date);\n return this;\n };\n\n /**\n * @name getCreationDate\n * @memberof jsPDF#\n * @function\n * @instance\n * @param {Object} type\n * @returns {Object}\n */\n API.getCreationDate = function(type) {\n return getCreationDate(type);\n };\n\n var padd2 = (API.__private__.padd2 = function(number) {\n return (\"0\" + parseInt(number)).slice(-2);\n });\n\n var padd2Hex = (API.__private__.padd2Hex = function(hexString) {\n hexString = hexString.toString();\n return (\"00\" + hexString).substr(hexString.length);\n });\n\n var objectNumber = 0; // 'n' Current object number\n var offsets = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.\n var content = [];\n var contentLength = 0;\n var additionalObjects = [];\n\n var pages = [];\n var currentPage;\n var hasCustomDestination = false;\n var outputDestination = content;\n\n var resetDocument = function() {\n //reset fields relevant for objectNumber generation and xref.\n objectNumber = 0;\n contentLength = 0;\n content = [];\n offsets = [];\n additionalObjects = [];\n\n rootDictionaryObjId = newObjectDeferred();\n resourceDictionaryObjId = newObjectDeferred();\n };\n\n API.__private__.setCustomOutputDestination = function(destination) {\n hasCustomDestination = true;\n outputDestination = destination;\n };\n var setOutputDestination = function(destination) {\n if (!hasCustomDestination) {\n outputDestination = destination;\n }\n };\n\n API.__private__.resetCustomOutputDestination = function() {\n hasCustomDestination = false;\n outputDestination = content;\n };\n\n var out = (API.__private__.out = function(string) {\n string = string.toString();\n contentLength += string.length + 1;\n outputDestination.push(string);\n\n return outputDestination;\n });\n\n var write = (API.__private__.write = function(value) {\n return out(\n arguments.length === 1\n ? value.toString()\n : Array.prototype.join.call(arguments, \" \")\n );\n });\n\n var getArrayBuffer = (API.__private__.getArrayBuffer = function(data) {\n var len = data.length,\n ab = new ArrayBuffer(len),\n u8 = new Uint8Array(ab);\n\n while (len--) u8[len] = data.charCodeAt(len);\n return ab;\n });\n\n var standardFonts = [\n [\"Helvetica\", \"helvetica\", \"normal\", \"WinAnsiEncoding\"],\n [\"Helvetica-Bold\", \"helvetica\", \"bold\", \"WinAnsiEncoding\"],\n [\"Helvetica-Oblique\", \"helvetica\", \"italic\", \"WinAnsiEncoding\"],\n [\"Helvetica-BoldOblique\", \"helvetica\", \"bolditalic\", \"WinAnsiEncoding\"],\n [\"Courier\", \"courier\", \"normal\", \"WinAnsiEncoding\"],\n [\"Courier-Bold\", \"courier\", \"bold\", \"WinAnsiEncoding\"],\n [\"Courier-Oblique\", \"courier\", \"italic\", \"WinAnsiEncoding\"],\n [\"Courier-BoldOblique\", \"courier\", \"bolditalic\", \"WinAnsiEncoding\"],\n [\"Times-Roman\", \"times\", \"normal\", \"WinAnsiEncoding\"],\n [\"Times-Bold\", \"times\", \"bold\", \"WinAnsiEncoding\"],\n [\"Times-Italic\", \"times\", \"italic\", \"WinAnsiEncoding\"],\n [\"Times-BoldItalic\", \"times\", \"bolditalic\", \"WinAnsiEncoding\"],\n [\"ZapfDingbats\", \"zapfdingbats\", \"normal\", null],\n [\"Symbol\", \"symbol\", \"normal\", null]\n ];\n\n API.__private__.getStandardFonts = function() {\n return standardFonts;\n };\n\n var activeFontSize = options.fontSize || 16;\n\n /**\n * Sets font size for upcoming text elements.\n *\n * @param {number} size Font size in points.\n * @function\n * @instance\n * @returns {jsPDF}\n * @memberof jsPDF#\n * @name setFontSize\n */\n API.__private__.setFontSize = API.setFontSize = function(size) {\n if (apiMode === ApiMode.ADVANCED) {\n activeFontSize = size / scaleFactor;\n } else {\n activeFontSize = size;\n }\n return this;\n };\n\n /**\n * Gets the fontsize for upcoming text elements.\n *\n * @function\n * @instance\n * @returns {number}\n * @memberof jsPDF#\n * @name getFontSize\n */\n var getFontSize = (API.__private__.getFontSize = API.getFontSize = function() {\n if (apiMode === ApiMode.COMPAT) {\n return activeFontSize;\n } else {\n return activeFontSize * scaleFactor;\n }\n });\n\n var R2L = options.R2L || false;\n\n /**\n * Set value of R2L functionality.\n *\n * @param {boolean} value\n * @function\n * @instance\n * @returns {jsPDF} jsPDF-instance\n * @memberof jsPDF#\n * @name setR2L\n */\n API.__private__.setR2L = API.setR2L = function(value) {\n R2L = value;\n return this;\n };\n\n /**\n * Get value of R2L functionality.\n *\n * @function\n * @instance\n * @returns {boolean} jsPDF-instance\n * @memberof jsPDF#\n * @name getR2L\n */\n API.__private__.getR2L = API.getR2L = function() {\n return R2L;\n };\n\n var zoomMode; // default: 1;\n\n var setZoomMode = (API.__private__.setZoomMode = function(zoom) {\n var validZoomModes = [\n undefined,\n null,\n \"fullwidth\",\n \"fullheight\",\n \"fullpage\",\n \"original\"\n ];\n\n if (/^\\d*\\.?\\d*%$/.test(zoom)) {\n zoomMode = zoom;\n } else if (!isNaN(zoom)) {\n zoomMode = parseInt(zoom, 10);\n } else if (validZoomModes.indexOf(zoom) !== -1) {\n zoomMode = zoom;\n } else {\n throw new Error(\n 'zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. \"' +\n zoom +\n '\" is not recognized.'\n );\n }\n });\n\n API.__private__.getZoomMode = function() {\n return zoomMode;\n };\n\n var pageMode; // default: 'UseOutlines';\n var setPageMode = (API.__private__.setPageMode = function(pmode) {\n var validPageModes = [\n undefined,\n null,\n \"UseNone\",\n \"UseOutlines\",\n \"UseThumbs\",\n \"FullScreen\"\n ];\n\n if (validPageModes.indexOf(pmode) == -1) {\n throw new Error(\n 'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. \"' +\n pmode +\n '\" is not recognized.'\n );\n }\n pageMode = pmode;\n });\n\n API.__private__.getPageMode = function() {\n return pageMode;\n };\n\n var layoutMode; // default: 'continuous';\n var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {\n var validLayoutModes = [\n undefined,\n null,\n \"continuous\",\n \"single\",\n \"twoleft\",\n \"tworight\",\n \"two\"\n ];\n\n if (validLayoutModes.indexOf(layout) == -1) {\n throw new Error(\n 'Layout mode must be one of continuous, single, twoleft, tworight. \"' +\n layout +\n '\" is not recognized.'\n );\n }\n layoutMode = layout;\n });\n\n API.__private__.getLayoutMode = function() {\n return layoutMode;\n };\n\n /**\n * Set the display mode options of the page like zoom and layout.\n *\n * @name setDisplayMode\n * @memberof jsPDF#\n * @function\n * @instance\n * @param {integer|String} zoom You can pass an integer or percentage as\n * a string. 2 will scale the document up 2x, '200%' will scale up by the\n * same amount. You can also set it to 'fullwidth', 'fullheight',\n * 'fullpage', or 'original'.\n *\n * Only certain PDF readers support this, such as Adobe Acrobat.\n *\n * @param {string} layout Layout mode can be: 'continuous' - this is the\n * default continuous scroll. 'single' - the single page mode only shows one\n * page at a time. 'twoleft' - two column left mode, first page starts on\n * the left, and 'tworight' - pages are laid out in two columns, with the\n * first page on the right. This would be used for books.\n * @param {string} pmode 'UseOutlines' - it shows the\n * outline of the document on the left. 'UseThumbs' - shows thumbnails along\n * the left. 'FullScreen' - prompts the user to enter fullscreen mode.\n *\n * @returns {jsPDF}\n */\n API.__private__.setDisplayMode = API.setDisplayMode = function(\n zoom,\n layout,\n pmode\n ) {\n setZoomMode(zoom);\n setLayoutMode(layout);\n setPageMode(pmode);\n return this;\n };\n\n var documentProperties = {\n title: \"\",\n subject: \"\",\n author: \"\",\n keywords: \"\",\n creator: \"\"\n };\n\n API.__private__.getDocumentProperty = function(key) {\n if (Object.keys(documentProperties).indexOf(key) === -1) {\n throw new Error(\"Invalid argument passed to jsPDF.getDocumentProperty\");\n }\n return documentProperties[key];\n };\n\n API.__private__.getDocumentProperties = function() {\n return documentProperties;\n };\n\n /**\n * Adds a properties to the PDF document.\n *\n * @param {Object} A property_name-to-property_value object structure.\n * @function\n * @instance\n * @returns {jsPDF}\n * @memberof jsPDF#\n * @name setDocumentProperties\n */\n API.__private__.setDocumentProperties = API.setProperties = API.setDocumentProperties = function(\n properties\n ) {\n // copying only those properties we can render.\n for (var property in documentProperties) {\n if (documentProperties.hasOwnProperty(property) && properties[property]) {\n documentProperties[property] = properties[property];\n }\n }\n return this;\n };\n\n API.__private__.setDocumentProperty = function(key, value) {\n if (Object.keys(documentProperties).indexOf(key) === -1) {\n throw new Error(\"Invalid arguments passed to jsPDF.setDocumentProperty\");\n }\n return (documentProperties[key] = value);\n };\n\n var fonts = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font.\n var fontmap = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont()\n var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle\n var fontStateStack = []; //\n var patterns = {}; // collection of pattern objects\n var patternMap = {}; // see fonts\n var gStates = {}; // collection of graphic state objects\n var gStatesMap = {}; // see fonts\n var activeGState = null;\n var scaleFactor; // Scale factor\n var page = 0;\n var pagesContext = [];\n var events = new PubSub(API);\n var hotfixes = options.hotfixes || [];\n\n var renderTargets = {};\n var renderTargetMap = {};\n var renderTargetStack = [];\n var pageX;\n var pageY;\n var pageMatrix; // only used for FormObjects\n\n /**\n * A matrix object for 2D homogenous transformations:
\n * | a b 0 |
\n * | c d 0 |
\n * | e f 1 |
\n * pdf multiplies matrices righthand: v' = v x m1 x m2 x ...\n *\n * @class\n * @name Matrix\n * @param {number} sx\n * @param {number} shy\n * @param {number} shx\n * @param {number} sy\n * @param {number} tx\n * @param {number} ty\n * @constructor\n */\n var Matrix = function(sx, shy, shx, sy, tx, ty) {\n if (!(this instanceof Matrix)) {\n return new Matrix(sx, shy, shx, sy, tx, ty);\n }\n\n if (isNaN(sx)) sx = 1;\n if (isNaN(shy)) shy = 0;\n if (isNaN(shx)) shx = 0;\n if (isNaN(sy)) sy = 1;\n if (isNaN(tx)) tx = 0;\n if (isNaN(ty)) ty = 0;\n\n this._matrix = [sx, shy, shx, sy, tx, ty];\n };\n\n /**\n * @name sx\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"sx\", {\n get: function() {\n return this._matrix[0];\n },\n set: function(value) {\n this._matrix[0] = value;\n }\n });\n\n /**\n * @name shy\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"shy\", {\n get: function() {\n return this._matrix[1];\n },\n set: function(value) {\n this._matrix[1] = value;\n }\n });\n\n /**\n * @name shx\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"shx\", {\n get: function() {\n return this._matrix[2];\n },\n set: function(value) {\n this._matrix[2] = value;\n }\n });\n\n /**\n * @name sy\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"sy\", {\n get: function() {\n return this._matrix[3];\n },\n set: function(value) {\n this._matrix[3] = value;\n }\n });\n\n /**\n * @name tx\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"tx\", {\n get: function() {\n return this._matrix[4];\n },\n set: function(value) {\n this._matrix[4] = value;\n }\n });\n\n /**\n * @name ty\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"ty\", {\n get: function() {\n return this._matrix[5];\n },\n set: function(value) {\n this._matrix[5] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"a\", {\n get: function() {\n return this._matrix[0];\n },\n set: function(value) {\n this._matrix[0] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"b\", {\n get: function() {\n return this._matrix[1];\n },\n set: function(value) {\n this._matrix[1] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"c\", {\n get: function() {\n return this._matrix[2];\n },\n set: function(value) {\n this._matrix[2] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"d\", {\n get: function() {\n return this._matrix[3];\n },\n set: function(value) {\n this._matrix[3] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"e\", {\n get: function() {\n return this._matrix[4];\n },\n set: function(value) {\n this._matrix[4] = value;\n }\n });\n\n Object.defineProperty(Matrix.prototype, \"f\", {\n get: function() {\n return this._matrix[5];\n },\n set: function(value) {\n this._matrix[5] = value;\n }\n });\n\n /**\n * @name rotation\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"rotation\", {\n get: function() {\n return Math.atan2(this.shx, this.sx);\n }\n });\n\n /**\n * @name scaleX\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"scaleX\", {\n get: function() {\n return this.decompose().scale.sx;\n }\n });\n\n /**\n * @name scaleY\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"scaleY\", {\n get: function() {\n return this.decompose().scale.sy;\n }\n });\n\n /**\n * @name isIdentity\n * @memberof Matrix#\n */\n Object.defineProperty(Matrix.prototype, \"isIdentity\", {\n get: function() {\n if (this.sx !== 1) {\n return false;\n }\n if (this.shy !== 0) {\n return false;\n }\n if (this.shx !== 0) {\n return false;\n }\n if (this.sy !== 1) {\n return false;\n }\n if (this.tx !== 0) {\n return false;\n }\n if (this.ty !== 0) {\n return false;\n }\n return true;\n }\n });\n\n /**\n * Join the Matrix Values to a String\n *\n * @function join\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.\n * @returns {string} A string with all array elements joined.\n * @memberof Matrix#\n */\n Matrix.prototype.join = function(separator) {\n return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty]\n .map(hpf)\n .join(separator);\n };\n\n /**\n * Multiply the matrix with given Matrix\n *\n * @function multiply\n * @param matrix\n * @returns {Matrix}\n * @memberof Matrix#\n */\n Matrix.prototype.multiply = function(matrix) {\n var sx = matrix.sx * this.sx + matrix.shy * this.shx;\n var shy = matrix.sx * this.shy + matrix.shy * this.sy;\n var shx = matrix.shx * this.sx + matrix.sy * this.shx;\n var sy = matrix.shx * this.shy + matrix.sy * this.sy;\n var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx;\n var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty;\n\n return new Matrix(sx, shy, shx, sy, tx, ty);\n };\n\n /**\n * @function decompose\n * @memberof Matrix#\n */\n Matrix.prototype.decompose = function() {\n var a = this.sx;\n var b = this.shy;\n var c = this.shx;\n var d = this.sy;\n var e = this.tx;\n var f = this.ty;\n\n var scaleX = Math.sqrt(a * a + b * b);\n a /= scaleX;\n b /= scaleX;\n\n var shear = a * c + b * d;\n c -= a * shear;\n d -= b * shear;\n\n var scaleY = Math.sqrt(c * c + d * d);\n c /= scaleY;\n d /= scaleY;\n shear /= scaleY;\n\n if (a * d < b * c) {\n a = -a;\n b = -b;\n shear = -shear;\n scaleX = -scaleX;\n }\n\n return {\n scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),\n translate: new Matrix(1, 0, 0, 1, e, f),\n rotate: new Matrix(a, b, -b, a, 0, 0),\n skew: new Matrix(1, 0, shear, 1, 0, 0)\n };\n };\n\n /**\n * @function toString\n * @memberof Matrix#\n */\n Matrix.prototype.toString = function(parmPrecision) {\n return this.join(\" \");\n };\n\n /**\n * @function inversed\n * @memberof Matrix#\n */\n Matrix.prototype.inversed = function() {\n var a = this.sx,\n b = this.shy,\n c = this.shx,\n d = this.sy,\n e = this.tx,\n f = this.ty;\n\n var quot = 1 / (a * d - b * c);\n\n var aInv = d * quot;\n var bInv = -b * quot;\n var cInv = -c * quot;\n var dInv = a * quot;\n var eInv = -aInv * e - cInv * f;\n var fInv = -bInv * e - dInv * f;\n\n return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);\n };\n\n /**\n * @function applyToPoint\n * @memberof Matrix#\n */\n Matrix.prototype.applyToPoint = function(pt) {\n var x = pt.x * this.sx + pt.y * this.shx + this.tx;\n var y = pt.x * this.shy + pt.y * this.sy + this.ty;\n return new Point(x, y);\n };\n\n /**\n * @function applyToRectangle\n * @memberof Matrix#\n */\n Matrix.prototype.applyToRectangle = function(rect) {\n var pt1 = this.applyToPoint(rect);\n var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));\n return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);\n };\n\n /**\n * Clone the Matrix\n *\n * @function clone\n * @memberof Matrix#\n * @name clone\n * @instance\n */\n Matrix.prototype.clone = function() {\n var sx = this.sx;\n var shy = this.shy;\n var shx = this.shx;\n var sy = this.sy;\n var tx = this.tx;\n var ty = this.ty;\n\n return new Matrix(sx, shy, shx, sy, tx, ty);\n };\n\n API.Matrix = Matrix;\n\n /**\n * Multiplies two matrices. (see {@link Matrix})\n * @param {Matrix} m1\n * @param {Matrix} m2\n * @memberof jsPDF#\n * @name matrixMult\n */\n var matrixMult = (API.matrixMult = function(m1, m2) {\n return m2.multiply(m1);\n });\n\n /**\n * The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)).\n * @type {Matrix}\n * @memberof! jsPDF#\n * @name identityMatrix\n */\n var identityMatrix = new Matrix(1, 0, 0, 1, 0, 0);\n API.unitMatrix = API.identityMatrix = identityMatrix;\n\n /**\n * Adds a new pattern for later use.\n * @param {String} key The key by it can be referenced later. The keys must be unique!\n * @param {API.Pattern} pattern The pattern\n */\n var addPattern = function(key, pattern) {\n // only add it if it is not already present (the keys provided by the user must be unique!)\n if (patternMap[key]) return;\n\n var prefix = pattern instanceof ShadingPattern ? \"Sh\" : \"P\";\n var patternKey = prefix + (Object.keys(patterns).length + 1).toString(10);\n pattern.id = patternKey;\n\n patternMap[key] = patternKey;\n patterns[patternKey] = pattern;\n\n events.publish(\"addPattern\", pattern);\n };\n\n /**\n * A pattern describing a shading pattern.\n *\n * Only available in \"advanced\" API mode.\n *\n * @param {String} type One of \"axial\" or \"radial\"\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 width = this.getTextWidth(text);\n var height = this.internal.getLineHeight() / this.internal.scaleFactor;\n this.text(text, x, y, options);\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 += height * 0.2;\n this.link(x, y - height, width, height, options);\n return width;\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