diff --git a/builder.html b/builder.html index 7c00469c6..675c9734c 100644 --- a/builder.html +++ b/builder.html @@ -47,302 +47,10 @@ + ' + '' + ''; - var nW = global.open(); - - if (nW !== null) { - nW.document.write(htmlForNewWindow); - } - - return nW; - - case 'pdfjsnewwindow': - var pdfJsUrl = options.pdfJsUrl || 'examples/PDF.js/web/viewer.html'; - var htmlForNewWindow = '' + '' + '' + ''; + var htmlForNewWindow = '' + '' + '' + '' + ''; var nW = global.open(); if (nW !== null) { nW.document.write(htmlForNewWindow); } - if (nW || typeof safari === "undefined") { return nW; } - // eslint-disable-next-line no-fallthrough + if (nW || typeof safari === "undefined") return nW; + + /* pass through */ case 'datauri': case 'dataurl': - return global.document.location.href = this.output('datauristring', options); + return global.document.location.href = 'data:application/pdf;filename=' + options.filename + ';base64,' + btoa(pdfDocument); default: return null; } }); - /** - * Used to see if a supplied hotfix was requested when the pdf instance was created. - * @param {string} hotfixName - The name of the hotfix to check. - * @returns {boolean} + /** + * Used to see if a supplied hotfix was requested when the pdf instance was created. + * @param {string} hotfixName - The name of the hotfix to check. + * @returns {boolean} */ var hasHotfix = function hasHotfix(hotfixName) { @@ -2949,7 +2060,7 @@ setFileId(); //--------------------------------------- // Public API - var getPageInfo = API.__private__.getPageInfo = API.getPageInfo = function (pageNumberOneBased) { + var getPageInfo = API.__private__.getPageInfo = function (pageNumberOneBased) { if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) { throw new Error('Invalid argument passed to jsPDF.getPageInfo'); } @@ -2977,24 +2088,24 @@ return getPageInfo(pageNumber); }; - var getCurrentPageInfo = API.__private__.getCurrentPageInfo = API.getCurrentPageInfo = function () { + var getCurrentPageInfo = API.__private__.getCurrentPageInfo = function () { return { objId: pagesContext[currentPage].objId, pageNumber: currentPage, pageContext: pagesContext[currentPage] }; }; - /** - * Adds (and transfers the focus to) new page to the PDF document. - * @param format {String/Array} The format of the new page. Can be:
- * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89] - * @param orientation {string} Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l"). - * @function - * @instance - * @returns {jsPDF} - * - * @memberof jsPDF# - * @name addPage + /** + * Adds (and transfers the focus to) new page to the PDF document. + * @param format {String/Array} The format of the new page. Can be:
+ * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89] + * @param orientation {string} Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l"). + * @function + * @instance + * @returns {jsPDF} + * + * @memberOf jsPDF + * @name addPage */ @@ -3003,22 +2114,22 @@ return this; }; - /** - * Adds (and transfers the focus to) new page to the PDF document. - * @function - * @instance - * @returns {jsPDF} - * - * @memberof jsPDF# - * @name setPage - * @param {number} page Switch the active page to the page number specified. - * @example - * doc = jsPDF() - * doc.addPage() - * doc.addPage() - * doc.text('I am on page 3', 10, 10) - * doc.setPage(1) - * doc.text('I am on page 1', 10, 10) + /** + * Adds (and transfers the focus to) new page to the PDF document. + * @function + * @instance + * @returns {jsPDF} + * + * @memberOf jsPDF + * @name setPage + * @param {number} page Switch the active page to the page number specified. + * @example + * doc = jsPDF() + * doc.addPage() + * doc.addPage() + * doc.text('I am on page 3', 10, 10) + * doc.setPage(1) + * doc.text('I am on page 1', 10, 10) */ @@ -3027,14 +2138,14 @@ return this; }; - /** - * @name insertPage - * @memberof jsPDF# - * - * @function - * @instance - * @param {Object} beforePage - * @returns {jsPDF} + /** + * @name insertPage + * @memberOf jsPDF + * + * @function + * @instance + * @param {Object} beforePage + * @returns {jsPDF} */ @@ -3043,23 +2154,21 @@ this.movePage(currentPage, beforePage); return this; }; - /** - * @name movePage - * @memberof jsPDF# - * @function - * @instance - * @param {number} targetPage - * @param {number} beforePage - * @returns {jsPDF} + /** + * @name movePage + * @memberOf jsPDF + * @function + * @instance + * @param {Object} targetPage + * @param {Object} beforePage + * @returns {jsPDF} */ API.movePage = function (targetPage, beforePage) { - var tmpPages, tmpPagesContext; - if (targetPage > beforePage) { - tmpPages = pages[targetPage]; - tmpPagesContext = pagesContext[targetPage]; + var tmpPages = pages[targetPage]; + var tmpPagesContext = pagesContext[targetPage]; for (var i = targetPage; i > beforePage; i--) { pages[i] = pages[i - 1]; @@ -3070,12 +2179,12 @@ pagesContext[beforePage] = tmpPagesContext; this.setPage(beforePage); } else if (targetPage < beforePage) { - tmpPages = pages[targetPage]; - tmpPagesContext = pagesContext[targetPage]; + var tmpPages = pages[targetPage]; + var tmpPagesContext = pagesContext[targetPage]; - for (var j = targetPage; j < beforePage; j++) { - pages[j] = pages[j + 1]; - pagesContext[j] = pagesContext[j + 1]; + for (var i = targetPage; i < beforePage; i++) { + pages[i] = pages[i + 1]; + pagesContext[i] = pagesContext[i + 1]; } pages[beforePage] = tmpPages; @@ -3085,14 +2194,13 @@ return this; }; - /** - * Deletes a page from the PDF. - * @name deletePage - * @memberof jsPDF# - * @function - * @param {number} targetPage - * @instance - * @returns {jsPDF} + /** + * Deletes a page from the PDF. + * @name deletePage + * @memberOf jsPDF + * @function + * @instance + * @returns {jsPDF} */ @@ -3101,54 +2209,45 @@ return this; }; - /** - * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings. - * - * @function - * @instance - * @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call. - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {Object} [options] - Collection of settings signaling how the text must be encoded. - * @param {string} [options.align=left] - The alignment of the text, possible values: left, center, right, justify. - * @param {string} [options.baseline=alphabetic] - Sets text baseline used when drawing the text, possible values: alphabetic, ideographic, bottom, top, middle, hanging - * @param {string} [options.angle=0] - Rotate the text clockwise or counterclockwise. Expects the angle in degree. - * @param {string} [options.rotationDirection=1] - Direction of the rotation. 0 = clockwise, 1 = counterclockwise. - * @param {string} [options.charSpace=0] - The space between each letter. - * @param {string} [options.lineHeightFactor=1.15] - The lineheight of each line. - * @param {string} [options.flags] - Flags for to8bitStream. - * @param {string} [options.flags.noBOM=true] - Don't add BOM to Unicode-text. - * @param {string} [options.flags.autoencode=true] - Autoencode the Text. - * @param {string} [options.maxWidth=0] - Split the text by given width, 0 = no split. - * @param {string} [options.renderingMode=fill] - Set how the text should be rendered, possible values: fill, stroke, fillThenStroke, invisible, fillAndAddForClipping, strokeAndAddPathForClipping, fillThenStrokeAndAddToPathForClipping, addToPathForClipping. - * @param {number|Matrix} transform If transform is a number the text will be rotated by this value around the anchor set by x and y. - * - * If it is a Matrix, this matrix gets directly applied to the text, which allows shearing - * effects etc.; the x and y offsets are then applied AFTER the coordinate system has been established by this - * matrix. This means passing a rotation matrix that is equivalent to some rotation angle will in general yield a - * DIFFERENT result. A matrix is only allowed in "advanced" API mode. - * @returns {jsPDF} - * @memberof jsPDF# - * @name text + /** + * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings. + * + * @function + * @instance + * @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call. + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {Object} [options] - Collection of settings signaling how the text must be encoded. + * @param {string} [options.align=left] - The alignment of the text, possible values: left, center, right, justify. + * @param {string} [options.baseline=alphabetic] - Sets text baseline used when drawing the text, possible values: alphabetic, ideographic, bottom, top, middle. + * @param {string} [options.angle=0] - Rotate the text counterclockwise. Expects the angle in degree. + * @param {string} [options.charSpace=0] - The space between each letter. + * @param {string} [options.lineHeightFactor=1.15] - The lineheight of each line. + * @param {string} [options.flags] - Flags for to8bitStream. + * @param {string} [options.flags.noBOM=true] - Don't add BOM to Unicode-text. + * @param {string} [options.flags.autoencode=true] - Autoencode the Text. + * @param {string} [options.maxWidth=0] - Split the text by given width, 0 = no split. + * @param {string} [options.renderingMode=fill] - Set how the text should be rendered, possible values: fill, stroke, fillThenStroke, invisible, fillAndAddForClipping, strokeAndAddPathForClipping, fillThenStrokeAndAddToPathForClipping, addToPathForClipping. + * @returns {jsPDF} + * @memberOf jsPDF + * @name text */ - var text = API.__private__.text = API.text = function (text, x, y, options, transform) { - /* - * Inserts something like this into PDF - * BT - * /F1 16 Tf % Font name + size - * 16 TL % How many units down for next line in multiline text - * 0 g % color - * 28.35 813.54 Td % position - * (line one) Tj - * T* (line two) Tj - * T* (line three) Tj - * ET + var text = API.__private__.text = API.text = function (text, x, y, options) { + /** + * Inserts something like this into PDF + * BT + * /F1 16 Tf % Font name + size + * 16 TL % How many units down for next line in multiline text + * 0 g % color + * 28.35 813.54 Td % position + * (line one) Tj + * T* (line two) Tj + * T* (line three) Tj + * ET */ - options = options || {}; - var scope = options.scope || this; //backwardsCompatibility - + //backwardsCompatibility var tmp; // Pre-August-2012 the order of arguments was function(x, y, text, flags) // in effort to make all calls have similar signature like // function(data, coordinates... , miscellaneous) @@ -3162,39 +2261,37 @@ text = tmp; } - var transformationMatrix; - - if (arguments[3] instanceof Matrix === false) { - var flags = arguments[3]; - var angle = arguments[4]; - var align = arguments[5]; + var flags = arguments[3]; + var angle = arguments[4]; + var align = arguments[5]; - if (_typeof(flags) !== "object" || flags === null) { - if (typeof angle === 'string') { - align = angle; - angle = null; - } - - if (typeof flags === 'string') { - align = flags; - flags = null; - } + if (_typeof(flags) !== "object" || flags === null) { + if (typeof angle === 'string') { + align = angle; + angle = null; + } - if (typeof flags === 'number') { - angle = flags; - flags = null; - } + if (typeof flags === 'string') { + align = flags; + flags = null; + } - options = { - flags: flags, - angle: angle, - align: align - }; + if (typeof flags === 'number') { + angle = flags; + flags = null; } - } else { - transformationMatrix = arguments[3]; + + options = { + flags: flags, + angle: angle, + align: align + }; } + flags = flags || {}; + flags.noBOM = flags.noBOM || true; + flags.autoencode = flags.autoencode || true; + if (isNaN(x) || isNaN(y) || typeof text === "undefined" || text === null) { throw new Error('Invalid arguments passed to jsPDF.text'); } @@ -3206,7 +2303,7 @@ var xtra = ''; var isHex = false; var lineHeight = typeof options.lineHeightFactor === 'number' ? options.lineHeightFactor : lineHeightFactor; - var k = scope.internal.scaleFactor; + var scope = options.scope || this; function ESC(s) { s = s.split("\t").join(Array(options.TabLen || 9).join(" ")); @@ -3227,7 +2324,7 @@ if (typeof curDa === "string") { da.push(curDa); } else { - if (Array.isArray(text) && (curDa.length === 1 || curDa[1] === undefined && curDa[2] === undefined)) { + if (Array.isArray(text) && curDa.length === 1) { da.push(curDa[0]); } else { da.push([curDa[0], curDa[1], curDa[2]]); @@ -3257,7 +2354,7 @@ if (typeof curDa === "string") { da.push(processingFunction(curDa)[0]); - } else if (Array.isArray(curDa) && typeof curDa[0] === "string") { + } else if (Array.isArray(curDa) && curDa[0] === "string") { tmpResult = processingFunction(curDa[0], curDa[1], curDa[2]); da.push([tmpResult[0], tmpResult[1], tmpResult[2]]); } @@ -3296,6 +2393,15 @@ if (textIsOfTypeString === false) { throw new Error('Type of text must be string or Array. "' + text + '" is not recognized.'); + } //Escaping + + + var activeFontEncoding = fonts[activeFontKey].encoding; + + if (activeFontEncoding === "WinAnsiEncoding" || activeFontEncoding === "StandardEncoding") { + text = processTextByFunction(text, function (text, posX, posY) { + return [ESC(text), posX, posY]; + }); } //If there are any newlines in text, we assume //the user wanted to print multiple lines, so break the //text up into an array. If the text is already an array, @@ -3369,35 +2475,26 @@ options = payload.options; //angle var angle = options.angle; + var k = scope.internal.scaleFactor; + var transformationMatrix = []; - if (transformationMatrix instanceof Matrix === false && angle && typeof angle === "number") { + if (angle) { angle *= Math.PI / 180; - - if (options.rotationDirection === 0) { - angle = -angle; - } - - var c = Math.cos(angle); - var s = Math.sin(angle); - transformationMatrix = new Matrix(f2(c), f2(s), f2(s * -1), f2(c), 0, 0); - } else if (angle && angle instanceof Matrix) { - transformationMatrix = angle; + var c = Math.cos(angle), + s = Math.sin(angle); + transformationMatrix = [f2(c), f2(s), f2(s * -1), f2(c)]; } //charSpace - var charSpace = options.charSpace || activeCharSpace; + var charSpace = options.charSpace; if (typeof charSpace !== 'undefined') { xtra += f3(charSpace * k) + " Tc\n"; - this.setCharSpace(this.getCharSpace() || 0); } //lang var lang = options.lang; - //renderingMode - - - var renderingMode = -1; + var tmpRenderingMode = -1; var parmRenderingMode = typeof options.renderingMode !== "undefined" ? options.renderingMode : options.stroke; var pageContext = scope.internal.getCurrentPageInfo().pageContext; @@ -3405,64 +2502,65 @@ case 0: case false: case 'fill': - renderingMode = 0; + tmpRenderingMode = 0; break; case 1: case true: case 'stroke': - renderingMode = 1; + tmpRenderingMode = 1; break; case 2: case 'fillThenStroke': - renderingMode = 2; + tmpRenderingMode = 2; break; case 3: case 'invisible': - renderingMode = 3; + tmpRenderingMode = 3; break; case 4: case 'fillAndAddForClipping': - renderingMode = 4; + tmpRenderingMode = 4; break; case 5: case 'strokeAndAddPathForClipping': - renderingMode = 5; + tmpRenderingMode = 5; break; case 6: case 'fillThenStrokeAndAddToPathForClipping': - renderingMode = 6; + tmpRenderingMode = 6; break; case 7: case 'addToPathForClipping': - renderingMode = 7; + tmpRenderingMode = 7; break; } var usedRenderingMode = typeof pageContext.usedRenderingMode !== 'undefined' ? pageContext.usedRenderingMode : -1; //if the coder wrote it explicitly to use a specific //renderingMode, then use it - if (renderingMode !== -1) { - xtra += renderingMode + " Tr\n"; //otherwise check if we used the rendering Mode already + if (tmpRenderingMode !== -1) { + xtra += tmpRenderingMode + " Tr\n"; //otherwise check if we used the rendering Mode already //if so then set the rendering Mode... } else if (usedRenderingMode !== -1) { xtra += "0 Tr\n"; } - if (renderingMode !== -1) { - pageContext.usedRenderingMode = renderingMode; + if (tmpRenderingMode !== -1) { + pageContext.usedRenderingMode = tmpRenderingMode; } //align var align = options.align || 'left'; var leading = activeFontSize * lineHeight; var pageWidth = scope.internal.pageSize.getWidth(); + var k = scope.internal.scaleFactor; var activeFont = fonts[activeFontKey]; var charSpace = options.charSpace || activeCharSpace; var maxWidth = options.maxWidth || 0; @@ -3548,7 +2646,7 @@ newX = i === 0 ? getHorizontalCoordinate(x) : 0; if (i < len - 1) { - wordSpacingPerLine.push(f2((maxWidth - lineWidths[i]) / (da[i].split(" ").length - 1) * k)); + wordSpacingPerLine.push(((maxWidth - lineWidths[i]) / (da[i].split(" ").length - 1) * k).toFixed(2)); } text.push([da[i], newX, newY]); @@ -3582,78 +2680,53 @@ }; events.publish('postProcessText', payload); text = payload.text; - isHex = payload.mutex.isHex || false; //Escaping - - var activeFontEncoding = fonts[activeFontKey].encoding; - - if (activeFontEncoding === "WinAnsiEncoding" || activeFontEncoding === "StandardEncoding") { - text = processTextByFunction(text, function (text, posX, posY) { - return [ESC(text), posX, posY]; - }); - } - + isHex = payload.mutex.isHex; var da = transformTextToSpecialArray(text); text = []; - var STRING = 0; - var ARRAY = 1; - var variant = Array.isArray(da[0]) ? ARRAY : STRING; + var variant = 0; + var len = da.length; var posX; var posY; var content; var wordSpacing = ''; - var generatePosition = function generatePosition(parmPosX, parmPosY, parmTransformationMatrix) { - var position = ''; - - if (parmTransformationMatrix instanceof Matrix) { - parmTransformationMatrix.tx = parseFloat(f2(parmPosX)); - parmTransformationMatrix.ty = parseFloat(f2(parmPosY)); - position = parmTransformationMatrix.join(" ") + " Tm\n"; - } else { - position = f2(parmPosX) + " " + f2(parmPosY) + " Td\n"; - } - - return position; - }; - - for (var lineIndex = 0; lineIndex < da.length; lineIndex++) { + for (var i = 0; i < len; i++) { wordSpacing = ''; - switch (variant) { - case ARRAY: - content = (isHex ? "<" : "(") + da[lineIndex][0] + (isHex ? ">" : ")"); - posX = parseFloat(da[lineIndex][1]); - posY = parseFloat(da[lineIndex][2]); - break; - - case STRING: - content = (isHex ? "<" : "(") + da[lineIndex] + (isHex ? ">" : ")"); - posX = getHorizontalCoordinate(x); - posY = getVerticalCoordinate(y); - break; + if (!Array.isArray(da[i])) { + posX = getHorizontalCoordinate(x); + posY = getVerticalCoordinate(y); + content = (isHex ? "<" : "(") + da[i] + (isHex ? ">" : ")"); + } else { + posX = parseFloat(da[i][1]); + posY = parseFloat(da[i][2]); + content = (isHex ? "<" : "(") + da[i][0] + (isHex ? ">" : ")"); + variant = 1; } - if (wordSpacingPerLine !== undefined && wordSpacingPerLine[lineIndex] !== undefined) { - wordSpacing = wordSpacingPerLine[lineIndex] + " Tw\n"; + if (wordSpacingPerLine !== undefined && wordSpacingPerLine[i] !== undefined) { + wordSpacing = wordSpacingPerLine[i] + " Tw\n"; } - if (lineIndex === 0) { - text.push(wordSpacing + generatePosition(posX, posY, transformationMatrix) + content); - } else if (variant === STRING) { + if (transformationMatrix.length !== 0 && i === 0) { + text.push(wordSpacing + transformationMatrix.join(" ") + " " + posX.toFixed(2) + " " + posY.toFixed(2) + " Tm\n" + content); + } else if (variant === 1 || variant === 0 && i === 0) { + text.push(wordSpacing + posX.toFixed(2) + " " + posY.toFixed(2) + " Td\n" + content); + } else { text.push(wordSpacing + content); - } else if (variant === ARRAY) { - text.push(wordSpacing + generatePosition(posX, posY) + content); } } - text = variant === STRING ? text.join(" Tj\nT* ") : text.join(" Tj\n"); - text += " Tj\n"; - var result = 'BT\n/'; - result += activeFontKey + ' ' + activeFontSize + ' Tf\n'; // font face, style, size - - result += f2(activeFontSize * lineHeight) + ' TL\n'; // line spacing + if (variant === 0) { + text = text.join(" Tj\nT* "); + } else { + text = text.join(" Tj\n"); + } - result += textColor + '\n'; + text += " Tj\n"; + var result = 'BT\n/' + activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size + (activeFontSize * lineHeight).toFixed(2) + ' TL\n' + // line spacing + textColor + '\n'; result += xtra; result += text; result += "ET"; @@ -3661,52 +2734,37 @@ usedFonts[activeFontKey] = true; return scope; }; - /** - * Letter spacing method to print text with gaps - * - * @function - * @instance - * @param {String|Array} text String to be added to the page. - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page - * @param {number} spacing Spacing (in units declared at inception) - * @returns {jsPDF} - * @memberof jsPDF# - * @name lstext - * @deprecated We'll be removing this function. It doesn't take character width into account. + /** + * Letter spacing method to print text with gaps + * + * @function + * @instance + * @param {String|Array} text String to be added to the page. + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page + * @param {number} spacing Spacing (in units declared at inception) + * @returns {jsPDF} + * @memberOf jsPDF + * @name lstext + * @deprecated We'll be removing this function. It doesn't take character width into account. */ var lstext = API.__private__.lstext = API.lstext = function (text, x, y, charSpace) { + console.warn('jsPDF.lstext is deprecated'); return this.text(text, x, y, { charSpace: charSpace }); - }; // PDF supports these path painting and clip path operators: - // - // S - stroke - // s - close/stroke - // f (F) - fill non-zero - // f* - fill evenodd - // B - fill stroke nonzero - // B* - fill stroke evenodd - // b - close fill stroke nonzero - // b* - close fill stroke evenodd - // n - nothing (consume path) - // W - clip nonzero - // W* - clip evenodd - // - // In order to keep the API small, we omit the close-and-fill/stroke operators and provide a separate close() - // method. - - /** - * - * @name clip - * @function - * @instance - * @param {string} rule Only possible value is 'evenodd' - * @returns {jsPDF} - * @memberof jsPDF# - * @description All .clip() after calling drawing ops with a style argument of null. + }; + /** + * + * @name clip + * @function + * @instance + * @param {string} rule + * @returns {jsPDF} + * @memberOf jsPDF + * @description All .clip() after calling drawing ops with a style argument of null. */ @@ -3717,48 +2775,25 @@ out('W*'); } else { out('W'); - } - }; - /** - * Modify the current clip path by intersecting it with the current path using the even-odd rule. Note - * that this will NOT consume the current path. In order to only use this path for clipping call - * {@link API.discardPath} afterwards. - * - * @return jsPDF - * @memberof jsPDF# - * @name clipEvenOdd - */ + } // End the path object without filling or stroking it. + // This operator is a path-painting no-op, used primarily for the side effect of changing the current clipping path + // (see Section 4.4.3, “Clipping Path Operators”) - var clipEvenOdd = API.clipEvenOdd = function () { - clip('evenodd'); - return this; + out('n'); }; - /** - * This fixes the previous function clip(). Perhaps the 'stroke path' hack was due to the missing 'n' instruction? - * We introduce the fixed version so as to not break API. - * @param fillRule - * @deprecated - * @ignore + /** + * This fixes the previous function clip(). Perhaps the 'stroke path' hack was due to the missing 'n' instruction? + * We introduce the fixed version so as to not break API. + * @param fillRule + * @ignore */ var clip_fixed = API.__private__.clip_fixed = API.clip_fixed = function (rule) { + console.log("clip_fixed is deprecated"); API.clip(rule); }; - /** - * Consumes the current path without any effect. Mainly used in combination with {@link clip} or - * {@link clipEvenOdd}. The PDF "n" operator. - * @return {jsPDF} - * @memberof jsPDF# - * @name discardPath - */ - - - var discardPath = API.__private__.discardPath = API.discardPath = function () { - out("n"); - return this; - }; var isValidStyle = API.__private__.isValidStyle = function (style) { var validStyleVariants = [undefined, null, 'S', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*']; @@ -3771,7 +2806,7 @@ return result; }; - var getStyle = API.__private__.getStyle = API.getStyle = function (style) { + var getStyle = API.__private__.getStyle = function (style) { // see path-painting operators in PDF spec var op = 'S'; // stroke @@ -3780,319 +2815,110 @@ } else if (style === 'FD' || style === 'DF') { op = 'B'; // both } else if (style === 'f' || style === 'f*' || style === 'B' || style === 'B*') { - /* - Allow direct use of these PDF path-painting operators: - - f fill using nonzero winding number rule - - f* fill using even-odd rule - - B fill then stroke with fill using non-zero winding number rule - - B* fill then stroke with fill using even-odd rule + /* + Allow direct use of these PDF path-painting operators: + - f fill using nonzero winding number rule + - f* fill using even-odd rule + - B fill then stroke with fill using non-zero winding number rule + - B* fill then stroke with fill using even-odd rule */ op = style; } return op; }; - /** - * Close the current path. The PDF "h" operator. - * @return jsPDF - * @memberof jsPDF# - * @name close + /** + * Draw a line on the current page. + * + * @name line + * @function + * @instance + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @returns {jsPDF} + * @memberOf jsPDF */ - var close = API.close = function () { - out("h"); - return this; - }; - /** - * Stroke the path. The PDF "S" operator. - * @return jsPDF - * @memberof jsPDF# - * @name stroke - */ - + var line = API.__private__.line = API.line = function (x1, y1, x2, y2) { + if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) { + throw new Error('Invalid arguments passed to jsPDF.line'); + } - var stroke = API.stroke = function () { - out("S"); - return this; + return this.lines([[x2 - x1, y2 - y1]], x1, y1); }; - /** - * Fill the current path using the nonzero winding number rule. If a pattern is provided, the path will be filled - * with this pattern, otherwise with the current fill color. Equivalent to the PDF "f" operator. - * @param {PatternData=} pattern If provided the path will be filled with this pattern - * @return jsPDF - * @memberof jsPDF# - * @name fill + /** + * Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates. + * All data points in `lines` are relative to last line origin. + * `x`, `y` become x1,y1 for first line / curve in the set. + * For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point. + * For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1. + * + * @example .lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, [1,1], 'F', false) // line, line, bezier curve, line + * @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves). + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction. + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @param {boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name lines */ - var fill = API.fill = function (pattern) { - fillWithOptionalPattern("f", pattern); - return this; - }; - /** - * Fill the current path using the even-odd rule. The PDF f* operator. - * @see API.fill - * @param {PatternData=} pattern Optional pattern - * @return jsPDF - * @memberof jsPDF# - * @name fillEvenOdd - */ + var lines = API.__private__.lines = API.lines = function (lines, x, y, scale, style, closed) { + var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4, tmp; // Pre-August-2012 the order of arguments was function(x, y, lines, scale, style) + // in effort to make all calls have similar signature like + // function(content, coordinateX, coordinateY , miscellaneous) + // this method had its args flipped. + // code below allows backward compatibility with old arg order. + if (typeof lines === 'number') { + tmp = y; + y = x; + x = lines; + lines = tmp; + } - var fillEvenOdd = API.fillEvenOdd = function (pattern) { - fillWithOptionalPattern("f*", pattern); - return this; - }; - /** - * Fill using the nonzero winding number rule and then stroke the current Path. The PDF "B" operator. - * @see API.fill - * @param {PatternData=} pattern Optional pattern - * @return jsPDF - * @memberof jsPDF# - * @name fillStroke - */ + scale = scale || [1, 1]; + closed = closed || false; + if (isNaN(x) || isNaN(y) || !Array.isArray(lines) || !Array.isArray(scale) || !isValidStyle(style) || typeof closed !== 'boolean') { + throw new Error('Invalid arguments passed to jsPDF.lines'); + } // starting point - var fillStroke = API.fillStroke = function (pattern) { - fillWithOptionalPattern("B", pattern); - return this; - }; - /** - * Fill using the even-odd rule and then stroke the current Path. The PDF "B" operator. - * @see API.fill - * @param {PatternData=} pattern Optional pattern - * @return jsPDF - * @memberof jsPDF# - * @name fillStrokeEvenOdd - */ + out(f3(getHorizontalCoordinate(x)) + ' ' + f3(getVerticalCoordinate(y)) + ' m '); + scalex = scale[0]; + scaley = scale[1]; + l = lines.length; //, x2, y2 // bezier only. In page default measurement "units", *after* scaling + //, x3, y3 // bezier only. In page default measurement "units", *after* scaling + // ending point for all, lines and bezier. . In page default measurement "units", *after* scaling - var fillStrokeEvenOdd = API.fillStrokeEvenOdd = function (pattern) { - fillWithOptionalPattern("B*", pattern); - return this; - }; + x4 = x; // last / ending point = starting point for first item. - var fillWithOptionalPattern = function fillWithOptionalPattern(style, pattern) { - if (_typeof(pattern) === "object") { - fillWithPattern(pattern, style); - } else { - out(style); - } - }; + y4 = y; // last / ending point = starting point for first item. - var putStyle = function putStyle(style, patternKey, patternData) { - if (style === null || style === undefined) { - return; - } + for (i = 0; i < l; i++) { + leg = lines[i]; - style = getStyle(style); // stroking / filling / both the path + if (leg.length === 2) { + // simple line + x4 = leg[0] * scalex + x4; // here last x4 was prior ending point - if (!patternKey) { - out(style); - return; - } + y4 = leg[1] * scaley + y4; // here last y4 was prior ending point - if (!patternData) { - patternData = { - matrix: identityMatrix - }; - } + out(f3(getHorizontalCoordinate(x4)) + ' ' + f3(getVerticalCoordinate(y4)) + ' l'); + } else { + // bezier curve + x2 = leg[0] * scalex + x4; // here last x4 is prior ending point - if (patternData instanceof Matrix) { - patternData = { - matrix: patternData - }; - } - - patternData.key = patternKey; - patternData || (patternData = identityMatrix); - fillWithPattern(patternData, style); - }; - - var fillWithPattern = function fillWithPattern(patternData, style) { - var patternId = patternMap[patternData.key]; - var pattern = patterns[patternId]; - - if (pattern instanceof API.ShadingPattern) { - out("q"); - out(clipRuleFromStyle(style)); - - if (pattern.gState) { - API.setGState(pattern.gState); - } - - out(patternData.matrix.toString() + " cm"); - out("/" + patternId + " sh"); - out("Q"); - } else if (pattern instanceof API.TilingPattern) { - // pdf draws patterns starting at the bottom left corner and they are not affected by the global transformation, - // so we must flip them - var matrix = new Matrix(1, 0, 0, -1, 0, pageHeight); - - if (patternData.matrix) { - matrix = (patternData.matrix || identityMatrix).multiply(matrix); // we cannot apply a matrix to the pattern on use so we must abuse the pattern matrix and create new instances - // for each use - - patternId = pattern.createClone(patternData.key, patternData.boundingBox, patternData.xStep, patternData.yStep, matrix).id; - } - - out("q"); - out("/Pattern cs"); - out("/" + patternId + " scn"); - - if (pattern.gState) { - API.setGState(pattern.gState); - } - - out(style); - out("Q"); - } - }; - - var clipRuleFromStyle = function clipRuleFromStyle(style) { - switch (style) { - case "f": - case "F": - return "W n"; - - case "f*": - return "W* n"; - - case "B": - return "W S"; - - case "B*": - return "W* S"; - // these two are for compatibility reasons (in the past, calling any primitive method with a shading pattern - // and "n"/"S" as style would still fill/fill and stroke the path) - - case "S": - return "W S"; - - case "n": - return "W n"; - } - }; - /** - * Begin a new subpath by moving the current point to coordinates (x, y). The PDF "m" operator. - * @param {number} x - * @param {number} y - * @memberof jsPDF# - * @name moveTo - */ - - - var moveTo = API.moveTo = function (x, y) { - out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " m"); - }; - /** - * Append a straight line segment from the current point to the point (x, y). The PDF "l" operator. - * @param {number} x - * @param {number} y - * @memberof jsPDF# - * @name lineTo - */ - - - var lineTo = API.lineTo = function (x, y) { - out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " l"); - }; - /** - * Draw a line on the current page. - * - * @name line - * @function - * @instance - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. default: 'S' - * @returns {jsPDF} - * @memberof jsPDF# - */ - - - var line = API.__private__.line = API.line = function (x1, y1, x2, y2, style) { - style = style || 'S'; - - if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2) || !isValidStyle(style)) { - throw new Error('Invalid arguments passed to jsPDF.line'); - } - - return this.lines([[x2 - x1, y2 - y1]], x1, y1); - }; - /** - * Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates. - * All data points in `lines` are relative to last line origin. - * `x`, `y` become x1,y1 for first line / curve in the set. - * For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point. - * For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1. - * - * @example .lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, [1,1], 'F', false) // line, line, bezier curve, line - * @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves). - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction. - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @param {boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name lines - */ - - - var lines = API.__private__.lines = API.lines = function (lines, x, y, scale, style, closed) { - var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4, tmp; // Pre-August-2012 the order of arguments was function(x, y, lines, scale, style) - // in effort to make all calls have similar signature like - // function(content, coordinateX, coordinateY , miscellaneous) - // this method had its args flipped. - // code below allows backward compatibility with old arg order. - - if (typeof lines === 'number') { - tmp = y; - y = x; - x = lines; - lines = tmp; - } - - scale = scale || [1, 1]; - closed = closed || false; - - if (isNaN(x) || isNaN(y) || !Array.isArray(lines) || !Array.isArray(scale) || !isValidStyle(style) || typeof closed !== 'boolean') { - throw new Error('Invalid arguments passed to jsPDF.lines'); - } // starting point - - - out(f3(getHorizontalCoordinate(x)) + ' ' + f3(getVerticalCoordinate(y)) + ' m '); - scalex = scale[0]; - scaley = scale[1]; - l = lines.length; //, x2, y2 // bezier only. In page default measurement "units", *after* scaling - //, x3, y3 // bezier only. In page default measurement "units", *after* scaling - // ending point for all, lines and bezier. . In page default measurement "units", *after* scaling - - x4 = x; // last / ending point = starting point for first item. - - y4 = y; // last / ending point = starting point for first item. - - for (i = 0; i < l; i++) { - leg = lines[i]; - - if (leg.length === 2) { - // simple line - x4 = leg[0] * scalex + x4; // here last x4 was prior ending point - - y4 = leg[1] * scaley + y4; // here last y4 was prior ending point - - out(f3(getHorizontalCoordinate(x4)) + ' ' + f3(getVerticalCoordinate(y4)) + ' l'); - } else { - // bezier curve - x2 = leg[0] * scalex + x4; // here last x4 is prior ending point - - y2 = leg[1] * scaley + y4; // here last y4 is prior ending point + y2 = leg[1] * scaley + y4; // here last y4 is prior ending point x3 = leg[2] * scalex + x4; // here last x4 is prior ending point @@ -4117,62 +2943,19 @@ return this; }; - /** - * Similar to {@link API.lines} but all coordinates are interpreted as absolute coordinates instead of relative. - * @param {Array} lines An array of {op: operator, c: coordinates} object, where op is one of "m" (move to), "l" (line to) - * "c" (cubic bezier curve) and "h" (close (sub)path)). c is an array of coordinates. "m" and "l" expect two, "c" - * six and "h" an empty array (or undefined). - * @param {String=} style The style. Deprecated! - * @param {String=} patternKey The pattern key for the pattern that should be used to fill the path. Deprecated! - * @param {(Matrix|PatternData)=} patternData The matrix that transforms the pattern into user space, or an object that - * will modify the pattern on use. Deprecated! - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name path - */ - - - API.path = function (lines, style, patternKey, patternData) { - for (var i = 0; i < lines.length; i++) { - var leg = lines[i]; - var coords = leg.c; - - switch (leg.op) { - case "m": - this.moveTo(coords[0], coords[1]); - break; - - case "l": - this.lineTo(coords[0], coords[1]); - break; - - case "c": - this.curveTo.apply(this, coords); - break; - - case "h": - this.close(); - break; - } - } - - putStyle(style, patternKey, patternData); - return this; - }; - /** - * Adds a rectangle to PDF. - * - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} w Width (in units declared at inception of PDF document). - * @param {number} h Height (in units declared at inception of PDF document). - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name rect + /** + * Adds a rectangle to PDF. + * + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} w Width (in units declared at inception of PDF document). + * @param {number} h Height (in units declared at inception of PDF document). + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name rect */ @@ -4189,21 +2972,21 @@ return this; }; - /** - * Adds a triangle to PDF. - * - * @param {number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name triangle + /** + * Adds a triangle to PDF. + * + * @param {number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name triangle */ @@ -4219,21 +3002,21 @@ [1, 1], style, true); return this; }; - /** - * Adds a rectangle with rounded corners to PDF. - * - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} w Width (in units declared at inception of PDF document). - * @param {number} h Height (in units declared at inception of PDF document). - * @param {number} rx Radius along x axis (in units declared at inception of PDF document). - * @param {number} ry Radius along y axis (in units declared at inception of PDF document). - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name roundedRect + /** + * Adds a rectangle with rounded corners to PDF. + * + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} w Width (in units declared at inception of PDF document). + * @param {number} h Height (in units declared at inception of PDF document). + * @param {number} rx Radius along x axis (in units declared at inception of PDF document). + * @param {number} ry Radius along y axis (in units declared at inception of PDF document). + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name roundedRect */ @@ -4247,19 +3030,19 @@ [1, 1], style); return this; }; - /** - * Adds an ellipse to PDF. - * - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} rx Radius along x axis (in units declared at inception of PDF document). - * @param {number} ry Radius along y axis (in units declared at inception of PDF document). - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name ellipse + /** + * Adds an ellipse to PDF. + * + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} rx Radius along x axis (in units declared at inception of PDF document). + * @param {number} ry Radius along y axis (in units declared at inception of PDF document). + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name ellipse */ @@ -4281,18 +3064,18 @@ return this; }; - /** - * Adds an circle to PDF. - * - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. - * @param {number} r Radius (in units declared at inception of PDF document). - * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name circle + /** + * Adds an circle to PDF. + * + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page. + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page. + * @param {number} r Radius (in units declared at inception of PDF document). + * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name circle */ @@ -4303,70 +3086,55 @@ return this.ellipse(x, y, r, r, style); }; - /** - * Sets text font face, variant for upcoming text elements. - * See output of jsPDF.getFontList() for possible font names, styles. - * - * @param {string} fontName Font name or family. Example: "times". - * @param {string} fontStyle Font style or variant. Example: "italic". - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setFont + /** + * Sets text font face, variant for upcoming text elements. + * See output of jsPDF.getFontList() for possible font names, styles. + * + * @param {string} fontName Font name or family. Example: "times". + * @param {string} fontStyle Font style or variant. Example: "italic". + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setFont */ API.setFont = function (fontName, fontStyle) { - activeFontKey = getFont(fontName, fontStyle, { + activeFontKey = _getFont(fontName, fontStyle, { disableWarning: false }); return this; }; - /** - * Gets text font face, variant for upcoming text elements. - * - * @function - * @instance - * @returns {Object} - * @memberof jsPDF# - * @name getFont - */ - - - var getFontEntry = API.__private__.getFont = API.getFont = function () { - return fonts[getFont.apply(API, arguments)]; - }; - /** - * Switches font style or variant for upcoming text elements, - * while keeping the font face or family same. - * See output of jsPDF.getFontList() for possible font names, styles. - * - * @param {string} style Font style or variant. Example: "italic". - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @deprecated - * @name setFontStyle + /** + * Switches font style or variant for upcoming text elements, + * while keeping the font face or family same. + * See output of jsPDF.getFontList() for possible font names, styles. + * + * @param {string} style Font style or variant. Example: "italic". + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setFontStyle */ API.setFontStyle = API.setFontType = function (style) { - activeFontKey = getFont(undefined, style); // if font is not found, the above line blows up and we never go further + activeFontKey = _getFont(undefined, style); // if font is not found, the above line blows up and we never go further return this; }; - /** - * Returns an object - a tree of fontName to fontStyle relationships available to - * active PDF document. - * - * @public - * @function - * @instance - * @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... } - * @memberof jsPDF# - * @name getFontList + /** + * Returns an object - a tree of fontName to fontStyle relationships available to + * active PDF document. + * + * @public + * @function + * @instance + * @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... } + * @memberOf jsPDF + * @name getFontList */ @@ -4391,17 +3159,17 @@ return list; }; - /** - * Add a custom font to the current instance. - * - * @property {string} postScriptName PDF specification full name for the font. - * @property {string} id PDF-document-instance-specific label assinged to the font. - * @property {string} fontStyle Style of the Font. - * @property {Object} encoding Encoding_name-to-Font_metrics_object mapping. - * @function - * @instance - * @memberof jsPDF# - * @name addFont + /** + * Add a custom font to the current instance. + * + * @property {string} postScriptName PDF specification full name for the font. + * @property {string} id PDF-document-instance-specific label assinged to the font. + * @property {string} fontStyle Style of the Font. + * @property {Object} encoding Encoding_name-to-Font_metrics_object mapping. + * @function + * @instance + * @memberOf jsPDF + * @name addFont */ @@ -4412,34 +3180,32 @@ var lineWidth = options.lineWidth || 0.200025; // 2mm - /** - * Sets line width for upcoming lines. - * - * @param {number} width Line width (in units declared at inception of PDF document). - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineWidth + /** + * Sets line width for upcoming lines. + * + * @param {number} width Line width (in units declared at inception of PDF document). + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setLineWidth */ var setLineWidth = API.__private__.setLineWidth = API.setLineWidth = function (width) { - out(f2(width * k) + ' w'); + out((width * k).toFixed(2) + ' w'); return this; }; - /** - * Sets the dash pattern for upcoming lines. - * - * To reset the settings simply call the method without any parameters. - * @param {Array} dashArray An array containing 0-2 numbers. The first number sets the length of the - * dashes, the second number the length of the gaps. If the second number is missing, the gaps are considered - * to be as long as the dashes. An empty array means solid, unbroken lines. - * @param {number} dashPhase The phase lines start with. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineDashPattern + /** + * Sets the dash pattern for upcoming lines. + * + * To reset the settings simply call the method without any parameters. + * @param {array} dashArray The pattern of the line, expects numbers. + * @param {number} dashPhase The phase at which the dash pattern starts. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setLineDash */ @@ -4452,9 +3218,9 @@ } dashArray = dashArray.map(function (x) { - return f3(x * k); + return (x * k).toFixed(3); }).join(' '); - dashPhase = f3(dashPhase * k); + dashPhase = parseFloat((dashPhase * k).toFixed(3)); out('[' + dashArray + '] ' + dashPhase + ' d'); return this; }; @@ -4470,15 +3236,15 @@ var getLineHeight = API.__private__.getLineHeight = API.getLineHeight = function () { return activeFontSize * lineHeightFactor; }; - /** - * Sets the LineHeightFactor of proportion. - * - * @param {number} value LineHeightFactor value. Default: 1.15. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineHeightFactor + /** + * Sets the LineHeightFactor of proportion. + * + * @param {number} value LineHeightFactor value. Default: 1.15. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setLineHeightFactor */ @@ -4491,14 +3257,14 @@ return this; }; - /** - * Gets the LineHeightFactor, default: 1.15. - * - * @function - * @instance - * @returns {number} lineHeightFactor - * @memberof jsPDF# - * @name getLineHeightFactor + /** + * Gets the LineHeightFactor, default: 1.15. + * + * @function + * @instance + * @returns {number} lineHeightFactor + * @memberOf jsPDF + * @name getLineHeightFactor */ @@ -4509,72 +3275,72 @@ setLineHeightFactor(options.lineHeight); var getHorizontalCoordinate = API.__private__.getHorizontalCoordinate = function (value) { - return scale(value); + return value * k; }; var getVerticalCoordinate = API.__private__.getVerticalCoordinate = function (value) { - return pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - scale(value); + return pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - value * k; }; - var getHorizontalCoordinateString = API.__private__.getHorizontalCoordinateString = API.getHorizontalCoordinateString = function (value) { - return f2(scale(value)); + var getHorizontalCoordinateString = API.__private__.getHorizontalCoordinateString = function (value) { + return f2(value * k); }; - var getVerticalCoordinateString = API.__private__.getVerticalCoordinateString = API.getVerticalCoordinateString = function (value) { - return f2(pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - scale(value)); + var getVerticalCoordinateString = API.__private__.getVerticalCoordinateString = function (value) { + return f2(pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - value * k); }; var strokeColor = options.strokeColor || '0 G'; - /** - * Gets the stroke color for upcoming elements. - * - * @function - * @instance - * @returns {string} colorAsHex - * @memberof jsPDF# - * @name getDrawColor + /** + * Gets the stroke color for upcoming elements. + * + * @function + * @instance + * @returns {string} colorAsHex + * @memberOf jsPDF + * @name getDrawColor */ var getStrokeColor = API.__private__.getStrokeColor = API.getDrawColor = function () { return decodeColorString(strokeColor); }; - /** - * Sets the stroke color for upcoming elements. - * - * Depending on the number of arguments given, Gray, RGB, or CMYK - * color space is implied. - * - * When only ch1 is given, "Gray" color space is implied and it - * must be a value in the range from 0.00 (solid black) to to 1.00 (white) - * if values are communicated as String types, or in range from 0 (black) - * to 255 (white) if communicated as Number type. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each - * value must be in the range from 0.00 (minimum intensity) to to 1.00 - * (max intensity) if values are communicated as String types, or - * from 0 (min intensity) to to 255 (max intensity) if values are communicated - * as Number types. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each - * value must be a in the range from 0.00 (0% concentration) to to - * 1.00 (100% concentration) - * - * Because JavaScript treats fixed point numbers badly (rounds to - * floating point nearest to binary representation) it is highly advised to - * communicate the fractional numbers as String types, not JavaScript Number type. - * - * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. - * @param {Number} ch2 Color channel value. - * @param {Number} ch3 Color channel value. - * @param {Number} ch4 Color channel value. - * - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setDrawColor + /** + * Sets the stroke color for upcoming elements. + * + * Depending on the number of arguments given, Gray, RGB, or CMYK + * color space is implied. + * + * When only ch1 is given, "Gray" color space is implied and it + * must be a value in the range from 0.00 (solid black) to to 1.00 (white) + * if values are communicated as String types, or in range from 0 (black) + * to 255 (white) if communicated as Number type. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each + * value must be in the range from 0.00 (minimum intensity) to to 1.00 + * (max intensity) if values are communicated as String types, or + * from 0 (min intensity) to to 255 (max intensity) if values are communicated + * as Number types. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each + * value must be a in the range from 0.00 (0% concentration) to to + * 1.00 (100% concentration) + * + * Because JavaScript treats fixed point numbers badly (rounds to + * floating point nearest to binary representation) it is highly advised to + * communicate the fractional numbers as String types, not JavaScript Number type. + * + * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. + * @param {Number|String} ch2 Color channel value. + * @param {Number|String} ch3 Color channel value. + * @param {Number|String} ch4 Color channel value. + * + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setDrawColor */ @@ -4593,56 +3359,56 @@ }; var fillColor = options.fillColor || '0 g'; - /** - * Gets the fill color for upcoming elements. - * - * @function - * @instance - * @returns {string} colorAsHex - * @memberof jsPDF# - * @name getFillColor + /** + * Gets the fill color for upcoming elements. + * + * @function + * @instance + * @returns {string} colorAsHex + * @memberOf jsPDF + * @name getFillColor */ var getFillColor = API.__private__.getFillColor = API.getFillColor = function () { return decodeColorString(fillColor); }; - /** - * Sets the fill color for upcoming elements. - * - * Depending on the number of arguments given, Gray, RGB, or CMYK - * color space is implied. - * - * When only ch1 is given, "Gray" color space is implied and it - * must be a value in the range from 0.00 (solid black) to to 1.00 (white) - * if values are communicated as String types, or in range from 0 (black) - * to 255 (white) if communicated as Number type. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each - * value must be in the range from 0.00 (minimum intensity) to to 1.00 - * (max intensity) if values are communicated as String types, or - * from 0 (min intensity) to to 255 (max intensity) if values are communicated - * as Number types. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each - * value must be a in the range from 0.00 (0% concentration) to to - * 1.00 (100% concentration) - * - * Because JavaScript treats fixed point numbers badly (rounds to - * floating point nearest to binary representation) it is highly advised to - * communicate the fractional numbers as String types, not JavaScript Number type. - * - * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. - * @param {Number} ch2 Color channel value. - * @param {Number} ch3 Color channel value. - * @param {Number} ch4 Color channel value. - * - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setFillColor + /** + * Sets the fill color for upcoming elements. + * + * Depending on the number of arguments given, Gray, RGB, or CMYK + * color space is implied. + * + * When only ch1 is given, "Gray" color space is implied and it + * must be a value in the range from 0.00 (solid black) to to 1.00 (white) + * if values are communicated as String types, or in range from 0 (black) + * to 255 (white) if communicated as Number type. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each + * value must be in the range from 0.00 (minimum intensity) to to 1.00 + * (max intensity) if values are communicated as String types, or + * from 0 (min intensity) to to 255 (max intensity) if values are communicated + * as Number types. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each + * value must be a in the range from 0.00 (0% concentration) to to + * 1.00 (100% concentration) + * + * Because JavaScript treats fixed point numbers badly (rounds to + * floating point nearest to binary representation) it is highly advised to + * communicate the fractional numbers as String types, not JavaScript Number type. + * + * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. + * @param {Number|String} ch2 Color channel value. + * @param {Number|String} ch3 Color channel value. + * @param {Number|String} ch4 Color channel value. + * + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setFillColor */ @@ -4661,56 +3427,56 @@ }; var textColor = options.textColor || '0 g'; - /** - * Gets the text color for upcoming elements. - * - * @function - * @instance - * @returns {string} colorAsHex - * @memberof jsPDF# - * @name getTextColor + /** + * Gets the text color for upcoming elements. + * + * @function + * @instance + * @returns {string} colorAsHex + * @memberOf jsPDF + * @name getTextColor */ var getTextColor = API.__private__.getTextColor = API.getTextColor = function () { return decodeColorString(textColor); }; - /** - * Sets the text color for upcoming elements. - * - * Depending on the number of arguments given, Gray, RGB, or CMYK - * color space is implied. - * - * When only ch1 is given, "Gray" color space is implied and it - * must be a value in the range from 0.00 (solid black) to to 1.00 (white) - * if values are communicated as String types, or in range from 0 (black) - * to 255 (white) if communicated as Number type. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each - * value must be in the range from 0.00 (minimum intensity) to to 1.00 - * (max intensity) if values are communicated as String types, or - * from 0 (min intensity) to to 255 (max intensity) if values are communicated - * as Number types. - * The RGB-like 0-255 range is provided for backward compatibility. - * - * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each - * value must be a in the range from 0.00 (0% concentration) to to - * 1.00 (100% concentration) - * - * Because JavaScript treats fixed point numbers badly (rounds to - * floating point nearest to binary representation) it is highly advised to - * communicate the fractional numbers as String types, not JavaScript Number type. - * - * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. - * @param {Number} ch2 Color channel value. - * @param {Number} ch3 Color channel value. - * @param {Number} ch4 Color channel value. - * - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setTextColor + /** + * Sets the text color for upcoming elements. + * + * Depending on the number of arguments given, Gray, RGB, or CMYK + * color space is implied. + * + * When only ch1 is given, "Gray" color space is implied and it + * must be a value in the range from 0.00 (solid black) to to 1.00 (white) + * if values are communicated as String types, or in range from 0 (black) + * to 255 (white) if communicated as Number type. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each + * value must be in the range from 0.00 (minimum intensity) to to 1.00 + * (max intensity) if values are communicated as String types, or + * from 0 (min intensity) to to 255 (max intensity) if values are communicated + * as Number types. + * The RGB-like 0-255 range is provided for backward compatibility. + * + * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each + * value must be a in the range from 0.00 (0% concentration) to to + * 1.00 (100% concentration) + * + * Because JavaScript treats fixed point numbers badly (rounds to + * floating point nearest to binary representation) it is highly advised to + * communicate the fractional numbers as String types, not JavaScript Number type. + * + * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. + * @param {Number|String} ch2 Color channel value. + * @param {Number|String} ch3 Color channel value. + * @param {Number|String} ch4 Color channel value. + * + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setTextColor */ @@ -4727,29 +3493,29 @@ return this; }; - var activeCharSpace = options.charSpace; - /** - * Get global value of CharSpace. - * - * @function - * @instance - * @returns {number} charSpace - * @memberof jsPDF# - * @name getCharSpace + var activeCharSpace = options.charSpace || 0; + /** + * Get global value of CharSpace. + * + * @function + * @instance + * @returns {number} charSpace + * @memberOf jsPDF + * @name getCharSpace */ var getCharSpace = API.__private__.getCharSpace = API.getCharSpace = function () { - return parseFloat(activeCharSpace || 0); - }; - /** - * Set global value of CharSpace. - * - * @param {number} charSpace - * @function - * @instance - * @returns {jsPDF} jsPDF-instance - * @memberof jsPDF# - * @name setCharSpace + return activeCharSpace; + }; + /** + * Set global value of CharSpace. + * + * @param {number} charSpace + * @function + * @instance + * @returns {jsPDF} jsPDF-instance + * @memberOf jsPDF + * @name setCharSpace */ @@ -4763,13 +3529,13 @@ }; var lineCapID = 0; - /** - * Is an Object providing a mapping from human-readable to - * integer flag values designating the varieties of line cap - * and join styles. - * - * @memberof jsPDF# - * @name CapJoinStyles + /** + * Is an Object providing a mapping from human-readable to + * integer flag values designating the varieties of line cap + * and join styles. + * + * @memberOf jsPDF + * @name CapJoinStyles */ API.CapJoinStyles = { @@ -4787,16 +3553,16 @@ 'square': 2, 'bevel': 2 }; - /** - * Sets the line cap styles. - * See {jsPDF.CapJoinStyles} for variants. - * - * @param {String|Number} style A string or number identifying the type of line cap. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineCap + /** + * Sets the line cap styles. + * See {jsPDF.CapJoinStyles} for variants. + * + * @param {String|Number} style A string or number identifying the type of line cap. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setLineCap */ var setLineCap = API.__private__.setLineCap = API.setLineCap = function (style) { @@ -4812,16 +3578,16 @@ }; var lineJoinID = 0; - /** - * Sets the line join styles. - * See {jsPDF.CapJoinStyles} for variants. - * - * @param {String|Number} style A string or number identifying the type of line join. - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineJoin + /** + * Sets the line join styles. + * See {jsPDF.CapJoinStyles} for variants. + * + * @param {String|Number} style A string or number identifying the type of line join. + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setLineJoin */ var setLineJoin = API.__private__.setLineJoin = API.setLineJoin = function (style) { @@ -4837,453 +3603,39 @@ }; var miterLimit; - /** - * Sets the miterLimit property, which effects the maximum miter length. - * - * @param {number} length The length of the miter - * @function - * @instance - * @returns {jsPDF} - * @memberof jsPDF# - * @name setLineMiterLimit + /** + * Sets the miterLimit property, which effects the maximum miter length. + * + * @param {number} length The length of the miter + * @function + * @instance + * @returns {jsPDF} + * @memberOf jsPDF + * @name setMiterLimit */ - var setLineMiterLimit = API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function (length) { + var setMiterLimit = API.__private__.setMiterLimit = API.setMiterLimit = function (length) { length = length || 0; if (isNaN(length)) { - throw new Error('Invalid argument passed to jsPDF.setLineMiterLimit'); + throw new Error('Invalid argument passed to jsPDF.setMiterLimit'); } miterLimit = parseFloat(f2(length * k)); out(miterLimit + ' M'); return this; }; - /** - * GState - */ - - /** - * An object representing a pdf graphics state. - * @param parameters A parameter object that contains all properties this graphics state wants to set. - * Supported are: opacity, stroke-opacity - * @constructor - */ - - - API.GState = function (parameters) { - var supported = "opacity,stroke-opacity".split(","); - - for (var p in parameters) { - if (parameters.hasOwnProperty(p) && supported.indexOf(p) >= 0) { - this[p] = parameters[p]; - } - } - - this.id = ""; // set by addGState() - - this.objectNumber = -1; // will be set by putGState() - }; - - API.GState.prototype.equals = function equals(other) { - var ignore = "id,objectNumber,equals"; - var p; - if (!other || _typeof(other) !== _typeof(this)) { return false; } - var count = 0; - - for (p in this) { - if (ignore.indexOf(p) >= 0) { continue; } - if (this.hasOwnProperty(p) && !other.hasOwnProperty(p)) { return false; } - if (this[p] !== other[p]) { return false; } - count++; - } - - for (p in other) { - if (other.hasOwnProperty(p) && ignore.indexOf(p) < 0) { count--; } - } - - return count === 0; - }; - /** - * Sets a either previously added {@link GState} (via {@link addGState}) or a new {@link GState}. - * @param {String|GState} gState If type is string, a previously added GState is used, if type is GState - * it will be added before use. - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name setGState - */ - - - API.setGState = function (gState) { - if (typeof gState === "string") { - gState = gStates[gStatesMap[gState]]; - } else { - gState = addGState(null, gState); - } - - if (!gState.equals(activeGState)) { - out("/" + gState.id + " gs"); - activeGState = gState; - } - }; - /** - * Adds a new Graphics State. Duplicates are automatically eliminated. - * @param {String} key Might also be null, if no later reference to this gState is needed - * @param {Object} gState The gState object - */ - - - var addGState = function addGState(key, gState) { - // only add it if it is not already present (the keys provided by the user must be unique!) - if (key && gStatesMap[key]) { return; } - var duplicate = false; - - for (var s in gStates) { - if (gStates.hasOwnProperty(s)) { - if (gStates[s].equals(gState)) { - duplicate = true; - break; - } - } - } - - if (duplicate) { - gState = gStates[s]; - } else { - var gStateKey = "GS" + (Object.keys(gStates).length + 1).toString(10); - gStates[gStateKey] = gState; - gState.id = gStateKey; - } // several user keys may point to the same GState object - - - key && (gStatesMap[key] = gState.id); - events.publish("addGState", gState); - return gState; - }; - /** - * Adds a new {@link GState} for later use. See {@link setGState}. - * @param {String} key - * @param {GState} gState - * @function - * @instance - * @returns {jsPDF} - * - * @memberof jsPDF# - * @name addGState - */ - - - API.addGState = function (key, gState) { - addGState(key, gState); - return this; - }; - /** - * Saves the current graphics state ("pushes it on the stack"). It can be restored by {@link restoreGraphicsState} - * later. Here, the general pdf graphics state is meant, also including the current transformation matrix, - * fill and stroke colors etc. - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name saveGraphicsState - */ - - - API.saveGraphicsState = function () { - out("q"); // as we cannot set font key and size independently we must keep track of both - - fontStateStack.push({ - key: activeFontKey, - size: activeFontSize, - color: textColor - }); - return this; - }; - /** - * Restores a previously saved graphics state saved by {@link saveGraphicsState} ("pops the stack"). - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name restoreGraphicsState - */ - - - API.restoreGraphicsState = function () { - out("Q"); // restore previous font state - - var fontState = fontStateStack.pop(); - activeFontKey = fontState.key; - activeFontSize = fontState.size; - textColor = fontState.color; - activeGState = null; - return this; - }; - /** - * Appends this matrix to the left of all previously applied matrices. - * - * @param {Matrix} matrix - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name setCurrentTransformationMatrix - */ - - - API.setCurrentTransformationMatrix = function (matrix) { - out(matrix.toString() + " cm"); - return this; - }; - /** - * Inserts a debug comment into the pdf. - * @param {String} text - * @returns {jsPDF} - * @memberof jsPDF# - * @name comment - */ - - - API.comment = function (text) { - out("#" + text); - return this; - }; - /** - * Matrix - */ - - - var Point = function Point(x, y) { - var _x = x || 0; - - Object.defineProperty(this, 'x', { - enumerable: true, - get: function get() { - return _x; - }, - set: function set(value) { - if (!isNaN(value)) { - _x = parseFloat(value); - } - } - }); - - var _y = y || 0; - - Object.defineProperty(this, 'y', { - enumerable: true, - get: function get() { - return _y; - }, - set: function set(value) { - if (!isNaN(value)) { - _y = parseFloat(value); - } - } - }); - var _type = 'pt'; - Object.defineProperty(this, 'type', { - enumerable: true, - get: function get() { - return _type; - }, - set: function set(value) { - _type = value.toString(); - } - }); - return this; - }; - - var Rectangle = function Rectangle(x, y, w, h) { - Point.call(this, x, y); - this.type = 'rect'; - - var _w = w || 0; - - Object.defineProperty(this, 'w', { - enumerable: true, - get: function get() { - return _w; - }, - set: function set(value) { - if (!isNaN(value)) { - _w = parseFloat(value); - } - } - }); - - var _h = h || 0; - - Object.defineProperty(this, 'h', { - enumerable: true, - get: function get() { - return _h; - }, - set: function set(value) { - if (!isNaN(value)) { - _h = parseFloat(value); - } - } - }); - return this; - }; - /** - * FormObject/RenderTarget - */ - - - var RenderTarget = function RenderTarget() { - this.page = page; - this.currentPage = currentPage; - this.pages = pages.slice(0); - this.pagedim = pagedim.slice(0); - this.pagesContext = pagesContext.slice(0); - this.x = pageX; - this.y = pageY; - this.matrix = pageMatrix; - this.width = pageWidth; - this.height = pageHeight; - this.id = ""; // set by endFormObject() - - this.objectNumber = -1; // will be set by putXObject() - }; - - RenderTarget.prototype = { - restore: function restore() { - page = this.page; - currentPage = this.currentPage; - pagesContext = this.pagesContext; - pagedim = this.pagedim; - pages = this.pages; - pageX = this.x; - pageY = this.y; - pageMatrix = this.matrix; - pageWidth = this.width; - pageHeight = this.height; - } - }; - - var beginNewRenderTarget = function beginNewRenderTarget(x, y, width, height, matrix) { - // save current state - renderTargetStack.push(new RenderTarget()); // clear pages - - page = currentPage = 0; - pages = []; - pageX = x; - pageY = y; - pageMatrix = matrix; - beginPage(width, height); - }; - - var endFormObject = function endFormObject(key) { - // only add it if it is not already present (the keys provided by the user must be unique!) - if (renderTargetMap[key]) { return; } // save the created xObject - - var newXObject = new RenderTarget(); - var xObjectId = "Xo" + (Object.keys(renderTargets).length + 1).toString(10); - newXObject.id = xObjectId; - renderTargetMap[key] = xObjectId; - renderTargets[xObjectId] = newXObject; - events.publish("addFormObject", newXObject); // restore state from stack - - renderTargetStack.pop().restore(); - }; - /** - * Starts a new pdf form object, which means that all consequent draw calls target a new independent object - * until {@link endFormObject} is called. The created object can be referenced and drawn later using - * {@link doFormObject}. Nested form objects are possible. - * x, y, width, height set the bounding box that is used to clip the content. - * - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - * @param {Matrix} matrix The matrix that will be applied to convert the form objects coordinate system to - * the parent's. - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name beginFormObject - */ - - - API.beginFormObject = function (x, y, width, height, matrix) { - // The user can set the output target to a new form object. Nested form objects are possible. - // Currently, they use the resource dictionary of the surrounding stream. This should be changed, as - // the PDF-Spec states: - // "In PDF 1.2 and later versions, form XObjects may be independent of the content streams in which - // they appear, and this is strongly recommended although not requiredIn PDF 1.2 and later versions, - // form XObjects may be independent of the content streams in which they appear, and this is strongly - // recommended although not required" - beginNewRenderTarget(x, y, width, height, matrix); - return this; - }; - /** - * Completes and saves the form object. - * @param {String} key The key by which this form object can be referenced. - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name endFormObject - */ - - - API.endFormObject = function (key) { - endFormObject(key); - return this; - }; - /** - * Draws the specified form object by referencing to the respective pdf XObject created with - * {@link API.beginFormObject} and {@link endFormObject}. - * The location is determined by matrix. - * - * @param {String} key The key to the form object. - * @param {Matrix} matrix The matrix applied before drawing the form object. - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name doFormObject - */ - - - API.doFormObject = function (key, matrix) { - var xObject = renderTargets[renderTargetMap[key]]; - out("q"); - out(matrix.toString() + " cm"); - out("/" + xObject.id + " Do"); - out("Q"); - return this; - }; - /** - * Returns the form object specified by key. - * @param key {String} - * @returns {{x: number, y: number, width: number, height: number, matrix: Matrix}} - * @function - * @returns {jsPDF} - * @memberof jsPDF# - * @name getFormObject - */ - - - API.getFormObject = function (key) { - var xObject = renderTargets[renderTargetMap[key]]; - return { - x: xObject.x, - y: xObject.y, - width: xObject.width, - height: xObject.height, - matrix: xObject.matrix - }; - }; - /** - * Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf'). - * Uses FileSaver.js-method saveAs. - * - * @memberof jsPDF# - * @name save - * @function - * @instance - * @param {string} filename The filename including extension. - * @param {Object} options An Object with additional options, possible options: 'returnPromise'. - * @returns {jsPDF} jsPDF-instance + /** + * Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf'). + * Uses FileSaver.js-method saveAs. + * + * @memberOf jsPDF + * @name save + * @function + * @instance + * @param {string} filename The filename including extension. + * @param {Object} options An Object with additional options, possible options: 'returnPromise'. + * @returns {jsPDF} jsPDF-instance */ @@ -5349,26 +3701,19 @@ } } } - - API.advancedAPI = function (body) { - if (typeof body !== "function") { - return this; - } - - body(this); - return this; - }; - /** - * Object exposing internal API to plugins - * @public - * @ignore + /** + * Object exposing internal API to plugins + * @public + * @ignore */ API.internal = { 'pdfEscape': pdfEscape, 'getStyle': getStyle, - 'getFont': getFontEntry, + 'getFont': function getFont() { + return fonts[_getFont.apply(API, arguments)]; + }, 'getFontSize': getFontSize, 'getCharSpace': getCharSpace, 'getTextColor': getTextColor, @@ -5418,9 +3763,6 @@ 'getPageInfoByObjId': getPageInfoByObjId, 'getCurrentPageInfo': getCurrentPageInfo, 'getPDFVersion': getPdfVersion, - 'Point': Point, - 'Rectangle': Rectangle, - 'Matrix': Matrix, 'hasHotfix': hasHotfix //Expose the hasHotfix check so plugins can also check them. }; @@ -5456,39 +3798,39 @@ events.publish('initialized'); return API; } - /** - * jsPDF.API is a STATIC property of jsPDF class. - * jsPDF.API is an object you can add methods and properties to. - * The methods / properties you add will show up in new jsPDF objects. - * - * One property is prepopulated. It is the 'events' Object. Plugin authors can add topics, - * callbacks to this object. These will be reassigned to all new instances of jsPDF. - * - * @static - * @public - * @memberof jsPDF# - * @name API - * - * @example - * jsPDF.API.mymethod = function(){ - * // 'this' will be ref to internal API object. see jsPDF source - * // , so you can refer to built-in methods like so: - * // this.line(....) - * // this.text(....) - * } - * var pdfdoc = new jsPDF() - * pdfdoc.mymethod() // <- !!!!!! + /** + * jsPDF.API is a STATIC property of jsPDF class. + * jsPDF.API is an object you can add methods and properties to. + * The methods / properties you add will show up in new jsPDF objects. + * + * One property is prepopulated. It is the 'events' Object. Plugin authors can add topics, + * callbacks to this object. These will be reassigned to all new instances of jsPDF. + * + * @static + * @public + * @memberOf jsPDF + * @name API + * + * @example + * jsPDF.API.mymethod = function(){ + * // 'this' will be ref to internal API object. see jsPDF source + * // , so you can refer to built-in methods like so: + * // this.line(....) + * // this.text(....) + * } + * var pdfdoc = new jsPDF() + * pdfdoc.mymethod() // <- !!!!!! */ jsPDF.API = { events: [] }; - /** - * The version of jsPDF. - * @name version - * @type {string} - * @memberof jsPDF# + /** + * The version of jsPDF. + * @name version + * @type {string} + * @memberOf jsPDF */ jsPDF.version = '1.5.3'; @@ -5505,27 +3847,30 @@ } return jsPDF; - })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || typeof global !== "undefined" && global || Function('return typeof this === "object" && this.content')() || Function('return this')()); // `self` is undefined in Firefox for Android content script context + }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || typeof global !== "undefined" && global || Function('return typeof this === "object" && this.content')() || Function('return this')()); // `self` is undefined in Firefox for Android content script context // while `this` is nsIContentFrameMessageManager // with an attribute `content` that corresponds to the window - /* global jsPDF */ + /*rollup-keeper-start*/ + - /** - * @license - * Copyright (c) 2016 Alexander Weidt, - * https://github.com/BiggA94 - * - * Licensed under the MIT License. http://opensource.org/licenses/mit-license + window.tmp = jsPDF; + /*rollup-keeper-end*/ + + /** + * @license + * Copyright (c) 2016 Alexander Weidt, + * https://github.com/BiggA94 + * + * Licensed under the MIT License. http://opensource.org/licenses/mit-license */ - /** - * jsPDF AcroForm Plugin - * @module AcroForm + /** + * jsPDF AcroForm Plugin + * @module AcroForm */ - (function (jsPDF, globalObj) { + (function (jsPDFAPI, globalObj) { - var jsPDFAPI = jsPDF.API; var scope; var scaleFactor = 1; @@ -5576,8 +3921,8 @@ xobj.BBox = [0, 0, Number(f2(width)), Number(f2(height))]; return xobj; }; - /** - * Bit-Operations + /** + * Bit-Operations */ @@ -5614,8 +3959,8 @@ return (number & 1 << bitPosition) === 0 ? 0 : 1; }; - /* - * Ff starts counting the bit position at 1 and not like javascript at 0 + /* + * Ff starts counting the bit position at 1 and not like javascript at 0 */ @@ -5635,7 +3980,7 @@ return setBit(number, bitPosition - 1); }; - var clearBitForPdf = jsPDFAPI.__acroform__.clearBitForPdf = function (number, bitPosition) { + var clearBitForPdf = jsPDFAPI.__acroform__.clearBitForPdf = function (number, bitPosition, value) { if (isNaN(number) || isNaN(bitPosition)) { throw new Error('Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf'); } @@ -5693,6 +4038,7 @@ var calculateX = function calculateX(formObject, text) { var maxFontSize = formObject.maxFontSize || 12; + var font = formObject.fontName; var returnValue = { text: "", fontSize: "" @@ -5702,6 +4048,9 @@ text = text.substr(text.length - 1) == ')' ? text.substr(0, text.length - 1) : text; // split into array of words var textSplit = text.split(' '); + + var color = scope.__private__.encodeColorString(formObject.color); + var fontSize = maxFontSize; // The Starting fontSize (The Maximum) var lineSpacing = 2; @@ -5830,12 +4179,12 @@ returnValue.fontSize = fontSize; return returnValue; }; - /** - * Small workaround for calculating the TextMetric approximately. - * - * @param text - * @param fontsize - * @returns {TextMetrics} (Has Height and Width) + /** + * Small workaround for calculating the TextMetric approximately. + * + * @param text + * @param fontsize + * @returns {TextMetrics} (Has Height and Width) */ @@ -5861,17 +4210,17 @@ fields: [], xForms: [], - /** - * acroFormDictionaryRoot contains information about the AcroForm - * Dictionary 0: The Event-Token, the AcroFormDictionaryCallback has - * 1: The Object ID of the Root + /** + * acroFormDictionaryRoot contains information about the AcroForm + * Dictionary 0: The Event-Token, the AcroFormDictionaryCallback has + * 1: The Object ID of the Root */ acroFormDictionaryRoot: null, - /** - * After the PDF gets evaluated, the reference to the root has to be - * reset, this indicates, whether the root has already been printed - * out + /** + * After the PDF gets evaluated, the reference to the root has to be + * reset, this indicates, whether the root has already been printed + * out */ printedOut: false, internal: null, @@ -5910,9 +4259,9 @@ scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(formObject); }; - /** - * Create the Reference to the widgetAnnotation, so that it gets referenced - * in the Annot[] int the+ (Requires the Annotation Plugin) + /** + * Create the Reference to the widgetAnnotation, so that it gets referenced + * in the Annot[] int the+ (Requires the Annotation Plugin) */ @@ -5941,9 +4290,9 @@ throw new Error('putCatalogCallback: Root missing.'); } }; - /** - * Adds /Acroform X 0 R to Document Catalog, and creates the AcroForm - * Dictionary + /** + * Adds /Acroform X 0 R to Document Catalog, and creates the AcroForm + * Dictionary */ @@ -5953,11 +4302,11 @@ delete scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID; scope.internal.acroformPlugin.printedOut = true; }; - /** - * Creates the single Fields and writes them into the Document - * - * If fieldArray is set, use the fields that are inside it instead of the - * fields from the AcroRoot (for the FormXObjects...) + /** + * Creates the single Fields and writes them into the Document + * + * If fieldArray is set, use the fields that are inside it instead of the + * fields from the AcroRoot (for the FormXObjects...) */ @@ -6030,7 +4379,7 @@ appearanceStreamString += "/" + i + " " + obj + " "; // In case the XForm is already used, e.g. OffState // of CheckBoxes, don't add it - if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0)) { scope.internal.acroformPlugin.xForms.push(obj); } + if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0)) scope.internal.acroformPlugin.xForms.push(obj); } } } else { @@ -6043,7 +4392,7 @@ } appearanceStreamString += "/" + i + " " + obj; - if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0)) { scope.internal.acroformPlugin.xForms.push(obj); } + if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0)) scope.internal.acroformPlugin.xForms.push(obj); } appearanceStreamString += ">>"; @@ -6179,17 +4528,17 @@ // Classes // ########################## - /** - * @class AcroFormPDFObject - * @classdesc A AcroFormPDFObject + /** + * @class AcroFormPDFObject + * @classdesc A AcroFormPDFObject */ var AcroFormPDFObject = function AcroFormPDFObject() { var _objId; - /** * - * @name AcroFormPDFObject#objId - * @type {any} + /** * + * @name AcroFormPDFObject#objId + * @type {any} */ @@ -6211,8 +4560,8 @@ } }); }; - /** - * @function AcroFormPDFObject.toString + /** + * @function AcroFormPDFObject.toString */ @@ -6228,11 +4577,11 @@ }); scope.internal.out("endobj"); }; - /** - * Returns an key-value-List of all non-configurable Variables from the Object - * - * @name getKeyValueListForStream - * @returns {string} + /** + * Returns an key-value-List of all non-configurable Variables from the Object + * + * @name getKeyValueListForStream + * @returns {string} */ @@ -6341,7 +4690,7 @@ if (_Kids.length > 0) { return _Kids; } else { - return undefined; + return; } } }); @@ -6360,7 +4709,7 @@ configurable: false, get: function get() { if (!_DA) { - return undefined; + return; } return '(' + _DA + ')'; @@ -6372,11 +4721,11 @@ }; inherit(AcroFormDictionary, AcroFormPDFObject); - /** - * The Field Object contains the Variables, that every Field needs - * - * @class AcroFormField - * @classdesc An AcroForm FieldObject + /** + * The Field Object contains the Variables, that every Field needs + * + * @class AcroFormField + * @classdesc An AcroForm FieldObject */ var AcroFormField = function AcroFormField() { @@ -6397,13 +4746,13 @@ } } }); - /** - * (PDF 1.2) If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of wether is is displayed on the screen. - * NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page. - * - * @name AcroFormField#showWhenPrinted - * @default true - * @type {boolean} + /** + * (PDF 1.2) If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of wether is is displayed on the screen. + * NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page. + * + * @name AcroFormField#showWhenPrinted + * @default true + * @type {boolean} */ Object.defineProperty(this, 'showWhenPrinted', { @@ -6441,7 +4790,7 @@ configurable: false, get: function get() { if (_Rect.length === 0) { - return undefined; + return; } return _Rect; @@ -6454,12 +4803,12 @@ } } }); - /** - * The x-position of the field. - * - * @name AcroFormField#x - * @default null - * @type {number} + /** + * The x-position of the field. + * + * @name AcroFormField#x + * @default null + * @type {number} */ Object.defineProperty(this, 'x', { @@ -6476,12 +4825,12 @@ _Rect[0] = scale(value); } }); - /** - * The y-position of the field. - * - * @name AcroFormField#y - * @default null - * @type {number} + /** + * The y-position of the field. + * + * @name AcroFormField#y + * @default null + * @type {number} */ Object.defineProperty(this, 'y', { @@ -6498,12 +4847,12 @@ _Rect[1] = scale(value); } }); - /** - * The width of the field. - * - * @name AcroFormField#width - * @default null - * @type {number} + /** + * The width of the field. + * + * @name AcroFormField#width + * @default null + * @type {number} */ Object.defineProperty(this, 'width', { @@ -6520,12 +4869,12 @@ _Rect[2] = scale(value); } }); - /** - * The height of the field. - * - * @name AcroFormField#height - * @default null - * @type {number} + /** + * The height of the field. + * + * @name AcroFormField#height + * @default null + * @type {number} */ Object.defineProperty(this, 'height', { @@ -6571,7 +4920,7 @@ if (!_T || _T.length < 1) { // In case of a Child from a Radio´Group, you don't need a FieldName if (this instanceof AcroFormChildClass) { - return undefined; + return; } _T = "FieldObject" + AcroFormField.FieldNum++; @@ -6583,12 +4932,12 @@ _T = value.toString(); } }); - /** - * (Optional) The partial field name (see 12.7.3.2, “Field Names”). - * - * @name AcroFormField#fieldName - * @default null - * @type {string} + /** + * (Optional) The partial field name (see 12.7.3.2, “Field Names”). + * + * @name AcroFormField#fieldName + * @default null + * @type {string} */ Object.defineProperty(this, 'fieldName', { @@ -6602,12 +4951,12 @@ } }); var _fontName = 'helvetica'; - /** - * The fontName of the font to be used. - * - * @name AcroFormField#fontName - * @default 'helvetica' - * @type {string} + /** + * The fontName of the font to be used. + * + * @name AcroFormField#fontName + * @default 'helvetica' + * @type {string} */ Object.defineProperty(this, 'fontName', { @@ -6621,12 +4970,12 @@ } }); var _fontStyle = 'normal'; - /** - * The fontStyle of the font to be used. - * - * @name AcroFormField#fontStyle - * @default 'normal' - * @type {string} + /** + * The fontStyle of the font to be used. + * + * @name AcroFormField#fontStyle + * @default 'normal' + * @type {string} */ Object.defineProperty(this, 'fontStyle', { @@ -6640,12 +4989,12 @@ } }); var _fontSize = 0; - /** - * The fontSize of the font to be used. - * - * @name AcroFormField#fontSize - * @default 0 (for auto) - * @type {number} + /** + * The fontSize of the font to be used. + * + * @name AcroFormField#fontSize + * @default 0 (for auto) + * @type {number} */ Object.defineProperty(this, 'fontSize', { @@ -6659,12 +5008,12 @@ } }); var _maxFontSize = 50; - /** - * The maximum fontSize of the font to be used. - * - * @name AcroFormField#maxFontSize - * @default 0 (for auto) - * @type {number} + /** + * The maximum fontSize of the font to be used. + * + * @name AcroFormField#maxFontSize + * @default 0 (for auto) + * @type {number} */ Object.defineProperty(this, 'maxFontSize', { @@ -6678,12 +5027,12 @@ } }); var _color = 'black'; - /** - * The color of the text - * - * @name AcroFormField#color - * @default 'black' - * @type {string|rgba} + /** + * The color of the text + * + * @name AcroFormField#color + * @default 'black' + * @type {string|rgba} */ Object.defineProperty(this, 'color', { @@ -6703,7 +5052,7 @@ configurable: false, get: function get() { if (!_DA || this instanceof AcroFormChildClass || this instanceof AcroFormTextField) { - return undefined; + return; } return toPdfString(_DA); @@ -6719,7 +5068,7 @@ configurable: false, get: function get() { if (!_DV) { - return undefined; + return; } if (this instanceof AcroFormButton === false) { @@ -6742,12 +5091,12 @@ } } }); - /** - * (Optional; inheritable) The default value to which the field reverts when a reset-form action is executed (see 12.7.5.3, “Reset-Form Action”). The format of this value is the same as that of value. - * - * @name AcroFormField#defaultValue - * @default null - * @type {any} + /** + * (Optional; inheritable) The default value to which the field reverts when a reset-form action is executed (see 12.7.5.3, “Reset-Form Action”). The format of this value is the same as that of value. + * + * @name AcroFormField#defaultValue + * @default null + * @type {any} */ Object.defineProperty(this, 'defaultValue', { @@ -6776,7 +5125,7 @@ configurable: false, get: function get() { if (!_V) { - return undefined; + return; } if (this instanceof AcroFormButton === false) { @@ -6799,12 +5148,12 @@ } } }); - /** - * (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. - * - * @name AcroFormField#value - * @default null - * @type {any} + /** + * (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. + * + * @name AcroFormField#value + * @default null + * @type {any} */ Object.defineProperty(this, 'value', { @@ -6827,12 +5176,12 @@ } } }); - /** - * Check if field has annotations - * - * @name AcroFormField#hasAnnotation - * @readonly - * @type {boolean} + /** + * Check if field has annotations + * + * @name AcroFormField#hasAnnotation + * @readonly + * @type {boolean} */ Object.defineProperty(this, 'hasAnnotation', { @@ -6857,12 +5206,12 @@ } }); var _hasAppearanceStream = false; - /** - * true if field has an appearanceStream - * - * @name AcroFormField#hasAppearanceStream - * @readonly - * @type {boolean} + /** + * true if field has an appearanceStream + * + * @name AcroFormField#hasAppearanceStream + * @readonly + * @type {boolean} */ Object.defineProperty(this, 'hasAppearanceStream', { @@ -6877,11 +5226,11 @@ _hasAppearanceStream = value; } }); - /** - * The page on which the AcroFormField is placed - * - * @name AcroFormField#page - * @type {number} + /** + * The page on which the AcroFormField is placed + * + * @name AcroFormField#page + * @type {number} */ var _page; @@ -6892,7 +5241,7 @@ writeable: true, get: function get() { if (!_page) { - return undefined; + return; } return _page; @@ -6901,12 +5250,12 @@ _page = value; } }); - /** - * If set, the user may not change the value of the field. Any associated widget annotations will not interact with the user; that is, they will not respond to mouse clicks or change their appearance in response to mouse motions. This flag is useful for fields whose values are computed or imported from a database. - * - * @name AcroFormField#readOnly - * @default false - * @type {boolean} + /** + * If set, the user may not change the value of the field. Any associated widget annotations will not interact with the user; that is, they will not respond to mouse clicks or change their appearance in response to mouse motions. This flag is useful for fields whose values are computed or imported from a database. + * + * @name AcroFormField#readOnly + * @default false + * @type {boolean} */ Object.defineProperty(this, 'readOnly', { @@ -6923,12 +5272,12 @@ } } }); - /** - * If set, the field shall have a value at the time it is exported by a submitform action (see 12.7.5.2, “Submit-Form Action”). - * - * @name AcroFormField#required - * @default false - * @type {boolean} + /** + * If set, the field shall have a value at the time it is exported by a submitform action (see 12.7.5.2, “Submit-Form Action”). + * + * @name AcroFormField#required + * @default false + * @type {boolean} */ Object.defineProperty(this, 'required', { @@ -6945,12 +5294,12 @@ } } }); - /** - * If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) - * - * @name AcroFormField#noExport - * @default false - * @type {boolean} + /** + * If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) + * + * @name AcroFormField#noExport + * @default false + * @type {boolean} */ Object.defineProperty(this, 'noExport', { @@ -6973,7 +5322,7 @@ configurable: false, get: function get() { if (_Q === null) { - return undefined; + return; } return _Q; @@ -6986,13 +5335,13 @@ } } }); - /** - * (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: - * 'left', 'center', 'right' - * - * @name AcroFormField#textAlign - * @default 'left' - * @type {string} + /** + * (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: + * 'left', 'center', 'right' + * + * @name AcroFormField#textAlign + * @default 'left' + * @type {string} */ Object.defineProperty(this, 'textAlign', { @@ -7040,9 +5389,9 @@ }; inherit(AcroFormField, AcroFormPDFObject); - /** - * @class AcroFormChoiceField - * @extends AcroFormField + /** + * @class AcroFormChoiceField + * @extends AcroFormField */ var AcroFormChoiceField = function AcroFormChoiceField() { @@ -7064,12 +5413,12 @@ _TI = value; } }); - /** - * (Optional) For scrollable list boxes, the top index (the index in the Opt array of the first option visible in the list). Default value: 0. - * - * @name AcroFormChoiceField#topIndex - * @default 0 - * @type {number} + /** + * (Optional) For scrollable list boxes, the top index (the index in the Opt array of the first option visible in the list). Default value: 0. + * + * @name AcroFormChoiceField#topIndex + * @default 0 + * @type {number} */ Object.defineProperty(this, 'topIndex', { @@ -7093,23 +5442,23 @@ _Opt = pdfArrayToStringArray(value); } }); - /** - * @memberof AcroFormChoiceField - * @name getOptions - * @function - * @instance - * @returns {array} array of Options + /** + * @memberof AcroFormChoiceField + * @name getOptions + * @function + * @instance + * @returns {array} array of Options */ this.getOptions = function () { return _Opt; }; - /** - * @memberof AcroFormChoiceField - * @name setOptions - * @function - * @instance - * @param {array} value + /** + * @memberof AcroFormChoiceField + * @name setOptions + * @function + * @instance + * @param {array} value */ @@ -7120,12 +5469,12 @@ _Opt.sort(); } }; - /** - * @memberof AcroFormChoiceField - * @name addOption - * @function - * @instance - * @param {string} value + /** + * @memberof AcroFormChoiceField + * @name addOption + * @function + * @instance + * @param {string} value */ @@ -7139,13 +5488,13 @@ _Opt.sort(); } }; - /** - * @memberof AcroFormChoiceField - * @name removeOption - * @function - * @instance - * @param {string} value - * @param {boolean} allEntries (default: false) + /** + * @memberof AcroFormChoiceField + * @name removeOption + * @function + * @instance + * @param {string} value + * @param {boolean} allEntries (default: false) */ @@ -7162,12 +5511,12 @@ } } }; - /** - * If set, the field is a combo box; if clear, the field is a list box. - * - * @name AcroFormChoiceField#combo - * @default false - * @type {boolean} + /** + * If set, the field is a combo box; if clear, the field is a list box. + * + * @name AcroFormChoiceField#combo + * @default false + * @type {boolean} */ @@ -7185,12 +5534,12 @@ } } }); - /** - * If set, the combo box shall include an editable text box as well as a drop-down list; if clear, it shall include only a drop-down list. This flag shall be used only if the Combo flag is set. - * - * @name AcroFormChoiceField#edit - * @default false - * @type {boolean} + /** + * If set, the combo box shall include an editable text box as well as a drop-down list; if clear, it shall include only a drop-down list. This flag shall be used only if the Combo flag is set. + * + * @name AcroFormChoiceField#edit + * @default false + * @type {boolean} */ Object.defineProperty(this, 'edit', { @@ -7210,12 +5559,12 @@ } } }); - /** - * If set, the field’s option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers. Conforming readers shall display the options in the order in which they occur in the Opt array (see Table 231). - * - * @name AcroFormChoiceField#sort - * @default false - * @type {boolean} + /** + * If set, the field’s option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers. Conforming readers shall display the options in the order in which they occur in the Opt array (see Table 231). + * + * @name AcroFormChoiceField#sort + * @default false + * @type {boolean} */ Object.defineProperty(this, 'sort', { @@ -7234,12 +5583,12 @@ } } }); - /** - * (PDF 1.4) If set, more than one of the field’s option items may be selected simultaneously; if clear, at most one item shall be selected - * - * @name AcroFormChoiceField#multiSelect - * @default false - * @type {boolean} + /** + * (PDF 1.4) If set, more than one of the field’s option items may be selected simultaneously; if clear, at most one item shall be selected + * + * @name AcroFormChoiceField#multiSelect + * @default false + * @type {boolean} */ Object.defineProperty(this, 'multiSelect', { @@ -7256,12 +5605,12 @@ } } }); - /** - * (PDF 1.4) If set, text entered in the field shall not be spellchecked. This flag shall not be used unless the Combo and Edit flags are both set. - * - * @name AcroFormChoiceField#doNotSpellCheck - * @default false - * @type {boolean} + /** + * (PDF 1.4) If set, text entered in the field shall not be spellchecked. This flag shall not be used unless the Combo and Edit flags are both set. + * + * @name AcroFormChoiceField#doNotSpellCheck + * @default false + * @type {boolean} */ Object.defineProperty(this, 'doNotSpellCheck', { @@ -7278,13 +5627,13 @@ } } }); - /** - * (PDF 1.5) If set, the new value shall be committed as soon as a selection is made (commonly with the pointing device). In this case, supplying a value for a field involves three actions: selecting the field for fill-in, selecting a choice for the fill-in value, and leaving that field, which finalizes or “commits” the data choice and triggers any actions associated with the entry or changing of this data. If this flag is on, then processing does not wait for leaving the field action to occur, but immediately proceeds to the third step. - * This option enables applications to perform an action once a selection is made, without requiring the user to exit the field. If clear, the new value is not committed until the user exits the field. - * - * @name AcroFormChoiceField#commitOnSelChange - * @default false - * @type {boolean} + /** + * (PDF 1.5) If set, the new value shall be committed as soon as a selection is made (commonly with the pointing device). In this case, supplying a value for a field involves three actions: selecting the field for fill-in, selecting a choice for the fill-in value, and leaving that field, which finalizes or “commits” the data choice and triggers any actions associated with the entry or changing of this data. If this flag is on, then processing does not wait for leaving the field action to occur, but immediately proceeds to the third step. + * This option enables applications to perform an action once a selection is made, without requiring the user to exit the field. If clear, the new value is not committed until the user exits the field. + * + * @name AcroFormChoiceField#commitOnSelChange + * @default false + * @type {boolean} */ Object.defineProperty(this, 'commitOnSelChange', { @@ -7305,10 +5654,10 @@ }; inherit(AcroFormChoiceField, AcroFormField); - /** - * @class AcroFormListBox - * @extends AcroFormChoiceField - * @extends AcroFormField + /** + * @class AcroFormListBox + * @extends AcroFormChoiceField + * @extends AcroFormField */ var AcroFormListBox = function AcroFormListBox() { @@ -7319,11 +5668,11 @@ }; inherit(AcroFormListBox, AcroFormChoiceField); - /** - * @class AcroFormComboBox - * @extends AcroFormListBox - * @extends AcroFormChoiceField - * @extends AcroFormField + /** + * @class AcroFormComboBox + * @extends AcroFormListBox + * @extends AcroFormChoiceField + * @extends AcroFormField */ var AcroFormComboBox = function AcroFormComboBox() { @@ -7332,12 +5681,12 @@ }; inherit(AcroFormComboBox, AcroFormListBox); - /** - * @class AcroFormEditBox - * @extends AcroFormComboBox - * @extends AcroFormListBox - * @extends AcroFormChoiceField - * @extends AcroFormField + /** + * @class AcroFormEditBox + * @extends AcroFormComboBox + * @extends AcroFormListBox + * @extends AcroFormChoiceField + * @extends AcroFormField */ var AcroFormEditBox = function AcroFormEditBox() { @@ -7346,19 +5695,19 @@ }; inherit(AcroFormEditBox, AcroFormComboBox); - /** - * @class AcroFormButton - * @extends AcroFormField + /** + * @class AcroFormButton + * @extends AcroFormField */ var AcroFormButton = function AcroFormButton() { AcroFormField.call(this); this.FT = "/Btn"; - /** - * (Radio buttons only) If set, exactly one radio button shall be selected at all times; selecting the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected. - * - * @name AcroFormButton#noToggleToOff - * @type {boolean} + /** + * (Radio buttons only) If set, exactly one radio button shall be selected at all times; selecting the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected. + * + * @name AcroFormButton#noToggleToOff + * @type {boolean} */ Object.defineProperty(this, 'noToggleToOff', { @@ -7375,11 +5724,11 @@ } } }); - /** - * If set, the field is a set of radio buttons; if clear, the field is a checkbox. This flag may be set only if the Pushbutton flag is clear. - * - * @name AcroFormButton#radio - * @type {boolean} + /** + * If set, the field is a set of radio buttons; if clear, the field is a checkbox. This flag may be set only if the Pushbutton flag is clear. + * + * @name AcroFormButton#radio + * @type {boolean} */ Object.defineProperty(this, 'radio', { @@ -7396,11 +5745,11 @@ } } }); - /** - * If set, the field is a pushbutton that does not retain a permanent value. - * - * @name AcroFormButton#pushButton - * @type {boolean} + /** + * If set, the field is a pushbutton that does not retain a permanent value. + * + * @name AcroFormButton#pushButton + * @type {boolean} */ Object.defineProperty(this, 'pushButton', { @@ -7417,11 +5766,11 @@ } } }); - /** - * (PDF 1.5) If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive (the same behavior as HTML radio buttons). - * - * @name AcroFormButton#radioIsUnison - * @type {boolean} + /** + * (PDF 1.5) If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive (the same behavior as HTML radio buttons). + * + * @name AcroFormButton#radioIsUnison + * @type {boolean} */ Object.defineProperty(this, 'radioIsUnison', { @@ -7456,7 +5805,7 @@ return result.join('\n'); } - return undefined; + return; }, set: function set(value) { if (_typeof(value) === "object") { @@ -7464,16 +5813,16 @@ } } }); - /** - * From the PDF reference: - * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. - * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). - * - * - '8' = Cross, - * - 'l' = Circle, - * - '' = nothing - * @name AcroFormButton#caption - * @type {string} + /** + * From the PDF reference: + * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. + * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). + * + * - '8' = Cross, + * - 'l' = Circle, + * - '' = nothing + * @name AcroFormButton#caption + * @type {string} */ Object.defineProperty(this, 'caption', { @@ -7501,11 +5850,11 @@ _AS = value; } }); - /** - * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") - * - * @name AcroFormButton#appearanceState - * @type {any} + /** + * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") + * + * @name AcroFormButton#appearanceState + * @type {any} */ Object.defineProperty(this, 'appearanceState', { @@ -7521,10 +5870,10 @@ }; inherit(AcroFormButton, AcroFormField); - /** - * @class AcroFormPushButton - * @extends AcroFormButton - * @extends AcroFormField + /** + * @class AcroFormPushButton + * @extends AcroFormButton + * @extends AcroFormField */ var AcroFormPushButton = function AcroFormPushButton() { @@ -7533,10 +5882,10 @@ }; inherit(AcroFormPushButton, AcroFormButton); - /** - * @class AcroFormRadioButton - * @extends AcroFormButton - * @extends AcroFormField + /** + * @class AcroFormRadioButton + * @extends AcroFormButton + * @extends AcroFormField */ var AcroFormRadioButton = function AcroFormRadioButton() { @@ -7561,12 +5910,12 @@ }; inherit(AcroFormRadioButton, AcroFormButton); - /** - * The Child class of a RadioButton (the radioGroup) -> The single Buttons - * - * @class AcroFormChildClass - * @extends AcroFormField - * @ignore + /** + * The Child class of a RadioButton (the radioGroup) -> The single Buttons + * + * @class AcroFormChildClass + * @extends AcroFormField + * @ignore */ var AcroFormChildClass = function AcroFormChildClass() { @@ -7619,16 +5968,16 @@ } } }); - /** - * From the PDF reference: - * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. - * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). - * - * - '8' = Cross, - * - 'l' = Circle, - * - '' = nothing - * @name AcroFormButton#caption - * @type {string} + /** + * From the PDF reference: + * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. + * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). + * + * - '8' = Cross, + * - 'l' = Circle, + * - '' = nothing + * @name AcroFormButton#caption + * @type {string} */ Object.defineProperty(this, 'caption', { @@ -7656,11 +6005,11 @@ _AS = value; } }); - /** - * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") - * - * @name AcroFormButton#appearanceState - * @type {any} + /** + * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") + * + * @name AcroFormButton#appearanceState + * @type {any} */ Object.defineProperty(this, 'appearanceState', { @@ -7688,6 +6037,7 @@ AcroFormRadioButton.prototype.setAppearance = function (appearance) { if (!('createAppearanceStream' in appearance && 'getCA' in appearance)) { throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!"); + return; } for (var objId in this.Kids) { @@ -7700,7 +6050,8 @@ }; AcroFormRadioButton.prototype.createOption = function (name) { - // Create new Child for RadioGroup + var kidCount = this.Kids.length; // Create new Child for RadioGroup + var child = new AcroFormChildClass(); child.Parent = this; child.optionName = name; // Add to Parent @@ -7709,10 +6060,10 @@ addField.call(this, child); return child; }; - /** - * @class AcroFormCheckBox - * @extends AcroFormButton - * @extends AcroFormField + /** + * @class AcroFormCheckBox + * @extends AcroFormButton + * @extends AcroFormField */ @@ -7727,19 +6078,19 @@ }; inherit(AcroFormCheckBox, AcroFormButton); - /** - * @class AcroFormTextField - * @extends AcroFormField + /** + * @class AcroFormTextField + * @extends AcroFormField */ var AcroFormTextField = function AcroFormTextField() { AcroFormField.call(this); this.FT = '/Tx'; - /** - * If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line. - * - * @name AcroFormTextField#multiline - * @type {boolean} + /** + * If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line. + * + * @name AcroFormTextField#multiline + * @type {boolean} */ Object.defineProperty(this, 'multiline', { @@ -7756,11 +6107,11 @@ } } }); - /** - * (PDF 1.4) If set, the text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field. - * - * @name AcroFormTextField#fileSelect - * @type {boolean} + /** + * (PDF 1.4) If set, the text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field. + * + * @name AcroFormTextField#fileSelect + * @type {boolean} */ Object.defineProperty(this, 'fileSelect', { @@ -7777,11 +6128,11 @@ } } }); - /** - * (PDF 1.4) If set, text entered in the field shall not be spell-checked. - * - * @name AcroFormTextField#doNotSpellCheck - * @type {boolean} + /** + * (PDF 1.4) If set, text entered in the field shall not be spell-checked. + * + * @name AcroFormTextField#doNotSpellCheck + * @type {boolean} */ Object.defineProperty(this, 'doNotSpellCheck', { @@ -7798,11 +6149,11 @@ } } }); - /** - * (PDF 1.4) If set, the field shall not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text shall be accepted for interactive form filling; for noninteractive form filling, the filler should take care not to add more character than will visibly fit in the defined area. - * - * @name AcroFormTextField#doNotScroll - * @type {boolean} + /** + * (PDF 1.4) If set, the field shall not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text shall be accepted for interactive form filling; for noninteractive form filling, the filler should take care not to add more character than will visibly fit in the defined area. + * + * @name AcroFormTextField#doNotScroll + * @type {boolean} */ Object.defineProperty(this, 'doNotScroll', { @@ -7819,11 +6170,11 @@ } } }); - /** - * (PDF 1.5) May be set only if the MaxLen entry is present in the text field dictionary (see Table 229) and if the Multiline, Password, and FileSelect flags are clear. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs. - * - * @name AcroFormTextField#comb - * @type {boolean} + /** + * (PDF 1.5) May be set only if the MaxLen entry is present in the text field dictionary (see Table 229) and if the Multiline, Password, and FileSelect flags are clear. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs. + * + * @name AcroFormTextField#comb + * @type {boolean} */ Object.defineProperty(this, 'comb', { @@ -7840,11 +6191,11 @@ } } }); - /** - * (PDF 1.5) If set, the value of this field shall be a rich text string (see 12.7.3.4, “Rich Text Strings”). If the field has a value, the RV entry of the field dictionary (Table 222) shall specify the rich text string. - * - * @name AcroFormTextField#richText - * @type {boolean} + /** + * (PDF 1.5) If set, the value of this field shall be a rich text string (see 12.7.3.4, “Rich Text Strings”). If the field has a value, the RV entry of the field dictionary (Table 222) shall specify the rich text string. + * + * @name AcroFormTextField#richText + * @type {boolean} */ Object.defineProperty(this, 'richText', { @@ -7872,11 +6223,11 @@ _MaxLen = value; } }); - /** - * (Optional; inheritable) The maximum length of the field’s text, in characters. - * - * @name AcroFormTextField#maxLength - * @type {number} + /** + * (Optional; inheritable) The maximum length of the field’s text, in characters. + * + * @name AcroFormTextField#maxLength + * @type {number} */ Object.defineProperty(this, 'maxLength', { @@ -7901,20 +6252,20 @@ }; inherit(AcroFormTextField, AcroFormField); - /** - * @class AcroFormPasswordField - * @extends AcroFormTextField - * @extends AcroFormField + /** + * @class AcroFormPasswordField + * @extends AcroFormTextField + * @extends AcroFormField */ var AcroFormPasswordField = function AcroFormPasswordField() { AcroFormTextField.call(this); - /** - * If set, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard shall instead be echoed in some unreadable form, such as asterisks or bullet characters. - * NOTE To protect password confidentiality, readers should never store the value of the text field in the PDF file if this flag is set. - * - * @name AcroFormTextField#password - * @type {boolean} + /** + * If set, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard shall instead be echoed in some unreadable form, such as asterisks or bullet characters. + * NOTE To protect password confidentiality, readers should never store the value of the text field in the PDF file if this flag is set. + * + * @name AcroFormTextField#password + * @type {boolean} */ Object.defineProperty(this, 'password', { @@ -7951,10 +6302,10 @@ return appearance; }, - /** - * Returns the standard On Appearance for a CheckBox - * - * @returns {AcroFormXObject} + /** + * Returns the standard On Appearance for a CheckBox + * + * @returns {AcroFormXObject} */ YesPushDown: function YesPushDown(formObject) { var xobj = createFormXObject(formObject); @@ -8007,10 +6358,10 @@ return xobj; }, - /** - * Returns the standard Off Appearance for a CheckBox - * - * @returns {AcroFormXObject} + /** + * Returns the standard Off Appearance for a CheckBox + * + * @returns {AcroFormXObject} */ OffPushDown: function OffPushDown(formObject) { var xobj = createFormXObject(formObject); @@ -8047,8 +6398,8 @@ DotRadius = Number((DotRadius * 0.9).toFixed(5)); var c = AcroFormAppearance.internal.Bezier_C; var DotRadiusBezier = Number((DotRadius * c).toFixed(5)); - /* - * The Following is a Circle created with Bezier-Curves. + /* + * The Following is a Circle created with Bezier-Curves. */ stream.push("q"); @@ -8122,12 +6473,12 @@ } }, Cross: { - /** - * Creates the Actual AppearanceDictionary-References - * - * @param {string} name - * @returns {Object} - * @ignore + /** + * Creates the Actual AppearanceDictionary-References + * + * @param {string} name + * @returns {Object} + * @ignore */ createAppearanceStream: function createAppearanceStream(name) { var appearanceStreamContent = { @@ -8192,10 +6543,10 @@ } }, - /** - * Returns the standard Appearance - * - * @returns {AcroFormXObject} + /** + * Returns the standard Appearance + * + * @returns {AcroFormXObject} */ createDefaultAppearanceStream: function createDefaultAppearanceStream(formObject) { // Set Helvetica to Standard Font (size: auto) @@ -8215,6 +6566,7 @@ var width = AcroFormAppearance.internal.getWidth(formObject); var height = AcroFormAppearance.internal.getHeight(formObject); var a = Math.min(width, height); + var cross = { x1: { // upperLeft @@ -8265,14 +6617,14 @@ return result; }; // Public: - /** - * Add an AcroForm-Field to the jsPDF-instance - * - * @name addField - * @function - * @instance - * @param {Object} fieldObject - * @returns {jsPDF} + /** + * Add an AcroForm-Field to the jsPDF-instance + * + * @name addField + * @function + * @instance + * @param {Object} fieldObject + * @returns {jsPDF} */ @@ -8288,13 +6640,13 @@ fieldObject.page = scope.internal.getCurrentPageInfo().pageNumber; return this; }; - /** - * @name addButton - * @function - * @instance - * @param {AcroFormButton} options - * @returns {jsPDF} - * @deprecated + /** + * @name addButton + * @function + * @instance + * @param {AcroFormButton} options + * @returns {jsPDF} + * @deprecated */ @@ -8305,13 +6657,13 @@ return addField.call(this, button); }; - /** - * @name addTextField - * @function - * @instance - * @param {AcroFormTextField} textField - * @returns {jsPDF} - * @deprecated + /** + * @name addTextField + * @function + * @instance + * @param {AcroFormTextField} textField + * @returns {jsPDF} + * @deprecated */ @@ -8322,13 +6674,13 @@ return addField.call(this, textField); }; - /** - * @name addChoiceField - * @function - * @instance - * @param {AcroFormChoiceField} - * @returns {jsPDF} - * @deprecated + /** + * @name addChoiceField + * @function + * @instance + * @param {AcroFormChoiceField} + * @returns {jsPDF} + * @deprecated */ @@ -8383,39 +6735,24 @@ PasswordField: AcroFormPasswordField, Appearance: AcroFormAppearance }; - jsPDF.AcroForm = { - ChoiceField: AcroFormChoiceField, - ListBox: AcroFormListBox, - ComboBox: AcroFormComboBox, - EditBox: AcroFormEditBox, - Button: AcroFormButton, - PushButton: AcroFormPushButton, - RadioButton: AcroFormRadioButton, - CheckBox: AcroFormCheckBox, - TextField: AcroFormTextField, - PasswordField: AcroFormPasswordField, - Appearance: AcroFormAppearance - }; - })(jsPDF, typeof window !== "undefined" && window || typeof global !== "undefined" && global); - - /* global jsPDF */ + })(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global); - /** @license - * jsPDF addImage plugin - * Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/ - * 2013 Chris Dowling, https://github.com/gingerchris - * 2013 Trinh Ho, https://github.com/ineedfat - * 2013 Edwin Alejandro Perez, https://github.com/eaparango - * 2013 Norah Smith, https://github.com/burnburnrocket - * 2014 Diego Casorran, https://github.com/diegocr - * 2014 James Robb, https://github.com/jamesbrobb - * - * + /** @license + * jsPDF addImage plugin + * Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/ + * 2013 Chris Dowling, https://github.com/gingerchris + * 2013 Trinh Ho, https://github.com/ineedfat + * 2013 Edwin Alejandro Perez, https://github.com/eaparango + * 2013 Norah Smith, https://github.com/burnburnrocket + * 2014 Diego Casorran, https://github.com/diegocr + * 2014 James Robb, https://github.com/jamesbrobb + * + * */ - /** - * @name addImage - * @module + /** + * @name addImage + * @module */ (function (jsPDFAPI) { @@ -8426,14 +6763,11 @@ [0x49, 0x49, 0x2A, 0x00] //Intel ], JPEG: [[0xFF, 0xD8, 0xFF, 0xE0, undefined, undefined, 0x4A, 0x46, 0x49, 0x46, 0x00], //JFIF - [0xFF, 0xD8, 0xFF, 0xE1, undefined, undefined, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00], //Exif - [0xFF, 0xD8, 0xFF, 0xDB], //JPEG RAW - [0xFF, 0xD8, 0xFF, 0xEE] //EXIF RAW + [0xFF, 0xD8, 0xFF, 0xE1, undefined, undefined, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00] //Exif ], JPEG2000: [[0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20]], GIF87a: [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61]], GIF89a: [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61]], - WEBP: [[0x52, 0x49, 0x46, 0x46, undefined, undefined, undefined, undefined, 0x57, 0x45, 0x42, 0x50]], BMP: [[0x42, 0x4D], //BM - Windows 3.1x, 95, NT, ... etc. [0x42, 0x41], //BA - OS/2 struct bitmap array [0x43, 0x49], //CI - OS/2 struct color icon @@ -8442,18 +6776,18 @@ [0x50, 0x54] //PT - OS/2 pointer ] }; - /** - * Recognize filetype of Image by magic-bytes - * - * https://en.wikipedia.org/wiki/List_of_file_signatures - * - * @name getImageFileTypeByImageData - * @public - * @function - * @param {string|arraybuffer} imageData imageData as binary String or arraybuffer - * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG' - * - * @returns {string} filetype of Image + /** + * Recognize filetype of Image by magic-bytes + * + * https://en.wikipedia.org/wiki/List_of_file_signatures + * + * @name getImageFileTypeByImageData + * @public + * @function + * @param {string|arraybuffer} imageData imageData as binary String or arraybuffer + * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG' + * + * @returns {string} filetype of Image */ var getImageFileTypeByImageData = jsPDFAPI.getImageFileTypeByImageData = function (imageData, fallbackFormat) { @@ -8604,7 +6938,7 @@ 'dp': dp, 'data': img['smask'] }; - if ('f' in img) { smask.f = img['f']; } + if ('f' in img) smask.f = img['f']; putImage.call(this, smask); } //Palette @@ -8637,7 +6971,7 @@ } }, checkCompressValue = function checkCompressValue(value) { - if (value && typeof value === 'string') { value = value.toUpperCase(); } + if (value && typeof value === 'string') value = value.toUpperCase(); return value in jsPDFAPI.image_compression ? value : jsPDFAPI.image_compression.NONE; }, getImages = function getImages() { @@ -8708,15 +7042,13 @@ } } - var canvas; - if (element.nodeName === 'CANVAS') { - canvas = element; + var canvas = element; return element.toDataURL('image/jpeg', 1.0); } //absolute fallback method - canvas = document.createElement('canvas'); + var canvas = document.createElement('canvas'); canvas.width = element.clientWidth || element.width; canvas.height = element.clientHeight || element.height; var ctx = canvas.getContext('2d'); @@ -8802,8 +7134,8 @@ this.internal.write('Q'); //Restore graphics state }; - /** - * COLOR SPACES + /** + * COLOR SPACES */ @@ -8820,8 +7152,8 @@ SEPARATION: 'Separation', DEVICE_N: 'DeviceN' }; - /** - * DECODE METHODS + /** + * DECODE METHODS */ jsPDFAPI.decode = { @@ -8835,8 +7167,8 @@ RUN_LENGTH_DECODE: 'RunLengthDecode', CCITT_FAX_DECODE: 'CCITTFaxDecode' }; - /** - * IMAGE COMPRESSION TYPES + /** + * IMAGE COMPRESSION TYPES */ jsPDFAPI.image_compression = { @@ -8845,11 +7177,11 @@ MEDIUM: 'MEDIUM', SLOW: 'SLOW' }; - /** - * @name sHashCode - * @function - * @param {string} str - * @returns {string} + /** + * @name sHashCode + * @function + * @param {string} str + * @returns {string} */ jsPDFAPI.sHashCode = function (str) { @@ -8857,7 +7189,7 @@ var hash = 0, i, chr; - if (str.length === 0) { return hash; } + if (str.length === 0) return hash; for (i = 0; i < str.length; i++) { chr = str.charCodeAt(i); @@ -8867,15 +7199,26 @@ return hash; }; - /** - * Validates if given String is a valid Base64-String - * - * @name validateStringAsBase64 - * @public - * @function - * @param {String} possible Base64-String - * - * @returns {boolean} + /** + * @name isString + * @function + * @param {any} object + * @returns {boolean} + */ + + + jsPDFAPI.isString = function (object) { + return typeof object === 'string'; + }; + /** + * Validates if given String is a valid Base64-String + * + * @name validateStringAsBase64 + * @public + * @function + * @param {String} possible Base64-String + * + * @returns {boolean} */ @@ -8902,34 +7245,34 @@ return result; }; - /** - * Strips out and returns info from a valid base64 data URI - * - * @name extractInfoFromBase64DataURI - * @function - * @param {string} dataUrl a valid data URI of format 'data:[][;base64],' - * @returns {Array}an Array containing the following - * [0] the complete data URI - * [1] - * [2] format - the second part of the mime-type i.e 'png' in 'image/png' - * [4] + /** + * Strips out and returns info from a valid base64 data URI + * + * @name extractInfoFromBase64DataURI + * @function + * @param {string} dataUrl a valid data URI of format 'data:[][;base64],' + * @returns {Array}an Array containing the following + * [0] the complete data URI + * [1] + * [2] format - the second part of the mime-type i.e 'png' in 'image/png' + * [4] */ jsPDFAPI.extractInfoFromBase64DataURI = function (dataURI) { return /^data:([\w]+?\/([\w]+?));\S*;*base64,(.+)$/g.exec(dataURI); }; - /** - * Strips out and returns info from a valid base64 data URI - * - * @name extractImageFromDataUrl - * @function - * @param {string} dataUrl a valid data URI of format 'data:[][;base64],' - * @returns {Array}an Array containing the following - * [0] the complete data URI - * [1] - * [2] format - the second part of the mime-type i.e 'png' in 'image/png' - * [4] + /** + * Strips out and returns info from a valid base64 data URI + * + * @name extractImageFromDataUrl + * @function + * @param {string} dataUrl a valid data URI of format 'data:[][;base64],' + * @returns {Array}an Array containing the following + * [0] the complete data URI + * [1] + * [2] format - the second part of the mime-type i.e 'png' in 'image/png' + * [4] */ @@ -8952,60 +7295,63 @@ return result; }; - /** - * Check to see if ArrayBuffer is supported - * - * @name supportsArrayBuffer - * @function - * @returns {boolean} + /** + * Check to see if ArrayBuffer is supported + * + * @name supportsArrayBuffer + * @function + * @returns {boolean} */ jsPDFAPI.supportsArrayBuffer = function () { return typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined'; }; - /** - * Tests supplied object to determine if ArrayBuffer - * - * @name isArrayBuffer - * @function - * @param {Object} object an Object - * - * @returns {boolean} + /** + * Tests supplied object to determine if ArrayBuffer + * + * @name isArrayBuffer + * @function + * @param {Object} object an Object + * + * @returns {boolean} */ jsPDFAPI.isArrayBuffer = function (object) { - return this.supportsArrayBuffer() && object instanceof ArrayBuffer; - }; - /** - * Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface - * - * @name isArrayBufferView - * @function - * @param {Object} object an Object - * @returns {boolean} + if (!this.supportsArrayBuffer()) return false; + return object instanceof ArrayBuffer; + }; + /** + * Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface + * + * @name isArrayBufferView + * @function + * @param {Object} object an Object + * @returns {boolean} */ jsPDFAPI.isArrayBufferView = function (object) { - return this.supportsArrayBuffer() && typeof Uint32Array !== 'undefined' && (object instanceof Int8Array || object instanceof Uint8Array || typeof Uint8ClampedArray !== 'undefined' && object instanceof Uint8ClampedArray || object instanceof Int16Array || object instanceof Uint16Array || object instanceof Int32Array || object instanceof Uint32Array || object instanceof Float32Array || object instanceof Float64Array); - }; - /** - * Convert the Buffer to a Binary String - * - * @name binaryStringToUint8Array - * @public - * @function - * @param {ArrayBuffer} BinaryString with ImageData - * - * @returns {Uint8Array} + if (!this.supportsArrayBuffer()) return false; + if (typeof Uint32Array === 'undefined') return false; + return object instanceof Int8Array || object instanceof Uint8Array || typeof Uint8ClampedArray !== 'undefined' && object instanceof Uint8ClampedArray || object instanceof Int16Array || object instanceof Uint16Array || object instanceof Int32Array || object instanceof Uint32Array || object instanceof Float32Array || object instanceof Float64Array; + }; + /** + * Convert the Buffer to a Binary String + * + * @name binaryStringToUint8Array + * @public + * @function + * @param {ArrayBuffer} BinaryString with ImageData + * + * @returns {Uint8Array} */ jsPDFAPI.binaryStringToUint8Array = function (binary_string) { - /* - * not sure how efficient this will be will bigger files. Is there a native method? + /* + * not sure how efficient this will be will bigger files. Is there a native method? */ var len = binary_string.length; var bytes = new Uint8Array(len); @@ -9016,15 +7362,15 @@ return bytes; }; - /** - * Convert the Buffer to a Binary String - * - * @name arrayBufferToBinaryString - * @public - * @function - * @param {ArrayBuffer} ArrayBuffer with ImageData - * - * @returns {String} + /** + * Convert the Buffer to a Binary String + * + * @name arrayBufferToBinaryString + * @public + * @function + * @param {ArrayBuffer} ArrayBuffer with ImageData + * + * @returns {String} */ @@ -9038,19 +7384,19 @@ return atob(this.arrayBufferToBase64(buffer)); } }; - /** - * Converts an ArrayBuffer directly to base64 - * - * Taken from http://jsperf.com/encoding-xhr-image-data/31 - * - * Need to test if this is a better solution for larger files - * - * @name arrayBufferToBase64 - * @param {arraybuffer} arrayBuffer - * @public - * @function - * - * @returns {string} + /** + * Converts an ArrayBuffer directly to base64 + * + * Taken from http://jsperf.com/encoding-xhr-image-data/31 + * + * Need to test if this is a better solution for larger files + * + * @name arrayBufferToBase64 + * @param {arraybuffer} arrayBuffer + * @public + * @function + * + * @returns {string} */ @@ -9103,26 +7449,26 @@ return base64; }; - /** - * - * @name createImageInfo - * @param {Object} data - * @param {number} wd width - * @param {number} ht height - * @param {Object} cs colorSpace - * @param {number} bpc bits per channel - * @param {any} f - * @param {number} imageIndex - * @param {string} alias - * @param {any} dp - * @param {any} trns - * @param {any} pal - * @param {any} smask - * @param {any} p - * @public - * @function - * - * @returns {Object} + /** + * + * @name createImageInfo + * @param {Object} data + * @param {number} wd width + * @param {number} ht height + * @param {Object} cs colorSpace + * @param {number} bpc bits per channel + * @param {any} f + * @param {number} imageIndex + * @param {string} alias + * @param {any} dp + * @param {any} trns + * @param {any} pal + * @param {any} smask + * @param {any} p + * @public + * @function + * + * @returns {Object} */ @@ -9137,32 +7483,32 @@ data: data // n: objectNumber will be added by putImage code }; - if (f) { info.f = f; } - if (dp) { info.dp = dp; } - if (trns) { info.trns = trns; } - if (pal) { info.pal = pal; } - if (smask) { info.smask = smask; } - if (p) { info.p = p; } // predictor parameter for PNG compression + if (f) info.f = f; + if (dp) info.dp = dp; + if (trns) info.trns = trns; + if (pal) info.pal = pal; + if (smask) info.smask = smask; + if (p) info.p = p; // predictor parameter for PNG compression return info; }; - /** - * Adds an Image to the PDF. - * - * @name addImage - * @public - * @function - * @param {string/Image-Element/Canvas-Element/Uint8Array} imageData imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement - * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG' - * @param {number} x x Coordinate (in units declared at inception of PDF document) against left edge of the page - * @param {number} y y Coordinate (in units declared at inception of PDF document) against upper edge of the page - * @param {number} width width of the image (in units declared at inception of PDF document) - * @param {number} height height of the Image (in units declared at inception of PDF document) - * @param {string} alias alias of the image (if used multiple times) - * @param {string} compression compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' - * @param {number} rotation rotation of the image in degrees (0-359) - * - * @returns jsPDF + /** + * Adds an Image to the PDF. + * + * @name addImage + * @public + * @function + * @param {string/Image-Element/Canvas-Element/Uint8Array} imageData imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement + * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG' + * @param {number} x x Coordinate (in units declared at inception of PDF document) against left edge of the page + * @param {number} y y Coordinate (in units declared at inception of PDF document) against upper edge of the page + * @param {number} width width of the image (in units declared at inception of PDF document) + * @param {number} height height of the Image (in units declared at inception of PDF document) + * @param {string} alias alias of the image (if used multiple times) + * @param {string} compression compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' + * @param {number} rotation rotation of the image in degrees (0-359) + * + * @returns jsPDF */ @@ -9213,12 +7559,12 @@ dataAsBinaryString; if (!(info = checkImagesForAlias(imageData, images))) { - if (isDOMElement(imageData)) { imageData = createDataURIFromElement(imageData, format); } - if (notDefined(alias)) { alias = generateAliasFromImageData(imageData); } + if (isDOMElement(imageData)) imageData = createDataURIFromElement(imageData, format); + if (notDefined(alias)) alias = generateAliasFromImageData(imageData); if (!(info = checkImagesForAlias(alias, images))) { - if (typeof imageData === 'string') { - tmpImageData = this.convertStringToImageData(imageData, false); + if (this.isString(imageData)) { + tmpImageData = this.convertStringToImageData(imageData); if (tmpImageData !== '') { imageData = tmpImageData; @@ -9231,11 +7577,11 @@ } } - format = getImageFileTypeByImageData(imageData, format); - if (!isImageTypeSupported(format)) { throw new Error('addImage does not support files of type \'' + format + '\', please ensure that a plugin for \'' + format + '\' support is added.'); } - /** - * need to test if it's more efficient to convert all binary strings - * to TypedArray - or should we just leave and process as string? + format = this.getImageFileTypeByImageData(imageData, format); + if (!isImageTypeSupported(format)) throw new Error('addImage does not support files of type \'' + format + '\', please ensure that a plugin for \'' + format + '\' support is added.'); + /** + * need to test if it's more efficient to convert all binary strings + * to TypedArray - or should we just leave and process as string? */ if (this.supportsArrayBuffer()) { @@ -9257,50 +7603,180 @@ writeImageToPDF.call(this, x, y, w, h, info, info.i, images, rotation); return this; }; - /** - * @name convertStringToImageData - * @function - * @param {string} stringData - * @returns {string} binary data + /** + * @name convertStringToImageData + * @function + * @param {string} stringData + * @returns {string} binary data */ - jsPDFAPI.convertStringToImageData = function (stringData, throwError) { - throwError = typeof throwError === "boolean" ? throwError : true; + jsPDFAPI.convertStringToImageData = function (stringData) { var base64Info; var imageData = ''; var rawData; - if (typeof stringData === 'string') { - base64Info = this.extractImageFromDataUrl(stringData); + if (this.isString(stringData)) { + var base64Info = this.extractImageFromDataUrl(stringData); rawData = base64Info !== null ? base64Info.data : stringData; try { imageData = atob(rawData); } catch (e) { if (!jsPDFAPI.validateStringAsBase64(rawData)) { - if (throwError) { - throw new Error('Supplied Data is not a valid base64-String jsPDF.convertStringToImageData '); - } else { - console.log('Supplied Data is not a valid base64-String jsPDF.convertStringToImageData '); - } + throw new Error('Supplied Data is not a valid base64-String jsPDF.convertStringToImageData '); } else { - if (throwError) { - throw new Error('atob-Error in jsPDF.convertStringToImageData ' + e.message); - } else { - console.log('atob-Error in jsPDF.convertStringToImageData ' + e.message); - } + throw new Error('atob-Error in jsPDF.convertStringToImageData ' + e.message); } } } return imageData; }; - /** - * @name getImageProperties - * @function - * @param {Object} imageData - * @returns {Object} + /** + * JPEG SUPPORT + **/ + //takes a string imgData containing the raw bytes of + //a jpeg image and returns [width, height] + //Algorithm from: http://www.64lines.com/jpeg-width-height + + + var getJpegSize = function getJpegSize(imgData) { + + var width, height, numcomponents; // Verify we have a valid jpeg header 0xff,0xd8,0xff,0xe0,?,?,'J','F','I','F',0x00 + + if (getImageFileTypeByImageData(imgData) !== 'JPEG') { + throw new Error('getJpegSize requires a binary string jpeg file'); + } + + var blockLength = imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5); + var i = 4, + len = imgData.length; + + while (i < len) { + i += blockLength; + + if (imgData.charCodeAt(i) !== 0xff) { + throw new Error('getJpegSize could not find the size of the image'); + } + + if (imgData.charCodeAt(i + 1) === 0xc0 || //(SOF) Huffman - Baseline DCT + imgData.charCodeAt(i + 1) === 0xc1 || //(SOF) Huffman - Extended sequential DCT + imgData.charCodeAt(i + 1) === 0xc2 || // Progressive DCT (SOF2) + imgData.charCodeAt(i + 1) === 0xc3 || // Spatial (sequential) lossless (SOF3) + imgData.charCodeAt(i + 1) === 0xc4 || // Differential sequential DCT (SOF5) + imgData.charCodeAt(i + 1) === 0xc5 || // Differential progressive DCT (SOF6) + imgData.charCodeAt(i + 1) === 0xc6 || // Differential spatial (SOF7) + imgData.charCodeAt(i + 1) === 0xc7) { + height = imgData.charCodeAt(i + 5) * 256 + imgData.charCodeAt(i + 6); + width = imgData.charCodeAt(i + 7) * 256 + imgData.charCodeAt(i + 8); + numcomponents = imgData.charCodeAt(i + 9); + return [width, height, numcomponents]; + } else { + i += 2; + blockLength = imgData.charCodeAt(i) * 256 + imgData.charCodeAt(i + 1); + } + } + }, + getJpegSizeFromBytes = function getJpegSizeFromBytes(data) { + var hdr = data[0] << 8 | data[1]; + if (hdr !== 0xFFD8) throw new Error('Supplied data is not a JPEG'); + var len = data.length, + block = (data[4] << 8) + data[5], + pos = 4, + bytes, + width, + height, + numcomponents; + + while (pos < len) { + pos += block; + bytes = readBytes(data, pos); + block = (bytes[2] << 8) + bytes[3]; + + if ((bytes[1] === 0xC0 || bytes[1] === 0xC2) && bytes[0] === 0xFF && block > 7) { + bytes = readBytes(data, pos + 5); + width = (bytes[2] << 8) + bytes[3]; + height = (bytes[0] << 8) + bytes[1]; + numcomponents = bytes[4]; + return { + width: width, + height: height, + numcomponents: numcomponents + }; + } + + pos += 2; + } + + throw new Error('getJpegSizeFromBytes could not find the size of the image'); + }, + readBytes = function readBytes(data, offset) { + return data.subarray(offset, offset + 5); + }; + /** + * @ignore + */ + + + jsPDFAPI.processJPEG = function (data, index, alias, compression, dataAsBinaryString, colorSpace) { + + var filter = this.decode.DCT_DECODE, + bpc = 8, + dims; + + if (!this.isString(data) && !this.isArrayBuffer(data) && !this.isArrayBufferView(data)) { + return null; + } + + if (this.isString(data)) { + dims = getJpegSize(data); + } + + if (this.isArrayBuffer(data)) { + data = new Uint8Array(data); + } + + if (this.isArrayBufferView(data)) { + dims = getJpegSizeFromBytes(data); // if we already have a stored binary string rep use that + + data = dataAsBinaryString || this.arrayBufferToBinaryString(data); + } + + if (colorSpace === undefined) { + switch (dims.numcomponents) { + case 1: + colorSpace = this.color_spaces.DEVICE_GRAY; + break; + + case 4: + colorSpace = this.color_spaces.DEVICE_CMYK; + break; + + default: + case 3: + colorSpace = this.color_spaces.DEVICE_RGB; + break; + } + } + + return this.createImageInfo(data, dims.width, dims.height, colorSpace, bpc, filter, index, alias); + }; + /** + * @ignore + */ + + + jsPDFAPI.processJPG = function () + /*data, index, alias, compression, dataAsBinaryString*/ + { + return this.processJPEG.apply(this, arguments); + }; + /** + * @name getImageProperties + * @function + * @param {Object} imageData + * @returns {Object} */ @@ -9313,14 +7789,18 @@ imageData = createDataURIFromElement(imageData); } - if (typeof imageData === "string") { - tmpImageData = this.convertStringToImageData(imageData, false); + if (this.isString(imageData)) { + tmpImageData = this.convertStringToImageData(imageData); - if (tmpImageData === '') { - tmpImageData = jsPDFAPI.loadFile(imageData) || ''; - } + if (tmpImageData !== '') { + imageData = tmpImageData; + } else { + tmpImageData = jsPDFAPI.loadFile(imageData); - imageData = tmpImageData; + if (tmpImageData !== undefined) { + imageData = tmpImageData; + } + } } format = this.getImageFileTypeByImageData(imageData); @@ -9328,9 +7808,9 @@ if (!isImageTypeSupported(format)) { throw new Error('addImage does not support files of type \'' + format + '\', please ensure that a plugin for \'' + format + '\' support is added.'); } - /** - * need to test if it's more efficient to convert all binary strings - * to TypedArray - or should we just leave and process as string? + /** + * need to test if it's more efficient to convert all binary strings + * to TypedArray - or should we just leave and process as string? */ @@ -9358,81 +7838,78 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF Annotations PlugIn - * - * There are many types of annotations in a PDF document. Annotations are placed - * on a page at a particular location. They are not 'attached' to an object. - *
- * This plugin current supports
- *
  • Goto Page (set pageNumber and top in options) - *
  • Goto Name (set name and top in options) - *
  • Goto URL (set url in options) - *

    - * The destination magnification factor can also be specified when goto is a page number or a named destination. (see documentation below) - * (set magFactor in options). XYZ is the default. - *

    - *

    - * Links, Text, Popup, and FreeText are supported. - *

    - *

    - * Options In PDF spec Not Implemented Yet - *

  • link border - *
  • named target - *
  • page coordinates - *
  • destination page scaling and layout - *
  • actions other than URL and GotoPage - *
  • background / hover actions - *

    - * @name annotations - * @module + /** + * jsPDF Annotations PlugIn + * + * There are many types of annotations in a PDF document. Annotations are placed + * on a page at a particular location. They are not 'attached' to an object. + *
    + * This plugin current supports
    + *
  • Goto Page (set pageNumber and top in options) + *
  • Goto Name (set name and top in options) + *
  • Goto URL (set url in options) + *

    + * The destination magnification factor can also be specified when goto is a page number or a named destination. (see documentation below) + * (set magFactor in options). XYZ is the default. + *

    + *

    + * Links, Text, Popup, and FreeText are supported. + *

    + *

    + * Options In PDF spec Not Implemented Yet + *

  • link border + *
  • named target + *
  • page coordinates + *
  • destination page scaling and layout + *
  • actions other than URL and GotoPage + *
  • background / hover actions + *

    + * @name annotations + * @module */ - /* - Destination Magnification Factors - See PDF 1.3 Page 386 for meanings and options - - [supported] - XYZ (options; left top zoom) - Fit (no options) - FitH (options: top) - FitV (options: left) - - [not supported] - FitR - FitB - FitBH - FitBV + /* + Destination Magnification Factors + See PDF 1.3 Page 386 for meanings and options + + [supported] + XYZ (options; left top zoom) + Fit (no options) + FitH (options: top) + FitV (options: left) + + [not supported] + FitR + FitB + FitBH + FitBV */ (function (jsPDFAPI) { - var notEmpty = function notEmpty(obj) { - if (typeof obj != 'undefined') { - if (obj != '') { - return true; - } - } - }; - jsPDF.API.events.push(['addPage', function (addPageData) { var pageInfo = this.internal.getPageInfo(addPageData.pageNumber); pageInfo.pageContext.annotations = []; }]); jsPDFAPI.events.push(['putPage', function (putPageData) { - var getHorizontalCoordinateString = this.internal.getCoordinateString; - var getVerticalCoordinateString = this.internal.getVerticalCoordinateString; var pageInfo = this.internal.getPageInfoByObjId(putPageData.objId); var pageAnnos = putPageData.pageContext.annotations; + + var notEmpty = function notEmpty(obj) { + if (typeof obj != 'undefined') { + if (obj != '') { + return true; + } + } + }; + var found = false; for (var a = 0; a < pageAnnos.length && !found; a++) { @@ -9442,10 +7919,9 @@ case 'link': if (notEmpty(anno.options.url) || notEmpty(anno.options.pageNumber)) { found = true; + break; } - break; - case 'reference': case 'text': case 'freetext': @@ -9459,9 +7935,12 @@ } this.internal.write("/Annots ["); + var pageHeight = this.internal.pageSize.height; + var getHorizontalCoordinateString = this.internal.getCoordinateString; + var getVerticalCoordinateString = this.internal.getVerticalCoordinateString; - for (var i = 0; i < pageAnnos.length; i++) { - var anno = pageAnnos[i]; + for (var a = 0; a < pageAnnos.length; a++) { + var anno = pageAnnos[a]; switch (anno.type) { case 'reference': @@ -9565,10 +8044,10 @@ this.internal.write("]"); }]); - /** - * @name createAnnotation - * @function - * @param {Object} options + /** + * @name createAnnotation + * @function + * @param {Object} options */ jsPDFAPI.createAnnotation = function (options) { @@ -9585,19 +8064,19 @@ break; } }; - /** - * Create a link - * - * valid options - *
  • pageNumber or url [required] - *

    If pageNumber is specified, top and zoom may also be specified

    - * @name link - * @function - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {Object} options + /** + * Create a link + * + * valid options + *
  • pageNumber or url [required] + *

    If pageNumber is specified, top and zoom may also be specified

    + * @name link + * @function + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {Object} options */ @@ -9612,24 +8091,24 @@ type: 'link' }); }; - /** - * Currently only supports single line text. - * Returns the width of the text/link - * - * @name textWithLink - * @function - * @param {string} text - * @param {number} x - * @param {number} y - * @param {Object} options - * @returns {number} width the width of the text/link + /** + * Currently only supports single line text. + * Returns the width of the text/link + * + * @name textWithLink + * @function + * @param {string} text + * @param {number} x + * @param {number} y + * @param {Object} options + * @returns {number} width the width of the text/link */ jsPDFAPI.textWithLink = function (text, x, y, options) { var width = this.getTextWidth(text); var height = this.internal.getLineHeight() / this.internal.scaleFactor; - this.text(text, x, y, options); //TODO We really need the text baseline height to do this correctly. + this.text(text, x, y); //TODO We really need the text baseline height to do this correctly. // Or ability to draw text on top, bottom, center, or baseline. y += height * .2; @@ -9637,11 +8116,11 @@ return width; }; //TODO move into external library - /** - * @name getTextWidth - * @function - * @param {string} text - * @returns {number} txtWidth + /** + * @name getTextWidth + * @function + * @param {string} text + * @returns {number} txtWidth */ @@ -9654,26 +8133,24 @@ return this; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * Copyright (c) 2017 Aras Abbasi - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Copyright (c) 2017 Aras Abbasi + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF arabic parser PlugIn - * - * @name arabic - * @module + /** + * jsPDF arabic parser PlugIn + * + * @name arabic + * @module */ (function (jsPDFAPI) { - /** - * Arabic shape substitutions: char code => (isolated, final, initial, medial). - * Arabic Substition A + /** + * Arabic shape substitutions: char code => (isolated, final, initial, medial). + * Arabic Substition A */ var arabicSubstitionA = { @@ -9966,6 +8443,7 @@ }; var getCorrectForm = jsPDFAPI.__arabicParser__.getCorrectForm = function (currentChar, beforeChar, nextChar) { + if (!isArabicLetter(currentChar)) { return -1; } @@ -9988,12 +8466,12 @@ return initialForm; }; - /** - * @name processArabic - * @function - * @param {string} text - * @param {boolean} reverse - * @returns {string} + /** + * @name processArabic + * @function + * @param {string} text + * @param {boolean} reverse + * @returns {string} */ @@ -10039,6 +8517,11 @@ var arabicParserFunction = function arabicParserFunction(args) { var text = args.text; + var x = args.x; + var y = args.y; + var options = args.options || {}; + var mutex = args.mutex || {}; + var lang = options.lang; var tmpText = []; if (Object.prototype.toString.call(text) === '[object Array]') { @@ -10062,32 +8545,31 @@ jsPDFAPI.events.push(['preProcessText', arabicParserFunction]); })(jsPDF.API); - /* global jsPDF */ - - /** @license - * jsPDF Autoprint Plugin - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** @license + * jsPDF Autoprint Plugin + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * @name autoprint - * @module + /** + * @name autoprint + * @module */ (function (jsPDFAPI) { - /** - * Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer. - * - * @name autoPrint - * @function - * @param {Object} options (optional) Set the attribute variant to 'non-conform' (default) or 'javascript' to activate different methods of automatic printing when opening in a PDF-viewer . - * @returns {jsPDF} - * @example - * var doc = new jsPDF(); - * doc.text(10, 10, 'This is a test'); - * doc.autoPrint({variant: 'non-conform'}); - * doc.save('autoprint.pdf'); + /** + * Makes the PDF automatically print. This works in Chrome, Firefox, Acrobat + * Reader. + * + * @name autoPrint + * @function + * @param {Object} options (optional) Set the attribute variant to 'non-conform' (default) or 'javascript' to activate different methods of automatic printing when opening in a PDF-viewer . + * @returns {jsPDF} + * @example + * var doc = new jsPDF(); + * doc.text(10, 10, 'This is a test'); + * doc.autoPrint({variant: 'non-conform'}); + * doc.save('autoprint.pdf'); */ jsPDFAPI.autoPrint = function (options) { @@ -10123,28 +8605,26 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF Canvas PlugIn - * This plugin mimics the HTML5 Canvas - * - * The goal is to provide a way for current canvas users to print directly to a PDF. - * @name canvas - * @module + /** + * jsPDF Canvas PlugIn + * This plugin mimics the HTML5 Canvas + * + * The goal is to provide a way for current canvas users to print directly to a PDF. + * @name canvas + * @module */ (function (jsPDFAPI) { - /** - * @class Canvas - * @classdesc A Canvas Wrapper for jsPDF + /** + * @class Canvas + * @classdesc A Canvas Wrapper for jsPDF */ var Canvas = function Canvas() { @@ -10158,11 +8638,11 @@ } }); var _width = 150; - /** - * The height property is a positive integer reflecting the height HTML attribute of the element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. - * This is one of the two properties, the other being width, that controls the size of the canvas. - * - * @name width + /** + * The height property is a positive integer reflecting the height HTML attribute of the element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. + * This is one of the two properties, the other being width, that controls the size of the canvas. + * + * @name width */ Object.defineProperty(this, 'width', { @@ -10182,11 +8662,11 @@ } }); var _height = 300; - /** - * The width property is a positive integer reflecting the width HTML attribute of the element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. - * This is one of the two properties, the other being height, that controls the size of the canvas. - * - * @name height + /** + * The width property is a positive integer reflecting the width HTML attribute of the element interpreted in CSS pixels. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. + * This is one of the two properties, the other being height, that controls the size of the canvas. + * + * @name height */ Object.defineProperty(this, 'height', { @@ -10223,15 +8703,19 @@ _style = value; } }); - Object.defineProperty(this, 'parentNode', {}); - }; - /** - * The getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported. - * - * @name getContext - * @function - * @param {string} contextType Is a String containing the context identifier defining the drawing context associated to the canvas. Possible value is "2d", leading to the creation of a Context2D object representing a two-dimensional rendering context. - * @param {object} contextAttributes + Object.defineProperty(this, 'parentNode', { + get: function get() { + return false; + } + }); + }; + /** + * The getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported. + * + * @name getContext + * @function + * @param {string} contextType Is a String containing the context identifier defining the drawing context associated to the canvas. Possible value is "2d", leading to the creation of a Context2D object representing a two-dimensional rendering context. + * @param {object} contextAttributes */ @@ -10252,11 +8736,11 @@ this.pdf.context2d._canvas = this; return this.pdf.context2d; }; - /** - * The toDataURL() method is just a stub to throw an error if accidently called. - * - * @name toDataURL - * @function + /** + * The toDataURL() method is just a stub to throw an error if accidently called. + * + * @name toDataURL + * @function */ @@ -10271,28 +8755,28 @@ return this; })(jsPDF.API); - /** - * @license - * ==================================================================== - * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com - * 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br - * 2013 Lee Driscoll, https://github.com/lsdriscoll - * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria - * 2014 James Hall, james@parall.ax - * 2014 Diego Casorran, https://github.com/diegocr - * - * - * ==================================================================== + /** + * @license + * ==================================================================== + * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com + * 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br + * 2013 Lee Driscoll, https://github.com/lsdriscoll + * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria + * 2014 James Hall, james@parall.ax + * 2014 Diego Casorran, https://github.com/diegocr + * + * + * ==================================================================== */ - /** - * @name cell - * @module + /** + * @name cell + * @module */ (function (jsPDFAPI) { /*jslint browser:true */ - /*global jsPDF */ + /*global document: false, jsPDF */ var padding = 3, margin = 13, @@ -10322,26 +8806,27 @@ top: 0, bottom: 0 }; - /** - * @name setHeaderFunction - * @function - * @param {function} func + /** + * @name setHeaderFunction + * @function + * @param {function} func */ jsPDFAPI.setHeaderFunction = function (func) { headerFunction = func; }; - /** - * @name getTextDimensions - * @function - * @param {string} txt - * @returns {Object} dimensions + /** + * @name getTextDimensions + * @function + * @param {string} txt + * @returns {Object} dimensions */ jsPDFAPI.getTextDimensions = function (text, options) { var fontSize = this.table_font_size || this.internal.getFontSize(); + var fontStyle = this.internal.getFont().fontStyle; options = options || {}; var scaleFactor = options.scaleFactor || this.internal.scaleFactor; var width = 0; @@ -10378,9 +8863,9 @@ h: height }; }; - /** - * @name cellAddPage - * @function + /** + * @name cellAddPage + * @function */ @@ -10391,9 +8876,9 @@ pages += 1; }; - /** - * @name cellInitialize - * @function + /** + * @name cellInitialize + * @function */ @@ -10407,17 +8892,17 @@ }; pages = 1; }; - /** - * @name cell - * @function - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {string} txt - * @param {number} ln lineNumber - * @param {string} align - * @return {jsPDF} jsPDF-instance + /** + * @name cell + * @function + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {string} txt + * @param {number} ln lineNumber + * @param {string} align + * @return {jsPDF} jsPDF-instance */ @@ -10445,7 +8930,7 @@ y = getLastCellPosition().y + getLastCellPosition().h; - if (pgAdded) { y = margin + 10; } + if (pgAdded) y = margin + 10; } } @@ -10474,14 +8959,14 @@ setLastCellPosition(x, y, w, h, ln); return this; }; - /** - * Return the maximum value from an array - * - * @name arrayMax - * @function - * @param {Array} array - * @param comparisonFn - * @returns {number} + /** + * Return the maximum value from an array + * + * @name arrayMax + * @function + * @param {Array} array + * @param comparisonFn + * @returns {number} */ @@ -10507,19 +8992,19 @@ return max; }; - /** - * Create a table from a set of data. - * @name table - * @function - * @param {Integer} [x] : left-position for top-left corner of table - * @param {Integer} [y] top-position for top-left corner of table - * @param {Object[]} [data] As array of objects containing key-value pairs corresponding to a row of data. - * @param {String[]} [headers] Omit or null to auto-generate headers at a performance cost - * @param {Object} [config.printHeaders] True to print column headers at the top of every page - * @param {Object} [config.autoSize] True to dynamically set the column widths to match the widest cell value - * @param {Object} [config.margins] margin values for left, top, bottom, and width - * @param {Object} [config.fontSize] Integer fontSize to use (optional) - * @returns {jsPDF} jsPDF-instance + /** + * Create a table from a set of data. + * @name table + * @function + * @param {Integer} [x] : left-position for top-left corner of table + * @param {Integer} [y] top-position for top-left corner of table + * @param {Object[]} [data] As array of objects containing key-value pairs corresponding to a row of data. + * @param {String[]} [headers] Omit or null to auto-generate headers at a performance cost + * @param {Object} [config.printHeaders] True to print column headers at the top of every page + * @param {Object} [config.autoSize] True to dynamically set the column widths to match the widest cell value + * @param {Object} [config.margins] margin values for left, top, bottom, and width + * @param {Object} [config.fontSize] Integer fontSize to use (optional) + * @returns {jsPDF} jsPDF-instance */ @@ -10573,9 +9058,9 @@ margins = config.margins; } } - /** - * @property {Number} lnMod - * Keep track of the current line number modifier used when creating cells + /** + * @property {Number} lnMod + * Keep track of the current line number modifier used when creating cells */ @@ -10654,6 +9139,7 @@ for (i = 0, ln = data.length; i < ln; i += 1) { + var lineHeight; model = data[i]; lineHeight = this.calculateLineHeight(headerNames, columnWidths, model); @@ -10668,15 +9154,15 @@ this.table_y = y; return this; }; - /** - * Calculate the height for containing the highest column - * - * @name calculateLineHeight - * @function - * @param {String[]} headerNames is the header, used as keys to the data - * @param {Integer[]} columnWidths is size of each column - * @param {Object[]} model is the line of data we want to calculate the height of - * @returns {number} lineHeight + /** + * Calculate the height for containing the highest column + * + * @name calculateLineHeight + * @function + * @param {String[]} headerNames is the header, used as keys to the data + * @param {Integer[]} columnWidths is size of each column + * @param {Object[]} model is the line of data we want to calculate the height of + * @returns {number} lineHeight */ @@ -10688,32 +9174,32 @@ header = headerNames[j]; model[header] = this.splitTextToSize(String(model[header]), columnWidths[header] - padding); var h = this.internal.getLineHeight() * model[header].length + padding; - if (h > lineHeight) { lineHeight = h; } + if (h > lineHeight) lineHeight = h; } return lineHeight; }; - /** - * Store the config for outputting a table header - * - * @name setTableHeaderRow - * @function - * @param {Object[]} config - * An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell - * except the ln parameter is excluded + /** + * Store the config for outputting a table header + * + * @name setTableHeaderRow + * @function + * @param {Object[]} config + * An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell + * except the ln parameter is excluded */ jsPDFAPI.setTableHeaderRow = function (config) { this.tableHeaderRow = config; }; - /** - * Output the store header row - * - * @name printHeaderRow - * @function - * @param {number} lineNumber The line number to output the header at - * @param {boolean} new_page + /** + * Output the store header row + * + * @name printHeaderRow + * @function + * @param {number} lineNumber The line number to output the header at + * @param {boolean} new_page */ @@ -10756,25 +9242,21 @@ }; })(jsPDF.API); - /* eslint-disable no-console */ - - /* global jsPDF, RGBColor */ - - /** - * jsPDF Context2D PlugIn Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv - * - * Licensed under the MIT License. http://opensource.org/licenses/mit-license + /** + * jsPDF Context2D PlugIn Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv + * + * Licensed under the MIT License. http://opensource.org/licenses/mit-license */ - /** - * This plugin mimics the HTML5 CanvasRenderingContext2D. - * - * The goal is to provide a way for current canvas implementations to print directly to a PDF. - * - * @name context2d - * @module + /** + * This plugin mimics the HTML5 CanvasRenderingContext2D. + * + * The goal is to provide a way for current canvas implementations to print directly to a PDF. + * + * @name context2d + * @module */ - (function (jsPDFAPI) { + (function (jsPDFAPI, globalObj) { var ContextLayer = function ContextLayer(ctx) { ctx = ctx || {}; @@ -10803,19 +9285,15 @@ }; //stub - var f2, getHorizontalCoordinateString, getVerticalCoordinateString, getHorizontalCoordinate, getVerticalCoordinate, Point, Rectangle, Matrix, _ctx; - + var f2, f3, getHorizontalCoordinateString, getVerticalCoordinateString, getHorizontalCoordinate, getVerticalCoordinate; jsPDFAPI.events.push(['initialized', function () { this.context2d = new Context2D(this); f2 = this.internal.f2; + f3 = this.internal.f3; getHorizontalCoordinateString = this.internal.getCoordinateString; getVerticalCoordinateString = this.internal.getVerticalCoordinateString; getHorizontalCoordinate = this.internal.getHorizontalCoordinate; getVerticalCoordinate = this.internal.getVerticalCoordinate; - Point = this.internal.Point; - Rectangle = this.internal.Rectangle; - Matrix = this.internal.Matrix; - _ctx = new ContextLayer(); }]); var Context2D = function Context2D(pdf) { @@ -10833,10 +9311,10 @@ } }); var _pageWrapXEnabled = false; - /** - * @name pageWrapXEnabled - * @type {boolean} - * @default false + /** + * @name pageWrapXEnabled + * @type {boolean} + * @default false */ Object.defineProperty(this, 'pageWrapXEnabled', { @@ -10848,10 +9326,10 @@ } }); var _pageWrapYEnabled = false; - /** - * @name pageWrapYEnabled - * @type {boolean} - * @default true + /** + * @name pageWrapYEnabled + * @type {boolean} + * @default true */ Object.defineProperty(this, 'pageWrapYEnabled', { @@ -10863,10 +9341,10 @@ } }); var _posX = 0; - /** - * @name posX - * @type {number} - * @default 0 + /** + * @name posX + * @type {number} + * @default 0 */ Object.defineProperty(this, 'posX', { @@ -10880,10 +9358,10 @@ } }); var _posY = 0; - /** - * @name posY - * @type {number} - * @default 0 + /** + * @name posY + * @type {number} + * @default 0 */ Object.defineProperty(this, 'posY', { @@ -10897,10 +9375,10 @@ } }); var _autoPaging = false; - /** - * @name autoPaging - * @type {boolean} - * @default true + /** + * @name autoPaging + * @type {boolean} + * @default true */ Object.defineProperty(this, 'autoPaging', { @@ -10912,10 +9390,10 @@ } }); var lastBreak = 0; - /** - * @name lastBreak - * @type {number} - * @default 0 + /** + * @name lastBreak + * @type {number} + * @default 0 */ Object.defineProperty(this, 'lastBreak', { @@ -10927,11 +9405,11 @@ } }); var pageBreaks = []; - /** - * Y Position of page breaks. - * @name pageBreaks - * @type {number} - * @default 0 + /** + * Y Position of page breaks. + * @name pageBreaks + * @type {number} + * @default 0 */ Object.defineProperty(this, 'pageBreaks', { @@ -10942,12 +9420,15 @@ pageBreaks = value; } }); - /** - * @name ctx - * @type {object} - * @default {} + + var _ctx = new ContextLayer(); + /** + * @name ctx + * @type {object} + * @default {} */ + Object.defineProperty(this, 'ctx', { get: function get() { return _ctx; @@ -10958,10 +9439,10 @@ } } }); - /** - * @name path - * @type {array} - * @default [] + /** + * @name path + * @type {array} + * @default [] */ Object.defineProperty(this, 'path', { @@ -10972,10 +9453,10 @@ _ctx.path = value; } }); - /** - * @name ctxStack - * @type {array} - * @default [] + /** + * @name ctxStack + * @type {array} + * @default [] */ var _ctxStack = []; @@ -10987,14 +9468,14 @@ _ctxStack = value; } }); - /** - * Sets or returns the color, gradient, or pattern used to fill the drawing - * - * @name fillStyle - * @default #000000 - * @property {(color|gradient|pattern)} value The color of the drawing. Default value is #000000
    - * A gradient object (linear or radial) used to fill the drawing (not supported by context2d)
    - * A pattern object to use to fill the drawing (not supported by context2d) + /** + * Sets or returns the color, gradient, or pattern used to fill the drawing + * + * @name fillStyle + * @default #000000 + * @property {(color|gradient|pattern)} value The color of the drawing. Default value is #000000
    + * A gradient object (linear or radial) used to fill the drawing (not supported by context2d)
    + * A pattern object to use to fill the drawing (not supported by context2d) */ Object.defineProperty(this, 'fillStyle', { @@ -11015,14 +9496,14 @@ }); } }); - /** - * Sets or returns the color, gradient, or pattern used for strokes - * - * @name strokeStyle - * @default #000000 - * @property {color} color A CSS color value that indicates the stroke color of the drawing. Default value is #000000 (not supported by context2d) - * @property {gradient} gradient A gradient object (linear or radial) used to create a gradient stroke (not supported by context2d) - * @property {pattern} pattern A pattern object used to create a pattern stroke (not supported by context2d) + /** + * Sets or returns the color, gradient, or pattern used for strokes + * + * @name strokeStyle + * @default #000000 + * @property {color} color A CSS color value that indicates the stroke color of the drawing. Default value is #000000 (not supported by context2d) + * @property {gradient} gradient A gradient object (linear or radial) used to create a gradient stroke (not supported by context2d) + * @property {pattern} pattern A pattern object used to create a pattern stroke (not supported by context2d) */ Object.defineProperty(this, 'strokeStyle', { @@ -11044,14 +9525,14 @@ } } }); - /** - * Sets or returns the style of the end caps for a line - * - * @name lineCap - * @default butt - * @property {(butt|round|square)} lineCap butt A flat edge is added to each end of the line
    - * round A rounded end cap is added to each end of the line
    - * square A square end cap is added to each end of the line
    + /** + * Sets or returns the style of the end caps for a line + * + * @name lineCap + * @default butt + * @property {(butt|round|square)} lineCap butt A flat edge is added to each end of the line
    + * round A rounded end cap is added to each end of the line
    + * square A square end cap is added to each end of the line
    */ Object.defineProperty(this, 'lineCap', { @@ -11065,12 +9546,12 @@ } } }); - /** - * Sets or returns the current line width - * - * @name lineWidth - * @default 1 - * @property {number} lineWidth The current line width, in pixels + /** + * Sets or returns the current line width + * + * @name lineWidth + * @default 1 + * @property {number} lineWidth The current line width, in pixels */ Object.defineProperty(this, 'lineWidth', { @@ -11084,8 +9565,8 @@ } } }); - /** - * Sets or returns the type of corner created, when two lines meet + /** + * Sets or returns the type of corner created, when two lines meet */ Object.defineProperty(this, 'lineJoin', { @@ -11099,11 +9580,11 @@ } } }); - /** - * A number specifying the miter limit ratio in coordinate space units. Zero, negative, Infinity, and NaN values are ignored. The default value is 10.0. - * - * @name miterLimit - * @default 10 + /** + * A number specifying the miter limit ratio in coordinate space units. Zero, negative, Infinity, and NaN values are ignored. The default value is 10.0. + * + * @name miterLimit + * @default 10 */ Object.defineProperty(this, 'miterLimit', { @@ -11142,7 +9623,6 @@ set: function set(value) { this.ctx.font = value; var rx, matches; //source: https://stackoverflow.com/a/10136041 - // eslint-disable-next-line no-useless-escape rx = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z]+?)\s*$/i; matches = rx.exec(value); @@ -11222,9 +9702,9 @@ } if (jsPdfFontName === '') { - for (var j = 0; j < parts.length; j++) { - if (fallbackFonts[parts[j]]) { - jsPdfFontName = fallbackFonts[parts[j]]; + for (var i = 0; i < parts.length; i++) { + if (fallbackFonts[parts[i]]) { + jsPdfFontName = fallbackFonts[parts[i]]; break; } } @@ -11264,24 +9744,24 @@ Context2D.prototype.fill = function () { pathPreProcess.call(this, 'fill', false); }; - /** - * Actually draws the path you have defined - * - * @name stroke - * @function - * @description The stroke() method actually draws the path you have defined with all those moveTo() and lineTo() methods. The default color is black. + /** + * Actually draws the path you have defined + * + * @name stroke + * @function + * @description The stroke() method actually draws the path you have defined with all those moveTo() and lineTo() methods. The default color is black. */ Context2D.prototype.stroke = function () { pathPreProcess.call(this, 'stroke', false); }; - /** - * Begins a path, or resets the current - * - * @name beginPath - * @function - * @description The beginPath() method begins a path, or resets the current path. + /** + * Begins a path, or resets the current + * + * @name beginPath + * @function + * @description The beginPath() method begins a path, or resets the current path. */ @@ -11290,13 +9770,13 @@ type: 'begin' }]; }; - /** - * Moves the path to the specified point in the canvas, without creating a line - * - * @name moveTo - * @function - * @param x {Number} The x-coordinate of where to move the path to - * @param y {Number} The y-coordinate of where to move the path to + /** + * Moves the path to the specified point in the canvas, without creating a line + * + * @name moveTo + * @function + * @param x {Number} The x-coordinate of where to move the path to + * @param y {Number} The y-coordinate of where to move the path to */ @@ -11314,12 +9794,12 @@ }); this.ctx.lastPoint = new Point(x, y); }; - /** - * Creates a path from the current point back to the starting point - * - * @name closePath - * @function - * @description The closePath() method creates a path from the current point back to the starting point. + /** + * Creates a path from the current point back to the starting point + * + * @name closePath + * @function + * @description The closePath() method creates a path from the current point back to the starting point. */ @@ -11350,14 +9830,14 @@ }); this.ctx.lastPoint = new Point(pathBegin.x, pathBegin.y); }; - /** - * Adds a new point and creates a line to that point from the last specified point in the canvas - * - * @name lineTo - * @function - * @param x The x-coordinate of where to create the line to - * @param y The y-coordinate of where to create the line to - * @description The lineTo() method adds a new point and creates a line TO that point FROM the last specified point in the canvas (this method does not draw the line). + /** + * Adds a new point and creates a line to that point from the last specified point in the canvas + * + * @name lineTo + * @function + * @param x The x-coordinate of where to create the line to + * @param y The y-coordinate of where to create the line to + * @description The lineTo() method adds a new point and creates a line TO that point FROM the last specified point in the canvas (this method does not draw the line). */ @@ -11375,12 +9855,12 @@ }); this.ctx.lastPoint = new Point(pt.x, pt.y); }; - /** - * Clips a region of any shape and size from the original canvas - * - * @name clip - * @function - * @description The clip() method clips a region of any shape and size from the original canvas. + /** + * Clips a region of any shape and size from the original canvas + * + * @name clip + * @function + * @description The clip() method clips a region of any shape and size from the original canvas. */ @@ -11388,16 +9868,16 @@ this.ctx.clip_path = JSON.parse(JSON.stringify(this.path)); pathPreProcess.call(this, null, true); }; - /** - * Creates a cubic Bézier curve - * - * @name quadraticCurveTo - * @function - * @param cpx {Number} The x-coordinate of the Bézier control point - * @param cpy {Number} The y-coordinate of the Bézier control point - * @param x {Number} The x-coordinate of the ending point - * @param y {Number} The y-coordinate of the ending point - * @description The quadraticCurveTo() method adds a point to the current path by using the specified control points that represent a quadratic Bézier curve.

    A quadratic Bézier curve requires two points. The first point is a control point that is used in the quadratic Bézier calculation and the second point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. + /** + * Creates a cubic Bézier curve + * + * @name quadraticCurveTo + * @function + * @param cpx {Number} The x-coordinate of the Bézier control point + * @param cpy {Number} The y-coordinate of the Bézier control point + * @param x {Number} The x-coordinate of the ending point + * @param y {Number} The y-coordinate of the ending point + * @description The quadraticCurveTo() method adds a point to the current path by using the specified control points that represent a quadratic Bézier curve.

    A quadratic Bézier curve requires two points. The first point is a control point that is used in the quadratic Bézier calculation and the second point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. */ @@ -11418,18 +9898,18 @@ }); this.ctx.lastPoint = new Point(pt0.x, pt0.y); }; - /** - * Creates a cubic Bézier curve - * - * @name bezierCurveTo - * @function - * @param cp1x {Number} The x-coordinate of the first Bézier control point - * @param cp1y {Number} The y-coordinate of the first Bézier control point - * @param cp2x {Number} The x-coordinate of the second Bézier control point - * @param cp2y {Number} The y-coordinate of the second Bézier control point - * @param x {Number} The x-coordinate of the ending point - * @param y {Number} The y-coordinate of the ending point - * @description The bezierCurveTo() method adds a point to the current path by using the specified control points that represent a cubic Bézier curve.

    A cubic bezier curve requires three points. The first two points are control points that are used in the cubic Bézier calculation and the last point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. + /** + * Creates a cubic Bézier curve + * + * @name bezierCurveTo + * @function + * @param cp1x {Number} The x-coordinate of the first Bézier control point + * @param cp1y {Number} The y-coordinate of the first Bézier control point + * @param cp2x {Number} The x-coordinate of the second Bézier control point + * @param cp2y {Number} The y-coordinate of the second Bézier control point + * @param x {Number} The x-coordinate of the ending point + * @param y {Number} The y-coordinate of the ending point + * @description The bezierCurveTo() method adds a point to the current path by using the specified control points that represent a cubic Bézier curve.

    A cubic bezier curve requires three points. The first two points are control points that are used in the cubic Bézier calculation and the last point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. */ @@ -11453,18 +9933,18 @@ }); this.ctx.lastPoint = new Point(pt0.x, pt0.y); }; - /** - * Creates an arc/curve (used to create circles, or parts of circles) - * - * @name arc - * @function - * @param x {Number} The x-coordinate of the center of the circle - * @param y {Number} The y-coordinate of the center of the circle - * @param radius {Number} The radius of the circle - * @param startAngle {Number} The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) - * @param endAngle {Number} The ending angle, in radians - * @param counterclockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. - * @description The arc() method creates an arc/curve (used to create circles, or parts of circles). + /** + * Creates an arc/curve (used to create circles, or parts of circles) + * + * @name arc + * @function + * @param x {Number} The x-coordinate of the center of the circle + * @param y {Number} The y-coordinate of the center of the circle + * @param radius {Number} The radius of the circle + * @param startAngle {Number} The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) + * @param endAngle {Number} The ending angle, in radians + * @param counterclockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. + * @description The arc() method creates an arc/curve (used to create circles, or parts of circles). */ @@ -11500,33 +9980,33 @@ counterclockwise: counterclockwise }); // this.ctx.lastPoint(new Point(pt.x,pt.y)); }; - /** - * Creates an arc/curve between two tangents - * - * @name arcTo - * @function - * @param x1 {Number} The x-coordinate of the first tangent - * @param y1 {Number} The y-coordinate of the first tangent - * @param x2 {Number} The x-coordinate of the second tangent - * @param y2 {Number} The y-coordinate of the second tangent - * @param radius The radius of the arc - * @description The arcTo() method creates an arc/curve between two tangents on the canvas. + /** + * Creates an arc/curve between two tangents + * + * @name arcTo + * @function + * @param x1 {Number} The x-coordinate of the first tangent + * @param y1 {Number} The y-coordinate of the first tangent + * @param x2 {Number} The x-coordinate of the second tangent + * @param y2 {Number} The y-coordinate of the second tangent + * @param radius The radius of the arc + * @description The arcTo() method creates an arc/curve between two tangents on the canvas. */ Context2D.prototype.arcTo = function (x1, y1, x2, y2, radius) { throw new Error('arcTo not implemented.'); }; - /** - * Creates a rectangle - * - * @name rect - * @function - * @param x {Number} The x-coordinate of the upper-left corner of the rectangle - * @param y {Number} The y-coordinate of the upper-left corner of the rectangle - * @param w {Number} The width of the rectangle, in pixels - * @param h {Number} The height of the rectangle, in pixels - * @description The rect() method creates a rectangle. + /** + * Creates a rectangle + * + * @name rect + * @function + * @param x {Number} The x-coordinate of the upper-left corner of the rectangle + * @param y {Number} The y-coordinate of the upper-left corner of the rectangle + * @param w {Number} The width of the rectangle, in pixels + * @param h {Number} The height of the rectangle, in pixels + * @description The rect() method creates a rectangle. */ @@ -11544,16 +10024,16 @@ this.lineTo(x + w, y); this.lineTo(x, y); }; - /** - * Draws a "filled" rectangle - * - * @name fillRect - * @function - * @param x {Number} The x-coordinate of the upper-left corner of the rectangle - * @param y {Number} The y-coordinate of the upper-left corner of the rectangle - * @param w {Number} The width of the rectangle, in pixels - * @param h {Number} The height of the rectangle, in pixels - * @description The fillRect() method draws a "filled" rectangle. The default color of the fill is black. + /** + * Draws a "filled" rectangle + * + * @name fillRect + * @function + * @param x {Number} The x-coordinate of the upper-left corner of the rectangle + * @param y {Number} The y-coordinate of the upper-left corner of the rectangle + * @param w {Number} The width of the rectangle, in pixels + * @param h {Number} The height of the rectangle, in pixels + * @description The fillRect() method draws a "filled" rectangle. The default color of the fill is black. */ @@ -11591,16 +10071,16 @@ this.lineJoin = tmp.lineJoin; } }; - /** - * Draws a rectangle (no fill) - * - * @name strokeRect - * @function - * @param x {Number} The x-coordinate of the upper-left corner of the rectangle - * @param y {Number} The y-coordinate of the upper-left corner of the rectangle - * @param w {Number} The width of the rectangle, in pixels - * @param h {Number} The height of the rectangle, in pixels - * @description The strokeRect() method draws a rectangle (no fill). The default color of the stroke is black. + /** + * Draws a rectangle (no fill) + * + * @name strokeRect + * @function + * @param x {Number} The x-coordinate of the upper-left corner of the rectangle + * @param y {Number} The y-coordinate of the upper-left corner of the rectangle + * @param w {Number} The width of the rectangle, in pixels + * @param h {Number} The height of the rectangle, in pixels + * @description The strokeRect() method draws a rectangle (no fill). The default color of the stroke is black. */ @@ -11618,20 +10098,20 @@ this.rect(x, y, w, h); this.stroke(); }; - /** - * Clears the specified pixels within a given rectangle - * - * @name clearRect - * @function - * @param x {Number} The x-coordinate of the upper-left corner of the rectangle - * @param y {Number} The y-coordinate of the upper-left corner of the rectangle - * @param w {Number} The width of the rectangle to clear, in pixels - * @param h {Number} The height of the rectangle to clear, in pixels - * @description We cannot clear PDF commands that were already written to PDF, so we use white instead.
    - * As a special case, read a special flag (ignoreClearRect) and do nothing if it is set. - * This results in all calls to clearRect() to do nothing, and keep the canvas transparent. - * This flag is stored in the save/restore context and is managed the same way as other drawing states. - * + /** + * Clears the specified pixels within a given rectangle + * + * @name clearRect + * @function + * @param x {Number} The x-coordinate of the upper-left corner of the rectangle + * @param y {Number} The y-coordinate of the upper-left corner of the rectangle + * @param w {Number} The width of the rectangle to clear, in pixels + * @param h {Number} The height of the rectangle to clear, in pixels + * @description We cannot clear PDF commands that were already written to PDF, so we use white instead.
    + * As a special case, read a special flag (ignoreClearRect) and do nothing if it is set. + * This results in all calls to clearRect() to do nothing, and keep the canvas transparent. + * This flag is stored in the save/restore context and is managed the same way as other drawing states. + * */ @@ -11648,11 +10128,11 @@ this.fillStyle = '#ffffff'; this.fillRect(x, y, w, h); }; - /** - * Saves the state of the current context - * - * @name save - * @function + /** + * Saves the state of the current context + * + * @name save + * @function */ @@ -11674,11 +10154,11 @@ this.ctx = ctx; } }; - /** - * Returns previously saved path state and attributes - * - * @name restore - * @function + /** + * Returns previously saved path state and attributes + * + * @name restore + * @function */ @@ -11703,9 +10183,9 @@ this.lineJoin = this.ctx.lineJoin; } }; - /** - * @name toDataURL - * @function + /** + * @name toDataURL + * @function */ @@ -11713,13 +10193,13 @@ throw new Error('toDataUrl not implemented.'); }; //helper functions - /** - * Get the decimal values of r, g, b and a - * - * @name getRGBA - * @function - * @private - * @ignore + /** + * Get the decimal values of r, g, b and a + * + * @name getRGBA + * @function + * @private + * @ignore */ @@ -11805,40 +10285,40 @@ style: style }; }; - /** - * @name isFillTransparent - * @function - * @private - * @ignore - * @returns {Boolean} + /** + * @name isFillTransparent + * @function + * @private + * @ignore + * @returns {Boolean} */ var isFillTransparent = function isFillTransparent() { return this.ctx.isFillTransparent || this.globalAlpha == 0; }; - /** - * @name isStrokeTransparent - * @function - * @private - * @ignore - * @returns {Boolean} + /** + * @name isStrokeTransparent + * @function + * @private + * @ignore + * @returns {Boolean} */ var isStrokeTransparent = function isStrokeTransparent() { return Boolean(this.ctx.isStrokeTransparent || this.globalAlpha == 0); }; - /** - * Draws "filled" text on the canvas - * - * @name fillText - * @function - * @param text {String} Specifies the text that will be written on the canvas - * @param x {Number} The x coordinate where to start painting the text (relative to the canvas) - * @param y {Number} The y coordinate where to start painting the text (relative to the canvas) - * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels - * @description The fillText() method draws filled text on the canvas. The default color of the text is black. + /** + * Draws "filled" text on the canvas + * + * @name fillText + * @function + * @param text {String} Specifies the text that will be written on the canvas + * @param x {Number} The x coordinate where to start painting the text (relative to the canvas) + * @param y {Number} The y coordinate where to start painting the text (relative to the canvas) + * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels + * @description The fillText() method draws filled text on the canvas. The default color of the text is black. */ @@ -11868,16 +10348,16 @@ maxWidth: maxWidth }); }; - /** - * Draws text on the canvas (no fill) - * - * @name strokeText - * @function - * @param text {String} Specifies the text that will be written on the canvas - * @param x {Number} The x coordinate where to start painting the text (relative to the canvas) - * @param y {Number} The y coordinate where to start painting the text (relative to the canvas) - * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels - * @description The strokeText() method draws text (with no fill) on the canvas. The default color of the text is black. + /** + * Draws text on the canvas (no fill) + * + * @name strokeText + * @function + * @param text {String} Specifies the text that will be written on the canvas + * @param x {Number} The x coordinate where to start painting the text (relative to the canvas) + * @param y {Number} The y coordinate where to start painting the text (relative to the canvas) + * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels + * @description The strokeText() method draws text (with no fill) on the canvas. The default color of the text is black. */ @@ -11906,14 +10386,14 @@ maxWidth: maxWidth }); }; - /** - * Returns an object that contains the width of the specified text - * - * @name measureText - * @function - * @param text {String} The text to be measured - * @description The measureText() method returns an object that contains the width of the specified text, in pixels. - * @returns {Number} + /** + * Returns an object that contains the width of the specified text + * + * @name measureText + * @function + * @param text {String} The text to be measured + * @description The measureText() method returns an object that contains the width of the specified text, in pixels. + * @returns {Number} */ @@ -11947,14 +10427,14 @@ }); }; //Transformations - /** - * Scales the current drawing bigger or smaller - * - * @name scale - * @function - * @param scalewidth {Number} Scales the width of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) - * @param scaleheight {Number} Scales the height of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) - * @description The scale() method scales the current drawing, bigger or smaller. + /** + * Scales the current drawing bigger or smaller + * + * @name scale + * @function + * @param scalewidth {Number} Scales the width of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) + * @param scaleheight {Number} Scales the height of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) + * @description The scale() method scales the current drawing, bigger or smaller. */ @@ -11967,14 +10447,14 @@ var matrix = new Matrix(scalewidth, 0.0, 0.0, scaleheight, 0.0, 0.0); this.ctx.transform = this.ctx.transform.multiply(matrix); }; - /** - * Rotates the current drawing - * - * @name rotate - * @function - * @param angle {Number} The rotation angle, in radians. - * @description To calculate from degrees to radians: degrees*Math.PI/180.
    - * Example: to rotate 5 degrees, specify the following: 5*Math.PI/180 + /** + * Rotates the current drawing + * + * @name rotate + * @function + * @param angle {Number} The rotation angle, in radians. + * @description To calculate from degrees to radians: degrees*Math.PI/180.
    + * Example: to rotate 5 degrees, specify the following: 5*Math.PI/180 */ @@ -11987,14 +10467,14 @@ var matrix = new Matrix(Math.cos(angle), Math.sin(angle), -Math.sin(angle), Math.cos(angle), 0.0, 0.0); this.ctx.transform = this.ctx.transform.multiply(matrix); }; - /** - * Remaps the (0,0) position on the canvas - * - * @name translate - * @function - * @param x {Number} The value to add to horizontal (x) coordinates - * @param y {Number} The value to add to vertical (y) coordinates - * @description The translate() method remaps the (0,0) position on the canvas. + /** + * Remaps the (0,0) position on the canvas + * + * @name translate + * @function + * @param x {Number} The value to add to horizontal (x) coordinates + * @param y {Number} The value to add to vertical (y) coordinates + * @description The translate() method remaps the (0,0) position on the canvas. */ @@ -12007,18 +10487,18 @@ var matrix = new Matrix(1.0, 0.0, 0.0, 1.0, x, y); this.ctx.transform = this.ctx.transform.multiply(matrix); }; - /** - * Replaces the current transformation matrix for the drawing - * - * @name transform - * @function - * @param a {Number} Horizontal scaling - * @param b {Number} Horizontal skewing - * @param c {Number} Vertical skewing - * @param d {Number} Vertical scaling - * @param e {Number} Horizontal moving - * @param f {Number} Vertical moving - * @description Each object on the canvas has a current transformation matrix.

    The transform() method replaces the current transformation matrix. It multiplies the current transformation matrix with the matrix described by:



    a c e

    b d f

    0 0 1

    In other words, the transform() method lets you scale, rotate, move, and skew the current context. + /** + * Replaces the current transformation matrix for the drawing + * + * @name transform + * @function + * @param a {Number} Horizontal scaling + * @param b {Number} Horizontal skewing + * @param c {Number} Vertical skewing + * @param d {Number} Vertical scaling + * @param e {Number} Horizontal moving + * @param f {Number} Vertical moving + * @description Each object on the canvas has a current transformation matrix.

    The transform() method replaces the current transformation matrix. It multiplies the current transformation matrix with the matrix described by:



    a c e

    b d f

    0 0 1

    In other words, the transform() method lets you scale, rotate, move, and skew the current context. */ @@ -12031,18 +10511,18 @@ var matrix = new Matrix(a, b, c, d, e, f); this.ctx.transform = this.ctx.transform.multiply(matrix); }; - /** - * Resets the current transform to the identity matrix. Then runs transform() - * - * @name setTransform - * @function - * @param a {Number} Horizontal scaling - * @param b {Number} Horizontal skewing - * @param c {Number} Vertical skewing - * @param d {Number} Vertical scaling - * @param e {Number} Horizontal moving - * @param f {Number} Vertical moving - * @description Each object on the canvas has a current transformation matrix.

    The setTransform() method resets the current transform to the identity matrix, and then runs transform() with the same arguments.

    In other words, the setTransform() method lets you scale, rotate, move, and skew the current context. + /** + * Resets the current transform to the identity matrix. Then runs transform() + * + * @name setTransform + * @function + * @param a {Number} Horizontal scaling + * @param b {Number} Horizontal skewing + * @param c {Number} Vertical skewing + * @param d {Number} Vertical scaling + * @param e {Number} Horizontal moving + * @param f {Number} Vertical moving + * @description Each object on the canvas has a current transformation matrix.

    The setTransform() method resets the current transform to the identity matrix, and then runs transform() with the same arguments.

    In other words, the setTransform() method lets you scale, rotate, move, and skew the current context. */ @@ -12055,19 +10535,19 @@ f = isNaN(f) ? 0 : f; this.ctx.transform = new Matrix(a, b, c, d, e, f); }; - /** - * Draws an image, canvas, or video onto the canvas - * - * @function - * @param img {} Specifies the image, canvas, or video element to use - * @param sx {Number} Optional. The x coordinate where to start clipping - * @param sy {Number} Optional. The y coordinate where to start clipping - * @param swidth {Number} Optional. The width of the clipped image - * @param sheight {Number} Optional. The height of the clipped image - * @param x {Number} The x coordinate where to place the image on the canvas - * @param y {Number} The y coordinate where to place the image on the canvas - * @param width {Number} Optional. The width of the image to use (stretch or reduce the image) - * @param height {Number} Optional. The height of the image to use (stretch or reduce the image) + /** + * Draws an image, canvas, or video onto the canvas + * + * @function + * @param img {} Specifies the image, canvas, or video element to use + * @param sx {Number} Optional. The x coordinate where to start clipping + * @param sy {Number} Optional. The y coordinate where to start clipping + * @param swidth {Number} Optional. The width of the clipped image + * @param sheight {Number} Optional. The height of the clipped image + * @param x {Number} The x coordinate where to place the image on the canvas + * @param y {Number} The y coordinate where to place the image on the canvas + * @param width {Number} Optional. The width of the image to use (stretch or reduce the image) + * @param height {Number} Optional. The height of the image to use (stretch or reduce the image) */ @@ -12112,6 +10592,7 @@ matrix = matrix.multiply(decomposedTransformationMatrix.translate); matrix = matrix.multiply(decomposedTransformationMatrix.skew); matrix = matrix.multiply(decomposedTransformationMatrix.scale); + var mP = matrix.applyToPoint(new Point(width, height)); var xRect = matrix.applyToRectangle(new Rectangle(x - sx * clipFactorX, y - sy * clipFactorY, swidth * factorX, sheight * factorY)); var pageArray = getPagesByPath.call(this, xRect); var pages = []; @@ -12297,14 +10778,14 @@ this.path = origPath; }; - /** - * Processes the paths - * - * @function - * @param rule {String} - * @param isClip {Boolean} - * @private - * @ignore + /** + * Processes the paths + * + * @function + * @param rule {String} + * @param isClip {Boolean} + * @private + * @ignore */ @@ -12422,7 +10903,9 @@ if (typeof arc.startAngle !== 'undefined') { var start = rad2deg(arc.startAngle); var end = rad2deg(arc.endAngle); - drawArc.call(this, arc.x, arc.y, arc.radius, start, end, arc.counterclockwise, style, isClip); + var x = arc.x; + var y = arc.y; + drawArc.call(this, x, y, arc.radius, start, end, arc.counterclockwise, style, isClip); } else { drawLine.call(this, arc.x, arc.y); } @@ -12502,16 +10985,16 @@ Context2D.prototype.createRadialGradient = function createRadialGradient() { return this.createLinearGradient(); }; - /** - * - * @param x Edge point X - * @param y Edge point Y - * @param r Radius - * @param a1 start angle - * @param a2 end angle - * @param counterclockwise - * @param style - * @param isClip + /** + * + * @param x Edge point X + * @param y Edge point Y + * @param r Radius + * @param a1 start angle + * @param a2 end angle + * @param counterclockwise + * @param style + * @param isClip */ @@ -12527,7 +11010,6 @@ if (i === 0) { doMove.call(this, curve.x1 + x, curve.y1 + y); } - drawCurve.call(this, x, y, curve.x2, curve.y2, curve.x3, curve.y3, curve.x4, curve.y4); } @@ -12552,7 +11034,6 @@ var doClip = function doClip() { this.pdf.clip(); - this.pdf.discardPath(); }; var doMove = function doMove(x, y) { @@ -12666,11 +11147,11 @@ var drawCurve = function drawCurve(x, y, x1, y1, x2, y2, x3, y3) { this.pdf.internal.out([f2(getHorizontalCoordinate(x1 + x)), f2(getVerticalCoordinate(y1 + y)), f2(getHorizontalCoordinate(x2 + x)), f2(getVerticalCoordinate(y2 + y)), f2(getHorizontalCoordinate(x3 + x)), f2(getVerticalCoordinate(y3 + y)), 'c'].join(' ')); }; - /** - * Return a array of objects that represent bezier curves which approximate the circular arc centered at the origin, from startAngle to endAngle (radians) with the specified radius. - * - * Each bezier curve is an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. - * @function createArc + /** + * Return a array of objects that represent bezier curves which approximate the circular arc centered at the origin, from startAngle to endAngle (radians) with the specified radius. + * + * Each bezier curve is an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. + * @function createArc */ @@ -12706,12 +11187,12 @@ return curves; }; - /** - * Cubic bezier approximation of a circular arc centered at the origin, from (radians) a1 to a2, where a2-a1 < pi/2. The arc's radius is r. - * - * Returns an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. - * - * This algorithm is based on the approach described in: A. Riškus, "Approximation of a Cubic Bezier Curve by Circular Arcs and Vice Versa," Information Technology and Control, 35(4), 2006 pp. 371-378. + /** + * Cubic bezier approximation of a circular arc centered at the origin, from (radians) a1 to a2, where a2-a1 < pi/2. The arc's radius is r. + * + * Returns an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. + * + * This algorithm is based on the approach described in: A. Riškus, "Approximation of a Cubic Bezier Curve by Circular Arcs and Vice Versa," Information Technology and Control, 35(4), 2006 pp. 371-378. */ @@ -12772,9 +11253,9 @@ var todx = dx - cx; var tody = dy - cy; var precision = 40; - var d, i, px, py, qx, qy, rx, ry, tx, ty, sx, sy, x, y, i, minx, miny, maxx, maxy, toqx, toqy, torx, tory, totx, toty; + var d, px, py, qx, qy, rx, ry, tx, ty, sx, sy, x, y, i, minx, miny, maxx, maxy, toqx, toqy, torx, tory, totx, toty; - for (i = 0; i < precision + 1; i++) { + for (var i = 0; i < precision + 1; i++) { d = i / precision; px = ax + d * tobx; py = ay + d * toby; @@ -12810,31 +11291,306 @@ return new Rectangle(Math.round(minx), Math.round(miny), Math.round(maxx - minx), Math.round(maxy - miny)); }; - })(jsPDF.API); - /* global jsPDF, Deflater */ - - /** - * jsPDF filters PlugIn - * Copyright (c) 2014 Aras Abbasi - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license - */ - (function (jsPDFAPI) { + var Point = function Point(x, y) { + var _x = x || 0; - var ASCII85Encode = function ASCII85Encode(a) { - var b, c, d, e, f, g, h, i, j, k; // eslint-disable-next-line no-control-regex + Object.defineProperty(this, 'x', { + enumerable: true, + get: function get() { + return _x; + }, + set: function set(value) { + if (!isNaN(value)) { + _x = parseFloat(value); + } + } + }); - for (!/[^\x00-\xFF]/.test(a), b = "\x00\x00\x00\x00".slice(a.length % 4 || 4), a += b, c = [], d = 0, e = a.length; e > d; d += 4) { - f = (a.charCodeAt(d) << 24) + (a.charCodeAt(d + 1) << 16) + (a.charCodeAt(d + 2) << 8) + a.charCodeAt(d + 3), 0 !== f ? (k = f % 85, f = (f - k) / 85, j = f % 85, f = (f - j) / 85, i = f % 85, f = (f - i) / 85, h = f % 85, f = (f - h) / 85, g = f % 85, c.push(g + 33, h + 33, i + 33, j + 33, k + 33)) : c.push(122); - } + var _y = y || 0; - return function (a, b) { - for (var c = b; c > 0; c--) { - a.pop(); + Object.defineProperty(this, 'y', { + enumerable: true, + get: function get() { + return _y; + }, + set: function set(value) { + if (!isNaN(value)) { + _y = parseFloat(value); + } } - }(c, b.length), String.fromCharCode.apply(String, c) + "~>"; + }); + var _type = 'pt'; + Object.defineProperty(this, 'type', { + enumerable: true, + get: function get() { + return _type; + }, + set: function set(value) { + _type = value.toString(); + } + }); + return this; + }; + + var Rectangle = function Rectangle(x, y, w, h) { + Point.call(this, x, y); + this.type = 'rect'; + + var _w = w || 0; + + Object.defineProperty(this, 'w', { + enumerable: true, + get: function get() { + return _w; + }, + set: function set(value) { + if (!isNaN(value)) { + _w = parseFloat(value); + } + } + }); + + var _h = h || 0; + + Object.defineProperty(this, 'h', { + enumerable: true, + get: function get() { + return _h; + }, + set: function set(value) { + if (!isNaN(value)) { + _h = parseFloat(value); + } + } + }); + return this; + }; + + var Matrix = function Matrix(sx, shy, shx, sy, tx, ty) { + var _matrix = []; + Object.defineProperty(this, 'sx', { + get: function get() { + return _matrix[0]; + }, + set: function set(value) { + _matrix[0] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'shy', { + get: function get() { + return _matrix[1]; + }, + set: function set(value) { + _matrix[1] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'shx', { + get: function get() { + return _matrix[2]; + }, + set: function set(value) { + _matrix[2] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'sy', { + get: function get() { + return _matrix[3]; + }, + set: function set(value) { + _matrix[3] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'tx', { + get: function get() { + return _matrix[4]; + }, + set: function set(value) { + _matrix[4] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'ty', { + get: function get() { + return _matrix[5]; + }, + set: function set(value) { + _matrix[5] = Math.round(value * 100000) / 100000; + } + }); + Object.defineProperty(this, 'rotation', { + get: function get() { + return Math.atan2(this.shx, this.sx); + } + }); + Object.defineProperty(this, 'scaleX', { + get: function get() { + return this.decompose().scale.sx; + } + }); + Object.defineProperty(this, 'scaleY', { + get: function get() { + return this.decompose().scale.sy; + } + }); + Object.defineProperty(this, 'isIdentity', { + get: function get() { + if (this.sx !== 1) { + return false; + } + + if (this.shy !== 0) { + return false; + } + + if (this.shx !== 0) { + return false; + } + + if (this.sy !== 1) { + return false; + } + + if (this.tx !== 0) { + return false; + } + + if (this.ty !== 0) { + return false; + } + + return true; + } + }); + this.sx = !isNaN(sx) ? sx : 1; + this.shy = !isNaN(shy) ? shy : 0; + this.shx = !isNaN(shx) ? shx : 0; + this.sy = !isNaN(sy) ? sy : 1; + this.tx = !isNaN(tx) ? tx : 0; + this.ty = !isNaN(ty) ? ty : 0; + return this; + }; + /** + * Multiply the matrix with given Matrix + * + * @function multiply + * @param matrix + * @returns {Matrix} + * @private + * @ignore + */ + + + Matrix.prototype.multiply = function (matrix) { + var sx = matrix.sx * this.sx + matrix.shy * this.shx; + var shy = matrix.sx * this.shy + matrix.shy * this.sy; + var shx = matrix.shx * this.sx + matrix.sy * this.shx; + var sy = matrix.shx * this.shy + matrix.sy * this.sy; + var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx; + var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty; + return new Matrix(sx, shy, shx, sy, tx, ty); + }; + /** + * @function decompose + * @private + * @ignore + */ + + + Matrix.prototype.decompose = function () { + var a = this.sx; + var b = this.shy; + var c = this.shx; + var d = this.sy; + var e = this.tx; + var f = this.ty; + var scaleX = Math.sqrt(a * a + b * b); + a /= scaleX; + b /= scaleX; + var shear = a * c + b * d; + c -= a * shear; + d -= b * shear; + var scaleY = Math.sqrt(c * c + d * d); + c /= scaleY; + d /= scaleY; + shear /= scaleY; + + if (a * d < b * c) { + a = -a; + b = -b; + shear = -shear; + scaleX = -scaleX; + } + + return { + scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0), + translate: new Matrix(1, 0, 0, 1, e, f), + rotate: new Matrix(a, b, -b, a, 0, 0), + skew: new Matrix(1, 0, shear, 1, 0, 0) + }; + }; + /** + * @function applyToPoint + * @private + * @ignore + */ + + + Matrix.prototype.applyToPoint = function (pt) { + var x = pt.x * this.sx + pt.y * this.shx + this.tx; + var y = pt.x * this.shy + pt.y * this.sy + this.ty; + return new Point(x, y); + }; + /** + * @function applyToRectangle + * @private + * @ignore + */ + + + Matrix.prototype.applyToRectangle = function (rect) { + var pt1 = this.applyToPoint(rect); + var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h)); + return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y); + }; + /** + * @function clone + * @private + * @ignore + */ + + + Matrix.prototype.clone = function () { + var sx = this.sx; + var shy = this.shy; + var shx = this.shx; + var sy = this.sy; + var tx = this.tx; + var ty = this.ty; + return new Matrix(sx, shy, shx, sy, tx, ty); + }; + })(jsPDF.API, typeof self !== 'undefined' && self || typeof window !== 'undefined' && window || typeof global !== 'undefined' && global || Function('return typeof this === "object" && this.content')() || Function('return this')()); + + /** + * jsPDF filters PlugIn + * Copyright (c) 2014 Aras Abbasi + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license + */ + (function (jsPDFAPI) { + + var ASCII85Encode = function ASCII85Encode(a) { + var b, c, d, e, f, g, h, i, j, k; + + for (!/[^\x00-\xFF]/.test(a), b = "\x00\x00\x00\x00".slice(a.length % 4 || 4), a += b, c = [], d = 0, e = a.length; e > d; d += 4) { + f = (a.charCodeAt(d) << 24) + (a.charCodeAt(d + 1) << 16) + (a.charCodeAt(d + 2) << 8) + a.charCodeAt(d + 3), 0 !== f ? (k = f % 85, f = (f - k) / 85, j = f % 85, f = (f - j) / 85, i = f % 85, f = (f - i) / 85, h = f % 85, f = (f - h) / 85, g = f % 85, c.push(g + 33, h + 33, i + 33, j + 33, k + 33)) : c.push(122); + } + + return function (a, b) { + for (var c = b; c > 0; c--) { + a.pop(); + } + }(c, b.length), String.fromCharCode.apply(String, c) + "~>"; }; var ASCII85Decode = function ASCII85Decode(a) { @@ -12860,9 +11616,80 @@ } }(e, c[l]), h.fromCharCode.apply(h, e); }; + /** + * TODO: Not Tested: + //https://gist.github.com/revolunet/843889 + // LZW-compress a string + var LZWEncode = function(s, options) { + options = Object.assign({ + predictor: 1, + colors: 1, + bitsPerComponent: 8, + columns: 1, + earlyChange: 1 + }, options); + var dict = {}; + var data = (s + "").split(""); + var out = []; + var currChar; + var phrase = data[0]; + var code = 256; //0xe000 + for (var i=1; i 1 ? dict['_'+phrase] : phrase.charCodeAt(0)); + dict['_' + phrase + currChar] = code; + code++; + phrase=currChar; + } + } + out.push(phrase.length > 1 ? dict['_'+phrase] : phrase.charCodeAt(0)); + for (var i=0; i> 8 & 0xff, adler32 >> 16 & 0xff, adler32 >> 24 & 0xff]), data.byteLength + 2); - data = arr.reduce(function (data, byte) { - return data + String.fromCharCode(byte); - }, ''); + deflater.append(new Uint8Array(arr)); + data = deflater.flush(); + arr = new Uint8Array(data.length + 6); + arr.set(new Uint8Array([120, 156])), arr.set(data, 2); + arr.set(new Uint8Array([adler32 & 0xFF, adler32 >> 8 & 0xFF, adler32 >> 16 & 0xFF, adler32 >> 24 & 0xFF]), data.length + 2); + data = String.fromCharCode.apply(null, arr); return data; }; @@ -12984,6 +11795,19 @@ reverseChain.push("/FlateDecode"); break; + /** + case "LZWDecode": + case "/LZWDecode": + data = LZWDecode(data); + reverseChain.push("/LZWEncode"); + break; + case "LZWEncode": + case "/LZWEncode": + data = LZWEncode(data); + reverseChain.push("/LZWDecode"); + break; + */ + default: throw "The filter: \"" + filterChain[i] + "\" is not implemented"; } @@ -12996,28 +11820,26 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * jsPDF fileloading PlugIn - * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com) - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * jsPDF fileloading PlugIn + * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com) + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * @name fileloading - * @module + /** + * @name fileloading + * @module */ (function (jsPDFAPI) { - /** - * @name loadFile - * @function - * @param {string} url - * @param {boolean} sync - * @param {function} callback - * @returns {string|undefined} result + /** + * @name loadFile + * @function + * @param {string} url + * @param {boolean} sync + * @param {function} callback + * @returns {string|undefined} result */ jsPDFAPI.loadFile = function (url, sync, callback) { @@ -13045,18 +11867,17 @@ req.open('GET', url, !sync); // XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com] - req.overrideMimeType('text/plain; charset=x-user-defined'); + req.overrideMimeType('text\/plain; charset=x-user-defined'); if (sync === false) { req.onload = function () { - callback(sanitizeUnicode(this.responseText)); + return sanitizeUnicode(this.responseText); }; } req.send(null); if (req.status !== 200) { - // eslint-disable-next-line no-console console.warn('Unable to load file "' + url + '"'); return; } @@ -13074,65 +11895,56 @@ return result; }; - /** - * @name loadImageFile - * @function - * @param {string} path - * @param {boolean} sync - * @param {function} callback + /** + * @name loadImageFile + * @function + * @param {string} path + * @param {boolean} sync + * @param {function} callback */ jsPDFAPI.loadImageFile = jsPDFAPI.loadFile; })(jsPDF.API); - /* global jsPDF html2canvas */ - - /** - * Copyright (c) 2018 Erik Koopmans - * Released under the MIT License. - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * Copyright (c) 2018 Erik Koopmans + * Released under the MIT License. + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF html PlugIn - * - * @name html - * @module + /** + * jsPDF html PlugIn + * + * @name html + * @module */ (function (jsPDFAPI, global) { - - if (typeof Promise === 'undefined') { - // eslint-disable-next-line no-console - console.warn('Promise not found. html-Plugin will not work'); - return; - } - /** - * Determine the type of a variable/object. - * - * @private - * @ignore + /** + * Determine the type of a variable/object. + * + * @private + * @ignore */ - var objType = function objType(obj) { var type = _typeof(obj); - if (type === 'undefined') { return 'undefined'; }else if (type === 'string' || obj instanceof String) { return 'string'; }else if (type === 'number' || obj instanceof Number) { return 'number'; }else if (type === 'function' || obj instanceof Function) { return 'function'; }else if (!!obj && obj.constructor === Array) { return 'array'; }else if (obj && obj.nodeType === 1) { return 'element'; }else if (type === 'object') { return 'object'; }else { return 'unknown'; } + if (type === 'undefined') return 'undefined';else if (type === 'string' || obj instanceof String) return 'string';else if (type === 'number' || obj instanceof Number) return 'number';else if (type === 'function' || obj instanceof Function) return 'function';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if (type === 'object') return 'object';else return 'unknown'; }; - /** - * Create an HTML element with optional className, innerHTML, and style. - * - * @private - * @ignore + /** + * Create an HTML element with optional className, innerHTML, and style. + * + * @private + * @ignore */ var createElement = function createElement(tagName, opt) { var el = document.createElement(tagName); - if (opt.className) { el.className = opt.className; } + if (opt.className) el.className = opt.className; if (opt.innerHTML) { el.innerHTML = opt.innerHTML; @@ -13149,11 +11961,11 @@ return el; }; - /** - * Deep-clone a node and preserve contents/properties. - * - * @private - * @ignore + /** + * Deep-clone a node and preserve contents/properties. + * + * @private + * @ignore */ @@ -13480,16 +12292,16 @@ }]; // Fulfill prereqs then perform the appropriate output. return this.thenList(prereqs).then(function outputPdf_main() { - /* Currently implemented output types: - * https://rawgit.com/MrRio/jsPDF/master/docs/jspdf.js.html#line992 - * save(options), arraybuffer, blob, bloburi/bloburl, - * datauristring/dataurlstring, dataurlnewwindow, datauri/dataurl + /* Currently implemented output types: + * https://rawgit.com/MrRio/jsPDF/master/docs/jspdf.js.html#line992 + * save(options), arraybuffer, blob, bloburi/bloburl, + * datauristring/dataurlstring, dataurlnewwindow, datauri/dataurl */ return this.prop.pdf.output(type, options); }); }; - Worker.prototype.outputImg = function outputImg(type) { + Worker.prototype.outputImg = function outputImg(type, options) { // Set up function prerequisites. var prereqs = [function checkImg() { return this.prop.img || this.toImg(); @@ -13519,7 +12331,7 @@ var result = typeof global.html2canvas !== "undefined"; if (!result) { - throw new Error("html2canvas not loaded."); + console.error("html2canvas not loaded."); } return result; @@ -13543,7 +12355,7 @@ }); }; - Worker.prototype.doCallback = function doCallback() { + Worker.prototype.doCallback = function doCallback(filename) { // Set up function prerequisites. var prereqs = [function checkPdf() { return this.prop.pdf || this.toPdf(); @@ -13617,7 +12429,6 @@ switch (objType(margin)) { case 'number': margin = [margin, margin, margin, margin]; - // eslint-disable-next-line no-fallthrough case 'array': if (margin.length === 2) { @@ -13628,8 +12439,6 @@ break; } - // eslint-disable-next-line no-fallthrough - default: return this.error('Invalid margin array.'); } // Set the margin property, then update pageSize. @@ -13667,10 +12476,10 @@ Worker.prototype.setProgress = function setProgress(val, state, n, stack) { // Immediately update all progress values. - if (val != null) { this.progress.val = val; } - if (state != null) { this.progress.state = state; } - if (n != null) { this.progress.n = n; } - if (stack != null) { this.progress.stack = stack; } + if (val != null) this.progress.val = val; + if (state != null) this.progress.state = state; + if (n != null) this.progress.n = n; + if (stack != null) this.progress.stack = stack; this.progress.ratio = this.progress.val / this.progress.state; // Return this for command chaining. return this; @@ -13821,68 +12630,64 @@ 'ledger': [1224, 792], 'tabloid': [792, 1224], 'credit-card': [153, 243] - }; - var k = 1; // Unit conversion + }; // Unit conversion switch (unit) { case 'pt': - k = 1; + var k = 1; break; case 'mm': - k = 72 / 25.4; + var k = 72 / 25.4; break; case 'cm': - k = 72 / 2.54; + var k = 72 / 2.54; break; case 'in': - k = 72; + var k = 72; break; case 'px': - k = 72 / 96; + var k = 72 / 96; break; case 'pc': - k = 12; + var k = 12; break; case 'em': - k = 12; + var k = 12; break; case 'ex': - k = 6; + var k = 6; break; default: throw 'Invalid unit: ' + unit; - } + } // Dimensions are stored as user units and converted to points on output - var pageHeight = 0; - var pageWidth = 0; // Dimensions are stored as user units and converted to points on output if (pageFormats.hasOwnProperty(format_as_string)) { - pageHeight = pageFormats[format_as_string][1] / k; - pageWidth = pageFormats[format_as_string][0] / k; + var pageHeight = pageFormats[format_as_string][1] / k; + var pageWidth = pageFormats[format_as_string][0] / k; } else { try { - pageHeight = format[1]; - pageWidth = format[0]; + var pageHeight = format[1]; + var pageWidth = format[0]; } catch (err) { throw new Error('Invalid format: ' + format); } - } + } // Handle page orientation - var tmp; // Handle page orientation if (orientation === 'p' || orientation === 'portrait') { orientation = 'p'; if (pageWidth > pageHeight) { - tmp = pageWidth; + var tmp = pageWidth; pageWidth = pageHeight; pageHeight = tmp; } @@ -13890,7 +12695,7 @@ orientation = 'l'; if (pageHeight > pageWidth) { - tmp = pageWidth; + var tmp = pageWidth; pageWidth = pageHeight; pageHeight = tmp; } @@ -13907,23 +12712,14 @@ }; return info; }; - /** - * Generate a PDF from an HTML element or string using. - * - * @name html - * @function - * @param {HTMLElement|string} source The source HTMLElement or a string containing HTML. - * @param {Object} [options] Collection of settings - * @param {string} [options.callback] The mandatory callback-function gets as first parameter the current jsPDF instance - * - * @example - * var doc = new jsPDF(); - * - * doc.html(document.body, { - * callback: function (doc) { - * doc.save(); - * } - * }); + /** + * Generate a PDF from an HTML element or string using. + * + * @name html + * @function + * @param {Element|string} source The source element or HTML string. + * @param {Object=} options An object of optional settings. + * @description The Plugin needs html2canvas from niklasvh */ @@ -13937,6 +12733,7 @@ options.html2canvas.canvas = options.html2canvas.canvas || this.canvas; options.jsPDF = options.jsPDF || this; // Create a new worker with the given options. + var pdf = options.jsPDF; var worker = new Worker(options); if (!options.worker) { @@ -13946,39 +12743,41 @@ // Otherwise, return the worker for new Promise-based operation. return worker; } + + return this; }; })(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global); - /*global jsPDF */ - - /** - * @license - * ==================================================================== - * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com - * - * - * ==================================================================== + /** + * @license + * ==================================================================== + * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com + * + * + * ==================================================================== */ - /** - * jsPDF JavaScript plugin - * - * @name javascript - * @module + /*global jsPDF */ + + /** + * jsPDF JavaScript plugin + * + * @name javascript + * @module */ (function (jsPDFAPI) { var jsNamesObj, jsJsObj, text; - /** - * @name addJS - * @function - * @param {string} javascript The javascript to be embedded into the PDF-file. - * @returns {jsPDF} + /** + * @name addJS + * @function + * @param {string} javascript The javascript to be embedded into the PDF-file. + * @returns {jsPDF} */ jsPDFAPI.addJS = function (javascript) { text = javascript; - this.internal.events.subscribe('postPutResources', function () { + this.internal.events.subscribe('postPutResources', function (javascript) { jsNamesObj = this.internal.newObject(); this.internal.out('<<'); this.internal.out('/Names [(EmbeddedJS) ' + (jsNamesObj + 1) + ' 0 R]'); @@ -14000,23 +12799,14 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF Outline PlugIn - * - * Generates a PDF Outline - * @name outline - * @module - */ (function (jsPDFAPI) { jsPDFAPI.events.push(['postPutResources', function () { @@ -14106,8 +12896,8 @@ children: [] } }; - /** - * Options: pageNumber + /** + * Options: pageNumber */ pdf.outline.add = function (parent, title, options) { @@ -14159,6 +12949,7 @@ }; pdf.outline.renderItems = function (node) { + var getHorizontalCoordinateString = this.ctx.pdf.internal.getCoordinateString; var getVerticalCoordinateString = this.ctx.pdf.internal.getVerticalCoordinateString; for (var i = 0; i < node.children.length; i++) { @@ -14208,7 +12999,8 @@ } for (var i = 0; i < node.children.length; i++) { - this.renderItems(node.children[i]); + var item = node.children[i]; + this.renderItems(item); } }; @@ -14228,7 +13020,7 @@ this.ctx.val += '\r\n' + node.id + ' 0 obj' + '\r\n<<\r\n'; }; - pdf.outline.objEnd = function () { + pdf.outline.objEnd = function (node) { this.ctx.val += '>> \r\n' + 'endobj' + '\r\n'; }; @@ -14244,237 +13036,86 @@ return this; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * + * Copyright (c) 2014 James Robb, https://github.com/jamesbrobb + * + * + * ==================================================================== */ - /** - * jsPDF jpeg Support PlugIn - * - * @name jpeg_support - * @module + /** + * jsPDF PNG PlugIn + * @name png_support + * @module */ (function (jsPDFAPI) { - //a jpeg image and returns [width, height] - //Algorithm from: http://www.64lines.com/jpeg-width-height - - var getJpegSize = function getJpegSize(imgData) { + /* + * @see http://www.w3.org/TR/PNG-Chunks.html + * + Color Allowed Interpretation + Type Bit Depths + 0 1,2,4,8,16 Each pixel is a grayscale sample. + 2 8,16 Each pixel is an R,G,B triple. + 3 1,2,4,8 Each pixel is a palette index; + a PLTE chunk must appear. + 4 8,16 Each pixel is a grayscale sample, + followed by an alpha sample. + 6 8,16 Each pixel is an R,G,B triple, + followed by an alpha sample. + */ - var width, height, numcomponents; - var blockLength = imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5); - var i = 4, - len = imgData.length; + /* + * PNG filter method types + * + * @see http://www.w3.org/TR/PNG-Filters.html + * @see http://www.libpng.org/pub/png/book/chapter09.html + * + * This is what the value 'Predictor' in decode params relates to + * + * 15 is "optimal prediction", which means the prediction algorithm can change from line to line. + * In that case, you actually have to read the first byte off each line for the prediction algorthim (which should be 0-4, corresponding to PDF 10-14) and select the appropriate unprediction algorithm based on that byte. + * + 0 None + 1 Sub + 2 Up + 3 Average + 4 Paeth + */ - while (i < len) { - i += blockLength; + var doesNotHavePngJS = function doesNotHavePngJS() { + return typeof PNG !== 'function' || typeof FlateStream !== 'function'; + }, + canCompress = function canCompress(value) { + return value !== jsPDFAPI.image_compression.NONE && hasCompressionJS(); + }, + hasCompressionJS = function hasCompressionJS() { + var inst = typeof Deflater === 'function'; + if (!inst) throw new Error("requires deflate.js for compression"); + return inst; + }, + compressBytes = function compressBytes(bytes, lineLength, colorsPerPixel, compression) { + var level = 5, + filter_method = filterUp; - if (imgData.charCodeAt(i) !== 0xff) { - throw new Error('getJpegSize could not find the size of the image'); - } + switch (compression) { + case jsPDFAPI.image_compression.FAST: + level = 3; + filter_method = filterSub; + break; - if (imgData.charCodeAt(i + 1) === 0xc0 || //(SOF) Huffman - Baseline DCT - imgData.charCodeAt(i + 1) === 0xc1 || //(SOF) Huffman - Extended sequential DCT - imgData.charCodeAt(i + 1) === 0xc2 || // Progressive DCT (SOF2) - imgData.charCodeAt(i + 1) === 0xc3 || // Spatial (sequential) lossless (SOF3) - imgData.charCodeAt(i + 1) === 0xc4 || // Differential sequential DCT (SOF5) - imgData.charCodeAt(i + 1) === 0xc5 || // Differential progressive DCT (SOF6) - imgData.charCodeAt(i + 1) === 0xc6 || // Differential spatial (SOF7) - imgData.charCodeAt(i + 1) === 0xc7) { - height = imgData.charCodeAt(i + 5) * 256 + imgData.charCodeAt(i + 6); - width = imgData.charCodeAt(i + 7) * 256 + imgData.charCodeAt(i + 8); - numcomponents = imgData.charCodeAt(i + 9); - return [width, height, numcomponents]; - } else { - i += 2; - blockLength = imgData.charCodeAt(i) * 256 + imgData.charCodeAt(i + 1); - } - } - }; + case jsPDFAPI.image_compression.MEDIUM: + level = 6; + filter_method = filterAverage; + break; - var getJpegSizeFromBytes = function getJpegSizeFromBytes(data) { - var hdr = data[0] << 8 | data[1]; - if (hdr !== 0xFFD8) { throw new Error('Supplied data is not a JPEG'); } - var len = data.length, - block = (data[4] << 8) + data[5], - pos = 4, - bytes, - width, - height, - numcomponents; + case jsPDFAPI.image_compression.SLOW: + level = 9; + filter_method = filterPaeth; //uses to sum to choose best filter for each line - while (pos < len) { - pos += block; - bytes = readBytes(data, pos); - block = (bytes[2] << 8) + bytes[3]; - - if ((bytes[1] === 0xC0 || bytes[1] === 0xC2) && bytes[0] === 0xFF && block > 7) { - bytes = readBytes(data, pos + 5); - width = (bytes[2] << 8) + bytes[3]; - height = (bytes[0] << 8) + bytes[1]; - numcomponents = bytes[4]; - return { - width: width, - height: height, - numcomponents: numcomponents - }; - } - - pos += 2; - } - - throw new Error('getJpegSizeFromBytes could not find the size of the image'); - }; - - var readBytes = function readBytes(data, offset) { - return data.subarray(offset, offset + 5); - }; - /** - * @ignore - */ - - - jsPDFAPI.processJPEG = function (data, index, alias, compression, dataAsBinaryString, colorSpace) { - - var filter = this.decode.DCT_DECODE, - bpc = 8, - dims; - - if (!(typeof data === 'string') && !this.isArrayBuffer(data) && !this.isArrayBufferView(data)) { - return null; - } - - if (typeof data === 'string') { - dims = getJpegSize(data); - } - - if (this.isArrayBuffer(data)) { - data = new Uint8Array(data); - } - - if (this.isArrayBufferView(data)) { - dims = getJpegSizeFromBytes(data); // if we already have a stored binary string rep use that - - data = dataAsBinaryString || this.arrayBufferToBinaryString(data); - } - - if (colorSpace === undefined) { - switch (dims.numcomponents) { - case 1: - colorSpace = this.color_spaces.DEVICE_GRAY; - break; - - case 4: - colorSpace = this.color_spaces.DEVICE_CMYK; - break; - - default: - case 3: - colorSpace = this.color_spaces.DEVICE_RGB; - break; - } - } - - return this.createImageInfo(data, dims.width, dims.height, colorSpace, bpc, filter, index, alias); - }; - /** - * @ignore - */ - - - jsPDFAPI.processJPG = function () - /*data, index, alias, compression, dataAsBinaryString*/ - { - return this.processJPEG.apply(this, arguments); - }; - })(jsPDF.API); - - /* global jsPDF, Deflater, PNG */ - - /** - * @license - * - * Copyright (c) 2014 James Robb, https://github.com/jamesbrobb - * - * - * ==================================================================== - */ - - /** - * jsPDF PNG PlugIn - * @name png_support - * @module - */ - (function (jsPDFAPI) { - /* - * @see http://www.w3.org/TR/PNG-Chunks.html - * - Color Allowed Interpretation - Type Bit Depths - 0 1,2,4,8,16 Each pixel is a grayscale sample. - 2 8,16 Each pixel is an R,G,B triple. - 3 1,2,4,8 Each pixel is a palette index; - a PLTE chunk must appear. - 4 8,16 Each pixel is a grayscale sample, - followed by an alpha sample. - 6 8,16 Each pixel is an R,G,B triple, - followed by an alpha sample. - */ - - /* - * PNG filter method types - * - * @see http://www.w3.org/TR/PNG-Filters.html - * @see http://www.libpng.org/pub/png/book/chapter09.html - * - * This is what the value 'Predictor' in decode params relates to - * - * 15 is "optimal prediction", which means the prediction algorithm can change from line to line. - * In that case, you actually have to read the first byte off each line for the prediction algorthim (which should be 0-4, corresponding to PDF 10-14) and select the appropriate unprediction algorithm based on that byte. - * - 0 None - 1 Sub - 2 Up - 3 Average - 4 Paeth - */ - - var doesNotHavePngJS = function doesNotHavePngJS() { - return typeof PNG !== 'function' || typeof FlateStream !== 'function'; - }, - canCompress = function canCompress(value) { - return value !== jsPDFAPI.image_compression.NONE && hasCompressionJS(); - }, - hasCompressionJS = function hasCompressionJS() { - var inst = typeof Deflater === 'function'; - if (!inst) { throw new Error("requires deflate.js for compression"); } - return inst; - }, - compressBytes = function compressBytes(bytes, lineLength, colorsPerPixel, compression) { - var level = 5, - filter_method = filterUp; - - switch (compression) { - case jsPDFAPI.image_compression.FAST: - level = 3; - filter_method = filterSub; - break; - - case jsPDFAPI.image_compression.MEDIUM: - level = 6; - filter_method = filterAverage; - break; - - case jsPDFAPI.image_compression.SLOW: - level = 9; - filter_method = filterPaeth; //uses to sum to choose best filter for each line - - break; - } + break; + } bytes = applyPngFilterMethod(bytes, lineLength, colorsPerPixel, filter_method); var header = new Uint8Array(createZlibHeader(level)); @@ -14494,8 +13135,8 @@ return jsPDFAPI.arrayBufferToBinaryString(cmpd); }, createZlibHeader = function createZlibHeader(bytes, level) { - /* - * @see http://www.ietf.org/rfc/rfc1950.txt for zlib header + /* + * @see http://www.ietf.org/rfc/rfc1950.txt for zlib header */ var cm = 8; var cinfo = Math.LOG2E * Math.log(0x8000) - 8; @@ -14564,15 +13205,15 @@ return result; }, - filterNone = function filterNone(line) { - /*var result = new Uint8Array(line.length + 1); - result[0] = 0; + filterNone = function filterNone(line, colorsPerPixel, prevLine) { + /*var result = new Uint8Array(line.length + 1); + result[0] = 0; result.set(line, 1);*/ var result = Array.apply([], line); result.unshift(0); return result; }, - filterSub = function filterSub(line, colorsPerPixel) { + filterSub = function filterSub(line, colorsPerPixel, prevLine) { var result = [], i = 0, len = line.length, @@ -14700,14 +13341,15 @@ return predictor; }; - /** - * @name processPNG - * @function - * @ignore + /** + * + * @name processPNG + * @function + * @ignore */ - jsPDFAPI.processPNG = function (imageData, imageIndex, alias, compression) { + jsPDFAPI.processPNG = function (imageData, imageIndex, alias, compression, dataAsBinaryString) { var colorSpace = this.color_spaces.DEVICE_RGB, decode = this.decode.FLATE_DECODE, @@ -14717,45 +13359,42 @@ trns, colors, pal, - smask, - pixels, - len, - alphaData, - imgData, - hasColors, - pixel, - i, - n; - if (this.isArrayBuffer(imageData)) { imageData = new Uint8Array(imageData); } + smask; + /* if(this.isString(imageData)) { + }*/ + + if (this.isArrayBuffer(imageData)) imageData = new Uint8Array(imageData); if (this.isArrayBufferView(imageData)) { - if (doesNotHavePngJS()) { throw new Error("PNG support requires png.js and zlib.js"); } + if (doesNotHavePngJS()) throw new Error("PNG support requires png.js and zlib.js"); img = new PNG(imageData); imageData = img.imgData; bpc = img.bits; colorSpace = img.colorSpace; - colors = img.colors; - /* - * colorType 6 - Each pixel is an R,G,B triple, followed by an alpha sample. - * - * colorType 4 - Each pixel is a grayscale sample, followed by an alpha sample. - * - * Extract alpha to create two separate images, using the alpha as a sMask + colors = img.colors; //logImg(img); + + /* + * colorType 6 - Each pixel is an R,G,B triple, followed by an alpha sample. + * + * colorType 4 - Each pixel is a grayscale sample, followed by an alpha sample. + * + * Extract alpha to create two separate images, using the alpha as a sMask */ if ([4, 6].indexOf(img.colorType) !== -1) { - /* - * processes 8 bit RGBA and grayscale + alpha images + /* + * processes 8 bit RGBA and grayscale + alpha images */ if (img.bits === 8) { - pixels = img.pixelBitlength == 32 ? new Uint32Array(img.decodePixels().buffer) : img.pixelBitlength == 16 ? new Uint16Array(img.decodePixels().buffer) : new Uint8Array(img.decodePixels().buffer); - len = pixels.length; - imgData = new Uint8Array(len * img.colors); - alphaData = new Uint8Array(len); - var pDiff = img.pixelBitlength - img.bits; - i = 0; - n = 0; - var pbl; + var pixels = img.pixelBitlength == 32 ? new Uint32Array(img.decodePixels().buffer) : img.pixelBitlength == 16 ? new Uint16Array(img.decodePixels().buffer) : new Uint8Array(img.decodePixels().buffer), + len = pixels.length, + imgData = new Uint8Array(len * img.colors), + alphaData = new Uint8Array(len), + pDiff = img.pixelBitlength - img.bits, + i = 0, + n = 0, + pixel, + pbl; for (; i < len; i++) { pixel = pixels[i]; @@ -14769,20 +13408,21 @@ alphaData[i] = pixel >>> pbl & 0xff; } } - /* - * processes 16 bit RGBA and grayscale + alpha images + /* + * processes 16 bit RGBA and grayscale + alpha images */ if (img.bits === 16) { - pixels = new Uint32Array(img.decodePixels().buffer); - len = pixels.length; - imgData = new Uint8Array(len * (32 / img.pixelBitlength) * img.colors); - alphaData = new Uint8Array(len * (32 / img.pixelBitlength)); - hasColors = img.colors > 1; - i = 0; - n = 0; - var a = 0; + var pixels = new Uint32Array(img.decodePixels().buffer), + len = pixels.length, + imgData = new Uint8Array(len * (32 / img.pixelBitlength) * img.colors), + alphaData = new Uint8Array(len * (32 / img.pixelBitlength)), + hasColors = img.colors > 1, + i = 0, + n = 0, + a = 0, + pixel; while (i < len) { pixel = pixels[i++]; @@ -14809,8 +13449,8 @@ decode = null; } } - /* - * Indexed png. Each pixel is a palette index. + /* + * Indexed png. Each pixel is a palette index. */ @@ -14820,31 +13460,31 @@ if (img.transparency.indexed) { var trans = img.transparency.indexed; - var total = 0; - i = 0; - len = trans.length; + var total = 0, + i = 0, + len = trans.length; for (; i < len; ++i) { total += trans[i]; } total = total / 255; - /* - * a single color is specified as 100% transparent (0), - * so we set trns to use a /Mask with that index + /* + * a single color is specified as 100% transparent (0), + * so we set trns to use a /Mask with that index */ if (total === len - 1 && trans.indexOf(0) !== -1) { trns = [trans.indexOf(0)]; - /* - * there's more than one colour within the palette that specifies - * a transparency value less than 255, so we unroll the pixels to create an image sMask + /* + * there's more than one colour within the palette that specifies + * a transparency value less than 255, so we unroll the pixels to create an image sMask */ } else if (total !== len) { - pixels = img.decodePixels(); - alphaData = new Uint8Array(pixels.length); - i = 0; - len = pixels.length; + var pixels = img.decodePixels(), + alphaData = new Uint8Array(pixels.length), + i = 0, + len = pixels.length; for (; i < len; i++) { alphaData[i] = trans[pixels[i]]; @@ -14856,10 +13496,10 @@ } var predictor = getPredictorFromCompression(compression); - if (decode === this.decode.FLATE_DECODE) { dp = '/Predictor ' + predictor + ' /Colors ' + colors + ' /BitsPerComponent ' + bpc + ' /Columns ' + img.width; }else //remove 'Predictor' as it applies to the type of png filter applied to its IDAT - we only apply with compression - { dp = '/Colors ' + colors + ' /BitsPerComponent ' + bpc + ' /Columns ' + img.width; } - if (this.isArrayBuffer(imageData) || this.isArrayBufferView(imageData)) { imageData = this.arrayBufferToBinaryString(imageData); } - if (smask && this.isArrayBuffer(smask) || this.isArrayBufferView(smask)) { smask = this.arrayBufferToBinaryString(smask); } + if (decode === this.decode.FLATE_DECODE) dp = '/Predictor ' + predictor + ' /Colors ' + colors + ' /BitsPerComponent ' + bpc + ' /Columns ' + img.width;else //remove 'Predictor' as it applies to the type of png filter applied to its IDAT - we only apply with compression + dp = '/Colors ' + colors + ' /BitsPerComponent ' + bpc + ' /Columns ' + img.width; + if (this.isArrayBuffer(imageData) || this.isArrayBufferView(imageData)) imageData = this.arrayBufferToBinaryString(imageData); + if (smask && this.isArrayBuffer(smask) || this.isArrayBufferView(smask)) smask = this.arrayBufferToBinaryString(smask); return this.createImageInfo(imageData, img.width, img.height, colorSpace, bpc, decode, imageIndex, alias, dp, trns, pal, smask, predictor); } @@ -14867,25 +13507,23 @@ }; })(jsPDF.API); - /* global jsPDF, GifReader, JPEGEncoder */ - - /** - * @license - * Copyright (c) 2017 Aras Abbasi - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Copyright (c) 2017 Aras Abbasi + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF gif Support PlugIn - * - * @name gif_support - * @module + /** + * jsPDF gif Support PlugIn + * + * @name gif_support + * @module */ (function (jsPDFAPI) { - jsPDFAPI.processGIF89A = function (imageData, imageIndex, alias, compression) { + jsPDFAPI.processGIF89A = function (imageData, imageIndex, alias, compression, dataAsBinaryString) { var reader = new GifReader(imageData); var width = reader.width, height = reader.height; @@ -14905,23 +13543,21 @@ jsPDFAPI.processGIF87A = jsPDFAPI.processGIF89A; })(jsPDF.API); - /* global jsPDF, BmpDecoder, JPEGEncoder */ - - /** - * Copyright (c) 2018 Aras Abbasi - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * Copyright (c) 2018 Aras Abbasi + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF bmp Support PlugIn - * @name bmp_support - * @module + /** + * jsPDF bmp Support PlugIn + * @name bmp_support + * @module */ (function (jsPDFAPI) { - jsPDFAPI.processBMP = function (imageData, imageIndex, alias, compression) { + jsPDFAPI.processBMP = function (imageData, imageIndex, alias, compression, dataAsBinaryString) { var reader = new BmpDecoder(imageData, false); var width = reader.width, height = reader.height; @@ -14938,68 +13574,31 @@ }; })(jsPDF.API); - /* global jsPDF, JPEGEncoder, WebPDecoder */ - - /** - * @license - * Copyright (c) 2019 Aras Abbasi - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license - */ - - /** - * jsPDF webp Support PlugIn - * - * @name webp_support - * @module - */ - (function (jsPDFAPI) { - - jsPDFAPI.processWEBP = function (imageData, imageIndex, alias, compression) { - var reader = new WebPDecoder(imageData, false); - var width = reader.width, - height = reader.height; - var qu = 100; - var pixels = reader.getData(); - var rawImageData = { - data: pixels, - width: width, - height: height - }; - var encoder = new JPEGEncoder(qu); - var data = encoder.encode(rawImageData, qu); - return jsPDFAPI.processJPEG.call(this, data, imageIndex, alias, compression); - }; - })(jsPDF.API); - - /* global jsPDF */ - - /** - * @license - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * jsPDF setLanguage Plugin - * - * @name setLanguage - * @module + /** + * jsPDF setLanguage Plugin + * + * @name setLanguage + * @module */ (function (jsPDFAPI) { - /** - * Add Language Tag to the generated PDF - * - * @name setLanguage - * @function - * @param {string} langCode The Language code as ISO-639-1 (e.g. 'en') or as country language code (e.g. 'en-GB'). - * @returns {jsPDF} - * @example - * var doc = new jsPDF() - * doc.text(10, 10, 'This is a test') - * doc.setLanguage("en-US") - * doc.save('english.pdf') + /** + * Add Language Tag to the generated PDF + * + * @name setLanguage + * @function + * @param {string} langCode The Language code as ISO-639-1 (e.g. 'en') or as country language code (e.g. 'en-GB'). + * @returns {jsPDF} + * @example + * var doc = new jsPDF() + * doc.text(10, 10, 'This is a test') + * doc.setLanguage("en-US") + * doc.save('english.pdf') */ jsPDFAPI.setLanguage = function (langCode) { @@ -15223,33 +13822,31 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** @license - * MIT license. - * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com - * 2014 Diego Casorran, https://github.com/diegocr - * - * - * ==================================================================== + /** @license + * MIT license. + * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com + * 2014 Diego Casorran, https://github.com/diegocr + * + * + * ==================================================================== */ - /** - * jsPDF split_text_to_size plugin - * - * @name split_text_to_size - * @module + /** + * jsPDF split_text_to_size plugin + * + * @name split_text_to_size + * @module */ (function (API) { - /** - * Returns an array of length matching length of the 'word' string, with each - * cell occupied by the width of the char in that position. - * - * @name getCharWidthsArray - * @function - * @param {string} text - * @param {Object} options - * @returns {Array} + /** + * Returns an array of length matching length of the 'word' string, with each + * cell occupied by the width of the char in that position. + * + * @name getCharWidthsArray + * @function + * @param {string} text + * @param {Object} options + * @returns {Array} */ var getCharWidthsArray = API.getCharWidthsArray = function (text, options) { @@ -15283,14 +13880,14 @@ return output; }; - /** - * Calculate the sum of a number-array - * - * @name getArraySum - * @public - * @function - * @param {Array} array Array of numbers - * @returns {number} + /** + * Calculate the sum of a number-array + * + * @name getArraySum + * @public + * @function + * @param {Array} array Array of numbers + * @returns {number} */ @@ -15305,21 +13902,21 @@ return output; }; - /** - * Returns a widths of string in a given font, if the font size is set as 1 point. - * - * In other words, this is "proportional" value. For 1 unit of font size, the length - * of the string will be that much. - * - * Multiply by font size to get actual width in *points* - * Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc. - * - * @name getStringUnitWidth - * @public - * @function - * @param {string} text - * @param {string} options - * @returns {number} result + /** + * Returns a widths of string in a given font, if the font size is set as 1 point. + * + * In other words, this is "proportional" value. For 1 unit of font size, the length + * of the string will be that much. + * + * Multiply by font size to get actual width in *points* + * Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc. + * + * @name getStringUnitWidth + * @public + * @function + * @param {string} text + * @param {string} options + * @returns {number} result */ @@ -15338,8 +13935,8 @@ return result; }; - /** - returns array of lines + /** + returns array of lines */ @@ -15470,36 +14067,34 @@ } } - var postProcess; - if (lineIndent) { - postProcess = function postProcess(ln, idx) { + var postProcess = function postProcess(ln, idx) { return (idx ? pad : '') + ln.join(" "); }; } else { - postProcess = function postProcess(ln) { + var postProcess = function postProcess(ln) { return ln.join(" "); }; } return lines.map(postProcess); }; - /** - * Splits a given string into an array of strings. Uses 'size' value - * (in measurement units declared as default for the jsPDF instance) - * and the font's "widths" and "Kerning" tables, where available, to - * determine display length of a given string for a given font. - * - * We use character's 100% of unit size (height) as width when Width - * table or other default width is not available. - * - * @name splitTextToSize - * @public - * @function - * @param {string} text Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string. - * @param {number} size Nominal number, measured in units default to this instance of jsPDF. - * @param {Object} options Optional flags needed for chopper to do the right thing. - * @returns {Array} array Array with strings chopped to size. + /** + * Splits a given string into an array of strings. Uses 'size' value + * (in measurement units declared as default for the jsPDF instance) + * and the font's "widths" and "Kerning" tables, where available, to + * determine display length of a given string for a given font. + * + * We use character's 100% of unit size (height) as width when Width + * table or other default width is not available. + * + * @name splitTextToSize + * @public + * @function + * @param {string} text Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string. + * @param {number} size Nominal number, measured in units default to this instance of jsPDF. + * @param {Object} options Optional flags needed for chopper to do the right thing. + * @returns {Array} array Array with strings chopped to size. */ @@ -15537,7 +14132,13 @@ widths: options.widths, kerning: options.kerning }; - } + } // then use default values + + + return { + widths: widths, + kerning: kerning + }; }.call(this, options); // first we split on end-of-line chars @@ -15574,170 +14175,149 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** @license - jsPDF standard_fonts_metrics plugin - * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com - * MIT license. - * - * ==================================================================== + /** @license + jsPDF standard_fonts_metrics plugin + * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com + * MIT license. + * + * ==================================================================== */ - /** - * This file adds the standard font metrics to jsPDF. - * - * Font metrics data is reprocessed derivative of contents of - * "Font Metrics for PDF Core 14 Fonts" package, which exhibits the following copyright and license: - * - * Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. - * - * This file and the 14 PostScript(R) AFM files it accompanies may be used, - * copied, and distributed for any purpose and without charge, with or without - * modification, provided that all copyright notices are retained; that the AFM - * files are not distributed without this file; that all modifications to this - * file or any of the AFM files are prominently noted in the modified file(s); - * and that this paragraph is not modified. Adobe Systems has no responsibility - * or obligation to support the use of the AFM files. - * - * @name standard_fonts_metrics - * @module - */ (function (API) { - /* - # reference (Python) versions of 'compress' and 'uncompress' - # only 'uncompress' function is featured lower as JavaScript - # if you want to unit test "roundtrip", just transcribe the reference - # 'compress' function from Python into JavaScript - - def compress(data): - - keys = '0123456789abcdef' - values = 'klmnopqrstuvwxyz' - mapping = dict(zip(keys, values)) - vals = [] - for key in data.keys(): - value = data[key] - try: - keystring = hex(key)[2:] - keystring = keystring[:-1] + mapping[keystring[-1:]] - except: - keystring = key.join(["'","'"]) - #print('Keystring is %s' % keystring) - - try: - if value < 0: - valuestring = hex(value)[3:] - numberprefix = '-' - else: - valuestring = hex(value)[2:] - numberprefix = '' - valuestring = numberprefix + valuestring[:-1] + mapping[valuestring[-1:]] - except: - if type(value) == dict: - valuestring = compress(value) - else: - raise Exception("Don't know what to do with value type %s" % type(value)) - - vals.append(keystring+valuestring) - - return '{' + ''.join(vals) + '}' - - def uncompress(data): - - decoded = '0123456789abcdef' - encoded = 'klmnopqrstuvwxyz' - mapping = dict(zip(encoded, decoded)) - - sign = +1 - stringmode = False - stringparts = [] - - output = {} - - activeobject = output - parentchain = [] - - keyparts = '' - valueparts = '' - - key = None - - ending = set(encoded) - - i = 1 - l = len(data) - 1 # stripping starting, ending {} - while i != l: # stripping {} - # -, {, }, ' are special. - - ch = data[i] - i += 1 - - if ch == "'": - if stringmode: - # end of string mode - stringmode = False - key = ''.join(stringparts) - else: - # start of string mode - stringmode = True - stringparts = [] - elif stringmode == True: - #print("Adding %s to stringpart" % ch) - stringparts.append(ch) - - elif ch == '{': - # start of object - parentchain.append( [activeobject, key] ) - activeobject = {} - key = None - #DEBUG = True - elif ch == '}': - # end of object - parent, key = parentchain.pop() - parent[key] = activeobject - key = None - activeobject = parent - #DEBUG = False - - elif ch == '-': - sign = -1 - else: - # must be number - if key == None: - #debug("In Key. It is '%s', ch is '%s'" % (keyparts, ch)) - if ch in ending: - #debug("End of key") - keyparts += mapping[ch] - key = int(keyparts, 16) * sign - sign = +1 - keyparts = '' - else: - keyparts += ch - else: - #debug("In value. It is '%s', ch is '%s'" % (valueparts, ch)) - if ch in ending: - #debug("End of value") - valueparts += mapping[ch] - activeobject[key] = int(valueparts, 16) * sign - sign = +1 - key = None - valueparts = '' - else: - valueparts += ch - - #debug(activeobject) - - return output - + /* + # reference (Python) versions of 'compress' and 'uncompress' + # only 'uncompress' function is featured lower as JavaScript + # if you want to unit test "roundtrip", just transcribe the reference + # 'compress' function from Python into JavaScript + + def compress(data): + + keys = '0123456789abcdef' + values = 'klmnopqrstuvwxyz' + mapping = dict(zip(keys, values)) + vals = [] + for key in data.keys(): + value = data[key] + try: + keystring = hex(key)[2:] + keystring = keystring[:-1] + mapping[keystring[-1:]] + except: + keystring = key.join(["'","'"]) + #print('Keystring is %s' % keystring) + + try: + if value < 0: + valuestring = hex(value)[3:] + numberprefix = '-' + else: + valuestring = hex(value)[2:] + numberprefix = '' + valuestring = numberprefix + valuestring[:-1] + mapping[valuestring[-1:]] + except: + if type(value) == dict: + valuestring = compress(value) + else: + raise Exception("Don't know what to do with value type %s" % type(value)) + + vals.append(keystring+valuestring) + + return '{' + ''.join(vals) + '}' + + def uncompress(data): + + decoded = '0123456789abcdef' + encoded = 'klmnopqrstuvwxyz' + mapping = dict(zip(encoded, decoded)) + + sign = +1 + stringmode = False + stringparts = [] + + output = {} + + activeobject = output + parentchain = [] + + keyparts = '' + valueparts = '' + + key = None + + ending = set(encoded) + + i = 1 + l = len(data) - 1 # stripping starting, ending {} + while i != l: # stripping {} + # -, {, }, ' are special. + + ch = data[i] + i += 1 + + if ch == "'": + if stringmode: + # end of string mode + stringmode = False + key = ''.join(stringparts) + else: + # start of string mode + stringmode = True + stringparts = [] + elif stringmode == True: + #print("Adding %s to stringpart" % ch) + stringparts.append(ch) + + elif ch == '{': + # start of object + parentchain.append( [activeobject, key] ) + activeobject = {} + key = None + #DEBUG = True + elif ch == '}': + # end of object + parent, key = parentchain.pop() + parent[key] = activeobject + key = None + activeobject = parent + #DEBUG = False + + elif ch == '-': + sign = -1 + else: + # must be number + if key == None: + #debug("In Key. It is '%s', ch is '%s'" % (keyparts, ch)) + if ch in ending: + #debug("End of key") + keyparts += mapping[ch] + key = int(keyparts, 16) * sign + sign = +1 + keyparts = '' + else: + keyparts += ch + else: + #debug("In value. It is '%s', ch is '%s'" % (valueparts, ch)) + if ch in ending: + #debug("End of value") + valueparts += mapping[ch] + activeobject[key] = int(valueparts, 16) * sign + sign = +1 + key = None + valueparts = '' + else: + valueparts += ch + + #debug(activeobject) + + return output + */ - /** - Uncompresses data compressed into custom, base16-like format. - @public - @function - @param - @returns {Type} + /** + Uncompresses data compressed into custom, base16-like format. + @public + @function + @param + @returns {Type} */ var uncompress = function uncompress(data) { @@ -15881,16 +14461,16 @@ 'Helvetica-Oblique': uncompress("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}") } }; - /* - This event handler is fired when a new jsPDF object is initialized - This event handler appends metrics data to standard fonts within - that jsPDF instance. The metrics are mapped over Unicode character - codes, NOT CIDs or other codes matching the StandardEncoding table of the - standard PDF fonts. - Future: - Also included is the encoding maping table, converting Unicode (UCS-2, UTF-16) - char codes to StandardEncoding character codes. The encoding table is to be used - somewhere around "pdfEscape" call. + /* + This event handler is fired when a new jsPDF object is initialized + This event handler appends metrics data to standard fonts within + that jsPDF instance. The metrics are mapped over Unicode character + codes, NOT CIDs or other codes matching the StandardEncoding table of the + standard PDF fonts. + Future: + Also included is the encoding maping table, converting Unicode (UCS-2, UTF-16) + char codes to StandardEncoding character codes. The encoding table is to be used + somewhere around "pdfEscape" call. */ API.events.push(['addFont', function (data) { @@ -15930,17 +14510,17 @@ }]); // end of adding event handler })(jsPDF.API); - /** - * @license - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * @license + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * @name ttfsupport - * @module + /** + * @name ttfsupport + * @module */ - (function (jsPDF) { + (function (jsPDF, global) { jsPDF.API.events.push(['addFont', function (data) { var font = data.font; @@ -15964,40 +14544,32 @@ throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('" + font.postScriptName + "')."); } }]); // end of adding event handler - })(jsPDF); + })(jsPDF, typeof self !== "undefined" && self || typeof global !== "undefined" && global || typeof window !== "undefined" && window || Function("return this")()); - /* global jsPDF, canvg */ - - /** @license - * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com - * - * - * ==================================================================== + /** @license + * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com + * + * + * ==================================================================== */ - /** - * jsPDF SVG plugin - * - * @name svg - * @module - */ (function (jsPDFAPI) { - /** - * Parses SVG XML and converts only some of the SVG elements into - * PDF elements. - * - * Supports: - * paths - * - * @name addSvg - * @public - * @function - * @param {string} SVG-Data as Text - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page - * @param {number} width of SVG (in units declared at inception of PDF document) - * @param {number} height of SVG (in units declared at inception of PDF document) - * @returns {Object} jsPDF-instance + /** + * Parses SVG XML and converts only some of the SVG elements into + * PDF elements. + * + * Supports: + * paths + * + * @name addSvg + * @public + * @function + * @param {string} SVG-Data as Text + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page + * @param {number} width of SVG (in units declared at inception of PDF document) + * @param {number} height of SVG (in units declared at inception of PDF document) + * @returns {Object} jsPDF-instance */ jsPDFAPI.addSvg = function (svgtext, x, y, w, h) { @@ -16125,24 +14697,24 @@ jsPDFAPI.addSVG = jsPDFAPI.addSvg; - /** - * Parses SVG XML and saves it as image into the PDF. - * - * Depends on canvas-element and canvg - * - * @name addSvgAsImage - * @public - * @function - * @param {string} SVG-Data as Text - * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page - * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page - * @param {number} width of SVG-Image (in units declared at inception of PDF document) - * @param {number} height of SVG-Image (in units declared at inception of PDF document) - * @param {string} alias of SVG-Image (if used multiple times) - * @param {string} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' - * @param {number} rotation of the image in degrees (0-359) - * - * @returns jsPDF jsPDF-instance + /** + * Parses SVG XML and saves it as image into the PDF. + * + * Depends on canvas-element and canvg + * + * @name addSvgAsImage + * @public + * @function + * @param {string} SVG-Data as Text + * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page + * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page + * @param {number} width of SVG-Image (in units declared at inception of PDF document) + * @param {number} height of SVG-Image (in units declared at inception of PDF document) + * @param {string} alias of SVG-Image (if used multiple times) + * @param {string} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' + * @param {number} rotation of the image in degrees (0-359) + * + * @returns jsPDF jsPDF-instance */ jsPDFAPI.addSvgAsImage = function (svg, x, y, w, h, alias, compression, rotation) { @@ -16175,28 +14747,26 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * @license - * ==================================================================== - * Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br - * - * - * ==================================================================== + /** + * @license + * ==================================================================== + * Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br + * + * + * ==================================================================== */ - /** - * jsPDF total_pages plugin - * @name total_pages - * @module + /** + * jsPDF total_pages plugin + * @name total_pages + * @module */ (function (jsPDFAPI) { - /** - * @name putTotalPages - * @function - * @param {string} pageExpression Regular Expression - * @returns {jsPDF} jsPDF-instance + /** + * @name putTotalPages + * @function + * @param {string} pageExpression Regular Expression + * @returns {jsPDF} jsPDF-instance */ jsPDFAPI.putTotalPages = function (pageExpression) { @@ -16222,111 +14792,109 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * jsPDF viewerPreferences Plugin - * @author Aras Abbasi (github.com/arasabbasi) - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * jsPDF viewerPreferences Plugin + * @author Aras Abbasi (github.com/arasabbasi) + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * Adds the ability to set ViewerPreferences and by thus - * controlling the way the document is to be presented on the - * screen or in print. - * @name viewerpreferences - * @module + /** + * Adds the ability to set ViewerPreferences and by thus + * controlling the way the document is to be presented on the + * screen or in print. + * @name viewerpreferences + * @module */ (function (jsPDFAPI) { - /** - * Set the ViewerPreferences of the generated PDF - * - * @name viewerPreferences - * @function - * @public - * @param {Object} options Array with the ViewerPreferences
    - * Example: doc.viewerPreferences({"FitWindow":true});
    - *
    - * You can set following preferences:
    - *
    - * HideToolbar (boolean)
    - * Default value: false
    - *
    - * HideMenubar (boolean)
    - * Default value: false.
    - *
    - * HideWindowUI (boolean)
    - * Default value: false.
    - *
    - * FitWindow (boolean)
    - * Default value: false.
    - *
    - * CenterWindow (boolean)
    - * Default value: false
    - *
    - * DisplayDocTitle (boolean)
    - * Default value: false.
    - *
    - * NonFullScreenPageMode (string)
    - * Possible values: UseNone, UseOutlines, UseThumbs, UseOC
    - * Default value: UseNone
    - *
    - * Direction (string)
    - * Possible values: L2R, R2L
    - * Default value: L2R.
    - *
    - * ViewArea (string)
    - * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    - * Default value: CropBox.
    - *
    - * ViewClip (string)
    - * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    - * Default value: CropBox
    - *
    - * PrintArea (string)
    - * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    - * Default value: CropBox
    - *
    - * PrintClip (string)
    - * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    - * Default value: CropBox.
    - *
    - * PrintScaling (string)
    - * Possible values: AppDefault, None
    - * Default value: AppDefault.
    - *
    - * Duplex (string)
    - * Possible values: Simplex, DuplexFlipLongEdge, DuplexFlipShortEdge - * Default value: none
    - *
    - * PickTrayByPDFSize (boolean)
    - * Default value: false
    - *
    - * PrintPageRange (Array)
    - * Example: [[1,5], [7,9]]
    - * Default value: as defined by PDF viewer application
    - *
    - * NumCopies (Number)
    - * Possible values: 1, 2, 3, 4, 5
    - * Default value: 1
    - *
    - * For more information see the PDF Reference, sixth edition on Page 577 - * @param {boolean} doReset True to reset the settings - * @function - * @returns jsPDF jsPDF-instance - * @example - * var doc = new jsPDF() - * doc.text('This is a test', 10, 10) - * doc.viewerPreferences({'FitWindow': true}, true) - * doc.save("viewerPreferences.pdf") - * - * // Example printing 10 copies, using cropbox, and hiding UI. - * doc.viewerPreferences({ - * 'HideWindowUI': true, - * 'PrintArea': 'CropBox', - * 'NumCopies': 10 - * }) + /** + * Set the ViewerPreferences of the generated PDF + * + * @name viewerPreferences + * @function + * @public + * @param {Object} options Array with the ViewerPreferences
    + * Example: doc.viewerPreferences({"FitWindow":true});
    + *
    + * You can set following preferences:
    + *
    + * HideToolbar (boolean)
    + * Default value: false
    + *
    + * HideMenubar (boolean)
    + * Default value: false.
    + *
    + * HideWindowUI (boolean)
    + * Default value: false.
    + *
    + * FitWindow (boolean)
    + * Default value: false.
    + *
    + * CenterWindow (boolean)
    + * Default value: false
    + *
    + * DisplayDocTitle (boolean)
    + * Default value: false.
    + *
    + * NonFullScreenPageMode (string)
    + * Possible values: UseNone, UseOutlines, UseThumbs, UseOC
    + * Default value: UseNone
    + *
    + * Direction (string)
    + * Possible values: L2R, R2L
    + * Default value: L2R.
    + *
    + * ViewArea (string)
    + * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    + * Default value: CropBox.
    + *
    + * ViewClip (string)
    + * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    + * Default value: CropBox
    + *
    + * PrintArea (string)
    + * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    + * Default value: CropBox
    + *
    + * PrintClip (string)
    + * Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    + * Default value: CropBox.
    + *
    + * PrintScaling (string)
    + * Possible values: AppDefault, None
    + * Default value: AppDefault.
    + *
    + * Duplex (string)
    + * Possible values: Simplex, DuplexFlipLongEdge, DuplexFlipShortEdge + * Default value: none
    + *
    + * PickTrayByPDFSize (boolean)
    + * Default value: false
    + *
    + * PrintPageRange (Array)
    + * Example: [[1,5], [7,9]]
    + * Default value: as defined by PDF viewer application
    + *
    + * NumCopies (Number)
    + * Possible values: 1, 2, 3, 4, 5
    + * Default value: 1
    + *
    + * For more information see the PDF Reference, sixth edition on Page 577 + * @param {boolean} doReset True to reset the settings + * @function + * @returns jsPDF jsPDF-instance + * @example + * var doc = new jsPDF() + * doc.text('This is a test', 10, 10) + * doc.viewerPreferences({'FitWindow': true}, true) + * doc.save("viewerPreferences.pdf") + * + * // Example printing 10 copies, using cropbox, and hiding UI. + * doc.viewerPreferences({ + * 'HideWindowUI': true, + * 'PrintArea': 'CropBox', + * 'NumCopies': 10 + * }) */ jsPDFAPI.viewerPreferences = function (options, doReset) { @@ -16577,33 +15145,33 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** ==================================================================== - * jsPDF XMP metadata plugin - * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi - * - * - * ==================================================================== + /** ==================================================================== + * jsPDF XMP metadata plugin + * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi + * + * + * ==================================================================== */ - /** - * @name xmp_metadata - * @module + /*global jsPDF */ + + /** + * @name xmp_metadata + * @module */ (function (jsPDFAPI) { var xmpmetadata = ""; var xmpnamespaceuri = ""; var metadata_object_number = ""; - /** - * Adds XMP formatted metadata to PDF - * - * @name addMetadata - * @function - * @param {String} metadata The actual metadata to be added. The metadata shall be stored as XMP simple value. Note that if the metadata string contains XML markup characters "<", ">" or "&", those characters should be written using XML entities. - * @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash. - * @returns {jsPDF} jsPDF-instance + /** + * Adds XMP formatted metadata to PDF + * + * @name addMetadata + * @function + * @param {String} metadata The actual metadata to be added. The metadata shall be stored as XMP simple value. Note that if the metadata string contains XML markup characters "<", ">" or "&", those characters should be written using XML entities. + * @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash. + * @returns {jsPDF} jsPDF-instance */ jsPDFAPI.addMetadata = function (metadata, namespaceuri) { @@ -16641,13 +15209,11 @@ }; })(jsPDF.API); - /* global jsPDF */ - - /** - * @name utf8 - * @module + /** + * @name utf8 + * @module */ - (function (jsPDF) { + (function (jsPDF, global) { var jsPDFAPI = jsPDF.API; /**************************************************/ @@ -16722,11 +15288,9 @@ range = []; } - if (map[code] !== undefined && map[code] !== null && typeof map[code].toString === "function") { - unicode = ('0000' + map[code].toString(16)).slice(-4); - code = ('0000' + (+code).toString(16)).slice(-4); - range.push("<" + code + "><" + unicode + ">"); - } + unicode = ('0000' + map[code].toString(16)).slice(-4); + code = ('0000' + (+code).toString(16)).slice(-4); + range.push("<" + code + "><" + unicode + ">"); } if (range.length) { @@ -16737,13 +15301,7 @@ return unicodeMap; }; - var identityHFunction = function identityHFunction(options) { - var font = options.font; - var out = options.out; - var newObject = options.newObject; - var putStream = options.putStream; - var pdfEscapeWithNeededParanthesis = options.pdfEscapeWithNeededParanthesis; - + var identityHFunction = function identityHFunction(font, out, newObject, putStream) { if (font.metadata instanceof jsPDF.API.TTFFont && font.encoding === 'Identity-H') { //Tag with Identity-H var widths = font.metadata.Unicode.widths; @@ -16771,7 +15329,7 @@ var fontDescriptor = newObject(); out('<<'); out('/Type /FontDescriptor'); - out('/FontName /' + pdfEscapeWithNeededParanthesis(font.fontName)); + out('/FontName /' + font.fontName); out('/FontFile2 ' + fontTable + ' 0 R'); out('/FontBBox ' + jsPDF.API.PDFObject.convert(font.metadata.bbox)); out('/Flags ' + font.metadata.flags); @@ -16785,7 +15343,7 @@ var DescendantFont = newObject(); out('<<'); out('/Type /Font'); - out('/BaseFont /' + pdfEscapeWithNeededParanthesis(font.fontName)); + out('/BaseFont /' + font.fontName); out('/FontDescriptor ' + fontDescriptor + ' 0 R'); out('/W ' + jsPDF.API.PDFObject.convert(widths)); out('/CIDToGIDMap /Identity'); @@ -16814,18 +15372,13 @@ }; jsPDFAPI.events.push(['putFont', function (args) { - identityHFunction(args); + identityHFunction(args.font, args.out, args.newObject, args.putStream); }]); - var winAnsiEncodingFunction = function winAnsiEncodingFunction(options) { - var font = options.font; - var out = options.out; - var newObject = options.newObject; - var putStream = options.putStream; - var pdfEscapeWithNeededParanthesis = options.pdfEscapeWithNeededParanthesis; - + var winAnsiEncodingFunction = function winAnsiEncodingFunction(font, out, newObject, putStream) { if (font.metadata instanceof jsPDF.API.TTFFont && font.encoding === 'WinAnsiEncoding') { //Tag with WinAnsi encoding + var widths = font.metadata.Unicode.widths; var data = font.metadata.rawData; var pdfOutput = data; var pdfOutput2 = ""; @@ -16856,15 +15409,15 @@ out('/FontFile2 ' + fontTable + ' 0 R'); out('/Flags 96'); out('/FontBBox ' + jsPDF.API.PDFObject.convert(font.metadata.bbox)); - out('/FontName /' + pdfEscapeWithNeededParanthesis(font.fontName)); + out('/FontName /' + font.fontName); out('/ItalicAngle ' + font.metadata.italicAngle); out('/Ascent ' + font.metadata.ascender); out('>>'); out('endobj'); font.objectNumber = newObject(); - for (var j = 0; j < font.metadata.hmtx.widths.length; j++) { - font.metadata.hmtx.widths[j] = parseInt(font.metadata.hmtx.widths[j] * (1000 / font.metadata.head.unitsPerEm)); //Change the width of Em units to Point units. + for (var i = 0; i < font.metadata.hmtx.widths.length; i++) { + font.metadata.hmtx.widths[i] = parseInt(font.metadata.hmtx.widths[i] * (1000 / font.metadata.head.unitsPerEm)); //Change the width of Em units to Point units. } out('<>'); @@ -16874,7 +15427,7 @@ }; jsPDFAPI.events.push(['putFont', function (args) { - winAnsiEncodingFunction(args); + winAnsiEncodingFunction(args.font, args.out, args.newObject, args.putStream); }]); var utf8TextFunction = function utf8TextFunction(args) { @@ -16886,11 +15439,13 @@ var pdfEscape = mutex.pdfEscape; var activeFontKey = mutex.activeFontKey; var fonts = mutex.fonts; - var key = activeFontKey; + var key, + fontSize = mutex.activeFontSize; var str = '', s = 0, cmapConfirm; var strText = ''; + var key = activeFontKey; var encoding = fonts[key].encoding; if (fonts[key].encoding !== 'Identity-H') { @@ -16902,7 +15457,6 @@ mutex: mutex }; } - strText = text; key = activeFontKey; @@ -16913,19 +15467,19 @@ for (s = 0; s < strText.length; s += 1) { if (fonts[key].metadata.hasOwnProperty('cmap')) { cmapConfirm = fonts[key].metadata.cmap.unicode.codeMap[strText[s].charCodeAt(0)]; - /* - if (Object.prototype.toString.call(text) === '[object Array]') { - var i = 0; - // for (i = 0; i < text.length; i += 1) { - if (Object.prototype.toString.call(text[s]) === '[object Array]') { - cmapConfirm = fonts[key].metadata.cmap.unicode.codeMap[strText[s][0].charCodeAt(0)]; //Make sure the cmap has the corresponding glyph id - } else { - - } - //} - - } else { - cmapConfirm = fonts[key].metadata.cmap.unicode.codeMap[strText[s].charCodeAt(0)]; //Make sure the cmap has the corresponding glyph id + /* + if (Object.prototype.toString.call(text) === '[object Array]') { + var i = 0; + // for (i = 0; i < text.length; i += 1) { + if (Object.prototype.toString.call(text[s]) === '[object Array]') { + cmapConfirm = fonts[key].metadata.cmap.unicode.codeMap[strText[s][0].charCodeAt(0)]; //Make sure the cmap has the corresponding glyph id + } else { + + } + //} + + } else { + cmapConfirm = fonts[key].metadata.cmap.unicode.codeMap[strText[s].charCodeAt(0)]; //Make sure the cmap has the corresponding glyph id }*/ } @@ -16965,6 +15519,7 @@ y = parms.y, options = parms.options, mutex = parms.mutex; + var lang = options.lang; var tmpText = []; var args = { text: text, @@ -17004,22 +15559,20 @@ }; jsPDFAPI.events.push(['postProcessText', utf8EscapeFunction]); - })(jsPDF); + })(jsPDF, typeof self !== "undefined" && self || typeof global !== "undefined" && global || typeof window !== "undefined" && window || Function("return this")()); - /* global jsPDF */ - - /** - * jsPDF virtual FileSystem functionality - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * jsPDF virtual FileSystem functionality + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ - /** - * Use the vFS to handle files - * - * @name vFS - * @module + /** + * Use the vFS to handle files + * + * @name vFS + * @module */ (function (jsPDFAPI) { @@ -17034,15 +15587,15 @@ return true; }; - /** - * Check if the file exists in the vFS - * - * @name existsFileInVFS - * @function - * @param {string} Possible filename in the vFS. - * @returns {boolean} - * @example - * doc.existsFileInVFS("someFile.txt"); + /** + * Check if the file exists in the vFS + * + * @name existsFileInVFS + * @function + * @param {string} Possible filename in the vFS. + * @returns {boolean} + * @example + * doc.existsFileInVFS("someFile.txt"); */ @@ -17053,16 +15606,16 @@ return false; }; - /** - * Add a file to the vFS - * - * @name addFileToVFS - * @function - * @param {string} filename The name of the file which should be added. - * @param {string} filecontent The content of the file. - * @returns {jsPDF} - * @example - * doc.addFileToVFS("someFile.txt", "BADFACE1"); + /** + * Add a file to the vFS + * + * @name addFileToVFS + * @function + * @param {string} filename The name of the file which should be added. + * @param {string} filecontent The content of the file. + * @returns {jsPDF} + * @example + * doc.addFileToVFS("someFile.txt", "BADFACE1"); */ @@ -17072,15 +15625,15 @@ this.internal.vFS[filename] = filecontent; return this; }; - /** - * Get the file from the vFS - * - * @name getFileFromVFS - * @function - * @param {string} The name of the file which gets requested. - * @returns {string} - * @example - * doc.getFileFromVFS("someFile.txt"); + /** + * Get the file from the vFS + * + * @name getFileFromVFS + * @function + * @param {string} The name of the file which gets requested. + * @returns {string} + * @example + * doc.getFileFromVFS("someFile.txt"); */ @@ -17095,37 +15648,37 @@ }; })(jsPDF.API); - /** - * jsPDF addHTML PlugIn - * Copyright (c) 2014 Diego Casorran - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * jsPDF addHTML PlugIn + * Copyright (c) 2014 Diego Casorran + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ (function (jsPDFAPI) { - /** - * Renders an HTML element to canvas object which added to the PDF - * - * This feature requires [html2canvas](https://github.com/niklasvh/html2canvas) - * or [rasterizeHTML](https://github.com/cburgmer/rasterizeHTML.js) - * - * @returns {jsPDF} - * @name addHTML - * @param element {Mixed} HTML Element, or anything supported by html2canvas. - * @param x {Number} starting X coordinate in jsPDF instance's declared units. - * @param y {Number} starting Y coordinate in jsPDF instance's declared units. - * @param options {Object} Additional options, check the code below. - * @param callback {Function} to call when the rendering has finished. - * NOTE: Every parameter is optional except 'element' and 'callback', in such - * case the image is positioned at 0x0 covering the whole PDF document - * size. Ie, to easily take screenshots of webpages saving them to PDF. - * @deprecated This is being replace with a vector-supporting API. See - * [this link](https://cdn.rawgit.com/MrRio/jsPDF/master/examples/html2pdf/showcase_supported_html.html) + /** + * Renders an HTML element to canvas object which added to the PDF + * + * This feature requires [html2canvas](https://github.com/niklasvh/html2canvas) + * or [rasterizeHTML](https://github.com/cburgmer/rasterizeHTML.js) + * + * @returns {jsPDF} + * @name addHTML + * @param element {Mixed} HTML Element, or anything supported by html2canvas. + * @param x {Number} starting X coordinate in jsPDF instance's declared units. + * @param y {Number} starting Y coordinate in jsPDF instance's declared units. + * @param options {Object} Additional options, check the code below. + * @param callback {Function} to call when the rendering has finished. + * NOTE: Every parameter is optional except 'element' and 'callback', in such + * case the image is positioned at 0x0 covering the whole PDF document + * size. Ie, to easily take screenshots of webpages saving them to PDF. + * @deprecated This is being replace with a vector-supporting API. See + * [this link](https://cdn.rawgit.com/MrRio/jsPDF/master/examples/html2pdf/showcase_supported_html.html) */ jsPDFAPI.addHTML = function (element, x, y, options, callback) { - if (typeof html2canvas === 'undefined' && typeof rasterizeHTML === 'undefined') { throw new Error('You need either ' + 'https://github.com/niklasvh/html2canvas' + ' or https://github.com/cburgmer/rasterizeHTML.js'); } + if (typeof html2canvas === 'undefined' && typeof rasterizeHTML === 'undefined') throw new Error('You need either ' + 'https://github.com/niklasvh/html2canvas' + ' or https://github.com/cburgmer/rasterizeHTML.js'); if (typeof x !== 'number') { options = x; @@ -17287,18 +15840,18 @@ }; })(jsPDF.API); - /** - * jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser - * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com - * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria - * 2014 Diego Casorran, https://github.com/diegocr - * 2014 Daniel Husar, https://github.com/danielhusar - * 2014 Wolfgang Gassler, https://github.com/woolfg - * 2014 Steven Spungin, https://github.com/flamenco - * - * @license - * - * ==================================================================== + /** + * jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser + * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com + * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria + * 2014 Diego Casorran, https://github.com/diegocr + * 2014 Daniel Husar, https://github.com/danielhusar + * 2014 Wolfgang Gassler, https://github.com/woolfg + * 2014 Steven Spungin, https://github.com/flamenco + * + * @license + * + * ==================================================================== */ (function (jsPDFAPI) { var clone, _DrillForContent, FontNameDB, FontStyleMap, TextAlignMap, FontWeightMap, FloatMap, ClearMap, GetCSS, PurgeWhiteSpace, Renderer, ResolveFont, ResolveUnitedNumber, UnitedNumberMap, elementHandledElsewhere, images, loadImgs, checkForFooter, process, tableToJson; @@ -17824,7 +16377,7 @@ } function loadImage(url, width, height) { - if (!url) { return; } + if (!url) return; var img = new Image(); found_images = ++x; img.crossOrigin = ''; @@ -17931,8 +16484,8 @@ }; process = function process(pdf, element, x, y, settings, callback) { - if (!element) { return false; } - if (typeof element !== "string" && !element.parentNode) { element = '' + element.innerHTML; } + if (!element) return false; + if (typeof element !== "string" && !element.parentNode) element = '' + element.innerHTML; if (typeof element === "string") { element = function (element) { @@ -17964,7 +16517,7 @@ r.pdf.internal.events.publish('htmlRenderingFinished'); out = r.dispose(); - if (typeof callback === 'function') { callback(out); }else if (found_images) { console.error('jsPDF Warning: rendering issues? provide a callback to fromHTML!'); } + if (typeof callback === 'function') callback(out);else if (found_images) console.error('jsPDF Warning: rendering issues? provide a callback to fromHTML!'); }); return out || { x: r.x, @@ -18362,24 +16915,24 @@ UnitedNumberMap = { normal: 1 }; - /** - * Converts HTML-formatted text into formatted PDF text. - * - * Notes: - * 2012-07-18 - * Plugin relies on having browser, DOM around. The HTML is pushed into dom and traversed. - * Plugin relies on jQuery for CSS extraction. - * Targeting HTML output from Markdown templating, which is a very simple - * markup - div, span, em, strong, p. No br-based paragraph separation supported explicitly (but still may work.) - * Images, tables are NOT supported. - * - * @public - * @function - * @param HTML {String|Object} HTML-formatted text, or pointer to DOM element that is to be rendered into PDF. - * @param x {Number} starting X coordinate in jsPDF instance's declared units. - * @param y {Number} starting Y coordinate in jsPDF instance's declared units. - * @param settings {Object} Additional / optional variables controlling parsing, rendering. - * @returns {Object} jsPDF instance + /** + * Converts HTML-formatted text into formatted PDF text. + * + * Notes: + * 2012-07-18 + * Plugin relies on having browser, DOM around. The HTML is pushed into dom and traversed. + * Plugin relies on jQuery for CSS extraction. + * Targeting HTML output from Markdown templating, which is a very simple + * markup - div, span, em, strong, p. No br-based paragraph separation supported explicitly (but still may work.) + * Images, tables are NOT supported. + * + * @public + * @function + * @param HTML {String|Object} HTML-formatted text, or pointer to DOM element that is to be rendered into PDF. + * @param x {Number} starting X coordinate in jsPDF instance's declared units. + * @param y {Number} starting Y coordinate in jsPDF instance's declared units. + * @param settings {Object} Additional / optional variables controlling parsing, rendering. + * @returns {Object} jsPDF instance */ jsPDFAPI.fromHTML = function (HTML, x, y, settings, callback, margins) { @@ -18388,18 +16941,18 @@ top: 0, bottom: 0 }; - if (!settings) { settings = {}; } - if (!settings.elementHandlers) { settings.elementHandlers = {}; } + if (!settings) settings = {}; + if (!settings.elementHandlers) settings.elementHandlers = {}; return process(this, HTML, isNaN(x) ? 4 : x, isNaN(y) ? 4 : y, settings, callback); }; })(jsPDF.API); - /** - * html2pdf.js - * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license + /** + * html2pdf.js + * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license */ (function (jsPDFAPI, globalObj) { globalObj.html2pdf = function (html, pdf, callback) { @@ -18522,15 +17075,20 @@ }); }; })(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global); + /*rollup-keeper-start*/ - /* Blob.js - * A Blob, File, FileReader & URL implementation. - * 2018-08-09 - * - * By Eli Grey, http://eligrey.com - * By Jimmy Wärting, https://github.com/jimmywarting - * License: MIT - * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md + + window.tmp = html2pdf; + /*rollup-keeper-end*/ + + /* Blob.js + * A Blob, File, FileReader & URL implementation. + * 2018-08-09 + * + * By Eli Grey, http://eligrey.com + * By Jimmy Wärting, https://github.com/jimmywarting + * License: MIT + * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md */ (function (global) { @@ -18558,10 +17116,10 @@ blobSupportsArrayBufferView = new Blob([new Uint8Array([1, 2])]).size === 2; } catch (e) {} - /** - * Helper function that maps ArrayBufferViews to ArrayBuffers - * Used by BlobBuilder constructor and old browsers that didn't - * support it in the Blob constructor. + /** + * Helper function that maps ArrayBufferViews to ArrayBuffers + * Used by BlobBuilder constructor and old browsers that didn't + * support it in the Blob constructor. */ @@ -18608,7 +17166,7 @@ for (var i = 0; i < str.length; i++) { var charcode = str.charCodeAt(i); - if (charcode < 0x80) { utf8.push(charcode); }else if (charcode < 0x800) { + if (charcode < 0x80) utf8.push(charcode);else if (charcode < 0x800) { utf8.push(0xc0 | charcode >> 6, 0x80 | charcode & 0x3f); } else if (charcode < 0xd800 || charcode >= 0xe000) { utf8.push(0xe0 | charcode >> 12, 0x80 | charcode >> 6 & 0x3f, 0x80 | charcode & 0x3f); @@ -18685,7 +17243,7 @@ } function encodeByteArray(input) { - var byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + var byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var output = []; for (var i = 0; i < input.length; i += 3) { @@ -18787,7 +17345,7 @@ File.prototype = create(Blob.prototype); File.prototype.constructor = File; - if (Object.setPrototypeOf) { Object.setPrototypeOf(File, Blob); }else { + if (Object.setPrototypeOf) Object.setPrototypeOf(File, Blob);else { try { File.__proto__ = Blob; } catch (e) {} @@ -18804,13 +17362,13 @@ function FileReader() { - if (!(this instanceof FileReader)) { throw new TypeError("Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); } + if (!(this instanceof FileReader)) throw new TypeError("Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); var delegate = document.createDocumentFragment(); this.addEventListener = delegate.addEventListener; this.dispatchEvent = function (evt) { var local = this['on' + evt.type]; - if (typeof local === 'function') { local(evt); } + if (typeof local === 'function') local(evt); delegate.dispatchEvent(evt); }; @@ -18818,7 +17376,7 @@ } function _read(fr, blob, kind) { - if (!(blob instanceof Blob)) { throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'."); } + if (!(blob instanceof Blob)) throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'."); fr.result = ''; setTimeout(function () { this.readyState = FileReader.LOADING; @@ -18942,7 +17500,7 @@ return '[object File]'; }; - if (strTag) { blob[strTag] = 'File'; } + if (strTag) blob[strTag] = 'File'; return blob; }; @@ -18962,6 +17520,191 @@ } })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || typeof global !== "undefined" && global || Function('return typeof this === "object" && this.content')() || Function('return this')()); + /* FileSaver.js + * A saveAs() FileSaver implementation. + * 1.3.8 + * 2018-03-22 14:03:47 + * + * By Eli Grey, https://eligrey.com + * License: MIT + * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md + */ + + /*global self */ + + /*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ + + /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/src/FileSaver.js */ + var saveAs = saveAs || function (view) { + + if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { + return; + } + + var doc = view.document // only get URL when necessary in case Blob.js hasn't overridden it yet + , + get_URL = function () { + return view.URL || view.webkitURL || view; + }, + save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a"), + can_use_save_link = "download" in save_link, + click = function (node) { + var event = new MouseEvent("click"); + node.dispatchEvent(event); + }, + is_safari = /constructor/i.test(view.HTMLElement) || view.safari, + is_chrome_ios = /CriOS\/[\d]+/.test(navigator.userAgent), + setImmediate = view.setImmediate || view.setTimeout, + throw_outside = function (ex) { + setImmediate(function () { + throw ex; + }, 0); + }, + force_saveable_type = "application/octet-stream" // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to + , + arbitrary_revoke_timeout = 1000 * 40 // in ms + , + revoke = function (file) { + var revoker = function () { + if (typeof file === "string") { + // file is an object URL + get_URL().revokeObjectURL(file); + } else { + // file is a File + file.remove(); + } + }; + + setTimeout(revoker, arbitrary_revoke_timeout); + }, + dispatch = function (filesaver, event_types, event) { + event_types = [].concat(event_types); + var i = event_types.length; + + while (i--) { + var listener = filesaver["on" + event_types[i]]; + + if (typeof listener === "function") { + try { + listener.call(filesaver, event || filesaver); + } catch (ex) { + throw_outside(ex); + } + } + } + }, + auto_bom = function (blob) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xFEFF), blob], { + type: blob.type + }); + } + + return blob; + }, + FileSaver = function (blob, name, no_auto_bom) { + if (!no_auto_bom) { + blob = auto_bom(blob); + } // First try a.download, then web filesystem, then object URLs + + + var filesaver = this, + type = blob.type, + force = type === force_saveable_type, + object_url, + dispatch_all = function () { + dispatch(filesaver, "writestart progress write writeend".split(" ")); + } // on any filesys errors revert to saving with object URLs + , + fs_error = function () { + if ((is_chrome_ios || force && is_safari) && view.FileReader) { + // Safari doesn't allow downloading of blob urls + var reader = new FileReader(); + + reader.onloadend = function () { + var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;'); + var popup = view.open(url, '_blank'); + if (!popup) view.location.href = url; + url = undefined; // release reference before dispatching + + filesaver.readyState = filesaver.DONE; + dispatch_all(); + }; + + reader.readAsDataURL(blob); + filesaver.readyState = filesaver.INIT; + return; + } // don't create more object URLs than needed + + + if (!object_url) { + object_url = get_URL().createObjectURL(blob); + } + + if (force) { + view.location.href = object_url; + } else { + var opened = view.open(object_url, "_blank"); + + if (!opened) { + // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html + view.location.href = object_url; + } + } + + filesaver.readyState = filesaver.DONE; + dispatch_all(); + revoke(object_url); + }; + + filesaver.readyState = filesaver.INIT; + + if (can_use_save_link) { + object_url = get_URL().createObjectURL(blob); + setImmediate(function () { + save_link.href = object_url; + save_link.download = name; + click(save_link); + dispatch_all(); + revoke(object_url); + filesaver.readyState = filesaver.DONE; + }, 0); + return; + } + + fs_error(); + }, + FS_proto = FileSaver.prototype, + saveAs = function (blob, name, no_auto_bom) { + return new FileSaver(blob, name || blob.name || "download", no_auto_bom); + }; // IE 10+ (native saveAs) + + + if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { + return function (blob, name, no_auto_bom) { + name = name || blob.name || "download"; + + if (!no_auto_bom) { + blob = auto_bom(blob); + } + + return navigator.msSaveOrOpenBlob(blob, name); + }; + } // todo: detect chrome extensions & packaged apps + //save_link.target = "_blank"; + + + FS_proto.abort = function () {}; + + FS_proto.readyState = FS_proto.INIT = 0; + FS_proto.WRITING = 1; + FS_proto.DONE = 2; + FS_proto.error = FS_proto.onwritestart = FS_proto.onprogress = FS_proto.onwrite = FS_proto.onabort = FS_proto.onerror = FS_proto.onwriteend = null; + return saveAs; + }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || undefined); + // (c) Dean McNamee , 2013. // // https://github.com/deanm/omggif @@ -18976,11 +17719,11 @@ var gopts = gopts === undefined ? {} : gopts; var loop_count = gopts.loop === undefined ? null : gopts.loop; var global_palette = gopts.palette === undefined ? null : gopts.palette; - if (width <= 0 || height <= 0 || width > 65535 || height > 65535) { throw "Width/Height invalid."; } + if (width <= 0 || height <= 0 || width > 65535 || height > 65535) throw "Width/Height invalid."; function check_palette_and_num_colors(palette) { var num_colors = palette.length; - if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1) { throw "Invalid code/color length, must be power of 2 and 2 .. 256."; } + if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1) throw "Invalid code/color length, must be power of 2 and 2 .. 256."; return num_colors; } // - Header. @@ -19000,21 +17743,19 @@ if (global_palette !== null) { var gp_num_colors = check_palette_and_num_colors(global_palette); - while (gp_num_colors >>= 1) { - ++gp_num_colors_pow2; - } + while (gp_num_colors >>= 1) ++gp_num_colors_pow2; gp_num_colors = 1 << gp_num_colors_pow2; --gp_num_colors_pow2; if (gopts.background !== undefined) { background = gopts.background; - if (background >= gp_num_colors) { throw "Background index out of range."; } // The GIF spec states that a background index of 0 should be ignored, so + if (background >= gp_num_colors) throw "Background index out of range."; // The GIF spec states that a background index of 0 should be ignored, so // this is probably a mistake and you really want to set it to another // slot in the palette. But actually in the end most browsers, etc end // up ignoring this almost completely (including for dispose background). - if (background === 0) { throw "Background index explicitly passed as 0."; } + if (background === 0) throw "Background index explicitly passed as 0."; } } // - Logical Screen Descriptor. // NOTE(deanm): w/h apparently ignored by implementations, but set anyway. @@ -19044,7 +17785,7 @@ if (loop_count !== null) { // Netscape block for looping. - if (loop_count < 0 || loop_count > 65535) { throw "Loop count invalid."; } // Extension code, label, and length. + if (loop_count < 0 || loop_count > 65535) throw "Loop count invalid."; // Extension code, label, and length. buf[p++] = 0x21; buf[p++] = 0xff; @@ -19081,9 +17822,9 @@ opts = opts === undefined ? {} : opts; // TODO(deanm): Bounds check x, y. Do they need to be within the virtual // canvas width/height, I imagine? - if (x < 0 || y < 0 || x > 65535 || y > 65535) { throw "x/y invalid."; } - if (w <= 0 || h <= 0 || w > 65535 || h > 65535) { throw "Width/Height invalid."; } - if (indexed_pixels.length < w * h) { throw "Not enough pixels for the frame size."; } + if (x < 0 || y < 0 || x > 65535 || y > 65535) throw "x/y invalid."; + if (w <= 0 || h <= 0 || w > 65535 || h > 65535) throw "Width/Height invalid."; + if (indexed_pixels.length < w * h) throw "Not enough pixels for the frame size."; var using_local_palette = true; var palette = opts.palette; @@ -19092,14 +17833,12 @@ palette = global_palette; } - if (palette === undefined || palette === null) { throw "Must supply either a local or global palette."; } + if (palette === undefined || palette === null) throw "Must supply either a local or global palette."; var num_colors = check_palette_and_num_colors(palette); // Compute the min_code_size (power of 2), destroying num_colors. var min_code_size = 0; - while (num_colors >>= 1) { - ++min_code_size; - } + while (num_colors >>= 1) ++min_code_size; num_colors = 1 << min_code_size; // Now we can easily get it back. @@ -19119,14 +17858,14 @@ var disposal = opts.disposal === undefined ? 0 : opts.disposal; if (disposal < 0 || disposal > 3) // 4-7 is reserved. - { throw "Disposal out of range."; } + throw "Disposal out of range."; var use_transparency = false; var transparent_index = 0; if (opts.transparent !== undefined && opts.transparent !== null) { use_transparency = true; transparent_index = opts.transparent; - if (transparent_index < 0 || transparent_index >= num_colors) { throw "Transparent color index."; } + if (transparent_index < 0 || transparent_index >= num_colors) throw "Transparent color index."; } if (disposal !== 0 || use_transparency || delay !== 0) { @@ -19310,7 +18049,7 @@ // decoder. From the encoders perspective this should happen after // we've already emitted the index buffer and are about to create the // first table entry that would overflow our current code bit size. - if (next_code >= 1 << cur_code_size) { ++cur_code_size; } + if (next_code >= 1 << cur_code_size) ++cur_code_size; code_table[cur_key] = next_code++; // Insert into code table. } @@ -19398,7 +18137,7 @@ while (true) { // Seek through subblocks. var block_size = buf[p++]; - if (block_size === 0) { break; } + if (block_size === 0) break; p += block_size; } } @@ -19407,11 +18146,11 @@ case 0xf9: // Graphics Control Extension - if (buf[p++] !== 0x4 || buf[p + 4] !== 0) { throw "Invalid graphics extension block."; } + if (buf[p++] !== 0x4 || buf[p + 4] !== 0) throw "Invalid graphics extension block."; var pf1 = buf[p++]; delay = buf[p++] | buf[p++] << 8; transparent_index = buf[p++]; - if ((pf1 & 1) === 0) { transparent_index = null; } + if ((pf1 & 1) === 0) transparent_index = null; disposal = pf1 >> 2 & 0x7; p++; // Skip terminator. @@ -19422,7 +18161,7 @@ while (true) { // Seek through subblocks. var block_size = buf[p++]; - if (block_size === 0) { break; } // console.log(buf.slice(p, p+block_size).toString('ascii')); + if (block_size === 0) break; // console.log(buf.slice(p, p+block_size).toString('ascii')); p += block_size; } @@ -19461,7 +18200,7 @@ while (true) { var block_size = buf[p++]; - if (block_size === 0) { break; } + if (block_size === 0) break; p += block_size; } @@ -19501,7 +18240,7 @@ }; this.frameInfo = function (frame_num) { - if (frame_num < 0 || frame_num >= frames.length) { throw "Frame index out of range."; } + if (frame_num < 0 || frame_num >= frames.length) throw "Frame index out of range."; return frames[frame_num]; }; @@ -19516,7 +18255,7 @@ // the profile, not sure if it's related to using a Uint8Array. var trans = frame.transparent_index; - if (trans === null) { trans = 256; } // We are possibly just blitting to a portion of the entire frame. + if (trans === null) trans = 256; // We are possibly just blitting to a portion of the entire frame. // That is a subrect within the framerect, so the additional pixels // must be skipped over after we finished a scanline. @@ -19582,7 +18321,7 @@ // the profile, not sure if it's related to using a Uint8Array. var trans = frame.transparent_index; - if (trans === null) { trans = 256; } // We are possibly just blitting to a portion of the entire frame. + if (trans === null) trans = 256; // We are possibly just blitting to a portion of the entire frame. // That is a subrect within the framerect, so the additional pixels // must be skipped over after we finished a scanline. @@ -19662,7 +18401,7 @@ while (true) { // Read up to two bytes, making sure we always 12-bits for max sized code. while (cur_shift < 16) { - if (subblock_size === 0) { break; } // No more data to be read. + if (subblock_size === 0) break; // No more data to be read. cur |= code_stream[p++] << cur_shift; cur_shift += 8; @@ -19677,7 +18416,7 @@ // and EOI. - if (cur_shift < cur_code_size) { break; } + if (cur_shift < cur_code_size) break; var code = cur & code_mask; cur >>= cur_code_size; cur_shift -= cur_code_size; // TODO(deanm): Maybe should check that the first code was a clear code, @@ -19740,7 +18479,7 @@ var b = op; // Track pointer, writing backwards. if (chase_code !== code) // The case of emitting {CODE-1} + k. - { output[op++] = k; } + output[op++] = k; chase = chase_code; while (chase_length--) { @@ -19778,26 +18517,32 @@ exports.GifReader = GifReader; } catch (e) {} // CommonJS. - /* - * Copyright (c) 2012 chick307 - * - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license - */ - (function (jsPDF, callback) { + /*rollup-keeper-start*/ + + + window.tmp = GifReader; + /*rollup-keeper-end*/ + + /* + * Copyright (c) 2012 chick307 + * + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license + */ + (function (jsPDF, callback) { jsPDF.API.adler32cs = callback(); })(jsPDF, function () { var _hasArrayBuffer = typeof ArrayBuffer === 'function' && typeof Uint8Array === 'function'; var _Buffer = null, _isBuffer = function () { - if (!_hasArrayBuffer) { return function _isBuffer() { + if (!_hasArrayBuffer) return function _isBuffer() { return false; - }; } + }; try { var buffer = {}; - if (typeof buffer.Buffer === 'function') { _Buffer = buffer.Buffer; } + if (typeof buffer.Buffer === 'function') _Buffer = buffer.Buffer; } catch (error) {} return function _isBuffer(value) { @@ -19851,7 +18596,7 @@ throw new TypeError('Constructor cannot called be as a function.'); } - if (!isFinite(checksum = checksum === null ? 1 : +checksum)) { + if (!isFinite(checksum = checksum == null ? 1 : +checksum)) { throw new Error('First arguments needs to be a finite number.'); } @@ -19869,7 +18614,7 @@ throw new TypeError('Constructor cannot called be as a function.'); } - if (binaryString === null) { throw new Error('First argument needs to be a string.'); } + if (binaryString == null) throw new Error('First argument needs to be a string.'); this.checksum = _update(1, binaryString.toString()); }); @@ -19881,7 +18626,7 @@ throw new TypeError('Constructor cannot called be as a function.'); } - if (utf8String === null) { throw new Error('First argument needs to be a string.'); } + if (utf8String == null) throw new Error('First argument needs to be a string.'); var binaryString = _utf8ToBinary(utf8String.toString()); @@ -19897,20 +18642,20 @@ throw new TypeError('Constructor cannot called be as a function.'); } - if (!_isBuffer(buffer)) { throw new Error('First argument needs to be ArrayBuffer.'); } + if (!_isBuffer(buffer)) throw new Error('First argument needs to be ArrayBuffer.'); var array = new Uint8Array(buffer); return this.checksum = _updateUint8Array(1, array); }); } proto.update = function update(binaryString) { - if (binaryString === null) { throw new Error('First argument needs to be a string.'); } + if (binaryString == null) throw new Error('First argument needs to be a string.'); binaryString = binaryString.toString(); return this.checksum = _update(this.checksum, binaryString); }; proto.updateUtf8 = function updateUtf8(utf8String) { - if (utf8String === null) { throw new Error('First argument needs to be a string.'); } + if (utf8String == null) throw new Error('First argument needs to be a string.'); var binaryString = _utf8ToBinary(utf8String.toString()); @@ -19919,7 +18664,7 @@ if (_hasArrayBuffer) { proto.updateBuffer = function updateBuffer(buffer) { - if (!_isBuffer(buffer)) { throw new Error('First argument needs to be ArrayBuffer.'); } + if (!_isBuffer(buffer)) throw new Error('First argument needs to be ArrayBuffer.'); var array = new Uint8Array(buffer); return this.checksum = _updateUint8Array(this.checksum, array); }; @@ -19933,12 +18678,12 @@ }(); exports.from = function from(binaryString) { - if (binaryString === null) { throw new Error('First argument needs to be a string.'); } + if (binaryString == null) throw new Error('First argument needs to be a string.'); return _update(1, binaryString.toString()); }; exports.fromUtf8 = function fromUtf8(utf8String) { - if (utf8String === null) { throw new Error('First argument needs to be a string.'); } + if (utf8String == null) throw new Error('First argument needs to be a string.'); var binaryString = _utf8ToBinary(utf8String.toString()); @@ -19947,7 +18692,7 @@ if (_hasArrayBuffer) { exports.fromBuffer = function fromBuffer(buffer) { - if (!_isBuffer(buffer)) { throw new Error('First argument need to be ArrayBuffer.'); } + if (!_isBuffer(buffer)) throw new Error('First argument need to be ArrayBuffer.'); var array = new Uint8Array(buffer); return _updateUint8Array(1, array); }; @@ -19956,58 +18701,58 @@ return exports; }); - /** - * Unicode Bidi Engine based on the work of Alex Shensis (@asthensis) - * MIT License + /** + * Unicode Bidi Engine based on the work of Alex Shensis (@asthensis) + * MIT License */ (function (jsPDF) { - /** - * Table of Unicode types. - * - * Generated by: - * - * var bidi = require("./bidi/index"); - * var bidi_accumulate = bidi.slice(0, 256).concat(bidi.slice(0x0500, 0x0500 + 256 * 3)). - * concat(bidi.slice(0x2000, 0x2000 + 256)).concat(bidi.slice(0xFB00, 0xFB00 + 256)). - * concat(bidi.slice(0xFE00, 0xFE00 + 2 * 256)); - * - * for( var i = 0; i < bidi_accumulate.length; i++) { - * if(bidi_accumulate[i] === undefined || bidi_accumulate[i] === 'ON') - * bidi_accumulate[i] = 'N'; //mark as neutral to conserve space and substitute undefined - * } - * var bidiAccumulateStr = 'return [ "' + bidi_accumulate.toString().replace(/,/g, '", "') + '" ];'; - * require("fs").writeFile('unicode-types.js', bidiAccumulateStr); - * - * Based on: - * https://github.com/mathiasbynens/unicode-8.0.0 + /** + * Table of Unicode types. + * + * Generated by: + * + * var bidi = require("./bidi/index"); + * var bidi_accumulate = bidi.slice(0, 256).concat(bidi.slice(0x0500, 0x0500 + 256 * 3)). + * concat(bidi.slice(0x2000, 0x2000 + 256)).concat(bidi.slice(0xFB00, 0xFB00 + 256)). + * concat(bidi.slice(0xFE00, 0xFE00 + 2 * 256)); + * + * for( var i = 0; i < bidi_accumulate.length; i++) { + * if(bidi_accumulate[i] === undefined || bidi_accumulate[i] === 'ON') + * bidi_accumulate[i] = 'N'; //mark as neutral to conserve space and substitute undefined + * } + * var bidiAccumulateStr = 'return [ "' + bidi_accumulate.toString().replace(/,/g, '", "') + '" ];'; + * require("fs").writeFile('unicode-types.js', bidiAccumulateStr); + * + * Based on: + * https://github.com/mathiasbynens/unicode-8.0.0 */ var bidiUnicodeTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "N", "N", "ET", "ET", "ET", "N", "N", "N", "N", "N", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "N", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "L", "N", "N", "BN", "N", "N", "ET", "ET", "EN", "EN", "N", "L", "N", "N", "N", "EN", "L", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "N", "N", "N", "N", "N", "ET", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "R", "NSM", "R", "NSM", "NSM", "R", "NSM", "NSM", "R", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "AN", "AN", "AN", "AN", "AN", "AN", "N", "N", "AL", "ET", "ET", "AL", "CS", "AL", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "N", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "N", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "R", "R", "N", "N", "N", "N", "R", "N", "N", "N", "N", "N", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "BN", "BN", "BN", "L", "R", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "WS", "B", "LRE", "RLE", "PDF", "LRO", "RLO", "CS", "ET", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "CS", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "WS", "BN", "BN", "BN", "BN", "BN", "N", "LRI", "RLI", "FSI", "PDI", "BN", "BN", "BN", "BN", "BN", "BN", "EN", "L", "N", "N", "EN", "EN", "EN", "EN", "EN", "EN", "ES", "ES", "N", "N", "N", "L", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "ES", "ES", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "R", "NSM", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "ES", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "N", "R", "R", "R", "R", "R", "N", "R", "N", "R", "R", "N", "R", "R", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "CS", "N", "CS", "N", "N", "CS", "N", "N", "N", "N", "N", "N", "N", "N", "N", "ET", "N", "N", "ES", "ES", "N", "N", "N", "N", "N", "ET", "ET", "N", "N", "N", "N", "N", "AL", "AL", "AL", "AL", "AL", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "N", "N", "BN", "N", "N", "N", "ET", "ET", "ET", "N", "N", "N", "N", "N", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "L", "L", "L", "L", "L", "L", "N", "N", "L", "L", "L", "L", "L", "L", "N", "N", "L", "L", "L", "L", "L", "L", "N", "N", "L", "L", "L", "N", "N", "N", "ET", "ET", "N", "N", "N", "ET", "ET", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N"]; - /** - * Unicode Bidi algorithm compliant Bidi engine. - * For reference see http://unicode.org/reports/tr9/ + /** + * Unicode Bidi algorithm compliant Bidi engine. + * For reference see http://unicode.org/reports/tr9/ */ - /** - * constructor ( options ) - * - * Initializes Bidi engine - * - * @param {Object} See 'setOptions' below for detailed description. - * options are cashed between invocation of 'doBidiReorder' method - * - * sample usage pattern of BidiEngine: - * var opt = { - * isInputVisual: true, - * isInputRtl: false, - * isOutputVisual: false, - * isOutputRtl: false, - * isSymmetricSwapping: true - * } - * var sourceToTarget = [], levels = []; - * var bidiEng = Globalize.bidiEngine(opt); - * var src = "text string to be reordered"; - * var ret = bidiEng.doBidiReorder(src, sourceToTarget, levels); + /** + * constructor ( options ) + * + * Initializes Bidi engine + * + * @param {Object} See 'setOptions' below for detailed description. + * options are cashed between invocation of 'doBidiReorder' method + * + * sample usage pattern of BidiEngine: + * var opt = { + * isInputVisual: true, + * isInputRtl: false, + * isOutputVisual: false, + * isOutputRtl: false, + * isSymmetricSwapping: true + * } + * var sourceToTarget = [], levels = []; + * var bidiEng = Globalize.bidiEngine(opt); + * var src = "text string to be reordered"; + * var ret = bidiEng.doBidiReorder(src, sourceToTarget, levels); */ jsPDF.__bidiEngine__ = jsPDF.prototype.__bidiEngine__ = function (options) { @@ -20494,16 +19239,16 @@ return text; }; - /** - * @name setOptions( options ) - * @function - * Sets options for Bidi conversion - * @param {Object}: - * - isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) - * - isInputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong character of input string) - * - isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) - * - isOutputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong characterof input string) - * - isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping), + /** + * @name setOptions( options ) + * @function + * Sets options for Bidi conversion + * @param {Object}: + * - isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) + * - isInputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong character of input string) + * - isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) + * - isOutputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong characterof input string) + * - isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping), */ @@ -20557,42 +19302,42 @@ jsPDF.API.events.push(['postProcessText', bidiEngineFunction]); })(jsPDF); - /* - Copyright (c) 2008, Adobe Systems Incorporated - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Adobe Systems Incorporated nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + /* + Copyright (c) 2008, Adobe Systems Incorporated + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Adobe Systems Incorporated nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* - JPEG encoder ported to JavaScript and optimized by Andreas Ritter, www.bytestrom.eu, 11/2009 - - Basic GUI blocking jpeg encoder + /* + JPEG encoder ported to JavaScript and optimized by Andreas Ritter, www.bytestrom.eu, 11/2009 + + Basic GUI blocking jpeg encoder */ function JPEGEncoder(quality) { var ffloor = Math.floor; @@ -21168,7 +19913,7 @@ this.encode = function (image, quality) // image data object { var time_start = new Date().getTime(); - if (quality) { setQuality(quality); } // Initialize bit writer + if (quality) setQuality(quality); // Initialize bit writer byteout = new Array(); bytenew = 0; @@ -21226,10 +19971,10 @@ r = imageData[p++]; g = imageData[p++]; b = imageData[p++]; - /* // calculate YUV values dynamically - YDU[pos]=((( 0.29900)*r+( 0.58700)*g+( 0.11400)*b))-128; //-0x80 - UDU[pos]=(((-0.16874)*r+(-0.33126)*g+( 0.50000)*b)); - VDU[pos]=((( 0.50000)*r+(-0.41869)*g+(-0.08131)*b)); + /* // calculate YUV values dynamically + YDU[pos]=((( 0.29900)*r+( 0.58700)*g+( 0.11400)*b))-128; //-0x80 + UDU[pos]=(((-0.16874)*r+(-0.33126)*g+( 0.50000)*b)); + VDU[pos]=((( 0.50000)*r+(-0.41869)*g+(-0.08131)*b)); */ // use lookup table (slightly faster) @@ -21270,7 +20015,7 @@ quality = 100; } - if (currentQuality == quality) { return; } // don't recalc if unchanged + if (currentQuality == quality) return; // don't recalc if unchanged var sf = 0; @@ -21286,7 +20031,7 @@ function init() { var time_start = new Date().getTime(); - if (!quality) { quality = 50; } // Create tables + if (!quality) quality = 50; // Create tables initCharLookupTable(); initHuffmanTbl(); @@ -21298,16 +20043,16 @@ init(); } + /*rollup-keeper-start*/ - try { - exports.JPEGEncoder = JPEGEncoder; - } catch (e) {} // CommonJS. + window.tmp = JPEGEncoder; + /*rollup-keeper-end*/ - /** - * @author shaozilee - * - * Bmp format decoder,support 1bit 4bit 8bit 24bit bmp - * + /** + * @author shaozilee + * + * Bmp format decoder,support 1bit 4bit 8bit 24bit bmp + * */ function BmpDecoder(buffer, is_with_alpha) { this.pos = 0; @@ -21317,7 +20062,7 @@ this.bottom_up = true; this.flag = String.fromCharCode(this.buffer[0]) + String.fromCharCode(this.buffer[1]); this.pos += 2; - if (["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag) === -1) { throw new Error("Invalid BMP File"); } + if (["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag) === -1) throw new Error("Invalid BMP File"); this.parseHeader(); this.parseBGR(); } @@ -21418,7 +20163,7 @@ } } - if (mode !== 0) { + if (mode != 0) { this.pos += 4 - mode; } } @@ -21441,4696 +20186,198 @@ this.data[location + 1] = rgb.green; this.data[location + 2] = rgb.red; this.data[location + 3] = 0xFF; - if (x * 2 + 1 >= this.width) { break; } + if (x * 2 + 1 >= this.width) break; rgb = this.palette[after]; - this.data[location + 4] = rgb.blue; - this.data[location + 4 + 1] = rgb.green; - this.data[location + 4 + 2] = rgb.red; - this.data[location + 4 + 3] = 0xFF; - } - - if (mode !== 0) { - this.pos += 4 - mode; - } - } - }; - - BmpDecoder.prototype.bit8 = function () { - var mode = this.width % 4; - - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - - for (var x = 0; x < this.width; x++) { - var b = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - - if (b < this.palette.length) { - var rgb = this.palette[b]; - this.data[location] = rgb.red; - this.data[location + 1] = rgb.green; - this.data[location + 2] = rgb.blue; - this.data[location + 3] = 0xFF; - } else { - this.data[location] = 0xFF; - this.data[location + 1] = 0xFF; - this.data[location + 2] = 0xFF; - this.data[location + 3] = 0xFF; - } - } - - if (mode !== 0) { - this.pos += 4 - mode; - } - } - }; - - BmpDecoder.prototype.bit15 = function () { - var dif_w = this.width % 3; - - var _11111 = parseInt("11111", 2), - _1_5 = _11111; - - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - - for (var x = 0; x < this.width; x++) { - var B = this.datav.getUint16(this.pos, true); - this.pos += 2; - var blue = (B & _1_5) / _1_5 * 255 | 0; - var green = (B >> 5 & _1_5) / _1_5 * 255 | 0; - var red = (B >> 10 & _1_5) / _1_5 * 255 | 0; - var alpha = B >> 15 ? 0xFF : 0x00; - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; - } //skip extra bytes - - - this.pos += dif_w; - } - }; - - BmpDecoder.prototype.bit16 = function () { - var dif_w = this.width % 3; - - var _11111 = parseInt("11111", 2), - _1_5 = _11111; - - var _111111 = parseInt("111111", 2), - _1_6 = _111111; - - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - - for (var x = 0; x < this.width; x++) { - var B = this.datav.getUint16(this.pos, true); - this.pos += 2; - var alpha = 0xFF; - var blue = (B & _1_5) / _1_5 * 255 | 0; - var green = (B >> 5 & _1_6) / _1_6 * 255 | 0; - var red = (B >> 11) / _1_5 * 255 | 0; - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; - } //skip extra bytes - - - this.pos += dif_w; - } - }; - - BmpDecoder.prototype.bit24 = function () { - //when height > 0 - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - - for (var x = 0; x < this.width; x++) { - var blue = this.datav.getUint8(this.pos++, true); - var green = this.datav.getUint8(this.pos++, true); - var red = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = 0xFF; - } //skip extra bytes - - - this.pos += this.width % 4; - } - }; - /** - * add 32bit decode func - * @author soubok - */ - - - BmpDecoder.prototype.bit32 = function () { - //when height > 0 - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - - for (var x = 0; x < this.width; x++) { - var blue = this.datav.getUint8(this.pos++, true); - var green = this.datav.getUint8(this.pos++, true); - var red = this.datav.getUint8(this.pos++, true); - var alpha = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; - } //skip extra bytes - //this.pos += (this.width % 4); - - } - }; - - BmpDecoder.prototype.getData = function () { - return this.data; - }; - - try { - exports.BmpDecoder = BmpDecoder; - } catch (e) {} // CommonJS. - - function WebPDecoder(imageData) { - // Copyright 2011 Google Inc. - // - // This code is licensed under the same terms as WebM: - // Software License Agreement: http://www.webmproject.org/license/software/ - // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ - // ----------------------------------------------------------------------------- - // - // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // - // ----------------------------------------------------------------------------- - // - // Copyright 2011-2017 Dominik Homberger - // Libwebp Javascript / libwebpjs - the libwebp implementation in javascript (v0.6.0) - // - // Author: Dominik Homberger (dominik.homberger@gmail.com) - function x(F) { - if (!F) { throw Error("assert :P"); } - } - - function fa(F, L, J) { - for (var H = 0; 4 > H; H++) { - if (F[L + H] != J.charCodeAt(H)) { return !0; } - } - - return !1; - } - - function I(F, L, J, H, Z) { - for (var O = 0; O < Z; O++) { - F[L + O] = J[H + O]; - } - } - - function M(F, L, J, H) { - for (var Z = 0; Z < H; Z++) { - F[L + Z] = J; - } - } - - function V(F) { - return new Int32Array(F); - } - - function wa(F, L) { - for (var J = [], H = 0; H < F; H++) { - J.push(new L()); - } - - return J; - } - - function wb() { - function F(J, H, Z) { - for (var O = Z[H], L = 0; L < O; L++) { - J.push(Z.length > H + 1 ? [] : 0); - if (Z.length < H + 1) { break; } - F(J[L], H + 1, Z); - } - } - - var L = []; - F(L, 0, [3, 11]); - return L; - } - - function Ed(F, L) { - function J(H, O, F) { - for (var Z = F[O], ma = 0; ma < Z; ma++) { - H.push(F.length > O + 1 ? [] : new L()); - if (F.length < O + 1) { break; } - J(H[ma], O + 1, F); - } - } - - var H = []; - J(H, 0, F); - return H; - } - - WebPDecoder = function WebPDecoder() { - - function L(a, b) { - for (var c = 1 << b - 1 >>> 0; a & c;) { - c >>>= 1; - } - - return c ? (a & c - 1) + c : a; - } - - function J(a, b, c, d, e) { - x(!(d % c)); - - do { - d -= c, a[b + d] = e; - } while (0 < d); - } - - function H(a, b, c, d, e, f) { - var g = b, - h = 1 << c, - k, - l, - m = V(16), - n = V(16); - x(0 != e); - x(null != d); - x(null != a); - x(0 < c); - - for (l = 0; l < e; ++l) { - if (15 < d[l]) { return 0; } - ++m[d[l]]; - } - - if (m[0] == e) { return 0; } - n[1] = 0; - - for (k = 1; 15 > k; ++k) { - if (m[k] > 1 << k) { return 0; } - n[k + 1] = n[k] + m[k]; - } - - for (l = 0; l < e; ++l) { - k = d[l], 0 < d[l] && (f[n[k]++] = l); - } - - if (1 == n[15]) { return d = new O(), d.g = 0, d.value = f[0], J(a, g, 1, h, d), h; } - var r = -1, - q = h - 1, - t = 0, - v = 1, - p = 1, - u, - w = 1 << c; - l = 0; - k = 1; - - for (e = 2; k <= c; ++k, e <<= 1) { - p <<= 1; - v += p; - p -= m[k]; - if (0 > p) { return 0; } - - for (; 0 < m[k]; --m[k]) { - d = new O(), d.g = k, d.value = f[l++], J(a, g + t, e, w, d), t = L(t, k); - } - } - - k = c + 1; - - for (e = 2; 15 >= k; ++k, e <<= 1) { - p <<= 1; - v += p; - p -= m[k]; - if (0 > p) { return 0; } - - for (; 0 < m[k]; --m[k]) { - d = new O(); - - if ((t & q) != r) { - g += w; - r = k; - - for (u = 1 << r - c; 15 > r;) { - u -= m[r]; - if (0 >= u) { break; } - ++r; - u <<= 1; - } - - u = r - c; - w = 1 << u; - h += w; - r = t & q; - a[b + r].g = u + c; - a[b + r].value = g - b - r; - } - - d.g = k - c; - d.value = f[l++]; - J(a, g + (t >> c), e, w, d); - t = L(t, k); - } - } - - return v != 2 * n[15] - 1 ? 0 : h; - } - - function Z(a, b, c, d, e) { - x(2328 >= e); - if (512 >= e) { var f = V(512); }else if (f = V(e), null == f) { return 0; } - return H(a, b, c, d, e, f); - } - - function O() { - this.value = this.g = 0; - } - - function Fd() { - this.value = this.g = 0; - } - - function Ub() { - this.G = wa(5, O); - this.H = V(5); - this.jc = this.Qb = this.qb = this.nd = 0; - this.pd = wa(xb, Fd); - } - - function ma(a, b, c, d) { - x(null != a); - x(null != b); - x(2147483648 > d); - a.Ca = 254; - a.I = 0; - a.b = -8; - a.Ka = 0; - a.oa = b; - a.pa = c; - a.Jd = b; - a.Yc = c + d; - a.Zc = 4 <= d ? c + d - 4 + 1 : c; - Qa(a); - } - - function na(a, b) { - for (var c = 0; 0 < b--;) { - c |= K(a, 128) << b; - } - - return c; - } - - function ca(a, b) { - var c = na(a, b); - return G(a) ? -c : c; - } - - function cb(a, b, c, d) { - var e, - f = 0; - x(null != a); - x(null != b); - x(4294967288 > d); - a.Sb = d; - a.Ra = 0; - a.u = 0; - a.h = 0; - 4 < d && (d = 4); - - for (e = 0; e < d; ++e) { - f += b[c + e] << 8 * e; - } - - a.Ra = f; - a.bb = d; - a.oa = b; - a.pa = c; - } - - function Vb(a) { - for (; 8 <= a.u && a.bb < a.Sb;) { - a.Ra >>>= 8, a.Ra += a.oa[a.pa + a.bb] << ob - 8 >>> 0, ++a.bb, a.u -= 8; - } - - db(a) && (a.h = 1, a.u = 0); - } - - function D(a, b) { - x(0 <= b); - - if (!a.h && b <= Gd) { - var c = pb(a) & Hd[b]; - a.u += b; - Vb(a); - return c; - } - - a.h = 1; - return a.u = 0; - } - - function Wb() { - this.b = this.Ca = this.I = 0; - this.oa = []; - this.pa = 0; - this.Jd = []; - this.Yc = 0; - this.Zc = []; - this.Ka = 0; - } - - function Ra() { - this.Ra = 0; - this.oa = []; - this.h = this.u = this.bb = this.Sb = this.pa = 0; - } - - function pb(a) { - return a.Ra >>> (a.u & ob - 1) >>> 0; - } - - function db(a) { - x(a.bb <= a.Sb); - return a.h || a.bb == a.Sb && a.u > ob; - } - - function qb(a, b) { - a.u = b; - a.h = db(a); - } - - function Sa(a) { - a.u >= Xb && (x(a.u >= Xb), Vb(a)); - } - - function Qa(a) { - x(null != a && null != a.oa); - a.pa < a.Zc ? (a.I = (a.oa[a.pa++] | a.I << 8) >>> 0, a.b += 8) : (x(null != a && null != a.oa), a.pa < a.Yc ? (a.b += 8, a.I = a.oa[a.pa++] | a.I << 8) : a.Ka ? a.b = 0 : (a.I <<= 8, a.b += 8, a.Ka = 1)); - } - - function G(a) { - return na(a, 1); - } - - function K(a, b) { - var c = a.Ca; - 0 > a.b && Qa(a); - var d = a.b, - e = c * b >>> 8, - f = (a.I >>> d > e) + 0; - f ? (c -= e, a.I -= e + 1 << d >>> 0) : c = e + 1; - d = c; - - for (e = 0; 256 <= d;) { - e += 8, d >>= 8; - } - - d = 7 ^ e + Id[d]; - a.b -= d; - a.Ca = (c << d) - 1; - return f; - } - - function ra(a, b, c) { - a[b + 0] = c >> 24 & 255; - a[b + 1] = c >> 16 & 255; - a[b + 2] = c >> 8 & 255; - a[b + 3] = c >> 0 & 255; - } - - function Ta(a, b) { - return a[b + 0] << 0 | a[b + 1] << 8; - } - - function Yb(a, b) { - return Ta(a, b) | a[b + 2] << 16; - } - - function Ha(a, b) { - return Ta(a, b) | Ta(a, b + 2) << 16; - } - - function Zb(a, b) { - var c = 1 << b; - x(null != a); - x(0 < b); - a.X = V(c); - if (null == a.X) { return 0; } - a.Mb = 32 - b; - a.Xa = b; - return 1; - } - - function $b(a, b) { - x(null != a); - x(null != b); - x(a.Xa == b.Xa); - I(b.X, 0, a.X, 0, 1 << b.Xa); - } - - function ac() { - this.X = []; - this.Xa = this.Mb = 0; - } - - function bc(a, b, c, d) { - x(null != c); - x(null != d); - var e = c[0], - f = d[0]; - 0 == e && (e = (a * f + b / 2) / b); - 0 == f && (f = (b * e + a / 2) / a); - if (0 >= e || 0 >= f) { return 0; } - c[0] = e; - d[0] = f; - return 1; - } - - function xa(a, b) { - return a + (1 << b) - 1 >>> b; - } - - function yb(a, b) { - return ((a & 4278255360) + (b & 4278255360) >>> 0 & 4278255360) + ((a & 16711935) + (b & 16711935) >>> 0 & 16711935) >>> 0; - } - - function X(a, b) { - self[b] = function (b, d, e, f, g, h, k) { - var c; - - for (c = 0; c < g; ++c) { - var m = self[a](h[k + c - 1], e, f + c); - h[k + c] = yb(b[d + c], m); - } - }; - } - - function Jd() { - this.ud = this.hd = this.jd = 0; - } - - function aa(a, b) { - return (((a ^ b) & 4278124286) >>> 1) + (a & b) >>> 0; - } - - function sa(a) { - if (0 <= a && 256 > a) { return a; } - if (0 > a) { return 0; } - if (255 < a) { return 255; } - } - - function eb(a, b) { - return sa(a + (a - b + .5 >> 1)); - } - - function Ia(a, b, c) { - return Math.abs(b - c) - Math.abs(a - c); - } - - function cc(a, b, c, d, e, f, g) { - d = f[g - 1]; - - for (c = 0; c < e; ++c) { - f[g + c] = d = yb(a[b + c], d); - } - } - - function Kd(a, b, c, d, e) { - var f; - - for (f = 0; f < c; ++f) { - var g = a[b + f], - h = g >> 8 & 255, - k = g & 16711935, - k = k + ((h << 16) + h), - k = k & 16711935; - d[e + f] = (g & 4278255360) + k >>> 0; - } - } - - function dc(a, b) { - b.jd = a >> 0 & 255; - b.hd = a >> 8 & 255; - b.ud = a >> 16 & 255; - } - - function Ld(a, b, c, d, e, f) { - var g; - - for (g = 0; g < d; ++g) { - var h = b[c + g], - k = h >>> 8, - l = h >>> 16, - m = h, - l = l + ((a.jd << 24 >> 24) * (k << 24 >> 24) >>> 5), - l = l & 255, - m = m + ((a.hd << 24 >> 24) * (k << 24 >> 24) >>> 5), - m = m + ((a.ud << 24 >> 24) * (l << 24 >> 24) >>> 5), - m = m & 255; - e[f + g] = (h & 4278255360) + (l << 16) + m; - } - } - - function ec(a, b, c, d, e) { - self[b] = function (a, b, c, k, l, m, n, r, q) { - for (k = n; k < r; ++k) { - for (n = 0; n < q; ++n) { - l[m++] = e(c[d(a[b++])]); - } - } - }; - - self[a] = function (a, b, h, k, l, m, n) { - var f = 8 >> a.b, - g = a.Ea, - t = a.K[0], - v = a.w; - if (8 > f) { for (a = (1 << a.b) - 1, v = (1 << f) - 1; b < h; ++b) { - var p = 0, - u; - - for (u = 0; u < g; ++u) { - u & a || (p = d(k[l++])), m[n++] = e(t[p & v]), p >>= f; - } - } } else { self["VP8LMapColor" + c](k, l, t, v, m, n, b, h, g); } - }; - } - - function Md(a, b, c, d, e) { - for (c = b + c; b < c;) { - var f = a[b++]; - d[e++] = f >> 16 & 255; - d[e++] = f >> 8 & 255; - d[e++] = f >> 0 & 255; - } - } - - function Nd(a, b, c, d, e) { - for (c = b + c; b < c;) { - var f = a[b++]; - d[e++] = f >> 16 & 255; - d[e++] = f >> 8 & 255; - d[e++] = f >> 0 & 255; - d[e++] = f >> 24 & 255; - } - } - - function Od(a, b, c, d, e) { - for (c = b + c; b < c;) { - var f = a[b++], - g = f >> 16 & 240 | f >> 12 & 15, - f = f >> 0 & 240 | f >> 28 & 15; - d[e++] = g; - d[e++] = f; - } - } - - function Pd(a, b, c, d, e) { - for (c = b + c; b < c;) { - var f = a[b++], - g = f >> 16 & 248 | f >> 13 & 7, - f = f >> 5 & 224 | f >> 3 & 31; - d[e++] = g; - d[e++] = f; - } - } - - function Qd(a, b, c, d, e) { - for (c = b + c; b < c;) { - var f = a[b++]; - d[e++] = f >> 0 & 255; - d[e++] = f >> 8 & 255; - d[e++] = f >> 16 & 255; - } - } - - function fb(a, b, c, d, e, f) { - if (0 == f) { for (c = b + c; b < c;) { - f = a[b++], ra(d, (f[0] >> 24 | f[1] >> 8 & 65280 | f[2] << 8 & 16711680 | f[3] << 24) >>> 0), e += 32; - } } else { I(d, e, a, b, c); } - } - - function gb(a, b) { - self[b][0] = self[a + "0"]; - self[b][1] = self[a + "1"]; - self[b][2] = self[a + "2"]; - self[b][3] = self[a + "3"]; - self[b][4] = self[a + "4"]; - self[b][5] = self[a + "5"]; - self[b][6] = self[a + "6"]; - self[b][7] = self[a + "7"]; - self[b][8] = self[a + "8"]; - self[b][9] = self[a + "9"]; - self[b][10] = self[a + "10"]; - self[b][11] = self[a + "11"]; - self[b][12] = self[a + "12"]; - self[b][13] = self[a + "13"]; - self[b][14] = self[a + "0"]; - self[b][15] = self[a + "0"]; - } - - function hb(a) { - return a == zb || a == Ab || a == Ja || a == Bb; - } - - function Rd() { - this.eb = []; - this.size = this.A = this.fb = 0; - } - - function Sd() { - this.y = []; - this.f = []; - this.ea = []; - this.F = []; - this.Tc = this.Ed = this.Cd = this.Fd = this.lb = this.Db = this.Ab = this.fa = this.J = this.W = this.N = this.O = 0; - } - - function Cb() { - this.Rd = this.height = this.width = this.S = 0; - this.f = {}; - this.f.RGBA = new Rd(); - this.f.kb = new Sd(); - this.sd = null; - } - - function Td() { - this.width = [0]; - this.height = [0]; - this.Pd = [0]; - this.Qd = [0]; - this.format = [0]; - } - - function Ud() { - this.Id = this.fd = this.Md = this.hb = this.ib = this.da = this.bd = this.cd = this.j = this.v = this.Da = this.Sd = this.ob = 0; - } - - function Vd(a) { - alert("todo:WebPSamplerProcessPlane"); - return a.T; - } - - function Wd(a, b) { - var c = a.T, - d = b.ba.f.RGBA, - e = d.eb, - f = d.fb + a.ka * d.A, - g = P[b.ba.S], - h = a.y, - k = a.O, - l = a.f, - m = a.N, - n = a.ea, - r = a.W, - q = b.cc, - t = b.dc, - v = b.Mc, - p = b.Nc, - u = a.ka, - w = a.ka + a.T, - y = a.U, - A = y + 1 >> 1; - 0 == u ? g(h, k, null, null, l, m, n, r, l, m, n, r, e, f, null, null, y) : (g(b.ec, b.fc, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y), ++c); - - for (; u + 2 < w; u += 2) { - q = l, t = m, v = n, p = r, m += a.Rc, r += a.Rc, f += 2 * d.A, k += 2 * a.fa, g(h, k - a.fa, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y); - } - - k += a.fa; - a.j + w < a.o ? (I(b.ec, b.fc, h, k, y), I(b.cc, b.dc, l, m, A), I(b.Mc, b.Nc, n, r, A), c--) : w & 1 || g(h, k, null, null, l, m, n, r, l, m, n, r, e, f + d.A, null, null, y); - return c; - } - - function Xd(a, b, c) { - var d = a.F, - e = [a.J]; - - if (null != d) { - var f = a.U, - g = b.ba.S, - h = g == ya || g == Ja; - b = b.ba.f.RGBA; - var k = [0], - l = a.ka; - k[0] = a.T; - a.Kb && (0 == l ? --k[0] : (--l, e[0] -= a.width), a.j + a.ka + a.T == a.o && (k[0] = a.o - a.j - l)); - var m = b.eb, - l = b.fb + l * b.A; - a = fc(d, e[0], a.width, f, k, m, l + (h ? 0 : 3), b.A); - x(c == k); - a && hb(g) && za(m, l, h, f, k, b.A); - } - - return 0; - } - - function gc(a) { - var b = a.ma, - c = b.ba.S, - d = 11 > c, - e = c == Ua || c == Va || c == ya || c == Db || 12 == c || hb(c); - b.memory = null; - b.Ib = null; - b.Jb = null; - b.Nd = null; - if (!hc(b.Oa, a, e ? 11 : 12)) { return 0; } - e && hb(c) && ic(); - if (a.da) { alert("todo:use_scaling"); }else { - if (d) { - if (b.Ib = Vd, a.Kb) { - c = a.U + 1 >> 1; - b.memory = V(a.U + 2 * c); - if (null == b.memory) { return 0; } - b.ec = b.memory; - b.fc = 0; - b.cc = b.ec; - b.dc = b.fc + a.U; - b.Mc = b.cc; - b.Nc = b.dc + c; - b.Ib = Wd; - ic(); - } - } else { alert("todo:EmitYUV"); } - - e && (b.Jb = Xd, d && Aa()); - } - - if (d && !jc) { - for (a = 0; 256 > a; ++a) { - Yd[a] = 89858 * (a - 128) + Ba >> Wa, Zd[a] = -22014 * (a - 128) + Ba, $d[a] = -45773 * (a - 128), ae[a] = 113618 * (a - 128) + Ba >> Wa; - } - - for (a = ta; a < Eb; ++a) { - b = 76283 * (a - 16) + Ba >> Wa, be[a - ta] = ga(b, 255), ce[a - ta] = ga(b + 8 >> 4, 15); - } - - jc = 1; - } - - return 1; - } - - function kc(a) { - var b = a.ma, - c = a.U, - d = a.T; - x(!(a.ka & 1)); - if (0 >= c || 0 >= d) { return 0; } - c = b.Ib(a, b); - null != b.Jb && b.Jb(a, b, c); - b.Dc += c; - return 1; - } - - function lc(a) { - a.ma.memory = null; - } - - function mc(a, b, c, d) { - if (47 != D(a, 8)) { return 0; } - b[0] = D(a, 14) + 1; - c[0] = D(a, 14) + 1; - d[0] = D(a, 1); - return 0 != D(a, 3) ? 0 : !a.h; - } - - function ib(a, b) { - if (4 > a) { return a + 1; } - var c = a - 2 >> 1; - return (2 + (a & 1) << c) + D(b, c) + 1; - } - - function nc(a, b) { - if (120 < b) { return b - 120; } - var c = de[b - 1], - c = (c >> 4) * a + (8 - (c & 15)); - return 1 <= c ? c : 1; - } - - function ua(a, b, c) { - var d = pb(c); - b += d & 255; - var e = a[b].g - 8; - 0 < e && (qb(c, c.u + 8), d = pb(c), b += a[b].value, b += d & (1 << e) - 1); - qb(c, c.u + a[b].g); - return a[b].value; - } - - function ub(a, b, c) { - c.g += a.g; - c.value += a.value << b >>> 0; - x(8 >= c.g); - return a.g; - } - - function ha(a, b, c) { - var d = a.xc; - b = 0 == d ? 0 : a.vc[a.md * (c >> d) + (b >> d)]; - x(b < a.Wb); - return a.Ya[b]; - } - - function oc(a, b, c, d) { - var e = a.ab, - f = a.c * b, - g = a.C; - b = g + b; - var h = c, - k = d; - d = a.Ta; - - for (c = a.Ua; 0 < e--;) { - var l = a.gc[e], - m = g, - n = b, - r = h, - q = k, - k = d, - h = c, - t = l.Ea; - x(m < n); - x(n <= l.nc); - - switch (l.hc) { - case 2: - pc(r, q, (n - m) * t, k, h); - break; - - case 0: - var v = l, - p = m, - u = n, - w = k, - y = h, - A = v.Ea; - 0 == p && (ee(r, q, null, null, 1, w, y), cc(r, q + 1, 0, 0, A - 1, w, y + 1), q += A, y += A, ++p); - - for (var E = 1 << v.b, B = E - 1, C = xa(A, v.b), N = v.K, v = v.w + (p >> v.b) * C; p < u;) { - var z = N, - Q = v, - S = 1; - - for (fe(r, q, w, y - A, 1, w, y); S < A;) { - var K = qc[z[Q++] >> 8 & 15], - D = (S & ~B) + E; - D > A && (D = A); - K(r, q + +S, w, y + S - A, D - S, w, y + S); - S = D; - } - - q += A; - y += A; - ++p; - p & B || (v += C); - } - - n != l.nc && I(k, h - t, k, h + (n - m - 1) * t, t); - break; - - case 1: - t = r; - u = q; - r = l.Ea; - q = 1 << l.b; - w = q - 1; - y = r & ~w; - A = r - y; - p = xa(r, l.b); - E = l.K; - - for (l = l.w + (m >> l.b) * p; m < n;) { - B = E; - C = l; - N = new Jd(); - v = u + y; - - for (z = u + r; u < v;) { - dc(B[C++], N), Fb(N, t, u, q, k, h), u += q, h += q; - } - - u < z && (dc(B[C++], N), Fb(N, t, u, A, k, h), u += A, h += A); - ++m; - m & w || (l += p); - } - - break; - - case 3: - if (r == k && q == h && 0 < l.b) { - y = (n - m) * xa(l.Ea, l.b); - t = h + (n - m) * t - y; - u = k; - r = t; - q = k; - w = h; - A = y; - p = []; - - for (y = A - 1; 0 <= y; --y) { - p[y] = q[w + y]; - } - - for (y = A - 1; 0 <= y; --y) { - u[r + y] = p[y]; - } - - rc(l, m, n, k, t, k, h); - } else { rc(l, m, n, r, q, k, h); } - - } - - h = d; - k = c; - } - - k != c && I(d, c, h, k, f); - } - - function ge(a, b) { - var c = a.V, - d = a.Ba + a.c * a.C, - e = b - a.C; - x(b <= a.l.o); - x(16 >= e); - - if (0 < e) { - var f = a.l, - g = a.Ta, - h = a.Ua, - k = f.width; - oc(a, e, c, d); - h = [h]; - c = a.C; - d = b; - e = h; - x(c < d); - x(f.v < f.va); - d > f.o && (d = f.o); - - if (c < f.j) { - var l = f.j - c, - c = f.j; - e[0] += l * k; - } - - c >= d ? c = 0 : (e[0] += 4 * f.v, f.ka = c - f.j, f.U = f.va - f.v, f.T = d - c, c = 1); - - if (c) { - h = h[0]; - c = a.ca; - - if (11 > c.S) { - for (var m = c.f.RGBA, d = c.S, e = f.U, f = f.T, l = m.eb, n = m.A, r = f, m = m.fb + a.Ma * m.A; 0 < r--;) { - var q = g, - t = h, - v = e, - p = l, - u = m; - - switch (d) { - case Ca: - sc(q, t, v, p, u); - break; - - case Ua: - Gb(q, t, v, p, u); - break; - - case zb: - Gb(q, t, v, p, u); - za(p, u, 0, v, 1, 0); - break; - - case tc: - uc(q, t, v, p, u); - break; - - case Va: - fb(q, t, v, p, u, 1); - break; - - case Ab: - fb(q, t, v, p, u, 1); - za(p, u, 0, v, 1, 0); - break; - - case ya: - fb(q, t, v, p, u, 0); - break; - - case Ja: - fb(q, t, v, p, u, 0); - za(p, u, 1, v, 1, 0); - break; - - case Db: - Hb(q, t, v, p, u); - break; - - case Bb: - Hb(q, t, v, p, u); - vc(p, u, v, 1, 0); - break; - - case wc: - xc(q, t, v, p, u); - break; - - default: - x(0); - } - - h += k; - m += n; - } - - a.Ma += f; - } else { alert("todo:EmitRescaledRowsYUVA"); } - - x(a.Ma <= c.height); - } - } - - a.C = b; - x(a.C <= a.i); - } - - function yc(a) { - var b; - if (0 < a.ua) { return 0; } - - for (b = 0; b < a.Wb; ++b) { - var c = a.Ya[b].G, - d = a.Ya[b].H; - if (0 < c[1][d[1] + 0].g || 0 < c[2][d[2] + 0].g || 0 < c[3][d[3] + 0].g) { return 0; } - } - - return 1; - } - - function zc(a, b, c, d, e, f) { - if (0 != a.Z) { - var g = a.qd, - h = a.rd; - - for (x(null != ia[a.Z]); b < c; ++b) { - ia[a.Z](g, h, d, e, d, e, f), g = d, h = e, e += f; - } - - a.qd = g; - a.rd = h; - } - } - - function Ib(a, b) { - var c = a.l.ma, - d = 0 == c.Z || 1 == c.Z ? a.l.j : a.C, - d = a.C < d ? d : a.C; - x(b <= a.l.o); - - if (b > d) { - var e = a.l.width, - f = c.ca, - g = c.tb + e * d, - h = a.V, - k = a.Ba + a.c * d, - l = a.gc; - x(1 == a.ab); - x(3 == l[0].hc); - he(l[0], d, b, h, k, f, g); - zc(c, d, b, f, g, e); - } - - a.C = a.Ma = b; - } - - function Jb(a, b, c, d, e, f, g) { - var h = a.$ / d, - k = a.$ % d, - l = a.m, - m = a.s, - n = c + a.$, - r = n; - e = c + d * e; - var q = c + d * f, - t = 280 + m.ua, - v = a.Pb ? h : 16777216, - p = 0 < m.ua ? m.Wa : null, - u = m.wc, - w = n < q ? ha(m, k, h) : null; - x(a.C < f); - x(q <= e); - var y = !1; - - a: for (;;) { - for (; y || n < q;) { - var A = 0; - - if (h >= v) { - var v = a, - E = n - c; - x(v.Pb); - v.wd = v.m; - v.xd = E; - 0 < v.s.ua && $b(v.s.Wa, v.s.vb); - v = h + ie; - } - - k & u || (w = ha(m, k, h)); - x(null != w); - w.Qb && (b[n] = w.qb, y = !0); - if (!y) { if (Sa(l), w.jc) { - var A = l, - E = b, - B = n, - C = w.pd[pb(A) & xb - 1]; - x(w.jc); - 256 > C.g ? (qb(A, A.u + C.g), E[B] = C.value, A = 0) : (qb(A, A.u + C.g - 256), x(256 <= C.value), A = C.value); - 0 == A && (y = !0); - } else { A = ua(w.G[0], w.H[0], l); } } - if (l.h) { break; } - - if (y || 256 > A) { - if (!y) { if (w.nd) { b[n] = (w.qb | A << 8) >>> 0; }else { - Sa(l); - y = ua(w.G[1], w.H[1], l); - Sa(l); - E = ua(w.G[2], w.H[2], l); - B = ua(w.G[3], w.H[3], l); - if (l.h) { break; } - b[n] = (B << 24 | y << 16 | A << 8 | E) >>> 0; - } } - y = !1; - ++n; - ++k; - if (k >= d && (k = 0, ++h, null != g && h <= f && !(h % 16) && g(a, h), null != p)) { for (; r < n;) { - A = b[r++], p.X[(506832829 * A & 4294967295) >>> p.Mb] = A; - } } - } else if (280 > A) { - A = ib(A - 256, l); - E = ua(w.G[4], w.H[4], l); - Sa(l); - E = ib(E, l); - E = nc(d, E); - if (l.h) { break; } - if (n - c < E || e - n < A) { break a; }else { for (B = 0; B < A; ++B) { - b[n + B] = b[n + B - E]; - } } - n += A; - - for (k += A; k >= d;) { - k -= d, ++h, null != g && h <= f && !(h % 16) && g(a, h); - } - - x(n <= e); - k & u && (w = ha(m, k, h)); - if (null != p) { for (; r < n;) { - A = b[r++], p.X[(506832829 * A & 4294967295) >>> p.Mb] = A; - } } - } else if (A < t) { - y = A - 280; - - for (x(null != p); r < n;) { - A = b[r++], p.X[(506832829 * A & 4294967295) >>> p.Mb] = A; - } - - A = n; - E = p; - x(!(y >>> E.Xa)); - b[A] = E.X[y]; - y = !0; - } else { break a; } - - y || x(l.h == db(l)); - } - - if (a.Pb && l.h && n < e) { x(a.m.h), a.a = 5, a.m = a.wd, a.$ = a.xd, 0 < a.s.ua && $b(a.s.vb, a.s.Wa); }else if (l.h) { break a; }else { null != g && g(a, h > f ? f : h), a.a = 0, a.$ = n - c; } - return 1; - } - - a.a = 3; - return 0; - } - - function Ac(a) { - x(null != a); - a.vc = null; - a.yc = null; - a.Ya = null; - var b = a.Wa; - null != b && (b.X = null); - a.vb = null; - x(null != a); - } - - function Bc() { - var a = new je(); - if (null == a) { return null; } - a.a = 0; - a.xb = Cc; - gb("Predictor", "VP8LPredictors"); - gb("Predictor", "VP8LPredictors_C"); - gb("PredictorAdd", "VP8LPredictorsAdd"); - gb("PredictorAdd", "VP8LPredictorsAdd_C"); - pc = Kd; - Fb = Ld; - sc = Md; - Gb = Nd; - Hb = Od; - xc = Pd; - uc = Qd; - self.VP8LMapColor32b = ke; - self.VP8LMapColor8b = le; - return a; - } - - function rb(a, b, c, d, e) { - var f = 1, - g = [a], - h = [b], - k = d.m, - l = d.s, - m = null, - n = 0; - - a: for (;;) { - if (c) { for (; f && D(k, 1);) { - var r = g, - q = h, - t = d, - v = 1, - p = t.m, - u = t.gc[t.ab], - w = D(p, 2); - if (t.Oc & 1 << w) { f = 0; }else { - t.Oc |= 1 << w; - u.hc = w; - u.Ea = r[0]; - u.nc = q[0]; - u.K = [null]; - ++t.ab; - x(4 >= t.ab); - - switch (w) { - case 0: - case 1: - u.b = D(p, 3) + 2; - v = rb(xa(u.Ea, u.b), xa(u.nc, u.b), 0, t, u.K); - u.K = u.K[0]; - break; - - case 3: - var y = D(p, 8) + 1, - A = 16 < y ? 0 : 4 < y ? 1 : 2 < y ? 2 : 3; - r[0] = xa(u.Ea, A); - u.b = A; - var v = rb(y, 1, 0, t, u.K), - E; - - if (E = v) { - var B, - C = y, - N = u, - z = 1 << (8 >> N.b), - Q = V(z); - if (null == Q) { E = 0; }else { - var S = N.K[0], - K = N.w; - Q[0] = N.K[0][0]; - - for (B = 1; B < 1 * C; ++B) { - Q[B] = yb(S[K + B], Q[B - 1]); - } - - for (; B < 4 * z; ++B) { - Q[B] = 0; - } - - N.K[0] = null; - N.K[0] = Q; - E = 1; - } - } - - v = E; - break; - - case 2: - break; - - default: - x(0); - } - - f = v; - } - } } - g = g[0]; - h = h[0]; - - if (f && D(k, 1) && (n = D(k, 4), f = 1 <= n && 11 >= n, !f)) { - d.a = 3; - break a; - } - - var H; - if (H = f) { b: { - var F = d, - G = g, - L = h, - J = n, - T = c, - Da, - ba, - X = F.m, - R = F.s, - P = [null], - U, - W = 1, - aa = 0, - na = me[J]; - - c: for (;;) { - if (T && D(X, 1)) { - var ca = D(X, 3) + 2, - ga = xa(G, ca), - ka = xa(L, ca), - qa = ga * ka; - if (!rb(ga, ka, 0, F, P)) { break c; } - P = P[0]; - R.xc = ca; - - for (Da = 0; Da < qa; ++Da) { - var ia = P[Da] >> 8 & 65535; - P[Da] = ia; - ia >= W && (W = ia + 1); - } - } - - if (X.h) { break c; } - - for (ba = 0; 5 > ba; ++ba) { - var Y = Dc[ba]; - !ba && 0 < J && (Y += 1 << J); - aa < Y && (aa = Y); - } - - var ma = wa(W * na, O); - var ua = W, - va = wa(ua, Ub); - if (null == va) { var la = null; }else { x(65536 >= ua), la = va; } - var ha = V(aa); - - if (null == la || null == ha || null == ma) { - F.a = 1; - break c; - } - - var pa = ma; - - for (Da = U = 0; Da < W; ++Da) { - var ja = la[Da], - da = ja.G, - ea = ja.H, - Fa = 0, - ra = 1, - Ha = 0; - - for (ba = 0; 5 > ba; ++ba) { - Y = Dc[ba]; - da[ba] = pa; - ea[ba] = U; - !ba && 0 < J && (Y += 1 << J); - - d: { - var sa, - za = Y, - ta = F, - oa = ha, - db = pa, - eb = U, - Ia = 0, - Ka = ta.m, - fb = D(Ka, 1); - M(oa, 0, 0, za); - - if (fb) { - var gb = D(Ka, 1) + 1, - hb = D(Ka, 1), - Ja = D(Ka, 0 == hb ? 1 : 8); - oa[Ja] = 1; - 2 == gb && (Ja = D(Ka, 8), oa[Ja] = 1); - var ya = 1; - } else { - var Ua = V(19), - Va = D(Ka, 4) + 4; - - if (19 < Va) { - ta.a = 3; - var Aa = 0; - break d; - } - - for (sa = 0; sa < Va; ++sa) { - Ua[ne[sa]] = D(Ka, 3); - } - - var Ba = void 0, - sb = void 0, - Wa = ta, - ib = Ua, - Ca = za, - Xa = oa, - Oa = 0, - La = Wa.m, - Ya = 8, - Za = wa(128, O); - - e: for (;;) { - if (!Z(Za, 0, 7, ib, 19)) { break e; } - - if (D(La, 1)) { - var kb = 2 + 2 * D(La, 3), - Ba = 2 + D(La, kb); - if (Ba > Ca) { break e; } - } else { Ba = Ca; } - - for (sb = 0; sb < Ca && Ba--;) { - Sa(La); - var $a = Za[0 + (pb(La) & 127)]; - qb(La, La.u + $a.g); - var jb = $a.value; - if (16 > jb) { Xa[sb++] = jb, 0 != jb && (Ya = jb); }else { - var lb = 16 == jb, - ab = jb - 16, - mb = oe[ab], - bb = D(La, pe[ab]) + mb; - if (sb + bb > Ca) { break e; }else { for (var nb = lb ? Ya : 0; 0 < bb--;) { - Xa[sb++] = nb; - } } - } - } - - Oa = 1; - break e; - } - - Oa || (Wa.a = 3); - ya = Oa; - } - - (ya = ya && !Ka.h) && (Ia = Z(db, eb, 8, oa, za)); - ya && 0 != Ia ? Aa = Ia : (ta.a = 3, Aa = 0); - } - - if (0 == Aa) { break c; } - ra && 1 == qe[ba] && (ra = 0 == pa[U].g); - Fa += pa[U].g; - U += Aa; - - if (3 >= ba) { - var Pa = ha[0], - tb; - - for (tb = 1; tb < Y; ++tb) { - ha[tb] > Pa && (Pa = ha[tb]); - } - - Ha += Pa; - } - } - - ja.nd = ra; - ja.Qb = 0; - ra && (ja.qb = (da[3][ea[3] + 0].value << 24 | da[1][ea[1] + 0].value << 16 | da[2][ea[2] + 0].value) >>> 0, 0 == Fa && 256 > da[0][ea[0] + 0].value && (ja.Qb = 1, ja.qb += da[0][ea[0] + 0].value << 8)); - ja.jc = !ja.Qb && 6 > Ha; - - if (ja.jc) { - var Ga, - Ea = ja; - - for (Ga = 0; Ga < xb; ++Ga) { - var Ma = Ga, - Na = Ea.pd[Ma], - vb = Ea.G[0][Ea.H[0] + Ma]; - 256 <= vb.value ? (Na.g = vb.g + 256, Na.value = vb.value) : (Na.g = 0, Na.value = 0, Ma >>= ub(vb, 8, Na), Ma >>= ub(Ea.G[1][Ea.H[1] + Ma], 16, Na), Ma >>= ub(Ea.G[2][Ea.H[2] + Ma], 0, Na), ub(Ea.G[3][Ea.H[3] + Ma], 24, Na)); - } - } - } - - R.vc = P; - R.Wb = W; - R.Ya = la; - R.yc = ma; - H = 1; - break b; - } - - H = 0; - } } - f = H; - - if (!f) { - d.a = 3; - break a; - } - - if (0 < n) { - if (l.ua = 1 << n, !Zb(l.Wa, n)) { - d.a = 1; - f = 0; - break a; - } - } else { l.ua = 0; } - - var Qa = d, - cb = g, - ob = h, - Ra = Qa.s, - Ta = Ra.xc; - Qa.c = cb; - Qa.i = ob; - Ra.md = xa(cb, Ta); - Ra.wc = 0 == Ta ? -1 : (1 << Ta) - 1; - - if (c) { - d.xb = re; - break a; - } - - m = V(g * h); - - if (null == m) { - d.a = 1; - f = 0; - break a; - } - - f = (f = Jb(d, m, 0, g, h, h, null)) && !k.h; - break a; - } - - f ? (null != e ? e[0] = m : (x(null == m), x(c)), d.$ = 0, c || Ac(l)) : Ac(l); - return f; - } - - function Ec(a, b) { - var c = a.c * a.i, - d = c + b + 16 * b; - x(a.c <= b); - a.V = V(d); - if (null == a.V) { return a.Ta = null, a.Ua = 0, a.a = 1, 0; } - a.Ta = a.V; - a.Ua = a.Ba + c + b; - return 1; - } - - function se(a, b) { - var c = a.C, - d = b - c, - e = a.V, - f = a.Ba + a.c * c; - - for (x(b <= a.l.o); 0 < d;) { - var g = 16 < d ? 16 : d, - h = a.l.ma, - k = a.l.width, - l = k * g, - m = h.ca, - n = h.tb + k * c, - r = a.Ta, - q = a.Ua; - oc(a, g, e, f); - Fc(r, q, m, n, l); - zc(h, c, c + g, m, n, k); - d -= g; - e += g * a.c; - c += g; - } - - x(c == b); - a.C = a.Ma = b; - } - - function te(a, b) { - var c = [0], - d = [0], - e = [0]; - - a: for (;;) { - if (null == a) { return 0; } - if (null == b) { return a.a = 2, 0; } - a.l = b; - a.a = 0; - cb(a.m, b.data, b.w, b.ha); - - if (!mc(a.m, c, d, e)) { - a.a = 3; - break a; - } - - a.xb = Cc; - b.width = c[0]; - b.height = d[0]; - if (!rb(c[0], d[0], 1, a, null)) { break a; } - return 1; - } - - x(0 != a.a); - return 0; - } - - function ue() { - this.ub = this.yd = this.td = this.Rb = 0; - } - - function ve() { - this.Kd = this.Ld = this.Ud = this.Td = this.i = this.c = 0; - } - - function we() { - this.Fb = this.Bb = this.Cb = 0; - this.Zb = V(4); - this.Lb = V(4); - } - - function Gc() { - this.Yb = wb(); - } - - function xe() { - this.jb = V(3); - this.Wc = Ed([4, 8], Gc); - this.Xc = Ed([4, 17], Gc); - } - - function ye() { - this.Pc = this.wb = this.Tb = this.zd = 0; - this.vd = new V(4); - this.od = new V(4); - } - - function Xa() { - this.ld = this.La = this.dd = this.tc = 0; - } - - function Hc() { - this.Na = this.la = 0; - } - - function ze() { - this.Sc = [0, 0]; - this.Eb = [0, 0]; - this.Qc = [0, 0]; - this.ia = this.lc = 0; - } - - function Kb() { - this.ad = V(384); - this.Za = 0; - this.Ob = V(16); - this.$b = this.Ad = this.ia = this.Gc = this.Hc = this.Dd = 0; - } - - function Ae() { - this.uc = this.M = this.Nb = 0; - this.wa = Array(new Xa()); - this.Y = 0; - this.ya = Array(new Kb()); - this.aa = 0; - this.l = new Oa(); - } - - function Ic() { - this.y = V(16); - this.f = V(8); - this.ea = V(8); - } - - function Be() { - this.cb = this.a = 0; - this.sc = ""; - this.m = new Wb(); - this.Od = new ue(); - this.Kc = new ve(); - this.ed = new ye(); - this.Qa = new we(); - this.Ic = this.$c = this.Aa = 0; - this.D = new Ae(); - this.Xb = this.Va = this.Hb = this.zb = this.yb = this.Ub = this.za = 0; - this.Jc = wa(8, Wb); - this.ia = 0; - this.pb = wa(4, ze); - this.Pa = new xe(); - this.Bd = this.kc = 0; - this.Ac = []; - this.Bc = 0; - this.zc = [0, 0, 0, 0]; - this.Gd = Array(new Ic()); - this.Hd = 0; - this.rb = Array(new Hc()); - this.sb = 0; - this.wa = Array(new Xa()); - this.Y = 0; - this.oc = []; - this.pc = 0; - this.sa = []; - this.ta = 0; - this.qa = []; - this.ra = 0; - this.Ha = []; - this.B = this.R = this.Ia = 0; - this.Ec = []; - this.M = this.ja = this.Vb = this.Fc = 0; - this.ya = Array(new Kb()); - this.L = this.aa = 0; - this.gd = Ed([4, 2], Xa); - this.ga = null; - this.Fa = []; - this.Cc = this.qc = this.P = 0; - this.Gb = []; - this.Uc = 0; - this.mb = []; - this.nb = 0; - this.rc = []; - this.Ga = this.Vc = 0; - } - - function ga(a, b) { - return 0 > a ? 0 : a > b ? b : a; - } - - function Oa() { - this.T = this.U = this.ka = this.height = this.width = 0; - this.y = []; - this.f = []; - this.ea = []; - this.Rc = this.fa = this.W = this.N = this.O = 0; - this.ma = "void"; - this.put = "VP8IoPutHook"; - this.ac = "VP8IoSetupHook"; - this.bc = "VP8IoTeardownHook"; - this.ha = this.Kb = 0; - this.data = []; - this.hb = this.ib = this.da = this.o = this.j = this.va = this.v = this.Da = this.ob = this.w = 0; - this.F = []; - this.J = 0; - } - - function Ce() { - var a = new Be(); - null != a && (a.a = 0, a.sc = "OK", a.cb = 0, a.Xb = 0, oa || (oa = De)); - return a; - } - - function T(a, b, c) { - 0 == a.a && (a.a = b, a.sc = c, a.cb = 0); - return 0; - } - - function Jc(a, b, c) { - return 3 <= c && 157 == a[b + 0] && 1 == a[b + 1] && 42 == a[b + 2]; - } - - function Kc(a, b) { - if (null == a) { return 0; } - a.a = 0; - a.sc = "OK"; - if (null == b) { return T(a, 2, "null VP8Io passed to VP8GetHeaders()"); } - var c = b.data; - var d = b.w; - var e = b.ha; - if (4 > e) { return T(a, 7, "Truncated header."); } - var f = c[d + 0] | c[d + 1] << 8 | c[d + 2] << 16; - var g = a.Od; - g.Rb = !(f & 1); - g.td = f >> 1 & 7; - g.yd = f >> 4 & 1; - g.ub = f >> 5; - if (3 < g.td) { return T(a, 3, "Incorrect keyframe parameters."); } - if (!g.yd) { return T(a, 4, "Frame not displayable."); } - d += 3; - e -= 3; - var h = a.Kc; - - if (g.Rb) { - if (7 > e) { return T(a, 7, "cannot parse picture header"); } - if (!Jc(c, d, e)) { return T(a, 3, "Bad code word"); } - h.c = (c[d + 4] << 8 | c[d + 3]) & 16383; - h.Td = c[d + 4] >> 6; - h.i = (c[d + 6] << 8 | c[d + 5]) & 16383; - h.Ud = c[d + 6] >> 6; - d += 7; - e -= 7; - a.za = h.c + 15 >> 4; - a.Ub = h.i + 15 >> 4; - b.width = h.c; - b.height = h.i; - b.Da = 0; - b.j = 0; - b.v = 0; - b.va = b.width; - b.o = b.height; - b.da = 0; - b.ib = b.width; - b.hb = b.height; - b.U = b.width; - b.T = b.height; - f = a.Pa; - M(f.jb, 0, 255, f.jb.length); - f = a.Qa; - x(null != f); - f.Cb = 0; - f.Bb = 0; - f.Fb = 1; - M(f.Zb, 0, 0, f.Zb.length); - M(f.Lb, 0, 0, f.Lb); - } - - if (g.ub > e) { return T(a, 7, "bad partition length"); } - f = a.m; - ma(f, c, d, g.ub); - d += g.ub; - e -= g.ub; - g.Rb && (h.Ld = G(f), h.Kd = G(f)); - h = a.Qa; - var k = a.Pa, - l; - x(null != f); - x(null != h); - h.Cb = G(f); - - if (h.Cb) { - h.Bb = G(f); - - if (G(f)) { - h.Fb = G(f); - - for (l = 0; 4 > l; ++l) { - h.Zb[l] = G(f) ? ca(f, 7) : 0; - } - - for (l = 0; 4 > l; ++l) { - h.Lb[l] = G(f) ? ca(f, 6) : 0; - } - } - - if (h.Bb) { for (l = 0; 3 > l; ++l) { - k.jb[l] = G(f) ? na(f, 8) : 255; - } } - } else { h.Bb = 0; } - - if (f.Ka) { return T(a, 3, "cannot parse segment header"); } - h = a.ed; - h.zd = G(f); - h.Tb = na(f, 6); - h.wb = na(f, 3); - h.Pc = G(f); - - if (h.Pc && G(f)) { - for (k = 0; 4 > k; ++k) { - G(f) && (h.vd[k] = ca(f, 6)); - } - - for (k = 0; 4 > k; ++k) { - G(f) && (h.od[k] = ca(f, 6)); - } - } - - a.L = 0 == h.Tb ? 0 : h.zd ? 1 : 2; - if (f.Ka) { return T(a, 3, "cannot parse filter header"); } - l = d; - var m = e; - e = l; - d = l + m; - h = m; - a.Xb = (1 << na(a.m, 2)) - 1; - k = a.Xb; - if (m < 3 * k) { c = 7; }else { - l += 3 * k; - h -= 3 * k; - - for (m = 0; m < k; ++m) { - var n = c[e + 0] | c[e + 1] << 8 | c[e + 2] << 16; - n > h && (n = h); - ma(a.Jc[+m], c, l, n); - l += n; - h -= n; - e += 3; - } - - ma(a.Jc[+k], c, l, h); - c = l < d ? 0 : 5; - } - if (0 != c) { return T(a, c, "cannot parse partitions"); } - l = a.m; - c = na(l, 7); - e = G(l) ? ca(l, 4) : 0; - d = G(l) ? ca(l, 4) : 0; - h = G(l) ? ca(l, 4) : 0; - k = G(l) ? ca(l, 4) : 0; - l = G(l) ? ca(l, 4) : 0; - m = a.Qa; - - for (n = 0; 4 > n; ++n) { - if (m.Cb) { - var r = m.Zb[n]; - m.Fb || (r += c); - } else if (0 < n) { - a.pb[n] = a.pb[0]; - continue; - } else { r = c; } - - var q = a.pb[n]; - q.Sc[0] = Lb[ga(r + e, 127)]; - q.Sc[1] = Mb[ga(r + 0, 127)]; - q.Eb[0] = 2 * Lb[ga(r + d, 127)]; - q.Eb[1] = 101581 * Mb[ga(r + h, 127)] >> 16; - 8 > q.Eb[1] && (q.Eb[1] = 8); - q.Qc[0] = Lb[ga(r + k, 117)]; - q.Qc[1] = Mb[ga(r + l, 127)]; - q.lc = r + l; - } - - if (!g.Rb) { return T(a, 4, "Not a key frame."); } - G(f); - g = a.Pa; - - for (c = 0; 4 > c; ++c) { - for (e = 0; 8 > e; ++e) { - for (d = 0; 3 > d; ++d) { - for (h = 0; 11 > h; ++h) { - k = K(f, Ee[c][e][d][h]) ? na(f, 8) : Fe[c][e][d][h], g.Wc[c][e].Yb[d][h] = k; - } - } - } - - for (e = 0; 17 > e; ++e) { - g.Xc[c][e] = g.Wc[c][Ge[e]]; - } - } - - a.kc = G(f); - a.kc && (a.Bd = na(f, 8)); - return a.cb = 1; - } - - function De(a, b, c, d, e, f, g) { - var h = b[e].Yb[c]; - - for (c = 0; 16 > e; ++e) { - if (!K(a, h[c + 0])) { return e; } - - for (; !K(a, h[c + 1]);) { - if (h = b[++e].Yb[0], c = 0, 16 == e) { return 16; } - } - - var k = b[e + 1].Yb; - - if (K(a, h[c + 2])) { - var l = a, - m = h, - n = c; - var r = 0; - if (K(l, m[n + 3])) { - if (K(l, m[n + 6])) { - h = 0; - r = K(l, m[n + 8]); - m = K(l, m[n + 9 + r]); - n = 2 * r + m; - r = 0; - - for (m = He[n]; m[h]; ++h) { - r += r + K(l, m[h]); - } - - r += 3 + (8 << n); - } else { K(l, m[n + 7]) ? (r = 7 + 2 * K(l, 165), r += K(l, 145)) : r = 5 + K(l, 159); } - } else { K(l, m[n + 4]) ? r = 3 + K(l, m[n + 5]) : r = 2; } - h = k[2]; - } else { r = 1, h = k[1]; } - - k = g + Ie[e]; - l = a; - 0 > l.b && Qa(l); - var m = l.b, - n = l.Ca >> 1, - q = n - (l.I >> m) >> 31; - --l.b; - l.Ca += q; - l.Ca |= 1; - l.I -= (n + 1 & q) << m; - f[k] = ((r ^ q) - q) * d[(0 < e) + 0]; - } - - return 16; - } - - function Lc(a) { - var b = a.rb[a.sb - 1]; - b.la = 0; - b.Na = 0; - M(a.zc, 0, 0, a.zc.length); - a.ja = 0; - } - - function Je(a, b) { - for (a.M = 0; a.M < a.Va; ++a.M) { - var c = a.Jc[a.M & a.Xb], - d = a.m, - e = a, - f; - - for (f = 0; f < e.za; ++f) { - var g = d; - var h = e; - var k = h.Ac, - l = h.Bc + 4 * f, - m = h.zc, - n = h.ya[h.aa + f]; - h.Qa.Bb ? n.$b = K(g, h.Pa.jb[0]) ? 2 + K(g, h.Pa.jb[2]) : K(g, h.Pa.jb[1]) : n.$b = 0; - h.kc && (n.Ad = K(g, h.Bd)); - n.Za = !K(g, 145) + 0; - - if (n.Za) { - var r = n.Ob, - q = 0; - - for (h = 0; 4 > h; ++h) { - var t = m[0 + h]; - var v; - - for (v = 0; 4 > v; ++v) { - t = Ke[k[l + v]][t]; - - for (var p = Mc[K(g, t[0])]; 0 < p;) { - p = Mc[2 * p + K(g, t[p])]; - } - - t = -p; - k[l + v] = t; - } - - I(r, q, k, l, 4); - q += 4; - m[0 + h] = t; - } - } else { t = K(g, 156) ? K(g, 128) ? 1 : 3 : K(g, 163) ? 2 : 0, n.Ob[0] = t, M(k, l, t, 4), M(m, 0, t, 4); } - - n.Dd = K(g, 142) ? K(g, 114) ? K(g, 183) ? 1 : 3 : 2 : 0; - } - - if (e.m.Ka) { return T(a, 7, "Premature end-of-partition0 encountered."); } - - for (; a.ja < a.za; ++a.ja) { - d = a; - e = c; - g = d.rb[d.sb - 1]; - k = d.rb[d.sb + d.ja]; - f = d.ya[d.aa + d.ja]; - if (l = d.kc ? f.Ad : 0) { g.la = k.la = 0, f.Za || (g.Na = k.Na = 0), f.Hc = 0, f.Gc = 0, f.ia = 0; }else { - var u, - w, - g = k, - k = e, - l = d.Pa.Xc, - m = d.ya[d.aa + d.ja], - n = d.pb[m.$b]; - h = m.ad; - r = 0; - q = d.rb[d.sb - 1]; - t = v = 0; - M(h, r, 0, 384); - - if (m.Za) { - var y = 0; - var A = l[3]; - } else { - p = V(16); - var E = g.Na + q.Na; - E = oa(k, l[1], E, n.Eb, 0, p, 0); - g.Na = q.Na = (0 < E) + 0; - if (1 < E) { Nc(p, 0, h, r); }else { - var B = p[0] + 3 >> 3; - - for (p = 0; 256 > p; p += 16) { - h[r + p] = B; - } - } - y = 1; - A = l[0]; - } - - var C = g.la & 15; - var N = q.la & 15; - - for (p = 0; 4 > p; ++p) { - var z = N & 1; - - for (B = w = 0; 4 > B; ++B) { - E = z + (C & 1), E = oa(k, A, E, n.Sc, y, h, r), z = E > y, C = C >> 1 | z << 7, w = w << 2 | (3 < E ? 3 : 1 < E ? 2 : 0 != h[r + 0]), r += 16; - } - - C >>= 4; - N = N >> 1 | z << 7; - v = (v << 8 | w) >>> 0; - } - - A = C; - y = N >> 4; - - for (u = 0; 4 > u; u += 2) { - w = 0; - C = g.la >> 4 + u; - N = q.la >> 4 + u; - - for (p = 0; 2 > p; ++p) { - z = N & 1; - - for (B = 0; 2 > B; ++B) { - E = z + (C & 1), E = oa(k, l[2], E, n.Qc, 0, h, r), z = 0 < E, C = C >> 1 | z << 3, w = w << 2 | (3 < E ? 3 : 1 < E ? 2 : 0 != h[r + 0]), r += 16; - } - - C >>= 2; - N = N >> 1 | z << 5; - } - - t |= w << 4 * u; - A |= C << 4 << u; - y |= (N & 240) << u; - } - - g.la = A; - q.la = y; - m.Hc = v; - m.Gc = t; - m.ia = t & 43690 ? 0 : n.ia; - l = !(v | t); - } - 0 < d.L && (d.wa[d.Y + d.ja] = d.gd[f.$b][f.Za], d.wa[d.Y + d.ja].La |= !l); - if (e.Ka) { return T(a, 7, "Premature end-of-file encountered."); } - } - - Lc(a); - c = a; - d = b; - e = 1; - f = c.D; - g = 0 < c.L && c.M >= c.zb && c.M <= c.Va; - if (0 == c.Aa) { a: { - f.M = c.M, f.uc = g, Oc(c, f), e = 1; - w = c.D; - f = w.Nb; - t = Ya[c.L]; - g = t * c.R; - k = t / 2 * c.B; - p = 16 * f * c.R; - B = 8 * f * c.B; - l = c.sa; - m = c.ta - g + p; - n = c.qa; - h = c.ra - k + B; - r = c.Ha; - q = c.Ia - k + B; - C = w.M; - N = 0 == C; - v = C >= c.Va - 1; - 2 == c.Aa && Oc(c, w); - if (w.uc) { for (E = c, z = E.D.M, x(E.D.uc), w = E.yb; w < E.Hb; ++w) { - var Q = E; - y = w; - A = z; - var S = Q.D, - D = S.Nb; - u = Q.R; - var S = S.wa[S.Y + y], - F = Q.sa, - H = Q.ta + 16 * D * u + 16 * y, - J = S.dd, - G = S.tc; - if (0 != G) { if (x(3 <= G), 1 == Q.L) { 0 < y && Pc(F, H, u, G + 4), S.La && Qc(F, H, u, G), 0 < A && Rc(F, H, u, G + 4), S.La && Sc(F, H, u, G); }else { - var L = Q.B, - O = Q.qa, - P = Q.ra + 8 * D * L + 8 * y, - R = Q.Ha, - Q = Q.Ia + 8 * D * L + 8 * y, - D = S.ld; - 0 < y && (Tc(F, H, u, G + 4, J, D), Uc(O, P, R, Q, L, G + 4, J, D)); - S.La && (Vc(F, H, u, G, J, D), Wc(O, P, R, Q, L, G, J, D)); - 0 < A && (Xc(F, H, u, G + 4, J, D), Yc(O, P, R, Q, L, G + 4, J, D)); - S.La && (Zc(F, H, u, G, J, D), $c(O, P, R, Q, L, G, J, D)); - } } - } } - c.ia && alert("todo:DitherRow"); - - if (null != d.put) { - w = 16 * C; - C = 16 * (C + 1); - N ? (d.y = c.sa, d.O = c.ta + p, d.f = c.qa, d.N = c.ra + B, d.ea = c.Ha, d.W = c.Ia + B) : (w -= t, d.y = l, d.O = m, d.f = n, d.N = h, d.ea = r, d.W = q); - v || (C -= t); - C > d.o && (C = d.o); - d.F = null; - d.J = null; - - if (null != c.Fa && 0 < c.Fa.length && w < C && (d.J = Le(c, d, w, C - w), d.F = c.mb, null == d.F && 0 == d.F.length)) { - e = T(c, 3, "Could not decode alpha data."); - break a; - } - - w < d.j && (t = d.j - w, w = d.j, x(!(t & 1)), d.O += c.R * t, d.N += c.B * (t >> 1), d.W += c.B * (t >> 1), null != d.F && (d.J += d.width * t)); - w < C && (d.O += d.v, d.N += d.v >> 1, d.W += d.v >> 1, null != d.F && (d.J += d.v), d.ka = w - d.j, d.U = d.va - d.v, d.T = C - w, e = d.put(d)); - } - - f + 1 != c.Ic || v || (I(c.sa, c.ta - g, l, m + 16 * c.R, g), I(c.qa, c.ra - k, n, h + 8 * c.B, k), I(c.Ha, c.Ia - k, r, q + 8 * c.B, k)); - } } - if (!e) { return T(a, 6, "Output aborted."); } - } - - return 1; - } - - function Me(a, b) { - if (null == a) { return 0; } - if (null == b) { return T(a, 2, "NULL VP8Io parameter in VP8Decode()."); } - if (!a.cb && !Kc(a, b)) { return 0; } - x(a.cb); - - if (null == b.ac || b.ac(b)) { - b.ob && (a.L = 0); - var c = Ya[a.L]; - 2 == a.L ? (a.yb = 0, a.zb = 0) : (a.yb = b.v - c >> 4, a.zb = b.j - c >> 4, 0 > a.yb && (a.yb = 0), 0 > a.zb && (a.zb = 0)); - a.Va = b.o + 15 + c >> 4; - a.Hb = b.va + 15 + c >> 4; - a.Hb > a.za && (a.Hb = a.za); - a.Va > a.Ub && (a.Va = a.Ub); - - if (0 < a.L) { - var d = a.ed; - - for (c = 0; 4 > c; ++c) { - var e; - - if (a.Qa.Cb) { - var f = a.Qa.Lb[c]; - a.Qa.Fb || (f += d.Tb); - } else { f = d.Tb; } - - for (e = 0; 1 >= e; ++e) { - var g = a.gd[c][e], - h = f; - d.Pc && (h += d.vd[0], e && (h += d.od[0])); - h = 0 > h ? 0 : 63 < h ? 63 : h; - - if (0 < h) { - var k = h; - 0 < d.wb && (k = 4 < d.wb ? k >> 2 : k >> 1, k > 9 - d.wb && (k = 9 - d.wb)); - 1 > k && (k = 1); - g.dd = k; - g.tc = 2 * h + k; - g.ld = 40 <= h ? 2 : 15 <= h ? 1 : 0; - } else { g.tc = 0; } - - g.La = e; - } - } - } - - c = 0; - } else { T(a, 6, "Frame setup failed"), c = a.a; } - - if (c = 0 == c) { - if (c) { - a.$c = 0; - 0 < a.Aa || (a.Ic = Ne); - - b: { - c = a.Ic; - var k = a.za, - d = 4 * k, - l = 32 * k, - m = k + 1, - n = 0 < a.L ? k * (0 < a.Aa ? 2 : 1) : 0, - r = (2 == a.Aa ? 2 : 1) * k; - e = 3 * (16 * c + Ya[a.L]) / 2 * l; - f = null != a.Fa && 0 < a.Fa.length ? a.Kc.c * a.Kc.i : 0; - g = d + 832 + e + f; - if (g != g) { c = 0; }else { - if (g > a.Vb) { - a.Vb = 0; - a.Ec = V(g); - a.Fc = 0; - - if (null == a.Ec) { - c = T(a, 1, "no memory during frame initialization."); - break b; - } - - a.Vb = g; - } - - g = a.Ec; - h = a.Fc; - a.Ac = g; - a.Bc = h; - h += d; - a.Gd = wa(l, Ic); - a.Hd = 0; - a.rb = wa(m + 1, Hc); - a.sb = 1; - a.wa = n ? wa(n, Xa) : null; - a.Y = 0; - a.D.Nb = 0; - a.D.wa = a.wa; - a.D.Y = a.Y; - 0 < a.Aa && (a.D.Y += k); - x(!0); - a.oc = g; - a.pc = h; - h += 832; - a.ya = wa(r, Kb); - a.aa = 0; - a.D.ya = a.ya; - a.D.aa = a.aa; - 2 == a.Aa && (a.D.aa += k); - a.R = 16 * k; - a.B = 8 * k; - l = Ya[a.L]; - k = l * a.R; - l = l / 2 * a.B; - a.sa = g; - a.ta = h + k; - a.qa = a.sa; - a.ra = a.ta + 16 * c * a.R + l; - a.Ha = a.qa; - a.Ia = a.ra + 8 * c * a.B + l; - a.$c = 0; - h += e; - a.mb = f ? g : null; - a.nb = f ? h : null; - x(h + f <= a.Fc + a.Vb); - Lc(a); - M(a.Ac, a.Bc, 0, d); - c = 1; - } - } - - if (c) { - b.ka = 0; - b.y = a.sa; - b.O = a.ta; - b.f = a.qa; - b.N = a.ra; - b.ea = a.Ha; - b.Vd = a.Ia; - b.fa = a.R; - b.Rc = a.B; - b.F = null; - b.J = 0; - - if (!ad) { - for (c = -255; 255 >= c; ++c) { - bd[255 + c] = 0 > c ? -c : c; - } - - for (c = -1020; 1020 >= c; ++c) { - cd[1020 + c] = -128 > c ? -128 : 127 < c ? 127 : c; - } - - for (c = -112; 112 >= c; ++c) { - dd[112 + c] = -16 > c ? -16 : 15 < c ? 15 : c; - } - - for (c = -255; 510 >= c; ++c) { - ed[255 + c] = 0 > c ? 0 : 255 < c ? 255 : c; - } - - ad = 1; - } - - Nc = Oe; - Za = Pe; - Nb = Qe; - pa = Re; - Ob = Se; - fd = Te; - Xc = Ue; - Tc = Ve; - Yc = We; - Uc = Xe; - Zc = Ye; - Vc = Ze; - $c = $e; - Wc = af; - Rc = gd; - Pc = hd; - Sc = bf; - Qc = cf; - W[0] = df; - W[1] = ef; - W[2] = ff; - W[3] = gf; - W[4] = hf; - W[5] = jf; - W[6] = kf; - W[7] = lf; - W[8] = mf; - W[9] = nf; - Y[0] = of; - Y[1] = pf; - Y[2] = qf; - Y[3] = rf; - Y[4] = sf; - Y[5] = tf; - Y[6] = uf; - ka[0] = vf; - ka[1] = wf; - ka[2] = xf; - ka[3] = yf; - ka[4] = zf; - ka[5] = Af; - ka[6] = Bf; - c = 1; - } else { c = 0; } - } - - c && (c = Je(a, b)); - null != b.bc && b.bc(b); - c &= 1; - } - - if (!c) { return 0; } - a.cb = 0; - return c; - } - - function qa(a, b, c, d, e) { - e = a[b + c + 32 * d] + (e >> 3); - a[b + c + 32 * d] = e & -256 ? 0 > e ? 0 : 255 : e; - } - - function kb(a, b, c, d, e, f) { - qa(a, b, 0, c, d + e); - qa(a, b, 1, c, d + f); - qa(a, b, 2, c, d - f); - qa(a, b, 3, c, d - e); - } - - function da(a) { - return (20091 * a >> 16) + a; - } - - function id(a, b, c, d) { - var e = 0, - f; - var g = V(16); - - for (f = 0; 4 > f; ++f) { - var h = a[b + 0] + a[b + 8]; - var k = a[b + 0] - a[b + 8]; - var l = (35468 * a[b + 4] >> 16) - da(a[b + 12]); - var m = da(a[b + 4]) + (35468 * a[b + 12] >> 16); - g[e + 0] = h + m; - g[e + 1] = k + l; - g[e + 2] = k - l; - g[e + 3] = h - m; - e += 4; - b++; - } - - for (f = e = 0; 4 > f; ++f) { - a = g[e + 0] + 4, h = a + g[e + 8], k = a - g[e + 8], l = (35468 * g[e + 4] >> 16) - da(g[e + 12]), m = da(g[e + 4]) + (35468 * g[e + 12] >> 16), qa(c, d, 0, 0, h + m), qa(c, d, 1, 0, k + l), qa(c, d, 2, 0, k - l), qa(c, d, 3, 0, h - m), e++, d += 32; - } - } - - function Te(a, b, c, d) { - var e = a[b + 0] + 4, - f = 35468 * a[b + 4] >> 16, - g = da(a[b + 4]), - h = 35468 * a[b + 1] >> 16; - a = da(a[b + 1]); - kb(c, d, 0, e + g, a, h); - kb(c, d, 1, e + f, a, h); - kb(c, d, 2, e - f, a, h); - kb(c, d, 3, e - g, a, h); - } - - function Pe(a, b, c, d, e) { - id(a, b, c, d); - e && id(a, b + 16, c, d + 4); - } - - function Qe(a, b, c, d) { - Za(a, b + 0, c, d, 1); - Za(a, b + 32, c, d + 128, 1); - } - - function Re(a, b, c, d) { - a = a[b + 0] + 4; - var e; - - for (e = 0; 4 > e; ++e) { - for (b = 0; 4 > b; ++b) { - qa(c, d, b, e, a); - } - } - } - - function Se(a, b, c, d) { - a[b + 0] && pa(a, b + 0, c, d); - a[b + 16] && pa(a, b + 16, c, d + 4); - a[b + 32] && pa(a, b + 32, c, d + 128); - a[b + 48] && pa(a, b + 48, c, d + 128 + 4); - } - - function Oe(a, b, c, d) { - var e = V(16), - f; - - for (f = 0; 4 > f; ++f) { - var g = a[b + 0 + f] + a[b + 12 + f]; - var h = a[b + 4 + f] + a[b + 8 + f]; - var k = a[b + 4 + f] - a[b + 8 + f]; - var l = a[b + 0 + f] - a[b + 12 + f]; - e[0 + f] = g + h; - e[8 + f] = g - h; - e[4 + f] = l + k; - e[12 + f] = l - k; - } - - for (f = 0; 4 > f; ++f) { - a = e[0 + 4 * f] + 3, g = a + e[3 + 4 * f], h = e[1 + 4 * f] + e[2 + 4 * f], k = e[1 + 4 * f] - e[2 + 4 * f], l = a - e[3 + 4 * f], c[d + 0] = g + h >> 3, c[d + 16] = l + k >> 3, c[d + 32] = g - h >> 3, c[d + 48] = l - k >> 3, d += 64; - } - } - - function Pb(a, b, c) { - var d = b - 32, - e = R, - f = 255 - a[d - 1], - g; - - for (g = 0; g < c; ++g) { - var h = e, - k = f + a[b - 1], - l; - - for (l = 0; l < c; ++l) { - a[b + l] = h[k + a[d + l]]; - } - - b += 32; - } - } - - function ef(a, b) { - Pb(a, b, 4); - } - - function wf(a, b) { - Pb(a, b, 8); - } - - function pf(a, b) { - Pb(a, b, 16); - } - - function qf(a, b) { - var c; - - for (c = 0; 16 > c; ++c) { - I(a, b + 32 * c, a, b - 32, 16); - } - } - - function rf(a, b) { - var c; - - for (c = 16; 0 < c; --c) { - M(a, b, a[b - 1], 16), b += 32; - } - } - - function $a(a, b, c) { - var d; - - for (d = 0; 16 > d; ++d) { - M(b, c + 32 * d, a, 16); - } - } - - function of(a, b) { - var c = 16, - d; - - for (d = 0; 16 > d; ++d) { - c += a[b - 1 + 32 * d] + a[b + d - 32]; - } - - $a(c >> 5, a, b); - } - - function sf(a, b) { - var c = 8, - d; - - for (d = 0; 16 > d; ++d) { - c += a[b - 1 + 32 * d]; - } - - $a(c >> 4, a, b); - } - - function tf(a, b) { - var c = 8, - d; - - for (d = 0; 16 > d; ++d) { - c += a[b + d - 32]; - } - - $a(c >> 4, a, b); - } - - function uf(a, b) { - $a(128, a, b); - } - - function z(a, b, c) { - return a + 2 * b + c + 2 >> 2; - } - - function ff(a, b) { - var c = b - 32, - c = new Uint8Array([z(a[c - 1], a[c + 0], a[c + 1]), z(a[c + 0], a[c + 1], a[c + 2]), z(a[c + 1], a[c + 2], a[c + 3]), z(a[c + 2], a[c + 3], a[c + 4])]), - d; - - for (d = 0; 4 > d; ++d) { - I(a, b + 32 * d, c, 0, c.length); - } - } - - function gf(a, b) { - var c = a[b - 1], - d = a[b - 1 + 32], - e = a[b - 1 + 64], - f = a[b - 1 + 96]; - ra(a, b + 0, 16843009 * z(a[b - 1 - 32], c, d)); - ra(a, b + 32, 16843009 * z(c, d, e)); - ra(a, b + 64, 16843009 * z(d, e, f)); - ra(a, b + 96, 16843009 * z(e, f, f)); - } - - function df(a, b) { - var c = 4, - d; - - for (d = 0; 4 > d; ++d) { - c += a[b + d - 32] + a[b - 1 + 32 * d]; - } - - c >>= 3; - - for (d = 0; 4 > d; ++d) { - M(a, b + 32 * d, c, 4); - } - } - - function hf(a, b) { - var c = a[b - 1 + 0], - d = a[b - 1 + 32], - e = a[b - 1 + 64], - f = a[b - 1 - 32], - g = a[b + 0 - 32], - h = a[b + 1 - 32], - k = a[b + 2 - 32], - l = a[b + 3 - 32]; - a[b + 0 + 96] = z(d, e, a[b - 1 + 96]); - a[b + 1 + 96] = a[b + 0 + 64] = z(c, d, e); - a[b + 2 + 96] = a[b + 1 + 64] = a[b + 0 + 32] = z(f, c, d); - a[b + 3 + 96] = a[b + 2 + 64] = a[b + 1 + 32] = a[b + 0 + 0] = z(g, f, c); - a[b + 3 + 64] = a[b + 2 + 32] = a[b + 1 + 0] = z(h, g, f); - a[b + 3 + 32] = a[b + 2 + 0] = z(k, h, g); - a[b + 3 + 0] = z(l, k, h); - } - - function kf(a, b) { - var c = a[b + 1 - 32], - d = a[b + 2 - 32], - e = a[b + 3 - 32], - f = a[b + 4 - 32], - g = a[b + 5 - 32], - h = a[b + 6 - 32], - k = a[b + 7 - 32]; - a[b + 0 + 0] = z(a[b + 0 - 32], c, d); - a[b + 1 + 0] = a[b + 0 + 32] = z(c, d, e); - a[b + 2 + 0] = a[b + 1 + 32] = a[b + 0 + 64] = z(d, e, f); - a[b + 3 + 0] = a[b + 2 + 32] = a[b + 1 + 64] = a[b + 0 + 96] = z(e, f, g); - a[b + 3 + 32] = a[b + 2 + 64] = a[b + 1 + 96] = z(f, g, h); - a[b + 3 + 64] = a[b + 2 + 96] = z(g, h, k); - a[b + 3 + 96] = z(h, k, k); - } - - function jf(a, b) { - var c = a[b - 1 + 0], - d = a[b - 1 + 32], - e = a[b - 1 + 64], - f = a[b - 1 - 32], - g = a[b + 0 - 32], - h = a[b + 1 - 32], - k = a[b + 2 - 32], - l = a[b + 3 - 32]; - a[b + 0 + 0] = a[b + 1 + 64] = f + g + 1 >> 1; - a[b + 1 + 0] = a[b + 2 + 64] = g + h + 1 >> 1; - a[b + 2 + 0] = a[b + 3 + 64] = h + k + 1 >> 1; - a[b + 3 + 0] = k + l + 1 >> 1; - a[b + 0 + 96] = z(e, d, c); - a[b + 0 + 64] = z(d, c, f); - a[b + 0 + 32] = a[b + 1 + 96] = z(c, f, g); - a[b + 1 + 32] = a[b + 2 + 96] = z(f, g, h); - a[b + 2 + 32] = a[b + 3 + 96] = z(g, h, k); - a[b + 3 + 32] = z(h, k, l); - } - - function lf(a, b) { - var c = a[b + 0 - 32], - d = a[b + 1 - 32], - e = a[b + 2 - 32], - f = a[b + 3 - 32], - g = a[b + 4 - 32], - h = a[b + 5 - 32], - k = a[b + 6 - 32], - l = a[b + 7 - 32]; - a[b + 0 + 0] = c + d + 1 >> 1; - a[b + 1 + 0] = a[b + 0 + 64] = d + e + 1 >> 1; - a[b + 2 + 0] = a[b + 1 + 64] = e + f + 1 >> 1; - a[b + 3 + 0] = a[b + 2 + 64] = f + g + 1 >> 1; - a[b + 0 + 32] = z(c, d, e); - a[b + 1 + 32] = a[b + 0 + 96] = z(d, e, f); - a[b + 2 + 32] = a[b + 1 + 96] = z(e, f, g); - a[b + 3 + 32] = a[b + 2 + 96] = z(f, g, h); - a[b + 3 + 64] = z(g, h, k); - a[b + 3 + 96] = z(h, k, l); - } - - function nf(a, b) { - var c = a[b - 1 + 0], - d = a[b - 1 + 32], - e = a[b - 1 + 64], - f = a[b - 1 + 96]; - a[b + 0 + 0] = c + d + 1 >> 1; - a[b + 2 + 0] = a[b + 0 + 32] = d + e + 1 >> 1; - a[b + 2 + 32] = a[b + 0 + 64] = e + f + 1 >> 1; - a[b + 1 + 0] = z(c, d, e); - a[b + 3 + 0] = a[b + 1 + 32] = z(d, e, f); - a[b + 3 + 32] = a[b + 1 + 64] = z(e, f, f); - a[b + 3 + 64] = a[b + 2 + 64] = a[b + 0 + 96] = a[b + 1 + 96] = a[b + 2 + 96] = a[b + 3 + 96] = f; - } - - function mf(a, b) { - var c = a[b - 1 + 0], - d = a[b - 1 + 32], - e = a[b - 1 + 64], - f = a[b - 1 + 96], - g = a[b - 1 - 32], - h = a[b + 0 - 32], - k = a[b + 1 - 32], - l = a[b + 2 - 32]; - a[b + 0 + 0] = a[b + 2 + 32] = c + g + 1 >> 1; - a[b + 0 + 32] = a[b + 2 + 64] = d + c + 1 >> 1; - a[b + 0 + 64] = a[b + 2 + 96] = e + d + 1 >> 1; - a[b + 0 + 96] = f + e + 1 >> 1; - a[b + 3 + 0] = z(h, k, l); - a[b + 2 + 0] = z(g, h, k); - a[b + 1 + 0] = a[b + 3 + 32] = z(c, g, h); - a[b + 1 + 32] = a[b + 3 + 64] = z(d, c, g); - a[b + 1 + 64] = a[b + 3 + 96] = z(e, d, c); - a[b + 1 + 96] = z(f, e, d); - } - - function xf(a, b) { - var c; - - for (c = 0; 8 > c; ++c) { - I(a, b + 32 * c, a, b - 32, 8); - } - } - - function yf(a, b) { - var c; - - for (c = 0; 8 > c; ++c) { - M(a, b, a[b - 1], 8), b += 32; - } - } - - function lb(a, b, c) { - var d; - - for (d = 0; 8 > d; ++d) { - M(b, c + 32 * d, a, 8); - } - } - - function vf(a, b) { - var c = 8, - d; - - for (d = 0; 8 > d; ++d) { - c += a[b + d - 32] + a[b - 1 + 32 * d]; - } - - lb(c >> 4, a, b); - } - - function Af(a, b) { - var c = 4, - d; - - for (d = 0; 8 > d; ++d) { - c += a[b + d - 32]; - } - - lb(c >> 3, a, b); - } - - function zf(a, b) { - var c = 4, - d; - - for (d = 0; 8 > d; ++d) { - c += a[b - 1 + 32 * d]; - } - - lb(c >> 3, a, b); - } - - function Bf(a, b) { - lb(128, a, b); - } - - function ab(a, b, c) { - var d = a[b - c], - e = a[b + 0], - f = 3 * (e - d) + Qb[1020 + a[b - 2 * c] - a[b + c]], - g = mb[112 + (f + 4 >> 3)]; - a[b - c] = R[255 + d + mb[112 + (f + 3 >> 3)]]; - a[b + 0] = R[255 + e - g]; - } - - function jd(a, b, c, d) { - var e = a[b + 0], - f = a[b + c]; - return U[255 + a[b - 2 * c] - a[b - c]] > d || U[255 + f - e] > d; - } - - function kd(a, b, c, d) { - return 4 * U[255 + a[b - c] - a[b + 0]] + U[255 + a[b - 2 * c] - a[b + c]] <= d; - } - - function ld(a, b, c, d, e) { - var f = a[b - 3 * c], - g = a[b - 2 * c], - h = a[b - c], - k = a[b + 0], - l = a[b + c], - m = a[b + 2 * c], - n = a[b + 3 * c]; - return 4 * U[255 + h - k] + U[255 + g - l] > d ? 0 : U[255 + a[b - 4 * c] - f] <= e && U[255 + f - g] <= e && U[255 + g - h] <= e && U[255 + n - m] <= e && U[255 + m - l] <= e && U[255 + l - k] <= e; - } - - function gd(a, b, c, d) { - var e = 2 * d + 1; - - for (d = 0; 16 > d; ++d) { - kd(a, b + d, c, e) && ab(a, b + d, c); - } - } - - function hd(a, b, c, d) { - var e = 2 * d + 1; - - for (d = 0; 16 > d; ++d) { - kd(a, b + d * c, 1, e) && ab(a, b + d * c, 1); - } - } - - function bf(a, b, c, d) { - var e; - - for (e = 3; 0 < e; --e) { - b += 4 * c, gd(a, b, c, d); - } - } - - function cf(a, b, c, d) { - var e; - - for (e = 3; 0 < e; --e) { - b += 4, hd(a, b, c, d); - } - } - - function ea(a, b, c, d, e, f, g, h) { - for (f = 2 * f + 1; 0 < e--;) { - if (ld(a, b, c, f, g)) { if (jd(a, b, c, h)) { ab(a, b, c); }else { - var k = a, - l = b, - m = c, - n = k[l - 2 * m], - r = k[l - m], - q = k[l + 0], - t = k[l + m], - v = k[l + 2 * m], - p = Qb[1020 + 3 * (q - r) + Qb[1020 + n - t]], - u = 27 * p + 63 >> 7, - w = 18 * p + 63 >> 7, - p = 9 * p + 63 >> 7; - k[l - 3 * m] = R[255 + k[l - 3 * m] + p]; - k[l - 2 * m] = R[255 + n + w]; - k[l - m] = R[255 + r + u]; - k[l + 0] = R[255 + q - u]; - k[l + m] = R[255 + t - w]; - k[l + 2 * m] = R[255 + v - p]; - } } - b += d; - } - } - - function Fa(a, b, c, d, e, f, g, h) { - for (f = 2 * f + 1; 0 < e--;) { - if (ld(a, b, c, f, g)) { if (jd(a, b, c, h)) { ab(a, b, c); }else { - var k = a, - l = b, - m = c, - n = k[l - m], - r = k[l + 0], - q = k[l + m], - t = 3 * (r - n), - v = mb[112 + (t + 4 >> 3)], - t = mb[112 + (t + 3 >> 3)], - p = v + 1 >> 1; - k[l - 2 * m] = R[255 + k[l - 2 * m] + p]; - k[l - m] = R[255 + n + t]; - k[l + 0] = R[255 + r - v]; - k[l + m] = R[255 + q - p]; - } } - b += d; - } - } - - function Ue(a, b, c, d, e, f) { - ea(a, b, c, 1, 16, d, e, f); - } - - function Ve(a, b, c, d, e, f) { - ea(a, b, 1, c, 16, d, e, f); - } - - function Ye(a, b, c, d, e, f) { - var g; - - for (g = 3; 0 < g; --g) { - b += 4 * c, Fa(a, b, c, 1, 16, d, e, f); - } - } - - function Ze(a, b, c, d, e, f) { - var g; - - for (g = 3; 0 < g; --g) { - b += 4, Fa(a, b, 1, c, 16, d, e, f); - } - } - - function We(a, b, c, d, e, f, g, h) { - ea(a, b, e, 1, 8, f, g, h); - ea(c, d, e, 1, 8, f, g, h); - } - - function Xe(a, b, c, d, e, f, g, h) { - ea(a, b, 1, e, 8, f, g, h); - ea(c, d, 1, e, 8, f, g, h); - } - - function $e(a, b, c, d, e, f, g, h) { - Fa(a, b + 4 * e, e, 1, 8, f, g, h); - Fa(c, d + 4 * e, e, 1, 8, f, g, h); - } - - function af(a, b, c, d, e, f, g, h) { - Fa(a, b + 4, 1, e, 8, f, g, h); - Fa(c, d + 4, 1, e, 8, f, g, h); - } - - function Cf() { - this.ba = new Cb(); - this.ec = []; - this.cc = []; - this.Mc = []; - this.Dc = this.Nc = this.dc = this.fc = 0; - this.Oa = new Ud(); - this.memory = 0; - this.Ib = "OutputFunc"; - this.Jb = "OutputAlphaFunc"; - this.Nd = "OutputRowFunc"; - } - - function md() { - this.data = []; - this.offset = this.kd = this.ha = this.w = 0; - this.na = []; - this.xa = this.gb = this.Ja = this.Sa = this.P = 0; - } - - function Df() { - this.nc = this.Ea = this.b = this.hc = 0; - this.K = []; - this.w = 0; - } - - function Ef() { - this.ua = 0; - this.Wa = new ac(); - this.vb = new ac(); - this.md = this.xc = this.wc = 0; - this.vc = []; - this.Wb = 0; - this.Ya = new Ub(); - this.yc = new O(); - } - - function je() { - this.xb = this.a = 0; - this.l = new Oa(); - this.ca = new Cb(); - this.V = []; - this.Ba = 0; - this.Ta = []; - this.Ua = 0; - this.m = new Ra(); - this.Pb = 0; - this.wd = new Ra(); - this.Ma = this.$ = this.C = this.i = this.c = this.xd = 0; - this.s = new Ef(); - this.ab = 0; - this.gc = wa(4, Df); - this.Oc = 0; - } - - function Ff() { - this.Lc = this.Z = this.$a = this.i = this.c = 0; - this.l = new Oa(); - this.ic = 0; - this.ca = []; - this.tb = 0; - this.qd = null; - this.rd = 0; - } - - function Rb(a, b, c, d, e, f, g) { - a = null == a ? 0 : a[b + 0]; - - for (b = 0; b < g; ++b) { - e[f + b] = a + c[d + b] & 255, a = e[f + b]; - } - } - - function Gf(a, b, c, d, e, f, g) { - if (null == a) { Rb(null, null, c, d, e, f, g); }else { - var h; - - for (h = 0; h < g; ++h) { - e[f + h] = a[b + h] + c[d + h] & 255; - } - } - } - - function Hf(a, b, c, d, e, f, g) { - if (null == a) { Rb(null, null, c, d, e, f, g); }else { - var h = a[b + 0], - k = h, - l = h, - m; - - for (m = 0; m < g; ++m) { - h = a[b + m], k = l + h - k, l = c[d + m] + (k & -256 ? 0 > k ? 0 : 255 : k) & 255, k = h, e[f + m] = l; - } - } - } - - function Le(a, b, c, d) { - var e = b.width, - f = b.o; - x(null != a && null != b); - if (0 > c || 0 >= d || c + d > f) { return null; } - - if (!a.Cc) { - if (null == a.ga) { - a.ga = new Ff(); - var g; - (g = null == a.ga) || (g = b.width * b.o, x(0 == a.Gb.length), a.Gb = V(g), a.Uc = 0, null == a.Gb ? g = 0 : (a.mb = a.Gb, a.nb = a.Uc, a.rc = null, g = 1), g = !g); - - if (!g) { - g = a.ga; - var h = a.Fa, - k = a.P, - l = a.qc, - m = a.mb, - n = a.nb, - r = k + 1, - q = l - 1, - t = g.l; - x(null != h && null != m && null != b); - ia[0] = null; - ia[1] = Rb; - ia[2] = Gf; - ia[3] = Hf; - g.ca = m; - g.tb = n; - g.c = b.width; - g.i = b.height; - x(0 < g.c && 0 < g.i); - if (1 >= l) { b = 0; }else if (g.$a = h[k + 0] >> 0 & 3, g.Z = h[k + 0] >> 2 & 3, g.Lc = h[k + 0] >> 4 & 3, k = h[k + 0] >> 6 & 3, 0 > g.$a || 1 < g.$a || 4 <= g.Z || 1 < g.Lc || k) { b = 0; }else if (t.put = kc, t.ac = gc, t.bc = lc, t.ma = g, t.width = b.width, t.height = b.height, t.Da = b.Da, t.v = b.v, t.va = b.va, t.j = b.j, t.o = b.o, g.$a) { b: { - x(1 == g.$a), b = Bc(); - - c: for (;;) { - if (null == b) { - b = 0; - break b; - } - - x(null != g); - g.mc = b; - b.c = g.c; - b.i = g.i; - b.l = g.l; - b.l.ma = g; - b.l.width = g.c; - b.l.height = g.i; - b.a = 0; - cb(b.m, h, r, q); - if (!rb(g.c, g.i, 1, b, null)) { break c; } - 1 == b.ab && 3 == b.gc[0].hc && yc(b.s) ? (g.ic = 1, h = b.c * b.i, b.Ta = null, b.Ua = 0, b.V = V(h), b.Ba = 0, null == b.V ? (b.a = 1, b = 0) : b = 1) : (g.ic = 0, b = Ec(b, g.c)); - if (!b) { break c; } - b = 1; - break b; - } - - g.mc = null; - b = 0; - } } else { b = q >= g.c * g.i; } - g = !b; - } - - if (g) { return null; } - 1 != a.ga.Lc ? a.Ga = 0 : d = f - c; - } - - x(null != a.ga); - x(c + d <= f); - - a: { - h = a.ga; - b = h.c; - f = h.l.o; - - if (0 == h.$a) { - r = a.rc; - q = a.Vc; - t = a.Fa; - k = a.P + 1 + c * b; - l = a.mb; - m = a.nb + c * b; - x(k <= a.P + a.qc); - if (0 != h.Z) { for (x(null != ia[h.Z]), g = 0; g < d; ++g) { - ia[h.Z](r, q, t, k, l, m, b), r = l, q = m, m += b, k += b; - } } else { for (g = 0; g < d; ++g) { - I(l, m, t, k, b), r = l, q = m, m += b, k += b; - } } - a.rc = r; - a.Vc = q; - } else { - x(null != h.mc); - b = c + d; - g = h.mc; - x(null != g); - x(b <= g.i); - if (g.C >= b) { b = 1; }else if (h.ic || Aa(), h.ic) { - var h = g.V, - r = g.Ba, - q = g.c, - v = g.i, - t = 1, - k = g.$ / q, - l = g.$ % q, - m = g.m, - n = g.s, - p = g.$, - u = q * v, - w = q * b, - y = n.wc, - A = p < w ? ha(n, l, k) : null; - x(p <= u); - x(b <= v); - x(yc(n)); - - c: for (;;) { - for (; !m.h && p < w;) { - l & y || (A = ha(n, l, k)); - x(null != A); - Sa(m); - v = ua(A.G[0], A.H[0], m); - if (256 > v) { h[r + p] = v, ++p, ++l, l >= q && (l = 0, ++k, k <= b && !(k % 16) && Ib(g, k)); }else if (280 > v) { - var v = ib(v - 256, m); - var E = ua(A.G[4], A.H[4], m); - Sa(m); - E = ib(E, m); - E = nc(q, E); - - if (p >= E && u - p >= v) { - var B; - - for (B = 0; B < v; ++B) { - h[r + p + B] = h[r + p + B - E]; - } - } else { - t = 0; - break c; - } - - p += v; - - for (l += v; l >= q;) { - l -= q, ++k, k <= b && !(k % 16) && Ib(g, k); - } - - p < w && l & y && (A = ha(n, l, k)); - } else { - t = 0; - break c; - } - x(m.h == db(m)); - } - - Ib(g, k > b ? b : k); - break c; - } - - !t || m.h && p < u ? (t = 0, g.a = m.h ? 5 : 3) : g.$ = p; - b = t; - } else { b = Jb(g, g.V, g.Ba, g.c, g.i, b, se); } - - if (!b) { - d = 0; - break a; - } - } - - c + d >= f && (a.Cc = 1); - d = 1; - } - - if (!d) { return null; } - if (a.Cc && (d = a.ga, null != d && (d.mc = null), a.ga = null, 0 < a.Ga)) { return alert("todo:WebPDequantizeLevels"), null; } - } - - return a.nb + c * e; - } - - function If(a, b, c, d, e, f) { - for (; 0 < e--;) { - var g = a, - h = b + (c ? 1 : 0), - k = a, - l = b + (c ? 0 : 3), - m; - - for (m = 0; m < d; ++m) { - var n = k[l + 4 * m]; - 255 != n && (n *= 32897, g[h + 4 * m + 0] = g[h + 4 * m + 0] * n >> 23, g[h + 4 * m + 1] = g[h + 4 * m + 1] * n >> 23, g[h + 4 * m + 2] = g[h + 4 * m + 2] * n >> 23); - } - - b += f; - } - } - - function Jf(a, b, c, d, e) { - for (; 0 < d--;) { - var f; - - for (f = 0; f < c; ++f) { - var g = a[b + 2 * f + 0], - h = a[b + 2 * f + 1], - k = h & 15, - l = 4369 * k, - h = (h & 240 | h >> 4) * l >> 16; - a[b + 2 * f + 0] = (g & 240 | g >> 4) * l >> 16 & 240 | (g & 15 | g << 4) * l >> 16 >> 4 & 15; - a[b + 2 * f + 1] = h & 240 | k; - } - - b += e; - } - } - - function Kf(a, b, c, d, e, f, g, h) { - var k = 255, - l, - m; - - for (m = 0; m < e; ++m) { - for (l = 0; l < d; ++l) { - var n = a[b + l]; - f[g + 4 * l] = n; - k &= n; - } - - b += c; - g += h; - } - - return 255 != k; - } - - function Lf(a, b, c, d, e) { - var f; - - for (f = 0; f < e; ++f) { - c[d + f] = a[b + f] >> 8; - } - } - - function Aa() { - za = If; - vc = Jf; - fc = Kf; - Fc = Lf; - } - - function va(a, b, c) { - self[a] = function (a, e, f, g, h, k, l, m, n, r, q, t, v, p, u, w, y) { - var d, - E = y - 1 >> 1; - var B = h[k + 0] | l[m + 0] << 16; - var C = n[r + 0] | q[t + 0] << 16; - x(null != a); - var z = 3 * B + C + 131074 >> 2; - b(a[e + 0], z & 255, z >> 16, v, p); - null != f && (z = 3 * C + B + 131074 >> 2, b(f[g + 0], z & 255, z >> 16, u, w)); - - for (d = 1; d <= E; ++d) { - var D = h[k + d] | l[m + d] << 16; - var G = n[r + d] | q[t + d] << 16; - var F = B + D + C + G + 524296; - var H = F + 2 * (D + C) >> 3; - F = F + 2 * (B + G) >> 3; - z = H + B >> 1; - B = F + D >> 1; - b(a[e + 2 * d - 1], z & 255, z >> 16, v, p + (2 * d - 1) * c); - b(a[e + 2 * d - 0], B & 255, B >> 16, v, p + (2 * d - 0) * c); - null != f && (z = F + C >> 1, B = H + G >> 1, b(f[g + 2 * d - 1], z & 255, z >> 16, u, w + (2 * d - 1) * c), b(f[g + 2 * d + 0], B & 255, B >> 16, u, w + (2 * d + 0) * c)); - B = D; - C = G; - } - - y & 1 || (z = 3 * B + C + 131074 >> 2, b(a[e + y - 1], z & 255, z >> 16, v, p + (y - 1) * c), null != f && (z = 3 * C + B + 131074 >> 2, b(f[g + y - 1], z & 255, z >> 16, u, w + (y - 1) * c))); - }; - } - - function ic() { - P[Ca] = Mf; - P[Ua] = nd; - P[tc] = Nf; - P[Va] = od; - P[ya] = pd; - P[Db] = qd; - P[wc] = Of; - P[zb] = nd; - P[Ab] = od; - P[Ja] = pd; - P[Bb] = qd; - } - - function Sb(a) { - return a & ~Pf ? 0 > a ? 0 : 255 : a >> rd; - } - - function bb(a, b) { - return Sb((19077 * a >> 8) + (26149 * b >> 8) - 14234); - } - - function nb(a, b, c) { - return Sb((19077 * a >> 8) - (6419 * b >> 8) - (13320 * c >> 8) + 8708); - } - - function Pa(a, b) { - return Sb((19077 * a >> 8) + (33050 * b >> 8) - 17685); - } - - function Ga(a, b, c, d, e) { - d[e + 0] = bb(a, c); - d[e + 1] = nb(a, b, c); - d[e + 2] = Pa(a, b); - } - - function Tb(a, b, c, d, e) { - d[e + 0] = Pa(a, b); - d[e + 1] = nb(a, b, c); - d[e + 2] = bb(a, c); - } - - function sd(a, b, c, d, e) { - var f = nb(a, b, c); - b = f << 3 & 224 | Pa(a, b) >> 3; - d[e + 0] = bb(a, c) & 248 | f >> 5; - d[e + 1] = b; - } - - function td(a, b, c, d, e) { - var f = Pa(a, b) & 240 | 15; - d[e + 0] = bb(a, c) & 240 | nb(a, b, c) >> 4; - d[e + 1] = f; - } - - function ud(a, b, c, d, e) { - d[e + 0] = 255; - Ga(a, b, c, d, e + 1); - } - - function vd(a, b, c, d, e) { - Tb(a, b, c, d, e); - d[e + 3] = 255; - } - - function wd(a, b, c, d, e) { - Ga(a, b, c, d, e); - d[e + 3] = 255; - } - - function ga(a, b) { - return 0 > a ? 0 : a > b ? b : a; - } - - function la(a, b, c) { - self[a] = function (a, e, f, g, h, k, l, m, n) { - for (var d = m + (n & -2) * c; m != d;) { - b(a[e + 0], f[g + 0], h[k + 0], l, m), b(a[e + 1], f[g + 0], h[k + 0], l, m + c), e += 2, ++g, ++k, m += 2 * c; - } - - n & 1 && b(a[e + 0], f[g + 0], h[k + 0], l, m); - }; - } - - function xd(a, b, c) { - return 0 == c ? 0 == a ? 0 == b ? 6 : 5 : 0 == b ? 4 : 0 : c; - } - - function yd(a, b, c, d, e) { - switch (a >>> 30) { - case 3: - Za(b, c, d, e, 0); - break; - - case 2: - fd(b, c, d, e); - break; - - case 1: - pa(b, c, d, e); - } - } - - function Oc(a, b) { - var c, - d, - e = b.M, - f = b.Nb, - g = a.oc, - h = a.pc + 40, - k = a.oc, - l = a.pc + 584, - m = a.oc, - n = a.pc + 600; - - for (c = 0; 16 > c; ++c) { - g[h + 32 * c - 1] = 129; - } - - for (c = 0; 8 > c; ++c) { - k[l + 32 * c - 1] = 129, m[n + 32 * c - 1] = 129; - } - - 0 < e ? g[h - 1 - 32] = k[l - 1 - 32] = m[n - 1 - 32] = 129 : (M(g, h - 32 - 1, 127, 21), M(k, l - 32 - 1, 127, 9), M(m, n - 32 - 1, 127, 9)); - - for (d = 0; d < a.za; ++d) { - var r = b.ya[b.aa + d]; - - if (0 < d) { - for (c = -1; 16 > c; ++c) { - I(g, h + 32 * c - 4, g, h + 32 * c + 12, 4); - } - - for (c = -1; 8 > c; ++c) { - I(k, l + 32 * c - 4, k, l + 32 * c + 4, 4), I(m, n + 32 * c - 4, m, n + 32 * c + 4, 4); - } - } - - var q = a.Gd, - t = a.Hd + d, - v = r.ad, - p = r.Hc; - 0 < e && (I(g, h - 32, q[t].y, 0, 16), I(k, l - 32, q[t].f, 0, 8), I(m, n - 32, q[t].ea, 0, 8)); - - if (r.Za) { - var u = g; - var w = h - 32 + 16; - 0 < e && (d >= a.za - 1 ? M(u, w, q[t].y[15], 4) : I(u, w, q[t + 1].y, 0, 4)); - - for (c = 0; 4 > c; c++) { - u[w + 128 + c] = u[w + 256 + c] = u[w + 384 + c] = u[w + 0 + c]; - } - - for (c = 0; 16 > c; ++c, p <<= 2) { - u = g, w = h + zd[c], W[r.Ob[c]](u, w), yd(p, v, 16 * +c, u, w); - } - } else if (u = xd(d, e, r.Ob[0]), Y[u](g, h), 0 != p) { for (c = 0; 16 > c; ++c, p <<= 2) { - yd(p, v, 16 * +c, g, h + zd[c]); - } } - - c = r.Gc; - u = xd(d, e, r.Dd); - ka[u](k, l); - ka[u](m, n); - r = c >> 0; - p = v; - u = k; - w = l; - r & 255 && (r & 170 ? Nb(p, 256, u, w) : Ob(p, 256, u, w)); - c >>= 8; - r = m; - p = n; - c & 255 && (c & 170 ? Nb(v, 320, r, p) : Ob(v, 320, r, p)); - e < a.Ub - 1 && (I(q[t].y, 0, g, h + 480, 16), I(q[t].f, 0, k, l + 224, 8), I(q[t].ea, 0, m, n + 224, 8)); - c = 8 * f * a.B; - q = a.sa; - t = a.ta + 16 * d + 16 * f * a.R; - v = a.qa; - r = a.ra + 8 * d + c; - p = a.Ha; - u = a.Ia + 8 * d + c; - - for (c = 0; 16 > c; ++c) { - I(q, t + c * a.R, g, h + 32 * c, 16); - } - - for (c = 0; 8 > c; ++c) { - I(v, r + c * a.B, k, l + 32 * c, 8), I(p, u + c * a.B, m, n + 32 * c, 8); - } - } - } - - function Ad(a, b, c, d, e, f, g, h, k) { - var l = [0], - m = [0], - n = 0, - r = null != k ? k.kd : 0, - q = null != k ? k : new md(); - if (null == a || 12 > c) { return 7; } - q.data = a; - q.w = b; - q.ha = c; - b = [b]; - c = [c]; - q.gb = [q.gb]; - - a: { - var t = b; - var v = c; - var p = q.gb; - x(null != a); - x(null != v); - x(null != p); - p[0] = 0; - - if (12 <= v[0] && !fa(a, t[0], "RIFF")) { - if (fa(a, t[0] + 8, "WEBP")) { - p = 3; - break a; - } - - var u = Ha(a, t[0] + 4); - - if (12 > u || 4294967286 < u) { - p = 3; - break a; - } - - if (r && u > v[0] - 8) { - p = 7; - break a; - } - - p[0] = u; - t[0] += 12; - v[0] -= 12; - } - - p = 0; - } - - if (0 != p) { return p; } - u = 0 < q.gb[0]; - - for (c = c[0];;) { - t = [0]; - n = [n]; - - a: { - var w = a; - v = b; - p = c; - var y = n, - A = l, - z = m, - B = t; - y[0] = 0; - if (8 > p[0]) { p = 7; }else { - if (!fa(w, v[0], "VP8X")) { - if (10 != Ha(w, v[0] + 4)) { - p = 3; - break a; - } - - if (18 > p[0]) { - p = 7; - break a; - } - - var C = Ha(w, v[0] + 8); - var D = 1 + Yb(w, v[0] + 12); - w = 1 + Yb(w, v[0] + 15); - - if (2147483648 <= D * w) { - p = 3; - break a; - } - - null != B && (B[0] = C); - null != A && (A[0] = D); - null != z && (z[0] = w); - v[0] += 18; - p[0] -= 18; - y[0] = 1; - } - - p = 0; - } - } - - n = n[0]; - t = t[0]; - if (0 != p) { return p; } - v = !!(t & 2); - if (!u && n) { return 3; } - null != f && (f[0] = !!(t & 16)); - null != g && (g[0] = v); - null != h && (h[0] = 0); - g = l[0]; - t = m[0]; - - if (n && v && null == k) { - p = 0; - break; - } - - if (4 > c) { - p = 7; - break; - } - - if (u && n || !u && !n && !fa(a, b[0], "ALPH")) { - c = [c]; - q.na = [q.na]; - q.P = [q.P]; - q.Sa = [q.Sa]; - - a: { - C = a; - p = b; - u = c; - var y = q.gb, - A = q.na, - z = q.P, - B = q.Sa; - D = 22; - x(null != C); - x(null != u); - w = p[0]; - var F = u[0]; - x(null != A); - x(null != B); - A[0] = null; - z[0] = null; - - for (B[0] = 0;;) { - p[0] = w; - u[0] = F; - - if (8 > F) { - p = 7; - break a; - } - - var G = Ha(C, w + 4); - - if (4294967286 < G) { - p = 3; - break a; - } - - var H = 8 + G + 1 & -2; - D += H; - - if (0 < y && D > y) { - p = 3; - break a; - } - - if (!fa(C, w, "VP8 ") || !fa(C, w, "VP8L")) { - p = 0; - break a; - } - - if (F[0] < H) { - p = 7; - break a; - } - - fa(C, w, "ALPH") || (A[0] = C, z[0] = w + 8, B[0] = G); - w += H; - F -= H; - } - } - - c = c[0]; - q.na = q.na[0]; - q.P = q.P[0]; - q.Sa = q.Sa[0]; - if (0 != p) { break; } - } - - c = [c]; - q.Ja = [q.Ja]; - q.xa = [q.xa]; - - a: if (y = a, p = b, u = c, A = q.gb[0], z = q.Ja, B = q.xa, C = p[0], w = !fa(y, C, "VP8 "), D = !fa(y, C, "VP8L"), x(null != y), x(null != u), x(null != z), x(null != B), 8 > u[0]) { p = 7; }else { - if (w || D) { - y = Ha(y, C + 4); - - if (12 <= A && y > A - 12) { - p = 3; - break a; - } - - if (r && y > u[0] - 8) { - p = 7; - break a; - } - - z[0] = y; - p[0] += 8; - u[0] -= 8; - B[0] = D; - } else { B[0] = 5 <= u[0] && 47 == y[C + 0] && !(y[C + 4] >> 5), z[0] = u[0]; } - - p = 0; - } - - c = c[0]; - q.Ja = q.Ja[0]; - q.xa = q.xa[0]; - b = b[0]; - if (0 != p) { break; } - if (4294967286 < q.Ja) { return 3; } - null == h || v || (h[0] = q.xa ? 2 : 1); - g = [g]; - t = [t]; - - if (q.xa) { - if (5 > c) { - p = 7; - break; - } - - h = g; - r = t; - v = f; - null == a || 5 > c ? a = 0 : 5 <= c && 47 == a[b + 0] && !(a[b + 4] >> 5) ? (u = [0], y = [0], A = [0], z = new Ra(), cb(z, a, b, c), mc(z, u, y, A) ? (null != h && (h[0] = u[0]), null != r && (r[0] = y[0]), null != v && (v[0] = A[0]), a = 1) : a = 0) : a = 0; - } else { - if (10 > c) { - p = 7; - break; - } - - h = t; - null == a || 10 > c || !Jc(a, b + 3, c - 3) ? a = 0 : (r = a[b + 0] | a[b + 1] << 8 | a[b + 2] << 16, v = (a[b + 7] << 8 | a[b + 6]) & 16383, a = (a[b + 9] << 8 | a[b + 8]) & 16383, r & 1 || 3 < (r >> 1 & 7) || !(r >> 4 & 1) || r >> 5 >= q.Ja || !v || !a ? a = 0 : (g && (g[0] = v), h && (h[0] = a), a = 1)); - } - - if (!a) { return 3; } - g = g[0]; - t = t[0]; - if (n && (l[0] != g || m[0] != t)) { return 3; } - null != k && (k[0] = q, k.offset = b - k.w, x(4294967286 > b - k.w), x(k.offset == k.ha - c)); - break; - } - - return 0 == p || 7 == p && n && null == k ? (null != f && (f[0] |= null != q.na && 0 < q.na.length), null != d && (d[0] = g), null != e && (e[0] = t), 0) : p; - } - - function hc(a, b, c) { - var d = b.width, - e = b.height, - f = 0, - g = 0, - h = d, - k = e; - b.Da = null != a && 0 < a.Da; - if (b.Da && (h = a.cd, k = a.bd, f = a.v, g = a.j, 11 > c || (f &= -2, g &= -2), 0 > f || 0 > g || 0 >= h || 0 >= k || f + h > d || g + k > e)) { return 0; } - b.v = f; - b.j = g; - b.va = f + h; - b.o = g + k; - b.U = h; - b.T = k; - b.da = null != a && 0 < a.da; - - if (b.da) { - c = [a.ib]; - f = [a.hb]; - if (!bc(h, k, c, f)) { return 0; } - b.ib = c[0]; - b.hb = f[0]; - } - - b.ob = null != a && a.ob; - b.Kb = null == a || !a.Sd; - b.da && (b.ob = b.ib < 3 * d / 4 && b.hb < 3 * e / 4, b.Kb = 0); - return 1; - } - - function Bd(a) { - if (null == a) { return 2; } - - if (11 > a.S) { - var b = a.f.RGBA; - b.fb += (a.height - 1) * b.A; - b.A = -b.A; - } else { b = a.f.kb, a = a.height, b.O += (a - 1) * b.fa, b.fa = -b.fa, b.N += (a - 1 >> 1) * b.Ab, b.Ab = -b.Ab, b.W += (a - 1 >> 1) * b.Db, b.Db = -b.Db, null != b.F && (b.J += (a - 1) * b.lb, b.lb = -b.lb); } - - return 0; - } - - function Cd(a, b, c, d) { - if (null == d || 0 >= a || 0 >= b) { return 2; } - - if (null != c) { - if (c.Da) { - var e = c.cd, - f = c.bd, - g = c.v & -2, - h = c.j & -2; - if (0 > g || 0 > h || 0 >= e || 0 >= f || g + e > a || h + f > b) { return 2; } - a = e; - b = f; - } - - if (c.da) { - e = [c.ib]; - f = [c.hb]; - if (!bc(a, b, e, f)) { return 2; } - a = e[0]; - b = f[0]; - } - } - - d.width = a; - d.height = b; - - a: { - var k = d.width; - var l = d.height; - a = d.S; - if (0 >= k || 0 >= l || !(a >= Ca && 13 > a)) { a = 2; }else { - if (0 >= d.Rd && null == d.sd) { - var g = f = e = b = 0, - h = k * Dd[a], - m = h * l; - 11 > a || (b = (k + 1) / 2, f = (l + 1) / 2 * b, 12 == a && (e = k, g = e * l)); - l = V(m + 2 * f + g); - - if (null == l) { - a = 1; - break a; - } - - d.sd = l; - 11 > a ? (k = d.f.RGBA, k.eb = l, k.fb = 0, k.A = h, k.size = m) : (k = d.f.kb, k.y = l, k.O = 0, k.fa = h, k.Fd = m, k.f = l, k.N = 0 + m, k.Ab = b, k.Cd = f, k.ea = l, k.W = 0 + m + f, k.Db = b, k.Ed = f, 12 == a && (k.F = l, k.J = 0 + m + 2 * f), k.Tc = g, k.lb = e); - } - - b = 1; - e = d.S; - f = d.width; - g = d.height; - if (e >= Ca && 13 > e) { - if (11 > e) { a = d.f.RGBA, h = Math.abs(a.A), b &= h * (g - 1) + f <= a.size, b &= h >= f * Dd[e], b &= null != a.eb; }else { - a = d.f.kb; - h = (f + 1) / 2; - m = (g + 1) / 2; - k = Math.abs(a.fa); - var l = Math.abs(a.Ab), - n = Math.abs(a.Db), - r = Math.abs(a.lb), - q = r * (g - 1) + f; - b &= k * (g - 1) + f <= a.Fd; - b &= l * (m - 1) + h <= a.Cd; - b &= n * (m - 1) + h <= a.Ed; - b = b & k >= f & l >= h & n >= h; - b &= null != a.y; - b &= null != a.f; - b &= null != a.ea; - 12 == e && (b &= r >= f, b &= q <= a.Tc, b &= null != a.F); - } - } else { b = 0; } - a = b ? 0 : 2; - } - } - - if (0 != a) { return a; } - null != c && c.fd && (a = Bd(d)); - return a; - } - - var xb = 64, - Hd = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215], - Gd = 24, - ob = 32, - Xb = 8, - Id = [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]; - X("Predictor0", "PredictorAdd0"); - - self.Predictor0 = function () { - return 4278190080; - }; - - self.Predictor1 = function (a) { - return a; - }; - - self.Predictor2 = function (a, b, c) { - return b[c + 0]; - }; - - self.Predictor3 = function (a, b, c) { - return b[c + 1]; - }; - - self.Predictor4 = function (a, b, c) { - return b[c - 1]; - }; - - self.Predictor5 = function (a, b, c) { - return aa(aa(a, b[c + 1]), b[c + 0]); - }; - - self.Predictor6 = function (a, b, c) { - return aa(a, b[c - 1]); - }; - - self.Predictor7 = function (a, b, c) { - return aa(a, b[c + 0]); - }; - - self.Predictor8 = function (a, b, c) { - return aa(b[c - 1], b[c + 0]); - }; - - self.Predictor9 = function (a, b, c) { - return aa(b[c + 0], b[c + 1]); - }; - - self.Predictor10 = function (a, b, c) { - return aa(aa(a, b[c - 1]), aa(b[c + 0], b[c + 1])); - }; - - self.Predictor11 = function (a, b, c) { - var d = b[c + 0]; - b = b[c - 1]; - return 0 >= Ia(d >> 24 & 255, a >> 24 & 255, b >> 24 & 255) + Ia(d >> 16 & 255, a >> 16 & 255, b >> 16 & 255) + Ia(d >> 8 & 255, a >> 8 & 255, b >> 8 & 255) + Ia(d & 255, a & 255, b & 255) ? d : a; - }; - - self.Predictor12 = function (a, b, c) { - var d = b[c + 0]; - b = b[c - 1]; - return (sa((a >> 24 & 255) + (d >> 24 & 255) - (b >> 24 & 255)) << 24 | sa((a >> 16 & 255) + (d >> 16 & 255) - (b >> 16 & 255)) << 16 | sa((a >> 8 & 255) + (d >> 8 & 255) - (b >> 8 & 255)) << 8 | sa((a & 255) + (d & 255) - (b & 255))) >>> 0; - }; - - self.Predictor13 = function (a, b, c) { - var d = b[c - 1]; - a = aa(a, b[c + 0]); - return (eb(a >> 24 & 255, d >> 24 & 255) << 24 | eb(a >> 16 & 255, d >> 16 & 255) << 16 | eb(a >> 8 & 255, d >> 8 & 255) << 8 | eb(a >> 0 & 255, d >> 0 & 255)) >>> 0; - }; - - var ee = self.PredictorAdd0; - self.PredictorAdd1 = cc; - X("Predictor2", "PredictorAdd2"); - X("Predictor3", "PredictorAdd3"); - X("Predictor4", "PredictorAdd4"); - X("Predictor5", "PredictorAdd5"); - X("Predictor6", "PredictorAdd6"); - X("Predictor7", "PredictorAdd7"); - X("Predictor8", "PredictorAdd8"); - X("Predictor9", "PredictorAdd9"); - X("Predictor10", "PredictorAdd10"); - X("Predictor11", "PredictorAdd11"); - X("Predictor12", "PredictorAdd12"); - X("Predictor13", "PredictorAdd13"); - var fe = self.PredictorAdd2; - ec("ColorIndexInverseTransform", "MapARGB", "32b", function (a) { - return a >> 8 & 255; - }, function (a) { - return a; - }); - ec("VP8LColorIndexInverseTransformAlpha", "MapAlpha", "8b", function (a) { - return a; - }, function (a) { - return a >> 8 & 255; - }); - var rc = self.ColorIndexInverseTransform, - ke = self.MapARGB, - he = self.VP8LColorIndexInverseTransformAlpha, - le = self.MapAlpha, - pc, - qc = self.VP8LPredictorsAdd = []; - qc.length = 16; - (self.VP8LPredictors = []).length = 16; - (self.VP8LPredictorsAdd_C = []).length = 16; - (self.VP8LPredictors_C = []).length = 16; - var Fb, - sc, - Gb, - Hb, - xc, - uc, - bd = V(511), - cd = V(2041), - dd = V(225), - ed = V(767), - ad = 0, - Qb = cd, - mb = dd, - R = ed, - U = bd, - Ca = 0, - Ua = 1, - tc = 2, - Va = 3, - ya = 4, - Db = 5, - wc = 6, - zb = 7, - Ab = 8, - Ja = 9, - Bb = 10, - pe = [2, 3, 7], - oe = [3, 3, 11], - Dc = [280, 256, 256, 256, 40], - qe = [0, 1, 1, 1, 0], - ne = [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - de = [24, 7, 23, 25, 40, 6, 39, 41, 22, 26, 38, 42, 56, 5, 55, 57, 21, 27, 54, 58, 37, 43, 72, 4, 71, 73, 20, 28, 53, 59, 70, 74, 36, 44, 88, 69, 75, 52, 60, 3, 87, 89, 19, 29, 86, 90, 35, 45, 68, 76, 85, 91, 51, 61, 104, 2, 103, 105, 18, 30, 102, 106, 34, 46, 84, 92, 67, 77, 101, 107, 50, 62, 120, 1, 119, 121, 83, 93, 17, 31, 100, 108, 66, 78, 118, 122, 33, 47, 117, 123, 49, 63, 99, 109, 82, 94, 0, 116, 124, 65, 79, 16, 32, 98, 110, 48, 115, 125, 81, 95, 64, 114, 126, 97, 111, 80, 113, 127, 96, 112], - me = [2954, 2956, 2958, 2962, 2970, 2986, 3018, 3082, 3212, 3468, 3980, 5004], - ie = 8, - Lb = [4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157], - Mb = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284], - oa = null, - He = [[173, 148, 140, 0], [176, 155, 140, 135, 0], [180, 157, 141, 134, 130, 0], [254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0]], - Ie = [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15], - Mc = [-0, 1, -1, 2, -2, 3, 4, 6, -3, 5, -4, -5, -6, 7, -7, 8, -8, -9], - Fe = [[[[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]], [[253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128], [189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128], [106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128]], [[1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128], [181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128], [78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128]], [[1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128], [184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128], [77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128]], [[1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128], [170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128], [37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128]], [[1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128], [207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128], [102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128]], [[1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128], [177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128], [80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128]], [[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]]], [[[198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62], [131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1], [68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128]], [[1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128], [184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128], [81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128]], [[1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128], [99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128], [23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128]], [[1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128], [109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128], [44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128]], [[1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128], [94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128], [22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128]], [[1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128], [124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128], [35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128]], [[1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128], [121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128], [45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128]], [[1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128], [203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128], [137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128]]], [[[253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128], [175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128], [73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128]], [[1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128], [239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128], [155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128]], [[1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128], [201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128], [69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128]], [[1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128], [223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128], [141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128]], [[1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128], [190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128], [149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128], [247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128], [240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128], [213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128], [55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]]], [[[202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255], [126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128], [61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128]], [[1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128], [166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128], [39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128]], [[1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128], [124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128], [24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128]], [[1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128], [149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128], [28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128]], [[1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128], [123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128], [20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128]], [[1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128], [168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128], [47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128]], [[1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128], [141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128], [42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128]], [[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]]]], - Ke = [[[231, 120, 48, 89, 115, 113, 120, 152, 112], [152, 179, 64, 126, 170, 118, 46, 70, 95], [175, 69, 143, 80, 85, 82, 72, 155, 103], [56, 58, 10, 171, 218, 189, 17, 13, 152], [114, 26, 17, 163, 44, 195, 21, 10, 173], [121, 24, 80, 195, 26, 62, 44, 64, 85], [144, 71, 10, 38, 171, 213, 144, 34, 26], [170, 46, 55, 19, 136, 160, 33, 206, 71], [63, 20, 8, 114, 114, 208, 12, 9, 226], [81, 40, 11, 96, 182, 84, 29, 16, 36]], [[134, 183, 89, 137, 98, 101, 106, 165, 148], [72, 187, 100, 130, 157, 111, 32, 75, 80], [66, 102, 167, 99, 74, 62, 40, 234, 128], [41, 53, 9, 178, 241, 141, 26, 8, 107], [74, 43, 26, 146, 73, 166, 49, 23, 157], [65, 38, 105, 160, 51, 52, 31, 115, 128], [104, 79, 12, 27, 217, 255, 87, 17, 7], [87, 68, 71, 44, 114, 51, 15, 186, 23], [47, 41, 14, 110, 182, 183, 21, 17, 194], [66, 45, 25, 102, 197, 189, 23, 18, 22]], [[88, 88, 147, 150, 42, 46, 45, 196, 205], [43, 97, 183, 117, 85, 38, 35, 179, 61], [39, 53, 200, 87, 26, 21, 43, 232, 171], [56, 34, 51, 104, 114, 102, 29, 93, 77], [39, 28, 85, 171, 58, 165, 90, 98, 64], [34, 22, 116, 206, 23, 34, 43, 166, 73], [107, 54, 32, 26, 51, 1, 81, 43, 31], [68, 25, 106, 22, 64, 171, 36, 225, 114], [34, 19, 21, 102, 132, 188, 16, 76, 124], [62, 18, 78, 95, 85, 57, 50, 48, 51]], [[193, 101, 35, 159, 215, 111, 89, 46, 111], [60, 148, 31, 172, 219, 228, 21, 18, 111], [112, 113, 77, 85, 179, 255, 38, 120, 114], [40, 42, 1, 196, 245, 209, 10, 25, 109], [88, 43, 29, 140, 166, 213, 37, 43, 154], [61, 63, 30, 155, 67, 45, 68, 1, 209], [100, 80, 8, 43, 154, 1, 51, 26, 71], [142, 78, 78, 16, 255, 128, 34, 197, 171], [41, 40, 5, 102, 211, 183, 4, 1, 221], [51, 50, 17, 168, 209, 192, 23, 25, 82]], [[138, 31, 36, 171, 27, 166, 38, 44, 229], [67, 87, 58, 169, 82, 115, 26, 59, 179], [63, 59, 90, 180, 59, 166, 93, 73, 154], [40, 40, 21, 116, 143, 209, 34, 39, 175], [47, 15, 16, 183, 34, 223, 49, 45, 183], [46, 17, 33, 183, 6, 98, 15, 32, 183], [57, 46, 22, 24, 128, 1, 54, 17, 37], [65, 32, 73, 115, 28, 128, 23, 128, 205], [40, 3, 9, 115, 51, 192, 18, 6, 223], [87, 37, 9, 115, 59, 77, 64, 21, 47]], [[104, 55, 44, 218, 9, 54, 53, 130, 226], [64, 90, 70, 205, 40, 41, 23, 26, 57], [54, 57, 112, 184, 5, 41, 38, 166, 213], [30, 34, 26, 133, 152, 116, 10, 32, 134], [39, 19, 53, 221, 26, 114, 32, 73, 255], [31, 9, 65, 234, 2, 15, 1, 118, 73], [75, 32, 12, 51, 192, 255, 160, 43, 51], [88, 31, 35, 67, 102, 85, 55, 186, 85], [56, 21, 23, 111, 59, 205, 45, 37, 192], [55, 38, 70, 124, 73, 102, 1, 34, 98]], [[125, 98, 42, 88, 104, 85, 117, 175, 82], [95, 84, 53, 89, 128, 100, 113, 101, 45], [75, 79, 123, 47, 51, 128, 81, 171, 1], [57, 17, 5, 71, 102, 57, 53, 41, 49], [38, 33, 13, 121, 57, 73, 26, 1, 85], [41, 10, 67, 138, 77, 110, 90, 47, 114], [115, 21, 2, 10, 102, 255, 166, 23, 6], [101, 29, 16, 10, 85, 128, 101, 196, 26], [57, 18, 10, 102, 102, 213, 34, 20, 43], [117, 20, 15, 36, 163, 128, 68, 1, 26]], [[102, 61, 71, 37, 34, 53, 31, 243, 192], [69, 60, 71, 38, 73, 119, 28, 222, 37], [68, 45, 128, 34, 1, 47, 11, 245, 171], [62, 17, 19, 70, 146, 85, 55, 62, 70], [37, 43, 37, 154, 100, 163, 85, 160, 1], [63, 9, 92, 136, 28, 64, 32, 201, 85], [75, 15, 9, 9, 64, 255, 184, 119, 16], [86, 6, 28, 5, 64, 255, 25, 248, 1], [56, 8, 17, 132, 137, 255, 55, 116, 128], [58, 15, 20, 82, 135, 57, 26, 121, 40]], [[164, 50, 31, 137, 154, 133, 25, 35, 218], [51, 103, 44, 131, 131, 123, 31, 6, 158], [86, 40, 64, 135, 148, 224, 45, 183, 128], [22, 26, 17, 131, 240, 154, 14, 1, 209], [45, 16, 21, 91, 64, 222, 7, 1, 197], [56, 21, 39, 155, 60, 138, 23, 102, 213], [83, 12, 13, 54, 192, 255, 68, 47, 28], [85, 26, 85, 85, 128, 128, 32, 146, 171], [18, 11, 7, 63, 144, 171, 4, 4, 246], [35, 27, 10, 146, 174, 171, 12, 26, 128]], [[190, 80, 35, 99, 180, 80, 126, 54, 45], [85, 126, 47, 87, 176, 51, 41, 20, 32], [101, 75, 128, 139, 118, 146, 116, 128, 85], [56, 41, 15, 176, 236, 85, 37, 9, 62], [71, 30, 17, 119, 118, 255, 17, 18, 138], [101, 38, 60, 138, 55, 70, 43, 26, 142], [146, 36, 19, 30, 171, 255, 97, 27, 20], [138, 45, 61, 62, 219, 1, 81, 188, 64], [32, 41, 20, 117, 151, 142, 20, 21, 163], [112, 19, 12, 61, 195, 128, 48, 4, 24]]], - Ee = [[[[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255], [223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255], [249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255], [234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255], [239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255], [250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255], [234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255]], [[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255]], [[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255], [249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255], [247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255], [250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255], [234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255], [251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255]], [[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255], [248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255], [246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255], [252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255]], [[255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255], [248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255]], [[255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255], [245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255], [252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255], [249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255], [250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]]], - Ge = [0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0], - Nc, - Y = [], - W = [], - ka = [], - Za, - fd, - Nb, - pa, - Ob, - Xc, - Tc, - Yc, - Uc, - Zc, - Vc, - $c, - Wc, - Rc, - Pc, - Sc, - Qc, - re = 1, - Cc = 2, - ia = [], - za, - vc, - fc, - Fc, - P = []; - va("UpsampleRgbLinePair", Ga, 3); - va("UpsampleBgrLinePair", Tb, 3); - va("UpsampleRgbaLinePair", wd, 4); - va("UpsampleBgraLinePair", vd, 4); - va("UpsampleArgbLinePair", ud, 4); - va("UpsampleRgba4444LinePair", td, 2); - va("UpsampleRgb565LinePair", sd, 2); - var Mf = UpsampleRgbLinePair, - Nf = UpsampleBgrLinePair, - nd = UpsampleRgbaLinePair, - od = UpsampleBgraLinePair, - pd = UpsampleArgbLinePair, - qd = UpsampleRgba4444LinePair, - Of = UpsampleRgb565LinePair, - Wa = 16, - Ba = 1 << Wa - 1, - ta = -227, - Eb = 482, - rd = 6, - Pf = (256 << rd) - 1, - jc = 0, - Yd = V(256), - ae = V(256), - $d = V(256), - Zd = V(256), - be = V(Eb - ta), - ce = V(Eb - ta); - la("YuvToRgbRow", Ga, 3); - la("YuvToBgrRow", Tb, 3); - la("YuvToRgbaRow", wd, 4); - la("YuvToBgraRow", vd, 4); - la("YuvToArgbRow", ud, 4); - la("YuvToRgba4444Row", td, 2); - la("YuvToRgb565Row", sd, 2); - var zd = [0, 4, 8, 12, 128, 132, 136, 140, 256, 260, 264, 268, 384, 388, 392, 396], - Ya = [0, 2, 8], - Qf = [8, 7, 6, 4, 4, 2, 2, 2, 1, 1, 1, 1], - Ne = 1; - - this.WebPDecodeRGBA = function (a, b, c, d, e) { - var f = Ua; - var g = new Cf(), - h = new Cb(); - g.ba = h; - h.S = f; - h.width = [h.width]; - h.height = [h.height]; - var k = h.width; - var l = h.height, - m = new Td(); - if (null == m || null == a) { var n = 2; }else { x(null != m), n = Ad(a, b, c, m.width, m.height, m.Pd, m.Qd, m.format, null); } - 0 != n ? k = 0 : (null != k && (k[0] = m.width[0]), null != l && (l[0] = m.height[0]), k = 1); - - if (k) { - h.width = h.width[0]; - h.height = h.height[0]; - null != d && (d[0] = h.width); - null != e && (e[0] = h.height); - - b: { - d = new Oa(); - e = new md(); - e.data = a; - e.w = b; - e.ha = c; - e.kd = 1; - b = [0]; - x(null != e); - a = Ad(e.data, e.w, e.ha, null, null, null, b, null, e); - (0 == a || 7 == a) && b[0] && (a = 4); - b = a; - - if (0 == b) { - x(null != g); - d.data = e.data; - d.w = e.w + e.offset; - d.ha = e.ha - e.offset; - d.put = kc; - d.ac = gc; - d.bc = lc; - d.ma = g; - - if (e.xa) { - a = Bc(); - - if (null == a) { - g = 1; - break b; - } - - if (te(a, d)) { - b = Cd(d.width, d.height, g.Oa, g.ba); - - if (d = 0 == b) { - c: { - d = a; - - d: for (;;) { - if (null == d) { - d = 0; - break c; - } - - x(null != d.s.yc); - x(null != d.s.Ya); - x(0 < d.s.Wb); - c = d.l; - x(null != c); - e = c.ma; - x(null != e); - - if (0 != d.xb) { - d.ca = e.ba; - d.tb = e.tb; - x(null != d.ca); - - if (!hc(e.Oa, c, Va)) { - d.a = 2; - break d; - } - - if (!Ec(d, c.width)) { break d; } - if (c.da) { break d; } - (c.da || hb(d.ca.S)) && Aa(); - 11 > d.ca.S || (alert("todo:WebPInitConvertARGBToYUV"), null != d.ca.f.kb.F && Aa()); - - if (d.Pb && 0 < d.s.ua && null == d.s.vb.X && !Zb(d.s.vb, d.s.Wa.Xa)) { - d.a = 1; - break d; - } - - d.xb = 0; - } - - if (!Jb(d, d.V, d.Ba, d.c, d.i, c.o, ge)) { break d; } - e.Dc = d.Ma; - d = 1; - break c; - } - - x(0 != d.a); - d = 0; - } - - d = !d; - } - - d && (b = a.a); - } else { b = a.a; } - } else { - a = new Ce(); - - if (null == a) { - g = 1; - break b; - } - - a.Fa = e.na; - a.P = e.P; - a.qc = e.Sa; - - if (Kc(a, d)) { - if (b = Cd(d.width, d.height, g.Oa, g.ba), 0 == b) { - a.Aa = 0; - c = g.Oa; - e = a; - x(null != e); - - if (null != c) { - k = c.Md; - k = 0 > k ? 0 : 100 < k ? 255 : 255 * k / 100; + this.data[location + 4] = rgb.blue; + this.data[location + 4 + 1] = rgb.green; + this.data[location + 4 + 2] = rgb.red; + this.data[location + 4 + 3] = 0xFF; + } - if (0 < k) { - for (l = m = 0; 4 > l; ++l) { - n = e.pb[l], 12 > n.lc && (n.ia = k * Qf[0 > n.lc ? 0 : n.lc] >> 3), m |= n.ia; - } + if (mode != 0) { + this.pos += 4 - mode; + } + } + }; - m && (alert("todo:VP8InitRandom"), e.ia = 1); - } + BmpDecoder.prototype.bit8 = function () { + var mode = this.width % 4; - e.Ga = c.Id; - 100 < e.Ga ? e.Ga = 100 : 0 > e.Ga && (e.Ga = 0); - } + for (var y = this.height - 1; y >= 0; y--) { + var line = this.bottom_up ? y : this.height - 1 - y; - Me(a, d) || (b = a.a); - } - } else { b = a.a; } - } + for (var x = 0; x < this.width; x++) { + var b = this.datav.getUint8(this.pos++, true); + var location = line * this.width * 4 + x * 4; - 0 == b && null != g.Oa && g.Oa.fd && (b = Bd(g.ba)); - } + if (b < this.palette.length) { + var rgb = this.palette[b]; + this.data[location] = rgb.red; + this.data[location + 1] = rgb.green; + this.data[location + 2] = rgb.blue; + this.data[location + 3] = 0xFF; + } else { + this.data[location] = 0xFF; + this.data[location + 1] = 0xFF; + this.data[location + 2] = 0xFF; + this.data[location + 3] = 0xFF; + } + } - g = b; - } + if (mode != 0) { + this.pos += 4 - mode; + } + } + }; - f = 0 != g ? null : 11 > f ? h.f.RGBA.eb : h.f.kb.y; - } else { f = null; } + BmpDecoder.prototype.bit15 = function () { + var dif_w = this.width % 3; - return f; - }; + var _11111 = parseInt("11111", 2), + _1_5 = _11111; - var Dd = [3, 4, 3, 4, 4, 2, 2, 4, 4, 4, 2, 1, 1]; - }; + for (var y = this.height - 1; y >= 0; y--) { + var line = this.bottom_up ? y : this.height - 1 - y; - new WebPDecoder(); - /*Copyright (c) 2017 Dominik Homberger - - - - https://webpjs.appspot.com - WebPRiffParser dominikhlbg@gmail.com - */ + for (var x = 0; x < this.width; x++) { + var B = this.datav.getUint16(this.pos, true); + this.pos += 2; + var blue = (B & _1_5) / _1_5 * 255 | 0; + var green = (B >> 5 & _1_5) / _1_5 * 255 | 0; + var red = (B >> 10 & _1_5) / _1_5 * 255 | 0; + var alpha = B >> 15 ? 0xFF : 0x00; + var location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } //skip extra bytes - function memcmp(data, data_off, str, size) { - for (var i = 0; i < size; i++) { - if (data[data_off + i] != str.charCodeAt(i)) { return true; } - } - return false; + this.pos += dif_w; } + }; - function GetTag(data, data_off) { - var str = ''; + BmpDecoder.prototype.bit16 = function () { + var dif_w = this.width % 3; - for (var i = 0; i < 4; i++) { - str += String.fromCharCode(data[data_off++]); - } + var _11111 = parseInt("11111", 2), + _1_5 = _11111; - return str; - } + var _111111 = parseInt("111111", 2), + _1_6 = _111111; - function GetLE16(data, data_off) { - return data[data_off + 0] << 0 | data[data_off + 1] << 8; - } + for (var y = this.height - 1; y >= 0; y--) { + var line = this.bottom_up ? y : this.height - 1 - y; - function GetLE24(data, data_off) { - return (data[data_off + 0] << 0 | data[data_off + 1] << 8 | data[data_off + 2] << 16) >>> 0; - } + for (var x = 0; x < this.width; x++) { + var B = this.datav.getUint16(this.pos, true); + this.pos += 2; + var alpha = 0xFF; + var blue = (B & _1_5) / _1_5 * 255 | 0; + var green = (B >> 5 & _1_6) / _1_6 * 255 | 0; + var red = (B >> 11) / _1_5 * 255 | 0; + var location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } //skip extra bytes - function GetLE32(data, data_off) { - return (data[data_off + 0] << 0 | data[data_off + 1] << 8 | data[data_off + 2] << 16 | data[data_off + 3] << 24) >>> 0; - } - function WebPRiffParser(src, src_off) { - var imagearray = {}; - var i = 0; - var alpha_chunk = false; - var alpha_size = 0; - var alpha_offset = 0; - imagearray['frames'] = []; - if (memcmp(src, src_off, 'RIFF', 4)) { return; } - src_off += 4; - var riff_size = GetLE32(src, src_off) + 8; - src_off += 8; - - while (src_off < src.length) { - var fourcc = GetTag(src, src_off); - src_off += 4; - var payload_size = GetLE32(src, src_off); - src_off += 4; - var payload_size_padded = payload_size + (payload_size & 1); - - switch (fourcc) { - case "VP8 ": - case "VP8L": - if (typeof imagearray['frames'][i] === 'undefined') { imagearray['frames'][i] = {}; } - var obj = imagearray['frames'][i]; - var height = [0]; - var width = [0]; - obj['src_off'] = alpha_chunk ? alpha_offset : src_off - 8; - obj['src_size'] = alpha_size + payload_size + 8; //var rgba = webpdecoder.WebPDecodeRGBA(src,(alpha_chunk?alpha_offset:src_off-8),alpha_size+payload_size+8,width,height); - //imagearray[i]={'rgba':rgba,'width':width[0],'height':height[0]}; + this.pos += dif_w; + } + }; - i++; + BmpDecoder.prototype.bit24 = function () { + //when height > 0 + for (var y = this.height - 1; y >= 0; y--) { + var line = this.bottom_up ? y : this.height - 1 - y; - if (alpha_chunk) { - alpha_chunk = false; - alpha_size = 0; - alpha_offset = 0; - } + for (var x = 0; x < this.width; x++) { + var blue = this.datav.getUint8(this.pos++, true); + var green = this.datav.getUint8(this.pos++, true); + var red = this.datav.getUint8(this.pos++, true); + var location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = 0xFF; + } //skip extra bytes - break; - case "VP8X": - var obj = imagearray['header'] = {}; - var feature_flags = obj['feature_flags'] = src[src_off]; - var src_off_ = src_off + 4; - var canvas_width = obj['canvas_width'] = 1 + GetLE24(src, src_off_); - src_off_ += 3; - var canvas_height = obj['canvas_height'] = 1 + GetLE24(src, src_off_); - src_off_ += 3; - break; + this.pos += this.width % 4; + } + }; + /** + * add 32bit decode func + * @author soubok + */ - case "ALPH": - alpha_chunk = true; - alpha_size = payload_size_padded + 8; - alpha_offset = src_off - 8; - break; - case "ANIM": - var obj = imagearray['header']; - var bgcolor = obj['bgcolor'] = GetLE32(src, src_off); - src_off_ = src_off + 4; - var loop_count = obj['loop_count'] = GetLE16(src, src_off_); - src_off_ += 2; - break; + BmpDecoder.prototype.bit32 = function () { + //when height > 0 + for (var y = this.height - 1; y >= 0; y--) { + var line = this.bottom_up ? y : this.height - 1 - y; - case "ANMF": - var offset_x = 0, - offset_y = 0, - width = 0, - height = 0, - duration = 0, - blend = 0, - dispose = 0, - temp = 0; - var obj = imagearray['frames'][i] = {}; - obj['offset_x'] = offset_x = 2 * GetLE24(src, src_off); - src_off += 3; - obj['offset_y'] = offset_y = 2 * GetLE24(src, src_off); - src_off += 3; - obj['width'] = width = 1 + GetLE24(src, src_off); - src_off += 3; - obj['height'] = height = 1 + GetLE24(src, src_off); - src_off += 3; - obj['duration'] = duration = GetLE24(src, src_off); - src_off += 3; - temp = src[src_off++]; - obj['dispose'] = dispose = temp & 1; - obj['blend'] = blend = temp >> 1 & 1; - break; + for (var x = 0; x < this.width; x++) { + var blue = this.datav.getUint8(this.pos++, true); + var green = this.datav.getUint8(this.pos++, true); + var red = this.datav.getUint8(this.pos++, true); + var alpha = this.datav.getUint8(this.pos++, true); + var location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } //skip extra bytes + //this.pos += (this.width % 4); - default: - } + } + }; - if (fourcc != "ANMF") { src_off += payload_size_padded; } - } + BmpDecoder.prototype.getData = function () { + return this.data; + }; + /*rollup-keeper-start*/ - return imagearray; - } - var height = [0]; - var width = [0]; - var pixels = []; - var webpdecoder = new WebPDecoder(); - var response = imageData; - var imagearray = WebPRiffParser(response, 0); - imagearray['response'] = response; - imagearray['rgbaoutput'] = true; - imagearray['dataurl'] = false; - var header = imagearray['header'] ? imagearray['header'] : null; - var frames = imagearray['frames'] ? imagearray['frames'] : null; - - if (header) { - header['loop_counter'] = header['loop_count']; - height = header['canvas_height']; - width = header['canvas_width']; - - for (var f = 0; f < frames.length; f++) { - if (frames[f]['blend'] == 0) { - break; - } - } - } + window.tmp = BmpDecoder; + /*rollup-keeper-end*/ - var frame = frames[0]; - var rgba = webpdecoder.WebPDecodeRGBA(response, frame['src_off'], frame['src_size'], width, height); - frame['rgba'] = rgba; - frame['imgwidth'] = width[0]; - frame['imgheight'] = height[0]; + /* + Copyright (c) 2013 Gildas Lormeau. All rights reserved. - for (var i = 0; i < width[0] * height[0] * 4; i++) { - pixels[i] = rgba[i]; - } + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - this.width = width; - this.height = height; - this.data = pixels; - return this; - } + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - WebPDecoder.prototype.getData = function () { - return this.data; - }; + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. - try { - exports.WebPDecoder = WebPDecoder; - } catch (e) {} // CommonJS. + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. - /* - Copyright (c) 2013 Gildas Lormeau. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, - INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* - * This program is based on JZlib 1.0.2 ymnk, JCraft,Inc. - * JZlib is based on zlib-1.1.3, so all credit should go authors - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) - * and contributors of zlib. + /* + * This program is based on JZlib 1.0.2 ymnk, JCraft,Inc. + * JZlib is based on zlib-1.1.3, so all credit should go authors + * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) + * and contributors of zlib. */ (function (global) { @@ -26225,17 +20472,17 @@ tree[n * 2 + 1] = bits; // We overwrite tree[n*2+1] which is no longer needed - if (n > that.max_code) { continue; } // not a leaf node + if (n > that.max_code) continue; // not a leaf node s.bl_count[bits]++; xbits = 0; - if (n >= base) { xbits = extra[n - base]; } + if (n >= base) xbits = extra[n - base]; f = tree[n * 2]; s.opt_len += f * (bits + xbits); - if (stree) { s.static_len += f * (stree[n * 2 + 1] + xbits); } + if (stree) s.static_len += f * (stree[n * 2 + 1] + xbits); } - if (overflow === 0) { return; } // This happens for example on obj2 and pic of the Calgary corpus + if (overflow === 0) return; // This happens for example on obj2 and pic of the Calgary corpus // Find the first bit length which could increase: do { @@ -26260,9 +20507,9 @@ while (n !== 0) { m = s.heap[--h]; - if (m > that.max_code) { continue; } + if (m > that.max_code) continue; - if (tree[m * 2 + 1] !== bits) { + if (tree[m * 2 + 1] != bits) { s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; tree[m * 2 + 1] = bits; } @@ -26316,14 +20563,14 @@ next_code[bits] = code = code + bl_count[bits - 1] << 1; } // Check that the bit counts in bl_count are consistent. The last code // must be all ones. - // Assert (code + bl_count[MAX_BITS]-1 === (1<= 3; max_blindex--) { - if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] !== 0) { break; } + if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] !== 0) break; } // Update opt_len to include the bit length tree and counts @@ -26886,14 +21133,14 @@ curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen === nextlen) { + if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(curlen, bl_tree); } while (--count !== 0); } else if (curlen !== 0) { - if (curlen !== prevlen) { + if (curlen != prevlen) { send_code(curlen, bl_tree); count--; } @@ -26914,7 +21161,7 @@ if (nextlen === 0) { max_count = 138; min_count = 3; - } else if (curlen === nextlen) { + } else if (curlen == nextlen) { max_count = 6; min_count = 3; } else { @@ -26946,7 +21193,7 @@ function bi_flush() { - if (bi_valid === 16) { + if (bi_valid == 16) { put_short(bi_buf); bi_buf = 0; bi_valid = 0; @@ -27016,10 +21263,10 @@ } out_length >>>= 3; - if (matches < Math.floor(last_lit / 2) && out_length < Math.floor(in_length / 2)) { return true; } + if (matches < Math.floor(last_lit / 2) && out_length < Math.floor(in_length / 2)) return true; } - return last_lit === lit_bufsize - 1; // We avoid equality with lit_bufsize because of wraparound at 64K + return last_lit == lit_bufsize - 1; // We avoid equality with lit_bufsize because of wraparound at 64K // on 16 bit machines and because stored blocks are restricted to // 64K-1 bytes. } // Send the block data compressed using the given Huffman trees @@ -27146,21 +21393,21 @@ opt_lenb = that.opt_len + 3 + 7 >>> 3; static_lenb = that.static_len + 3 + 7 >>> 3; - if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; } + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; } else { opt_lenb = static_lenb = stored_len + 5; // force a stored block } - if (stored_len + 4 <= opt_lenb && buf !== -1) { + if (stored_len + 4 <= opt_lenb && buf != -1) { // 4: two words for the lengths - // The test buf !== NULL is only necessary if LIT_BUFSIZE > WSIZE. + // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. // Otherwise we can't have processed more than WSIZE input bytes // since // the last block flush, because compression would have been // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to // transform a block into a stored block. _tr_stored_block(buf, stored_len, eof); - } else if (static_lenb === opt_lenb) { + } else if (static_lenb == opt_lenb) { send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); } else { @@ -27203,10 +21450,10 @@ if (more === 0 && strstart === 0 && lookahead === 0) { more = w_size; - } else if (more === -1) { + } else if (more == -1) { // Very unlikely, but possible on 16 bit machine if strstart == // 0 - // and lookahead === 1 (input done one byte at time) + // and lookahead == 1 (input done one byte at time) more--; // If the window is almost full and there is insufficient // lookahead, // move the upper half to the lower one to make room in the @@ -27244,15 +21491,15 @@ more += w_size; } - if (strm.avail_in === 0) { return; } // If there was no sliding: + if (strm.avail_in === 0) return; // If there was no sliding: // strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - // more === window_size - lookahead - strstart + // more == window_size - lookahead - strstart // => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) // => more >= window_size - 2*WSIZE + 2 // In the BIG_MEM or MMAP case (not yet supported), - // window_size === input_size + MIN_LOOKAHEAD && + // window_size == input_size + MIN_LOOKAHEAD && // strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - // Otherwise, window_size === 2*WSIZE so more >= 2. + // Otherwise, window_size == 2*WSIZE so more >= 2. // If there was sliding, more >= WSIZE. So in all cases, more >= 2. n = strm.read_buf(window, strstart + lookahead, more); @@ -27292,8 +21539,8 @@ // Fill the window as much as possible: if (lookahead <= 1) { fill_window(); - if (lookahead === 0 && flush === Z_NO_FLUSH) { return NeedMore; } - if (lookahead === 0) { break; } // flush the current block + if (lookahead === 0 && flush == Z_NO_FLUSH) return NeedMore; + if (lookahead === 0) break; // flush the current block } strstart += lookahead; @@ -27306,20 +21553,20 @@ lookahead = strstart - max_start; strstart = max_start; flush_block_only(false); - if (strm.avail_out === 0) { return NeedMore; } + if (strm.avail_out === 0) return NeedMore; } // Flush if we may have to slide, otherwise block_start may become // negative and the data will be gone: if (strstart - block_start >= w_size - MIN_LOOKAHEAD) { flush_block_only(false); - if (strm.avail_out === 0) { return NeedMore; } + if (strm.avail_out === 0) return NeedMore; } } - flush_block_only(flush === Z_FINISH); - if (strm.avail_out === 0) { return flush === Z_FINISH ? FinishStarted : NeedMore; } - return flush === Z_FINISH ? FinishDone : BlockDone; + flush_block_only(flush == Z_FINISH); + if (strm.avail_out === 0) return flush == Z_FINISH ? FinishStarted : NeedMore; + return flush == Z_FINISH ? FinishDone : BlockDone; } function longest_match(cur_match) { @@ -27352,13 +21599,13 @@ // to make deflate deterministic. - if (_nice_match > lookahead) { _nice_match = lookahead; } + if (_nice_match > lookahead) _nice_match = lookahead; do { match = cur_match; // Skip to next match if the match length cannot increase // or if the match length is less than 2: - if (window[match + best_len] !== scan_end || window[match + best_len - 1] !== scan_end1 || window[match] !== window[scan] || window[++match] !== window[scan + 1]) { continue; } // The check at best_len-1 can be removed because it will be made + if (window[match + best_len] != scan_end || window[match + best_len - 1] != scan_end1 || window[match] != window[scan] || window[++match] != window[scan + 1]) continue; // The check at best_len-1 can be removed because it will be made // again later. (This heuristic is not always a win.) // It is not necessary to compare scan[2] and match[2] since they // are always equal when the other bytes match, given that @@ -27368,7 +21615,7 @@ match++; // We check for insufficient lookahead only every 8th comparison; // the 256th check will be made at strstart+258. - do {} while (window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && window[++scan] === window[++match] && scan < strend); + do {} while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); len = MAX_MATCH - (strend - scan); scan = strend - MAX_MATCH; @@ -27376,13 +21623,13 @@ if (len > best_len) { match_start = cur_match; best_len = len; - if (len >= _nice_match) { break; } + if (len >= _nice_match) break; scan_end1 = window[scan + best_len - 1]; scan_end = window[scan + best_len]; } } while ((cur_match = prev[cur_match & wmask] & 0xffff) > limit && --chain_length !== 0); - if (best_len <= lookahead) { return best_len; } + if (best_len <= lookahead) return best_len; return lookahead; } // Compress as much as possible from the input stream, return the current // block state. @@ -27405,11 +21652,11 @@ if (lookahead < MIN_LOOKAHEAD) { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return NeedMore; } - if (lookahead === 0) { break; } // flush the current block + if (lookahead === 0) break; // flush the current block } // Insert the string window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: @@ -27428,7 +21675,7 @@ // To simplify the code, we prevent matches with the string // of window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy !== Z_HUFFMAN_ONLY) { + if (strategy != Z_HUFFMAN_ONLY) { match_length = longest_match(hash_head); } // longest_match() sets match_start @@ -27471,17 +21718,17 @@ if (bflush) { flush_block_only(false); - if (strm.avail_out === 0) { return NeedMore; } + if (strm.avail_out === 0) return NeedMore; } } - flush_block_only(flush === Z_FINISH); + flush_block_only(flush == Z_FINISH); if (strm.avail_out === 0) { - if (flush === Z_FINISH) { return FinishStarted; }else { return NeedMore; } + if (flush == Z_FINISH) return FinishStarted;else return NeedMore; } - return flush === Z_FINISH ? FinishDone : BlockDone; + return flush == Z_FINISH ? FinishDone : BlockDone; } // Same as above, but achieves better compression. We use a lazy // evaluation for matches: a match is finally adopted only if there is // no better match at the next window position. @@ -27503,11 +21750,11 @@ if (lookahead < MIN_LOOKAHEAD) { fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return NeedMore; } - if (lookahead === 0) { break; } // flush the current block + if (lookahead === 0) break; // flush the current block } // Insert the string window[strstart .. strstart+2] in the // dictionary, and set hash_head to the head of the hash chain: @@ -27529,12 +21776,12 @@ // To simplify the code, we prevent matches with the string // of window index 0 (in particular we have to avoid a match // of the string with itself at the start of the input file). - if (strategy !== Z_HUFFMAN_ONLY) { + if (strategy != Z_HUFFMAN_ONLY) { match_length = longest_match(hash_head); } // longest_match() sets match_start - if (match_length <= 5 && (strategy === Z_FILTERED || match_length === MIN_MATCH && strstart - match_start > 4096)) { + if (match_length <= 5 && (strategy == Z_FILTERED || match_length == MIN_MATCH && strstart - match_start > 4096)) { // If prev_match is also MIN_MATCH, match_start is garbage // but we will ignore the current match anyway. match_length = MIN_MATCH - 1; @@ -27571,7 +21818,7 @@ if (bflush) { flush_block_only(false); - if (strm.avail_out === 0) { return NeedMore; } + if (strm.avail_out === 0) return NeedMore; } } else if (match_available !== 0) { // If there was no match at the previous position, output a @@ -27585,7 +21832,7 @@ strstart++; lookahead--; - if (strm.avail_out === 0) { return NeedMore; } + if (strm.avail_out === 0) return NeedMore; } else { // There is no previous match to compare with, wait for // the next step to decide. @@ -27600,13 +21847,13 @@ match_available = 0; } - flush_block_only(flush === Z_FINISH); + flush_block_only(flush == Z_FINISH); if (strm.avail_out === 0) { - if (flush === Z_FINISH) { return FinishStarted; }else { return NeedMore; } + if (flush == Z_FINISH) return FinishStarted;else return NeedMore; } - return flush === Z_FINISH ? FinishDone : BlockDone; + return flush == Z_FINISH ? FinishDone : BlockDone; } function deflateReset(strm) { @@ -27623,19 +21870,19 @@ } that.deflateInit = function (strm, _level, bits, _method, memLevel, _strategy) { - if (!_method) { _method = Z_DEFLATED; } - if (!memLevel) { memLevel = DEF_MEM_LEVEL; } - if (!_strategy) { _strategy = Z_DEFAULT_STRATEGY; } // byte[] my_version=ZLIB_VERSION; + if (!_method) _method = Z_DEFLATED; + if (!memLevel) memLevel = DEF_MEM_LEVEL; + if (!_strategy) _strategy = Z_DEFAULT_STRATEGY; // byte[] my_version=ZLIB_VERSION; // - // if (!version || version[0] !== my_version[0] - // || stream_size !== sizeof(z_stream)) { + // if (!version || version[0] != my_version[0] + // || stream_size != sizeof(z_stream)) { // return Z_VERSION_ERROR; // } strm.msg = null; - if (_level === Z_DEFAULT_COMPRESSION) { _level = 6; } + if (_level == Z_DEFAULT_COMPRESSION) _level = 6; - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || _method !== Z_DEFLATED || bits < 9 || bits > 15 || _level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || _method != Z_DEFLATED || bits < 9 || bits > 15 || _level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { return Z_STREAM_ERROR; } @@ -27664,7 +21911,7 @@ }; that.deflateEnd = function () { - if (status !== INIT_STATE && status !== BUSY_STATE && status !== FINISH_STATE) { + if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE) { return Z_STREAM_ERROR; } // Deallocate in reverse order of allocations: @@ -27675,13 +21922,13 @@ window = null; // free that.dstate = null; - return status === BUSY_STATE ? Z_DATA_ERROR : Z_OK; + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; }; that.deflateParams = function (strm, _level, _strategy) { var err = Z_OK; - if (_level === Z_DEFAULT_COMPRESSION) { + if (_level == Z_DEFAULT_COMPRESSION) { _level = 6; } @@ -27689,12 +21936,12 @@ return Z_STREAM_ERROR; } - if (config_table[level].func !== config_table[_level].func && strm.total_in !== 0) { + if (config_table[level].func != config_table[_level].func && strm.total_in !== 0) { // Flush the last buffer: err = strm.deflate(Z_PARTIAL_FLUSH); } - if (level !== _level) { + if (level != _level) { level = _level; max_lazy_match = config_table[level].max_lazy; good_match = config_table[level].good_length; @@ -27710,8 +21957,8 @@ var length = dictLength; var n, index = 0; - if (!dictionary || status !== INIT_STATE) { return Z_STREAM_ERROR; } - if (length < MIN_MATCH) { return Z_OK; } + if (!dictionary || status != INIT_STATE) return Z_STREAM_ERROR; + if (length < MIN_MATCH) return Z_OK; if (length > w_size - MIN_LOOKAHEAD) { length = w_size - MIN_LOOKAHEAD; @@ -27743,7 +21990,7 @@ return Z_STREAM_ERROR; } - if (!_strm.next_out || !_strm.next_in && _strm.avail_in !== 0 || status === FINISH_STATE && flush !== Z_FINISH) { + if (!_strm.next_out || !_strm.next_in && _strm.avail_in !== 0 || status == FINISH_STATE && flush != Z_FINISH) { _strm.msg = z_errmsg[Z_NEED_DICT - Z_STREAM_ERROR]; return Z_STREAM_ERROR; } @@ -27758,12 +22005,12 @@ old_flush = last_flush; last_flush = flush; // Write the zlib header - if (status === INIT_STATE) { + if (status == INIT_STATE) { header = Z_DEFLATED + (w_bits - 8 << 4) << 8; level_flags = (level - 1 & 0xff) >> 1; - if (level_flags > 3) { level_flags = 3; } + if (level_flags > 3) level_flags = 3; header |= level_flags << 6; - if (strstart !== 0) { header |= PRESET_DICT; } + if (strstart !== 0) header |= PRESET_DICT; header += 31 - header % 31; status = BUSY_STATE; putShortMSB(header); @@ -27787,19 +22034,19 @@ // flushes. For repeated and useless calls with Z_FINISH, we keep // returning Z_STREAM_END instead of Z_BUFF_ERROR. - } else if (strm.avail_in === 0 && flush <= old_flush && flush !== Z_FINISH) { + } else if (strm.avail_in === 0 && flush <= old_flush && flush != Z_FINISH) { strm.msg = z_errmsg[Z_NEED_DICT - Z_BUF_ERROR]; return Z_BUF_ERROR; } // User must not provide more input after the first FINISH: - if (status === FINISH_STATE && strm.avail_in !== 0) { + if (status == FINISH_STATE && strm.avail_in !== 0) { _strm.msg = z_errmsg[Z_NEED_DICT - Z_BUF_ERROR]; return Z_BUF_ERROR; } // Start a new block or continue the current one. - if (strm.avail_in !== 0 || lookahead !== 0 || flush !== Z_NO_FLUSH && status !== FINISH_STATE) { + if (strm.avail_in !== 0 || lookahead !== 0 || flush != Z_NO_FLUSH && status != FINISH_STATE) { bstate = -1; switch (config_table[level].func) { @@ -27818,16 +22065,16 @@ default: } - if (bstate === FinishStarted || bstate === FinishDone) { + if (bstate == FinishStarted || bstate == FinishDone) { status = FINISH_STATE; } - if (bstate === NeedMore || bstate === FinishStarted) { + if (bstate == NeedMore || bstate == FinishStarted) { if (strm.avail_out === 0) { last_flush = -1; // avoid BUF_ERROR next call, see above } - return Z_OK; // If flush !== Z_NO_FLUSH && avail_out === 0, the next call + return Z_OK; // If flush != Z_NO_FLUSH && avail_out === 0, the next call // of deflate should use the same flush parameter to make sure // that the flush is complete. So we don't have to output an // empty block here, this will be done at next call. This also @@ -27835,8 +22082,8 @@ // one empty block. } - if (bstate === BlockDone) { - if (flush === Z_PARTIAL_FLUSH) { + if (bstate == BlockDone) { + if (flush == Z_PARTIAL_FLUSH) { _tr_align(); } else { // FULL_FLUSH or SYNC_FLUSH @@ -27844,7 +22091,7 @@ // as a special marker by inflate_sync(). - if (flush === Z_FULL_FLUSH) { + if (flush == Z_FULL_FLUSH) { // state.head[s.hash_size-1]=0; for (i = 0; i < hash_size /*-1*/ @@ -27865,7 +22112,7 @@ } } - if (flush !== Z_FINISH) { return Z_OK; } + if (flush != Z_FINISH) return Z_OK; return Z_STREAM_END; }; } // ZStream @@ -27892,7 +22139,7 @@ deflateInit: function deflateInit(level, bits) { var that = this; that.dstate = new Deflate(); - if (!bits) { bits = MAX_BITS; } + if (!bits) bits = MAX_BITS; return that.dstate.deflateInit(that, level, bits); }, deflate: function deflate(flush) { @@ -27906,19 +22153,19 @@ }, deflateEnd: function deflateEnd() { var that = this; - if (!that.dstate) { return Z_STREAM_ERROR; } + if (!that.dstate) return Z_STREAM_ERROR; var ret = that.dstate.deflateEnd(); that.dstate = null; return ret; }, deflateParams: function deflateParams(level, strategy) { var that = this; - if (!that.dstate) { return Z_STREAM_ERROR; } + if (!that.dstate) return Z_STREAM_ERROR; return that.dstate.deflateParams(that, level, strategy); }, deflateSetDictionary: function deflateSetDictionary(dictionary, dictLength) { var that = this; - if (!that.dstate) { return Z_STREAM_ERROR; } + if (!that.dstate) return Z_STREAM_ERROR; return that.dstate.deflateSetDictionary(that, dictionary, dictLength); }, // Read a new buffer from the current input stream, update the @@ -27929,8 +22176,8 @@ read_buf: function read_buf(buf, start, size) { var that = this; var len = that.avail_in; - if (len > size) { len = size; } - if (len === 0) { return 0; } + if (len > size) len = size; + if (len === 0) return 0; that.avail_in -= len; buf.set(that.next_in.subarray(that.next_in_index, that.next_in_index + len), start); that.next_in_index += len; @@ -27944,8 +22191,8 @@ flush_pending: function flush_pending() { var that = this; var len = that.dstate.pending; - if (len > that.avail_out) { len = that.avail_out; } - if (len === 0) { return; } // if (that.dstate.pending_buf.length <= that.dstate.pending_out || that.next_out.length <= that.next_out_index + if (len > that.avail_out) len = that.avail_out; + if (len === 0) return; // if (that.dstate.pending_buf.length <= that.dstate.pending_out || that.next_out.length <= that.next_out_index // || that.dstate.pending_buf.length < (that.dstate.pending_out + len) || that.next_out.length < (that.next_out_index + // len)) { // console.log(that.dstate.pending_buf.length + ", " + that.dstate.pending_out + ", " + that.next_out.length + ", " + @@ -27973,7 +22220,7 @@ var flush = Z_NO_FLUSH; var buf = new Uint8Array(bufsize); var level = options ? options.level : Z_DEFAULT_COMPRESSION; - if (typeof level === "undefined") { level = Z_DEFAULT_COMPRESSION; } + if (typeof level == "undefined") level = Z_DEFAULT_COMPRESSION; z.deflateInit(level); z.next_out = buf; @@ -27984,7 +22231,7 @@ bufferIndex = 0, bufferSize = 0, array; - if (!data.length) { return; } + if (!data.length) return; z.next_in_index = 0; z.next_in = data; z.avail_in = data.length; @@ -27993,11 +22240,11 @@ z.next_out_index = 0; z.avail_out = bufsize; err = z.deflate(flush); - if (err !== Z_OK) { throw new Error("deflating: " + z.msg); } - if (z.next_out_index) { if (z.next_out_index === bufsize) { buffers.push(new Uint8Array(buf)); }else { buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); } } + if (err != Z_OK) throw new Error("deflating: " + z.msg); + if (z.next_out_index) if (z.next_out_index == bufsize) buffers.push(new Uint8Array(buf));else buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); bufferSize += z.next_out_index; - if (onprogress && z.next_in_index > 0 && z.next_in_index !== lastIndex) { + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { onprogress(z.next_in_index); lastIndex = z.next_in_index; } @@ -28022,8 +22269,8 @@ z.next_out_index = 0; z.avail_out = bufsize; err = z.deflate(Z_FINISH); - if (err !== Z_STREAM_END && err !== Z_OK) { throw new Error("deflating: " + z.msg); } - if (bufsize - z.avail_out > 0) { buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); } + if (err != Z_STREAM_END && err != Z_OK) throw new Error("deflating: " + z.msg); + if (bufsize - z.avail_out > 0) buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); bufferSize += z.next_out_index; } while (z.avail_in > 0 || z.avail_out === 0); @@ -28044,11 +22291,11 @@ // while `this` is nsIContentFrameMessageManager // with an attribute `content` that corresponds to the window - /** - * A class to parse color values - * @author Stoyan Stefanov - * {@link http://www.phpied.com/rgb-color-parser-in-javascript/} - * @license Use it if you like it + /** + * A class to parse color values + * @author Stoyan Stefanov + * {@link http://www.phpied.com/rgb-color-parser-in-javascript/} + * @license Use it if you like it */ (function (global) { @@ -28211,7 +22458,14 @@ yellow: 'ffff00', yellowgreen: '9acd32' }; - color_string = simple_colors[color_string] || color_string; // array of color definition objects + + for (var key in simple_colors) { + if (color_string == key) { + color_string = simple_colors[key]; + } + } // emd of simple type-in colors + // array of color definition objects + var color_defs = [{ re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, @@ -28260,9 +22514,9 @@ var r = this.r.toString(16); var g = this.g.toString(16); var b = this.b.toString(16); - if (r.length == 1) { r = '0' + r; } - if (g.length == 1) { g = '0' + g; } - if (b.length == 1) { b = '0' + b; } + if (r.length == 1) r = '0' + r; + if (g.length == 1) g = '0' + g; + if (b.length == 1) b = '0' + b; return '#' + r + g + b; }; } @@ -28272,14 +22526,14 @@ // while `this` is nsIContentFrameMessageManager // with an attribute `content` that corresponds to the window - /************************************************ - * Title : custom font * - * Start Data : 2017. 01. 22. * - * Comment : TEXT API * + /************************************************ + * Title : custom font * + * Start Data : 2017. 01. 22. * + * Comment : TEXT API * ************************************************/ - /****************************** - * jsPDF extension API Design * + /****************************** + * jsPDF extension API Design * * ****************************/ (function (jsPDF) { @@ -28355,15 +22609,15 @@ var decode = function decode(elt) { var code = elt.charCodeAt(0); - if (code === PLUS || code === PLUS_URL_SAFE) { return 62; } // '+' + if (code === PLUS || code === PLUS_URL_SAFE) return 62; // '+' - if (code === SLASH || code === SLASH_URL_SAFE) { return 63; } // '/' + if (code === SLASH || code === SLASH_URL_SAFE) return 63; // '/' - if (code < NUMBER) { return -1; } //no match + if (code < NUMBER) return -1; //no match - if (code < NUMBER + 10) { return code - NUMBER + 26 + 26; } - if (code < UPPER + 26) { return code - UPPER; } - if (code < LOWER + 26) { return code - LOWER + 26; } + if (code < NUMBER + 10) return code - NUMBER + 26 + 26; + if (code < UPPER + 26) return code - UPPER; + if (code < LOWER + 26) return code - LOWER + 26; }; jsPDF.API.TTFFont = function () { @@ -28672,9 +22926,9 @@ return _results; }; - /*Data.prototype.stringAt = function (pos, length) { - this.pos = pos; - return this.readString(length); + /*Data.prototype.stringAt = function (pos, length) { + this.pos = pos; + return this.readString(length); };*/ @@ -28725,8 +22979,8 @@ Data.prototype.writeInt = function (val) { return this.writeInt32(val); }; - /*Data.prototype.slice = function (start, end) { - return this.data.slice(start, end); + /*Data.prototype.slice = function (start, end) { + return this.data.slice(start, end); };*/ @@ -28878,7 +23132,7 @@ __hasProp = {}.hasOwnProperty, __extends = function __extends(child, parent) { for (var key in parent) { - if (__hasProp.call(parent, key)) { child[key] = parent[key]; } + if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { @@ -29371,26 +23625,26 @@ this.metricDataFormat = data.readShort(); return this.numberOfMetrics = data.readUInt16(); }; - /*HheaTable.prototype.encode = function (ids) { - var i, table, _i, _ref; - table = new Data; - table.writeInt(this.version); - table.writeShort(this.ascender); - table.writeShort(this.decender); - table.writeShort(this.lineGap); - table.writeShort(this.advanceWidthMax); - table.writeShort(this.minLeftSideBearing); - table.writeShort(this.minRightSideBearing); - table.writeShort(this.xMaxExtent); - table.writeShort(this.caretSlopeRise); - table.writeShort(this.caretSlopeRun); - table.writeShort(this.caretOffset); - for (i = _i = 0, _ref = 4 * 2; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { - table.writeByte(0); - } - table.writeShort(this.metricDataFormat); - table.writeUInt16(ids.length); - return table.data; + /*HheaTable.prototype.encode = function (ids) { + var i, table, _i, _ref; + table = new Data; + table.writeInt(this.version); + table.writeShort(this.ascender); + table.writeShort(this.decender); + table.writeShort(this.lineGap); + table.writeShort(this.advanceWidthMax); + table.writeShort(this.minLeftSideBearing); + table.writeShort(this.minRightSideBearing); + table.writeShort(this.xMaxExtent); + table.writeShort(this.caretSlopeRise); + table.writeShort(this.caretSlopeRun); + table.writeShort(this.caretOffset); + for (i = _i = 0, _ref = 4 * 2; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { + table.writeByte(0); + } + table.writeShort(this.metricDataFormat); + table.writeUInt16(ids.length); + return table.data; };*/ @@ -29483,8 +23737,8 @@ } } }; - /*OS2Table.prototype.encode = function () { - return this.raw(); + /*OS2Table.prototype.encode = function () { + return this.raw(); };*/ @@ -29655,52 +23909,52 @@ this.compatibleFull = strings[18]; return this.sampleText = strings[19]; }; - /*NameTable.prototype.encode = function () { - var id, list, nameID, nameTable, postscriptName, strCount, strTable, string, strings, table, val, _i, _len, _ref; - strings = {}; - _ref = this.strings; - for (id in _ref) { - val = _ref[id]; - strings[id] = val; - } - postscriptName = new NameEntry("" + subsetTag + "+" + this.postscriptName, { - platformID: 1 - , encodingID: 0 - , languageID: 0 - }); - strings[6] = [postscriptName]; - subsetTag = successorOf(subsetTag); - strCount = 0; - for (id in strings) { - list = strings[id]; - if (list != null) { - strCount += list.length; - } - } - table = new Data; - strTable = new Data; - table.writeShort(0); - table.writeShort(strCount); - table.writeShort(6 + 12 * strCount); - for (nameID in strings) { - list = strings[nameID]; - if (list != null) { - for (_i = 0, _len = list.length; _i < _len; _i++) { - string = list[_i]; - table.writeShort(string.platformID); - table.writeShort(string.encodingID); - table.writeShort(string.languageID); - table.writeShort(nameID); - table.writeShort(string.length); - table.writeShort(strTable.pos); - strTable.writeString(string.raw); - } - } - } - return nameTable = { - postscriptName: postscriptName.raw - , table: table.data.concat(strTable.data) - }; + /*NameTable.prototype.encode = function () { + var id, list, nameID, nameTable, postscriptName, strCount, strTable, string, strings, table, val, _i, _len, _ref; + strings = {}; + _ref = this.strings; + for (id in _ref) { + val = _ref[id]; + strings[id] = val; + } + postscriptName = new NameEntry("" + subsetTag + "+" + this.postscriptName, { + platformID: 1 + , encodingID: 0 + , languageID: 0 + }); + strings[6] = [postscriptName]; + subsetTag = successorOf(subsetTag); + strCount = 0; + for (id in strings) { + list = strings[id]; + if (list != null) { + strCount += list.length; + } + } + table = new Data; + strTable = new Data; + table.writeShort(0); + table.writeShort(strCount); + table.writeShort(6 + 12 * strCount); + for (nameID in strings) { + list = strings[nameID]; + if (list != null) { + for (_i = 0, _len = list.length; _i < _len; _i++) { + string = list[_i]; + table.writeShort(string.platformID); + table.writeShort(string.encodingID); + table.writeShort(string.languageID); + table.writeShort(nameID); + table.writeShort(string.length); + table.writeShort(strTable.pos); + strTable.writeString(string.raw); + } + } + } + return nameTable = { + postscriptName: postscriptName.raw + , table: table.data.concat(strTable.data) + }; };*/ return NameTable; @@ -29733,25 +23987,25 @@ this.maxComponentElements = data.readUInt16(); return this.maxComponentDepth = data.readUInt16(); }; - /*MaxpTable.prototype.encode = function (ids) { - var table; - table = new Data; - table.writeInt(this.version); - table.writeUInt16(ids.length); - table.writeUInt16(this.maxPoints); - table.writeUInt16(this.maxContours); - table.writeUInt16(this.maxCompositePoints); - table.writeUInt16(this.maxComponentContours); - table.writeUInt16(this.maxZones); - table.writeUInt16(this.maxTwilightPoints); - table.writeUInt16(this.maxStorage); - table.writeUInt16(this.maxFunctionDefs); - table.writeUInt16(this.maxInstructionDefs); - table.writeUInt16(this.maxStackElements); - table.writeUInt16(this.maxSizeOfInstructions); - table.writeUInt16(this.maxComponentElements); - table.writeUInt16(this.maxComponentDepth); - return table.data; + /*MaxpTable.prototype.encode = function (ids) { + var table; + table = new Data; + table.writeInt(this.version); + table.writeUInt16(ids.length); + table.writeUInt16(this.maxPoints); + table.writeUInt16(this.maxContours); + table.writeUInt16(this.maxCompositePoints); + table.writeUInt16(this.maxComponentContours); + table.writeUInt16(this.maxZones); + table.writeUInt16(this.maxTwilightPoints); + table.writeUInt16(this.maxStorage); + table.writeUInt16(this.maxFunctionDefs); + table.writeUInt16(this.maxInstructionDefs); + table.writeUInt16(this.maxStackElements); + table.writeUInt16(this.maxSizeOfInstructions); + table.writeUInt16(this.maxComponentElements); + table.writeUInt16(this.maxComponentDepth); + return table.data; };*/ @@ -29839,16 +24093,16 @@ lsb: this.leftSideBearings[id - this.metrics.length] }; }; - /*HmtxTable.prototype.encode = function (mapping) { - var id, metric, table, _i, _len; - table = new Data; - for (_i = 0, _len = mapping.length; _i < _len; _i++) { - id = mapping[_i]; - metric = this.forGlyph(id); - table.writeUInt16(metric.advance); - table.writeUInt16(metric.lsb); - } - return table.data; + /*HmtxTable.prototype.encode = function (mapping) { + var id, metric, table, _i, _len; + table = new Data; + for (_i = 0, _len = mapping.length; _i < _len; _i++) { + id = mapping[_i]; + metric = this.forGlyph(id); + table.writeUInt16(metric.advance); + table.writeUInt16(metric.lsb); + } + return table.data; };*/ @@ -30135,51 +24389,51 @@ return ret; }; - /*var successorOf = function (input) { - var added, alphabet, carry, i, index, isUpperCase, last, length, next, result; - alphabet = 'abcdefghijklmnopqrstuvwxyz'; - length = alphabet.length; - result = input; - i = input.length; - while (i >= 0) { - last = input.charAt(--i); - if (isNaN(last)) { - index = alphabet.indexOf(last.toLowerCase()); - if (index === -1) { - next = last; - carry = true; - } - else { - next = alphabet.charAt((index + 1) % length); - isUpperCase = last === last.toUpperCase(); - if (isUpperCase) { - next = next.toUpperCase(); - } - carry = index + 1 >= length; - if (carry && i === 0) { - added = isUpperCase ? 'A' : 'a'; - result = added + next + result.slice(1); - break; - } - } - } - else { - next = +last + 1; - carry = next > 9; - if (carry) { - next = 0; - } - if (carry && i === 0) { - result = '1' + next + result.slice(1); - break; - } - } - result = result.slice(0, i) + next + result.slice(i + 1); - if (!carry) { - break; - } - } - return result; + /*var successorOf = function (input) { + var added, alphabet, carry, i, index, isUpperCase, last, length, next, result; + alphabet = 'abcdefghijklmnopqrstuvwxyz'; + length = alphabet.length; + result = input; + i = input.length; + while (i >= 0) { + last = input.charAt(--i); + if (isNaN(last)) { + index = alphabet.indexOf(last.toLowerCase()); + if (index === -1) { + next = last; + carry = true; + } + else { + next = alphabet.charAt((index + 1) % length); + isUpperCase = last === last.toUpperCase(); + if (isUpperCase) { + next = next.toUpperCase(); + } + carry = index + 1 >= length; + if (carry && i === 0) { + added = isUpperCase ? 'A' : 'a'; + result = added + next + result.slice(1); + break; + } + } + } + else { + next = +last + 1; + carry = next > 9; + if (carry) { + next = 0; + } + if (carry && i === 0) { + result = '1' + next + result.slice(1); + break; + } + } + result = result.slice(0, i) + next + result.slice(i + 1); + if (!carry) { + break; + } + } + return result; };*/ @@ -30190,28 +24444,28 @@ this.unicodes = {}; this.next = 33; } - /*Subset.prototype.use = function (character) { - var i, _i, _ref; - if (typeof character === 'string') { - for (i = _i = 0, _ref = character.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { - this.use(character.charCodeAt(i)); - } - return; - } - if (!this.unicodes[character]) { - this.subset[this.next] = character; - return this.unicodes[character] = this.next++; - } + /*Subset.prototype.use = function (character) { + var i, _i, _ref; + if (typeof character === 'string') { + for (i = _i = 0, _ref = character.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { + this.use(character.charCodeAt(i)); + } + return; + } + if (!this.unicodes[character]) { + this.subset[this.next] = character; + return this.unicodes[character] = this.next++; + } };*/ - /*Subset.prototype.encodeText = function (text) { - var char, i, string, _i, _ref; - string = ''; - for (i = _i = 0, _ref = text.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { - char = this.unicodes[text.charCodeAt(i)]; - string += String.fromCharCode(char); - } - return string; + /*Subset.prototype.encodeText = function (text) { + var char, i, string, _i, _ref; + string = ''; + for (i = _i = 0, _ref = text.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { + char = this.unicodes[text.charCodeAt(i)]; + string += String.fromCharCode(char); + } + return string; };*/ /***************************************************************/ @@ -30237,19 +24491,19 @@ return mapping; }; - /*Subset.prototype.glyphIDs = function () { - var ret, roman, unicode, unicodeCmap, val, _ref; - unicodeCmap = this.font.cmap.tables[0].codeMap; - ret = [0]; - _ref = this.subset; - for (roman in _ref) { - unicode = _ref[roman]; - val = unicodeCmap[unicode]; - if ((val != null) && __indexOf.call(ret, val) < 0) { - ret.push(val); - } - } - return ret.sort(); + /*Subset.prototype.glyphIDs = function () { + var ret, roman, unicode, unicodeCmap, val, _ref; + unicodeCmap = this.font.cmap.tables[0].codeMap; + ret = [0]; + _ref = this.subset; + for (roman in _ref) { + unicode = _ref[roman]; + val = unicodeCmap[unicode]; + if ((val != null) && __indexOf.call(ret, val) < 0) { + ret.push(val); + } + } + return ret.sort(); };*/ /******************************************************************/ @@ -30428,15 +24682,14 @@ }(); })(jsPDF); - /* global FlateStream */ // Generated by CoffeeScript 1.4.0 - /* - # PNG.js - # Copyright (c) 2011 Devon Govett - # MIT LICENSE - # - # + /* + # PNG.js + # Copyright (c) 2011 Devon Govett + # MIT LICENSE + # + # */ (function (global) { var PNG; @@ -30565,9 +24818,9 @@ case 3: palLen = this.palette.length / 3; this.transparency.indexed = this.read(chunkSize); - if (this.transparency.indexed.length > palLen) { throw new Error('More transparent colors than palette size'); } - /* - * According to the PNG spec trns should be increased to the same size as palette if shorter + if (this.transparency.indexed.length > palLen) throw new Error('More transparent colors than palette size'); + /* + * According to the PNG spec trns should be increased to the same size as palette if shorter */ //palShort = 255 - this.transparency.indexed.length; @@ -30643,6 +24896,8 @@ throw new Error("Incomplete or corrupt PNG file"); } } + + return; } PNG.prototype.read = function (bytes) { @@ -30795,22 +25050,22 @@ } if (_this.interlaceMethod == 1) { - /* - 1 6 4 6 2 6 4 6 - 7 7 7 7 7 7 7 7 - 5 6 5 6 5 6 5 6 - 7 7 7 7 7 7 7 7 - 3 6 4 6 3 6 4 6 - 7 7 7 7 7 7 7 7 - 5 6 5 6 5 6 5 6 - 7 7 7 7 7 7 7 7 + /* + 1 6 4 6 2 6 4 6 + 7 7 7 7 7 7 7 7 + 5 6 5 6 5 6 5 6 + 7 7 7 7 7 7 7 7 + 3 6 4 6 3 6 4 6 + 7 7 7 7 7 7 7 7 + 5 6 5 6 5 6 5 6 + 7 7 7 7 7 7 7 7 */ pass(0, 0, 8, 8); // 1 - /* NOTE these seem to follow the pattern: - * pass(x, 0, 2*x, 2*x); - * pass(0, x, x, 2*x); - * with x being 4, 2, 1. + /* NOTE these seem to follow the pattern: + * pass(x, 0, 2*x, 2*x); + * pass(0, x, x, 2*x); + * with x being 4, 2, 1. */ pass(4, 0, 8, 8); // 2 @@ -30841,7 +25096,7 @@ length = palette.length; c = 0; - for (i = _i = 0, _ref = length; _i < _ref; i = _i += 3) { + for (i = _i = 0, _ref = palette.length; _i < _ref; i = _i += 3) { ret[pos++] = palette[i]; ret[pos++] = palette[i + 1]; ret[pos++] = palette[i + 2]; @@ -31022,20 +25277,20 @@ // while `this` is nsIContentFrameMessageManager // with an attribute `content` that corresponds to the window - /* - * Extracted from pdf.js - * https://github.com/andreasgal/pdf.js - * - * Copyright (c) 2011 Mozilla Foundation - * - * Contributors: Andreas Gal - * Chris G Jones - * Shaon Barman - * Vivien Nicolas <21@vingtetun.org> - * Justin D'Arcangelo - * Yury Delendik - * - * + /* + * Extracted from pdf.js + * https://github.com/andreasgal/pdf.js + * + * Copyright (c) 2011 Mozilla Foundation + * + * Contributors: Andreas Gal + * Chris G Jones + * Shaon Barman + * Vivien Nicolas <21@vingtetun.org> + * Justin D'Arcangelo + * Yury Delendik + * + * */ var DecodeStream = function () { function constructor() { @@ -31049,7 +25304,7 @@ ensureBuffer: function decodestream_ensureBuffer(requested) { var buffer = this.buffer; var current = buffer ? buffer.byteLength : 0; - if (requested < current) { return buffer; } + if (requested < current) return buffer; var size = 512; while (size < requested) { @@ -31068,7 +25323,7 @@ var pos = this.pos; while (this.bufferLength <= pos) { - if (this.eof) { return null; } + if (this.eof) return null; this.readBlock(); } @@ -31086,7 +25341,7 @@ } var bufEnd = this.bufferLength; - if (end > bufEnd) { end = bufEnd; } + if (end > bufEnd) end = bufEnd; } else { while (!this.eof) { this.readBlock(); @@ -31102,7 +25357,7 @@ var pos = this.pos; while (this.bufferLength <= pos) { - if (this.eof) { return null; } + if (this.eof) return null; this.readBlock(); } @@ -31112,7 +25367,7 @@ var pos = this.pos; while (this.bufferLength <= pos) { - if (this.eof) { return null; } + if (this.eof) return null; this.readBlock(); } @@ -31128,7 +25383,7 @@ return new Stream(this.buffer, start, length, dict); }, skip: function decodestream_skip(n) { - if (!n) { n = 1; } + if (!n) n = 1; this.pos += n; }, reset: function decodestream_reset() { @@ -31158,10 +25413,10 @@ var bytesPos = 0; var cmf = bytes[bytesPos++]; var flg = bytes[bytesPos++]; - if (cmf == -1 || flg == -1) { error('Invalid header in flate stream'); } - if ((cmf & 0x0f) != 0x08) { error('Unknown compression method in flate stream'); } - if (((cmf << 8) + flg) % 31 != 0) { error('Bad FCHECK in flate stream'); } - if (flg & 0x20) { error('FDICT bit set in flate stream'); } + if (cmf == -1 || flg == -1) error('Invalid header in flate stream'); + if ((cmf & 0x0f) != 0x08) error('Unknown compression method in flate stream'); + if (((cmf << 8) + flg) % 31 != 0) error('Bad FCHECK in flate stream'); + if (flg & 0x20) error('FDICT bit set in flate stream'); this.bytes = bytes; this.bytesPos = bytesPos; this.codeSize = 0; @@ -31179,7 +25434,7 @@ var b; while (codeSize < bits) { - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad encoding in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad encoding in flate stream'); codeBuf |= b << codeSize; codeSize += 8; } @@ -31201,7 +25456,7 @@ while (codeSize < maxLen) { var b; - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad encoding in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad encoding in flate stream'); codeBuf |= b << codeSize; codeSize += 8; } @@ -31209,7 +25464,7 @@ var code = codes[codeBuf & (1 << maxLen) - 1]; var codeLen = code >> 16; var codeVal = code & 0xffff; - if (codeSize == 0 || codeSize < codeLen || codeLen == 0) { error('Bad encoding in flate stream'); } + if (codeSize == 0 || codeSize < codeLen || codeLen == 0) error('Bad encoding in flate stream'); this.codeBuf = codeBuf >> codeLen; this.codeSize = codeSize - codeLen; this.bytesPos = bytesPos; @@ -31222,7 +25477,7 @@ var maxLen = 0; for (var i = 0; i < n; ++i) { - if (lengths[i] > maxLen) { maxLen = lengths[i]; } + if (lengths[i] > maxLen) maxLen = lengths[i]; } // build the table @@ -31265,7 +25520,7 @@ var hdr = this.getBits(3); - if (hdr & 1) { this.eof = true; } + if (hdr & 1) this.eof = true; hdr >>= 1; if (hdr == 0) { @@ -31273,15 +25528,15 @@ var bytes = this.bytes; var bytesPos = this.bytesPos; var b; - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad block header in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad block header in flate stream'); var blockLen = b; - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad block header in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad block header in flate stream'); blockLen |= b << 8; - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad block header in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad block header in flate stream'); var check = b; - if (typeof (b = bytes[bytesPos++]) == 'undefined') { error('Bad block header in flate stream'); } + if (typeof (b = bytes[bytesPos++]) == 'undefined') error('Bad block header in flate stream'); check |= b << 8; - if (check != (~blockLen & 0xffff)) { error('Bad uncompressed block length in flate stream'); } + if (check != (~blockLen & 0xffff)) error('Bad uncompressed block length in flate stream'); this.codeBuf = 0; this.codeSize = 0; var bufferLength = this.bufferLength; @@ -31374,12 +25629,12 @@ code1 -= 257; code1 = lengthDecode[code1]; var code2 = code1 >> 16; - if (code2 > 0) { code2 = this.getBits(code2); } + if (code2 > 0) code2 = this.getBits(code2); var len = (code1 & 0xffff) + code2; code1 = this.getCode(distCodeTable); code1 = distDecode[code1]; code2 = code1 >> 16; - if (code2 > 0) { code2 = this.getBits(code2); } + if (code2 > 0) code2 = this.getBits(code2); var dist = (code1 & 0xffff) + code2; if (pos + len >= limit) { @@ -31395,186 +25650,11 @@ return constructor; }(); + /*rollup-keeper-start*/ - (function (global, factory) { - if (typeof define === "function" && define.amd) { - define([], factory); - } else if (typeof exports !== "undefined") { - factory(); - } else { - var mod = { - exports: {} - }; - factory(); - global.FileSaver = mod.exports; - } - })(window, function () { - /* - * FileSaver.js - * A saveAs() FileSaver implementation. - * - * By Eli Grey, http://eligrey.com - * - * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT) - * source : http://purl.eligrey.com/github/FileSaver.js - */ - // The one and only way of getting global scope in all environments - // https://stackoverflow.com/q/3277182/1008999 - - var _global = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.window === window ? window : (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self ? self : (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global ? global : void 0; - - function bom(blob, opts) { - if (typeof opts === 'undefined') { opts = { - autoBom: false - }; }else if (_typeof(opts) !== 'object') { - console.warn('Deprecated: Expected third argument to be a object'); - opts = { - autoBom: !opts - }; - } // prepend BOM for UTF-8 XML and text/* types (including HTML) - // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF - - if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { - return new Blob([String.fromCharCode(0xFEFF), blob], { - type: blob.type - }); - } - - return blob; - } - - function download(url, name, opts) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url); - xhr.responseType = 'blob'; - - xhr.onload = function () { - saveAs(xhr.response, name, opts); - }; - - xhr.onerror = function () { - console.error('could not download file'); - }; - - xhr.send(); - } - - function corsEnabled(url) { - var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker - - xhr.open('HEAD', url, false); - xhr.send(); - return xhr.status >= 200 && xhr.status <= 299; - } // `a.click()` doesn't work for all browsers (#465) - - - function click(node) { - try { - node.dispatchEvent(new MouseEvent('click')); - } catch (e) { - var evt = document.createEvent('MouseEvents'); - evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); - node.dispatchEvent(evt); - } - } - - var saveAs = _global.saveAs || ( // probably in some web worker - (typeof window === "undefined" ? "undefined" : _typeof(window)) !== 'object' || window !== _global ? function saveAs() {} - /* noop */ - // Use download attribute first if possible (#193 Lumia mobile) - : 'download' in HTMLAnchorElement.prototype ? function saveAs(blob, name, opts) { - var URL = _global.URL || _global.webkitURL; - var a = document.createElement('a'); - name = name || blob.name || 'download'; - a.download = name; - a.rel = 'noopener'; // tabnabbing - // TODO: detect chrome extensions & packaged apps - // a.target = '_blank' - - if (typeof blob === 'string') { - // Support regular links - a.href = blob; - - if (a.origin !== location.origin) { - corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank'); - } else { - click(a); - } - } else { - // Support blobs - a.href = URL.createObjectURL(blob); - setTimeout(function () { - URL.revokeObjectURL(a.href); - }, 4E4); // 40s - - setTimeout(function () { - click(a); - }, 0); - } - } // Use msSaveOrOpenBlob as a second approach - : 'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) { - name = name || blob.name || 'download'; - - if (typeof blob === 'string') { - if (corsEnabled(blob)) { - download(blob, name, opts); - } else { - var a = document.createElement('a'); - a.href = blob; - a.target = '_blank'; - setTimeout(function () { - click(a); - }); - } - } else { - navigator.msSaveOrOpenBlob(bom(blob, opts), name); - } - } // Fallback to using FileReader and a popup - : function saveAs(blob, name, opts, popup) { - // Open a popup immediately do go around popup blocker - // Mostly only available on user interaction and the fileReader is async so... - popup = popup || open('', '_blank'); - - if (popup) { - popup.document.title = popup.document.body.innerText = 'downloading...'; - } - - if (typeof blob === 'string') { return download(blob, name, opts); } - var force = blob.type === 'application/octet-stream'; - - var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari; - - var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); - - if ((isChromeIOS || force && isSafari) && (typeof FileReader === "undefined" ? "undefined" : _typeof(FileReader)) === 'object') { - // Safari doesn't allow downloading of blob URLs - var reader = new FileReader(); - - reader.onloadend = function () { - var url = reader.result; - url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); - if (popup) { popup.location.href = url; }else { location = url; } - popup = null; // reverse-tabnabbing #460 - }; - - reader.readAsDataURL(blob); - } else { - var URL = _global.URL || _global.webkitURL; - var url = URL.createObjectURL(blob); - if (popup) { popup.location = url; }else { location.href = url; } - popup = null; // reverse-tabnabbing #460 - - setTimeout(function () { - URL.revokeObjectURL(url); - }, 4E4); // 40s - } - }); - _global.saveAs = saveAs.saveAs = saveAs; - if (typeof module !== 'undefined') { - module.exports = saveAs; - } - }); + window.tmp = FlateStream; + /*rollup-keeper-end*/ })); diff --git a/dist/jspdf.min.js b/dist/jspdf.min.js index 282314144..36b245641 100644 --- a/dist/jspdf.min.js +++ b/dist/jspdf.min.js @@ -1,13 +1,10 @@ !function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict"; /** @license * jsPDF - PDF Document creation from JavaScript - * Version 1.5.3 Built on 2019-03-28T02:02:22.223Z - * CommitID cf389e836e + * Version 1.5.3 Built on 2018-12-27T14:11:42.696Z + * CommitID d93d28db14 * - * Copyright (c) 2010-2018 James Hall , https://github.com/MrRio/jsPDF - * 2015-2018 yWorks GmbH, http://www.yworks.com - * 2015-2018 Lukas Holländer , https://github.com/HackbrettXXX - * 2016-2018 Aras Abbasi + * Copyright (c) 2010-2016 James Hall , https://github.com/MrRio/jsPDF * 2010 Aaron Spike, https://github.com/acspike * 2012 Willow Systems Corporation, willow-systems.com * 2012 Pablo Hess, https://github.com/pablohess @@ -29,7 +26,15 @@ * Contributor(s): * siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango, * kim3er, mfo, alnorth, Flamenco - */function De(t){return(De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)} + */function se(t){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t){if("object"!==se(t.console)){t.console={};for(var e,n,r=t.console,i=function(){},o=["memory"],a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");e=o.pop();)r[e]||(r[e]={});for(;n=a.pop();)r[n]||(r[n]=i)}var s,l,h,u,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";void 0===t.btoa&&(t.btoa=function(t){var e,n,r,i,o,a=0,s=0,l="",h=[];if(!t)return t;for(;e=(o=t.charCodeAt(a++)<<16|t.charCodeAt(a++)<<8|t.charCodeAt(a++))>>18&63,n=o>>12&63,r=o>>6&63,i=63&o,h[s++]=c.charAt(e)+c.charAt(n)+c.charAt(r)+c.charAt(i),a>16&255,n=a>>8&255,r=255&a,h[l++]=64==i?String.fromCharCode(e):64==o?String.fromCharCode(e,n):String.fromCharCode(e,n,r),s>>0,r=new Array(n),i=1>>0,i=0;i>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i>16&255,r=l>>8&255,i=255&l}if(void 0===r||void 0===o&&n===r&&r===i)if("string"==typeof n)e=n+" "+a[0];else switch(t.precision){case 2:e=Z(n/255)+" "+a[0];break;case 3:default:e=Q(n/255)+" "+a[0]}else if(void 0===o||"object"===se(o)){if(o&&!isNaN(o.a)&&0===o.a)return e=["1.000","1.000","1.000",a[1]].join(" ");if("string"==typeof n)e=[n,r,i,a[1]].join(" ");else switch(t.precision){case 2:e=[Z(n/255),Z(r/255),Z(i/255),a[1]].join(" ");break;default:case 3:e=[Q(n/255),Q(r/255),Q(i/255),a[1]].join(" ")}}else if("string"==typeof n)e=[n,r,i,o,a[2]].join(" ");else switch(t.precision){case 2:e=[Z(n/255),Z(r/255),Z(i/255),Z(o/255),a[2]].join(" ");break;case 3:default:e=[Q(n/255),Q(r/255),Q(i/255),Q(o/255),a[2]].join(" ")}return e},ct=l.__private__.getFilters=function(){return o},ft=l.__private__.putStream=function(t){var e=(t=t||{}).data||"",n=t.filters||ct(),r=t.alreadyAppliedFilters||[],i=t.addLength1||!1,o=e.length,a={};!0===n&&(n=["FlateEncode"]);var s=t.additionalKeyValues||[],l=(a=void 0!==ae.API.processDataByFilters?ae.API.processDataByFilters(e,n):{data:e,reverseChain:[]}).reverseChain+(Array.isArray(r)?r.join(" "):r.toString());0!==a.data.length&&(s.push({key:"Length",value:a.data.length}),!0===i&&s.push({key:"Length1",value:o})),0!=l.length&&(l.split("/").length-1==1?s.push({key:"Filter",value:l}):s.push({key:"Filter",value:"["+l+"]"})),tt("<<");for(var h=0;h>"),0!==a.data.length&&(tt("stream"),tt(a.data),tt("endstream"))},pt=l.__private__.putPage=function(t){t.mediaBox;var e=t.number,n=t.data,r=t.objId,i=t.contentsObjId;ot(r,!0);V[x].mediaBox.topRightX,V[x].mediaBox.bottomLeftX,V[x].mediaBox.topRightY,V[x].mediaBox.bottomLeftY;tt("<>"),tt("endobj");var o=n.join("\n");return ot(i,!0),ft({data:o,filters:ct()}),tt("endobj"),r},dt=l.__private__.putPages=function(){var t,e,n=[];for(t=1;t<=W;t++)V[t].objId=X(),V[t].contentsObjId=X();for(t=1;t<=W;t++)n.push(pt({number:t,data:I[t],objId:V[t].objId,contentsObjId:V[t].contentsObjId,mediaBox:V[t].mediaBox,cropBox:V[t].cropBox,bleedBox:V[t].bleedBox,trimBox:V[t].trimBox,artBox:V[t].artBox,userUnit:V[t].userUnit,rootDictionaryObjId:st,resourceDictionaryObjId:lt}));ot(st,!0),tt("<>"),tt("endobj"),it.publish("postPutPages")},gt=function(){!function(){for(var t in rt)rt.hasOwnProperty(t)&&(!1===s||!0===s&&K.hasOwnProperty(t))&&(e=rt[t],it.publish("putFont",{font:e,out:tt,newObject:J,putStream:ft}),!0!==e.isAlreadyPutted&&(e.objectNumber=J(),tt("<<"),tt("/Type /Font"),tt("/BaseFont /"+e.postScriptName),tt("/Subtype /Type1"),"string"==typeof e.encoding&&tt("/Encoding /"+e.encoding),tt("/FirstChar 32"),tt("/LastChar 255"),tt(">>"),tt("endobj")));var e}(),it.publish("putResources"),ot(lt,!0),tt("<<"),function(){for(var t in tt("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),tt("/Font <<"),rt)rt.hasOwnProperty(t)&&(!1===s||!0===s&&K.hasOwnProperty(t))&&tt("/"+t+" "+rt[t].objectNumber+" 0 R");tt(">>"),tt("/XObject <<"),it.publish("putXobjectDict"),tt(">>")}(),tt(">>"),tt("endobj"),it.publish("postPutResources")},mt=function(t,e,n){H.hasOwnProperty(e)||(H[e]={}),H[e][n]=t},yt=function(t,e,n,r,i){i=i||!1;var o="F"+(Object.keys(rt).length+1).toString(10),a={id:o,postScriptName:t,fontName:e,fontStyle:n,encoding:r,isStandardFont:i,metadata:{}};return it.publish("addFont",{font:a,instance:this}),void 0!==o&&(rt[o]=a,mt(o,e,n)),o},vt=l.__private__.pdfEscape=l.pdfEscape=function(t,e){return function(t,e){var n,r,i,o,a,s,l,h,u;if(i=(e=e||{}).sourceEncoding||"Unicode",a=e.outputEncoding,(e.autoencode||a)&&rt[$].metadata&&rt[$].metadata[i]&&rt[$].metadata[i].encoding&&(o=rt[$].metadata[i].encoding,!a&&rt[$].encoding&&(a=rt[$].encoding),!a&&o.codePages&&(a=o.codePages[0]),"string"==typeof a&&(a=o[a]),a)){for(l=!1,s=[],n=0,r=t.length;n>8&&(l=!0);t=s.join("")}for(n=t.length;void 0===l&&0!==n;)t.charCodeAt(n-1)>>8&&(l=!0),n--;if(!l)return t;for(s=e.noBOM?[]:[254,255],n=0,r=t.length;n>8)>>8)throw new Error("Character at position "+n+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");s.push(u),s.push(h-(u<<8))}return String.fromCharCode.apply(void 0,s)}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},wt=l.__private__.beginPage=function(t,e){var n,r="string"==typeof e&&e.toLowerCase();if("string"==typeof t&&(n=f(t.toLowerCase()))&&(t=n[0],e=n[1]),Array.isArray(t)&&(e=t[1],t=t[0]),(isNaN(t)||isNaN(e))&&(t=i[0],e=i[1]),r){switch(r.substr(0,1)){case"l":t>"),tt("endobj")},St=l.__private__.putCatalog=function(t){var e=(t=t||{}).rootDictionaryObjId||st;switch(J(),tt("<<"),tt("/Type /Catalog"),tt("/Pages "+e+" 0 R"),L||(L="fullwidth"),L){case"fullwidth":tt("/OpenAction [3 0 R /FitH null]");break;case"fullheight":tt("/OpenAction [3 0 R /FitV null]");break;case"fullpage":tt("/OpenAction [3 0 R /Fit]");break;case"original":tt("/OpenAction [3 0 R /XYZ null null 1]");break;default:var n=""+L;"%"===n.substr(n.length-1)&&(L=parseInt(L)/100),"number"==typeof L&&tt("/OpenAction [3 0 R /XYZ null null "+Z(L)+"]")}switch(S||(S="continuous"),S){case"continuous":tt("/PageLayout /OneColumn");break;case"single":tt("/PageLayout /SinglePage");break;case"two":case"twoleft":tt("/PageLayout /TwoColumnLeft");break;case"tworight":tt("/PageLayout /TwoColumnRight")}A&&tt("/PageMode /"+A),it.publish("putCatalog"),tt(">>"),tt("endobj")},_t=l.__private__.putTrailer=function(){tt("trailer"),tt("<<"),tt("/Size "+(U+1)),tt("/Root "+U+" 0 R"),tt("/Info "+(U-1)+" 0 R"),tt("/ID [ <"+d+"> <"+d+"> ]"),tt(">>")},Ft=l.__private__.putHeader=function(){tt("%PDF-"+h),tt("%ºß¬à")},Pt=l.__private__.putXRef=function(){var t=1,e="0000000000";for(tt("xref"),tt("0 "+(U+1)),tt("0000000000 65535 f "),t=1;t<=U;t++){"function"==typeof z[t]?tt((e+z[t]()).slice(-10)+" 00000 n "):void 0!==z[t]?tt((e+z[t]).slice(-10)+" 00000 n "):tt("0000000000 00000 n ")}},kt=l.__private__.buildDocument=function(){k=!1,B=U=0,C=[],z=[],G=[],st=X(),lt=X(),it.publish("buildDocument"),Ft(),dt(),function(){it.publish("putAdditionalObjects");for(var t=0;t',i=ie.open();if(null!==i&&i.document.write(r),i||"undefined"==typeof safari)return i;case"datauri":case"dataurl":return ie.document.location.href="data:application/pdf;filename="+e.filename+";base64,"+btoa(n);default:return null}}).foo=function(){try{return F.apply(this,arguments)}catch(t){var e=t.stack||"";~e.indexOf(" at ")&&(e=e.split(" at ")[1]);var n="Error in function "+e.split("\n")[0].split("<")[0]+": "+t.message;if(!ie.console)throw new Error(n);ie.console.error(n,t),ie.alert&&alert(n)}},(F.foo.bar=F).foo),Bt=function(t){return!0===Array.isArray(Y)&&-1":")"),Y=1):(W=Wt(e),V=Vt(n),G=(l?"<":"(")+v[H]+(l?">":")")),void 0!==q&&void 0!==q[H]&&(J=q[H]+" Tw\n"),0!==S.length&&0===H?t.push(J+S.join(" ")+" "+W.toFixed(2)+" "+V.toFixed(2)+" Tm\n"+G):1===Y||0===Y&&0===H?t.push(J+W.toFixed(2)+" "+V.toFixed(2)+" Td\n"+G):t.push(J+G);t=0===Y?t.join(" Tj\nT* "):t.join(" Tj\n"),t+=" Tj\n";var X="BT\n/"+$+" "+et+" Tf\n"+(et*u).toFixed(2)+" TL\n"+Kt+"\n";return X+=h,X+=t,tt(X+="ET"),K[$]=!0,c},l.__private__.lstext=l.lstext=function(t,e,n,r){return console.warn("jsPDF.lstext is deprecated"),this.text(t,e,n,{charSpace:r})},l.__private__.clip=l.clip=function(t){tt("evenodd"===t?"W*":"W"),tt("n")},l.__private__.clip_fixed=l.clip_fixed=function(t){console.log("clip_fixed is deprecated"),l.clip(t)};var Ot=l.__private__.isValidStyle=function(t){var e=!1;return-1!==[void 0,null,"S","F","DF","FD","f","f*","B","B*"].indexOf(t)&&(e=!0),e},qt=l.__private__.getStyle=function(t){var e="S";return"F"===t?e="f":"FD"===t||"DF"===t?e="B":"f"!==t&&"f*"!==t&&"B"!==t&&"B*"!==t||(e=t),e};l.__private__.line=l.line=function(t,e,n,r){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r))throw new Error("Invalid arguments passed to jsPDF.line");return this.lines([[n-t,r-e]],t,e)},l.__private__.lines=l.lines=function(t,e,n,r,i,o){var a,s,l,h,u,c,f,p,d,g,m,y;if("number"==typeof t&&(y=n,n=e,e=t,t=y),r=r||[1,1],o=o||!1,isNaN(e)||isNaN(n)||!Array.isArray(t)||!Array.isArray(r)||!Ot(i)||"boolean"!=typeof o)throw new Error("Invalid arguments passed to jsPDF.lines");for(tt(Q(Wt(e))+" "+Q(Vt(n))+" m "),a=r[0],s=r[1],h=t.length,g=e,m=n,l=0;l=o.length-1;if(b&&!x){m+=" ";continue}if(b||x){if(x)d=w;else if(i.multiline&&a<(h+2)*(y+2)+2)continue t}else{if(!i.multiline)continue t;if(a<(h+2)*(y+2)+2)continue t;d=w}for(var N="",L=p;L<=d;L++)N+=o[L]+" ";switch(N=" "==N.substr(N.length-1)?N.substr(0,N.length-1):N,g=F(N,i,r).width,i.textAlign){case"right":c=s-g-2;break;case"center":c=(s-g)/2;break;case"left":default:c=2}t+=_(c)+" "+_(f)+" Td\n",t+="("+S(N)+") Tj\n",t+=-_(c)+" 0 Td\n",f=-(r+2),g=0,p=d+1,y++,m=""}else;break}return n.text=t,n.fontSize=r,n},F=function(t,e,n){var r=A.internal.getFont(e.fontName,e.fontStyle),i=A.getStringUnitWidth(t,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n);return{height:A.getStringUnitWidth("3",{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n)*1.5,width:i}},u={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},p=function(){A.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var t=A.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];n.objId=void 0,n.hasAnnotation&&d.call(A,n)}},d=function(t){var e={type:"reference",object:t};void 0===A.internal.getPageInfo(t.page).pageContext.annotations.find(function(t){return t.type===e.type&&t.object===e.object})&&A.internal.getPageInfo(t.page).pageContext.annotations.push(e)},g=function(){if(void 0===A.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("putCatalogCallback: Root missing.");A.internal.write("/AcroForm "+A.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R")},m=function(){A.internal.events.unsubscribe(A.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete A.internal.acroformPlugin.acroFormDictionaryRoot._eventID,A.internal.acroformPlugin.printedOut=!0},L=function(t){var e=!t;t||(A.internal.newObjectDeferredBegin(A.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),A.internal.acroformPlugin.acroFormDictionaryRoot.putStream());t=t||A.internal.acroformPlugin.acroFormDictionaryRoot.Kids;for(var n in t)if(t.hasOwnProperty(n)){var r=t[n],i=[],o=r.Rect;if(r.Rect&&(r.Rect=c.call(this,r.Rect)),A.internal.newObjectDeferredBegin(r.objId,!0),r.DA=Y.createDefaultAppearanceStream(r),"object"===se(r)&&"function"==typeof r.getKeyValueListForStream&&(i=r.getKeyValueListForStream()),r.Rect=o,r.hasAppearanceStream&&!r.appearanceStreamContent){var a=f.call(this,r);i.push({key:"AP",value:"<>"}),A.internal.acroformPlugin.xForms.push(a)}if(r.appearanceStreamContent){var s="";for(var l in r.appearanceStreamContent)if(r.appearanceStreamContent.hasOwnProperty(l)){var h=r.appearanceStreamContent[l];if(s+="/"+l+" ",s+="<<",1<=Object.keys(h).length||Array.isArray(h))for(var n in h){var u;if(h.hasOwnProperty(n))"function"==typeof(u=h[n])&&(u=u.call(this,r)),s+="/"+n+" "+u+" ",0<=A.internal.acroformPlugin.xForms.indexOf(u)||A.internal.acroformPlugin.xForms.push(u)}else"function"==typeof(u=h)&&(u=u.call(this,r)),s+="/"+n+" "+u,0<=A.internal.acroformPlugin.xForms.indexOf(u)||A.internal.acroformPlugin.xForms.push(u);s+=">>"}i.push({key:"AP",value:"<<\n"+s+">>"})}A.internal.putStream({additionalKeyValues:i}),A.internal.out("endobj")}e&&P.call(this,A.internal.acroformPlugin.xForms)},P=function(t){for(var e in t)if(t.hasOwnProperty(e)){var n=e,r=t[e];A.internal.newObjectDeferredBegin(r&&r.objId,!0),"object"===se(r)&&"function"==typeof r.putStream&&r.putStream(),delete t[n]}},k=function(){if(void 0!==this.internal&&(void 0===this.internal.acroformPlugin||!1===this.internal.acroformPlugin.isInitialized)){if(A=this,M.FieldNum=0,this.internal.acroformPlugin=JSON.parse(JSON.stringify(u)),this.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");n=A.internal.scaleFactor,A.internal.acroformPlugin.acroFormDictionaryRoot=new E,A.internal.acroformPlugin.acroFormDictionaryRoot._eventID=A.internal.events.subscribe("postPutResources",m),A.internal.events.subscribe("buildDocument",p),A.internal.events.subscribe("putCatalog",g),A.internal.events.subscribe("postPutPages",L),A.internal.acroformPlugin.isInitialized=!0}},I=t.__acroform__.arrayToPdfArray=function(t){if(Array.isArray(t)){for(var e="[",n=0;n>"),e.join("\n")}},set:function(t){"object"===se(t)&&(n=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return n.CA||""},set:function(t){"string"==typeof t&&(n.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return e.substr(1,e.length-1)},set:function(t){e="/"+t}})};r(D,M);var U=function(){D.call(this),this.pushButton=!0};r(U,D);var z=function(){D.call(this),this.radio=!0,this.pushButton=!1;var e=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=void 0!==t?t:[]}})};r(z,D);var H=function(){var e,n;M.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return n},set:function(t){n=t}});var r,i={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t,e=[];for(t in e.push("<<"),i)e.push("/"+t+" ("+i[t]+")");return e.push(">>"),e.join("\n")},set:function(t){"object"===se(t)&&(i=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return i.CA||""},set:function(t){"string"==typeof t&&(i.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return r},set:function(t){r=t}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return r.substr(1,r.length-1)},set:function(t){r="/"+t}}),this.optionName=name,this.caption="l",this.appearanceState="Off",this._AppearanceType=Y.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(name)};r(H,M),z.prototype.setAppearance=function(t){if(!("createAppearanceStream"in t&&"getCA"in t))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var e in this.Kids)if(this.Kids.hasOwnProperty(e)){var n=this.Kids[e];n.appearanceStreamContent=t.createAppearanceStream(n.optionName),n.caption=t.getCA()}},z.prototype.createOption=function(t){this.Kids.length;var e=new H;return e.Parent=this,e.optionName=t,this.Kids.push(e),J.call(this,e),e};var W=function(){D.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=Y.CheckBox.createAppearanceStream()};r(W,D);var V=function(){M.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,13))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,13):this.Ff=N(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,21))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,21):this.Ff=N(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,23):this.Ff=N(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,24))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,24):this.Ff=N(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,25))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,25):this.Ff=N(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,26):this.Ff=N(this.Ff,26)}});var e=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){Number.isInteger(t)&&(e=t)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};r(V,M);var G=function(){V.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return Boolean(b(this.Ff,14))},set:function(t){!0===Boolean(t)?this.Ff=x(this.Ff,14):this.Ff=N(this.Ff,14)}}),this.password=!0};r(G,V);var Y={CheckBox:{createAppearanceStream:function(){return{N:{On:Y.CheckBox.YesNormal},D:{On:Y.CheckBox.YesPushDown,Off:Y.CheckBox.OffPushDown}}},YesPushDown:function(t){var e=l(t),n=[],r=A.internal.getFont(t.fontName,t.fontStyle).id,i=A.__private__.encodeColorString(t.color),o=h(t,t.caption);return n.push("0.749023 g"),n.push("0 0 "+_(Y.internal.getWidth(t))+" "+_(Y.internal.getHeight(t))+" re"),n.push("f"),n.push("BMC"),n.push("q"),n.push("0 0 1 rg"),n.push("/"+r+" "+_(o.fontSize)+" Tf "+i),n.push("BT"),n.push(o.text),n.push("ET"),n.push("Q"),n.push("EMC"),e.stream=n.join("\n"),e},YesNormal:function(t){var e=l(t),n=A.internal.getFont(t.fontName,t.fontStyle).id,r=A.__private__.encodeColorString(t.color),i=[],o=Y.internal.getHeight(t),a=Y.internal.getWidth(t),s=h(t,t.caption);return i.push("1 g"),i.push("0 0 "+_(a)+" "+_(o)+" re"),i.push("f"),i.push("q"),i.push("0 0 1 rg"),i.push("0 0 "+_(a-1)+" "+_(o-1)+" re"),i.push("W"),i.push("n"),i.push("0 g"),i.push("BT"),i.push("/"+n+" "+_(s.fontSize)+" Tf "+r),i.push(s.text),i.push("ET"),i.push("Q"),e.stream=i.join("\n"),e},OffPushDown:function(t){var e=l(t),n=[];return n.push("0.749023 g"),n.push("0 0 "+_(Y.internal.getWidth(t))+" "+_(Y.internal.getHeight(t))+" re"),n.push("f"),e.stream=n.join("\n"),e}},RadioButton:{Circle:{createAppearanceStream:function(t){var e={D:{Off:Y.RadioButton.Circle.OffPushDown},N:{}};return e.N[t]=Y.RadioButton.Circle.YesNormal,e.D[t]=Y.RadioButton.Circle.YesPushDown,e},getCA:function(){return"l"},YesNormal:function(t){var e=l(t),n=[],r=Y.internal.getWidth(t)<=Y.internal.getHeight(t)?Y.internal.getWidth(t)/4:Y.internal.getHeight(t)/4;r=Number((.9*r).toFixed(5));var i=Y.internal.Bezier_C,o=Number((r*i).toFixed(5));return n.push("q"),n.push("1 0 0 1 "+s(Y.internal.getWidth(t)/2)+" "+s(Y.internal.getHeight(t)/2)+" cm"),n.push(r+" 0 m"),n.push(r+" "+o+" "+o+" "+r+" 0 "+r+" c"),n.push("-"+o+" "+r+" -"+r+" "+o+" -"+r+" 0 c"),n.push("-"+r+" -"+o+" -"+o+" -"+r+" 0 -"+r+" c"),n.push(o+" -"+r+" "+r+" -"+o+" "+r+" 0 c"),n.push("f"),n.push("Q"),e.stream=n.join("\n"),e},YesPushDown:function(t){var e=l(t),n=[],r=Y.internal.getWidth(t)<=Y.internal.getHeight(t)?Y.internal.getWidth(t)/4:Y.internal.getHeight(t)/4,i=(r=Number((.9*r).toFixed(5)),Number((2*r).toFixed(5))),o=Number((i*Y.internal.Bezier_C).toFixed(5)),a=Number((r*Y.internal.Bezier_C).toFixed(5));return n.push("0.749023 g"),n.push("q"),n.push("1 0 0 1 "+s(Y.internal.getWidth(t)/2)+" "+s(Y.internal.getHeight(t)/2)+" cm"),n.push(i+" 0 m"),n.push(i+" "+o+" "+o+" "+i+" 0 "+i+" c"),n.push("-"+o+" "+i+" -"+i+" "+o+" -"+i+" 0 c"),n.push("-"+i+" -"+o+" -"+o+" -"+i+" 0 -"+i+" c"),n.push(o+" -"+i+" "+i+" -"+o+" "+i+" 0 c"),n.push("f"),n.push("Q"),n.push("0 g"),n.push("q"),n.push("1 0 0 1 "+s(Y.internal.getWidth(t)/2)+" "+s(Y.internal.getHeight(t)/2)+" cm"),n.push(r+" 0 m"),n.push(r+" "+a+" "+a+" "+r+" 0 "+r+" c"),n.push("-"+a+" "+r+" -"+r+" "+a+" -"+r+" 0 c"),n.push("-"+r+" -"+a+" -"+a+" -"+r+" 0 -"+r+" c"),n.push(a+" -"+r+" "+r+" -"+a+" "+r+" 0 c"),n.push("f"),n.push("Q"),e.stream=n.join("\n"),e},OffPushDown:function(t){var e=l(t),n=[],r=Y.internal.getWidth(t)<=Y.internal.getHeight(t)?Y.internal.getWidth(t)/4:Y.internal.getHeight(t)/4,i=(r=Number((.9*r).toFixed(5)),Number((2*r).toFixed(5))),o=Number((i*Y.internal.Bezier_C).toFixed(5));return n.push("0.749023 g"),n.push("q"),n.push("1 0 0 1 "+s(Y.internal.getWidth(t)/2)+" "+s(Y.internal.getHeight(t)/2)+" cm"),n.push(i+" 0 m"),n.push(i+" "+o+" "+o+" "+i+" 0 "+i+" c"),n.push("-"+o+" "+i+" -"+i+" "+o+" -"+i+" 0 c"),n.push("-"+i+" -"+o+" -"+o+" -"+i+" 0 -"+i+" c"),n.push(o+" -"+i+" "+i+" -"+o+" "+i+" 0 c"),n.push("f"),n.push("Q"),e.stream=n.join("\n"),e}},Cross:{createAppearanceStream:function(t){var e={D:{Off:Y.RadioButton.Cross.OffPushDown},N:{}};return e.N[t]=Y.RadioButton.Cross.YesNormal,e.D[t]=Y.RadioButton.Cross.YesPushDown,e},getCA:function(){return"8"},YesNormal:function(t){var e=l(t),n=[],r=Y.internal.calculateCross(t);return n.push("q"),n.push("1 1 "+_(Y.internal.getWidth(t)-2)+" "+_(Y.internal.getHeight(t)-2)+" re"),n.push("W"),n.push("n"),n.push(_(r.x1.x)+" "+_(r.x1.y)+" m"),n.push(_(r.x2.x)+" "+_(r.x2.y)+" l"),n.push(_(r.x4.x)+" "+_(r.x4.y)+" m"),n.push(_(r.x3.x)+" "+_(r.x3.y)+" l"),n.push("s"),n.push("Q"),e.stream=n.join("\n"),e},YesPushDown:function(t){var e=l(t),n=Y.internal.calculateCross(t),r=[];return r.push("0.749023 g"),r.push("0 0 "+_(Y.internal.getWidth(t))+" "+_(Y.internal.getHeight(t))+" re"),r.push("f"),r.push("q"),r.push("1 1 "+_(Y.internal.getWidth(t)-2)+" "+_(Y.internal.getHeight(t)-2)+" re"),r.push("W"),r.push("n"),r.push(_(n.x1.x)+" "+_(n.x1.y)+" m"),r.push(_(n.x2.x)+" "+_(n.x2.y)+" l"),r.push(_(n.x4.x)+" "+_(n.x4.y)+" m"),r.push(_(n.x3.x)+" "+_(n.x3.y)+" l"),r.push("s"),r.push("Q"),e.stream=r.join("\n"),e},OffPushDown:function(t){var e=l(t),n=[];return n.push("0.749023 g"),n.push("0 0 "+_(Y.internal.getWidth(t))+" "+_(Y.internal.getHeight(t))+" re"),n.push("f"),e.stream=n.join("\n"),e}}},createDefaultAppearanceStream:function(t){var e=A.internal.getFont(t.fontName,t.fontStyle).id,n=A.__private__.encodeColorString(t.color);return"/"+e+" "+t.fontSize+" Tf "+n}};Y.internal={Bezier_C:.551915024494,calculateCross:function(t){var e=Y.internal.getWidth(t),n=Y.internal.getHeight(t),r=Math.min(e,n);return{x1:{x:(e-r)/2,y:(n-r)/2+r},x2:{x:(e-r)/2+r,y:(n-r)/2},x3:{x:(e-r)/2,y:(n-r)/2},x4:{x:(e-r)/2+r,y:(n-r)/2+r}}}},Y.internal.getWidth=function(t){var e=0;return"object"===se(t)&&(e=v(t.Rect[2])),e},Y.internal.getHeight=function(t){var e=0;return"object"===se(t)&&(e=v(t.Rect[3])),e};var J=t.addField=function(t){if(k.call(this),!(t instanceof M))throw new Error("Invalid argument passed to jsPDF.addField.");return function(t){A.internal.acroformPlugin.printedOut&&(A.internal.acroformPlugin.printedOut=!1,A.internal.acroformPlugin.acroFormDictionaryRoot=null),A.internal.acroformPlugin.acroFormDictionaryRoot||k.call(A),A.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(t)}.call(this,t),t.page=A.internal.getCurrentPageInfo().pageNumber,this};t.addButton=function(t){if(t instanceof D==!1)throw new Error("Invalid argument passed to jsPDF.addButton.");return J.call(this,t)},t.addTextField=function(t){if(t instanceof V==!1)throw new Error("Invalid argument passed to jsPDF.addTextField.");return J.call(this,t)},t.addChoiceField=function(t){if(t instanceof O==!1)throw new Error("Invalid argument passed to jsPDF.addChoiceField.");return J.call(this,t)};"object"==se(e)&&void 0===e.ChoiceField&&void 0===e.ListBox&&void 0===e.ComboBox&&void 0===e.EditBox&&void 0===e.Button&&void 0===e.PushButton&&void 0===e.RadioButton&&void 0===e.CheckBox&&void 0===e.TextField&&void 0===e.PasswordField?(e.ChoiceField=O,e.ListBox=q,e.ComboBox=T,e.EditBox=R,e.Button=D,e.PushButton=U,e.RadioButton=z,e.CheckBox=W,e.TextField=V,e.PasswordField=G,e.AcroForm={Appearance:Y}):console.warn("AcroForm-Classes are not populated into global-namespace, because the class-Names exist already."),t.AcroFormChoiceField=O,t.AcroFormListBox=q,t.AcroFormComboBox=T,t.AcroFormEditBox=R,t.AcroFormButton=D,t.AcroFormPushButton=U,t.AcroFormRadioButton=z,t.AcroFormCheckBox=W,t.AcroFormTextField=V,t.AcroFormPasswordField=G,t.AcroFormAppearance=Y,t.AcroForm={ChoiceField:O,ListBox:q,ComboBox:T,EditBox:R,Button:D,PushButton:U,RadioButton:z,CheckBox:W,TextField:V,PasswordField:G,Appearance:Y}})((window.tmp=lt).API,"undefined"!=typeof window&&window||"undefined"!=typeof global&&global), /** @license * jsPDF addImage plugin * Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/ @@ -42,15 +47,7 @@ * * */ -var m,b,u,v,n,y,w,x,L,A,N,t,S,e,r,_,l,P,k,d,p,F,o,a,s,c,h,f,i,g,C,I,j,B,O,M,E,T,R,D,q,U,z,H,W,V,G,Y,J,X,K,Z,Q,$,tt,et,nt,rt,it,ot,at,st,ut,lt,ct,ht,ft,dt,pt,gt,mt,bt,vt,yt,wt,xt,Lt,At,Nt,St,_t,Pt;function kt(x){var t=0;if(71!==x[t++]||73!==x[t++]||70!==x[t++]||56!==x[t++]||56!=(x[t++]+1&253)||97!==x[t++])throw"Invalid GIF 87a/89a header.";var L=x[t++]|x[t++]<<8,e=x[t++]|x[t++]<<8,n=x[t++],r=n>>7,i=1<<1+(7&n);x[t++];x[t++];var o=null;r&&(o=t,t+=3*i);var a=!0,s=[],u=0,l=null,c=0,h=null;for(this.width=L,this.height=e;a&&t>2&7,t++;break;case 254:for(;;){if(0===(N=x[t++]))break;t+=N}break;default:throw"Unknown graphic control label: 0x"+x[t-1].toString(16)}break;case 44:var d=x[t++]|x[t++]<<8,p=x[t++]|x[t++]<<8,g=x[t++]|x[t++]<<8,m=x[t++]|x[t++]<<8,b=x[t++],v=b>>6&1,y=o,w=!1;if(b>>7){w=!0;y=t,t+=3*(1<<1+(7&b))}var A=t;for(t++;;){var N;if(0===(N=x[t++]))break;t+=N}s.push({x:d,y:p,width:g,height:m,has_local_palette:w,palette_offset:y,data_offset:A,data_length:t-A,transparent_index:l,interlaced:!!v,delay:u,disposal:c});break;case 59:a=!1;break;default:throw"Unknown gif block: 0x"+x[t-1].toString(16)}this.numFrames=function(){return s.length},this.loopCount=function(){return h},this.frameInfo=function(t){if(t<0||t>=s.length)throw"Frame index out of range.";return s[t]},this.decodeAndBlitFrameBGRA=function(t,e){var n=this.frameInfo(t),r=n.width*n.height,i=new Uint8Array(r);Ft(x,n.data_offset,i,r);var o=n.palette_offset,a=n.transparent_index;null===a&&(a=256);var s=n.width,u=L-s,l=s,c=4*(n.y*L+n.x),h=4*((n.y+n.height)*L+n.x),f=c,d=4*u;!0===n.interlaced&&(d+=4*(s+u)*7);for(var p=8,g=0,m=i.length;g>=1)),b===a)f+=4;else{var v=x[o+3*b],y=x[o+3*b+1],w=x[o+3*b+2];e[f++]=w,e[f++]=y,e[f++]=v,e[f++]=255}--l}},this.decodeAndBlitFrameRGBA=function(t,e){var n=this.frameInfo(t),r=n.width*n.height,i=new Uint8Array(r);Ft(x,n.data_offset,i,r);var o=n.palette_offset,a=n.transparent_index;null===a&&(a=256);var s=n.width,u=L-s,l=s,c=4*(n.y*L+n.x),h=4*((n.y+n.height)*L+n.x),f=c,d=4*u;!0===n.interlaced&&(d+=4*(s+u)*7);for(var p=8,g=0,m=i.length;g>=1)),b===a)f+=4;else{var v=x[o+3*b],y=x[o+3*b+1],w=x[o+3*b+2];e[f++]=v,e[f++]=y,e[f++]=w,e[f++]=255}--l}}}function Ft(t,e,n,r){for(var i=t[e++],o=1<>=u,c-=u,m!=o){if(m==a)break;for(var b=m>8,++v;var w=y;if(r>=8;null!==g&&s<4096&&(p[s++]=g<<8|w,l+1<=s&&u<12&&(++u,l=l<<1|1)),g=m}else s=1+a,l=(1<<(u=i+1))-1,g=null}return f!==r&&console.log("Warning, gif stream shorter than expected."),n}!function(t){if("object"!==De(t.console)){t.console={};for(var e,n,r=t.console,i=function(){},o=["memory"],a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");e=o.pop();)r[e]||(r[e]={});for(;n=a.pop();)r[n]||(r[n]=i)}var s,u,l,c,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";void 0===t.btoa&&(t.btoa=function(t){var e,n,r,i,o,a=0,s=0,u="",l=[];if(!t)return t;for(;e=(o=t.charCodeAt(a++)<<16|t.charCodeAt(a++)<<8|t.charCodeAt(a++))>>18&63,n=o>>12&63,r=o>>6&63,i=63&o,l[s++]=h.charAt(e)+h.charAt(n)+h.charAt(r)+h.charAt(i),a>16&255,n=a>>8&255,r=255&a,l[u++]=64==i?String.fromCharCode(e):64==o?String.fromCharCode(e,n):String.fromCharCode(e,n,r),s>>0,r=new Array(n),i=1>>0,i=0;if(2<=arguments.length)e=arguments[1];else{for(;i>>0,i=0;if(2<=arguments.length)e=arguments[1];else{for(;i>>0,i=0;i>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i>16&255,r=u>>8&255,i=255&u}if(void 0===r||void 0===o&&n===r&&r===i)if("string"==typeof n)e=n+" "+a[0];else switch(t.precision){case 2:e=tt(n/255)+" "+a[0];break;case 3:default:e=et(n/255)+" "+a[0]}else if(void 0===o||"object"===De(o)){if(o&&!isNaN(o.a)&&0===o.a)return e=["1.000","1.000","1.000",a[1]].join(" ");if("string"==typeof n)e=[n,r,i,a[1]].join(" ");else switch(t.precision){case 2:e=[tt(n/255),tt(r/255),tt(i/255),a[1]].join(" ");break;default:case 3:e=[et(n/255),et(r/255),et(i/255),a[1]].join(" ")}}else if("string"==typeof n)e=[n,r,i,o,a[2]].join(" ");else switch(t.precision){case 2:e=[tt(n),tt(r),tt(i),tt(o),a[2]].join(" ");break;case 3:default:e=[et(n),et(r),et(i),et(o),a[2]].join(" ")}return e},Ct=l.__private__.getFilters=function(){return r},It=l.__private__.putStream=function(t){var e=(t=t||{}).data||"",n=t.filters||Ct(),r=t.alreadyAppliedFilters||[],i=t.addLength1||!1,o=e.length,a={};!0===n&&(n=["FlateEncode"]);var s=t.additionalKeyValues||[],u=(a=void 0!==Re.API.processDataByFilters?Re.API.processDataByFilters(e,n):{data:e,reverseChain:[]}).reverseChain+(Array.isArray(r)?r.join(" "):r.toString());0!==a.data.length&&(s.push({key:"Length",value:a.data.length}),!0===i&&s.push({key:"Length1",value:o})),0!=u.length&&(u.split("/").length-1==1?s.push({key:"Filter",value:u}):s.push({key:"Filter",value:"["+u+"]"})),rt("<<");for(var l=0;l>"),0!==a.data.length&&(rt("stream"),rt(a.data),rt("endstream"))},jt=l.__private__.putPage=function(t){var e=t.number,n=t.data,r=t.objId,i=t.contentsObjId;Nt(r,!0),rt("<>"),rt("endobj");var o=n.join("\n");return Nt(i,!0),It({data:o,filters:Ct()}),rt("endobj"),r},Bt=l.__private__.putPages=function(){var t,e,n=[];for(t=1;t<=ht;t++)ft[t].objId=At(),ft[t].contentsObjId=At();for(t=1;t<=ht;t++)n.push(jt({number:t,data:T[t],objId:ft[t].objId,contentsObjId:ft[t].contentsObjId,mediaBox:ft[t].mediaBox,cropBox:ft[t].cropBox,bleedBox:ft[t].bleedBox,trimBox:ft[t].trimBox,artBox:ft[t].artBox,userUnit:ft[t].userUnit,rootDictionaryObjId:_t,resourceDictionaryObjId:Pt}));Nt(_t,!0),rt("<>"),rt("endobj"),pt.publish("postPutPages")},Ot=function(t){t.objectNumber=Lt(),rt("<<"),rt("/Type /XObject"),rt("/Subtype /Form"),rt("/BBox ["+[b(t.x),b(t.y),b(t.x+t.width),b(t.y+t.height)].join(" ")+"]"),rt("/Matrix ["+t.matrix.toString()+"]");var e=t.pages[1].join("\n");rt("/Length "+e.length),rt(">>"),It(e),rt("endobj")},Mt=function(t,e){rt("/Shading <<"),e||(e=21);var n=Lt(),r=function(t,e){var n,r=[],i=1/(e-1);for(n=0;n<1;n+=i)r.push(n);if(r.push(1),0!=t[0].offset){var o={offset:0,color:t[0].color};t.unshift(o)}if(1!=t[t.length-1].offset){var a={offset:1,color:t[t.length-1].color};t.push(a)}for(var s="",u=0,l=0;lt[u+1].offset;)u++;var c=t[u].offset,h=(n-c)/(t[u+1].offset-c),f=t[u].color,d=t[u+1].color;s+=M(Math.round((1-h)*f[0]+h*d[0]).toString(16))+M(Math.round((1-h)*f[1]+h*d[1]).toString(16))+M(Math.round((1-h)*f[2]+h*d[2]).toString(16))}return s.trim()}(t.colors,e);rt("<< /FunctionType 0"),rt("/Domain [0.0 1.0]"),rt("/Size ["+e+"]"),rt("/BitsPerSample 8"),rt("/Range [0.0 1.0 0.0 1.0 0.0 1.0]"),rt("/Decode [0.0 1.0 0.0 1.0 0.0 1.0]"),rt("/Length "+r.length),rt("/Filter /ASCIIHexDecode"),rt(">>"),It(r),rt("endobj"),t.objectNumber=Lt(),rt("<< /ShadingType "+t.type),rt("/ColorSpace /DeviceRGB");var i="/Coords ["+b(parseFloat(t.coords[0]))+" "+b(parseFloat(t.coords[1]))+" ";2===t.type?i+=b(parseFloat(t.coords[2]))+" "+b(parseFloat(t.coords[3])):i+=b(parseFloat(t.coords[2]))+" "+b(parseFloat(t.coords[3]))+" "+b(parseFloat(t.coords[4]))+" "+b(parseFloat(t.coords[5])),rt(i+="]"),t.matrix&&rt("/Matrix ["+t.matrix.toString()+"]"),rt("/Function "+n+" 0 R"),rt("/Extend [true true]"),rt(">>"),rt("endobj"),rt(">>")},Et=function(t){for(var e in t.objectNumber=Lt(),rt("<<"),t)switch(e){case"opacity":rt("/ca "+tt(t[e]));break;case"stroke-opacity":rt("/CA "+tt(t[e]))}rt(">>"),rt("endobj")},Tt=function(){rt("<<"),rt("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),function(){for(var t in rt("/Font <<"),at)at.hasOwnProperty(t)&&(!1===i||!0===i&&$.hasOwnProperty(t))&&rt("/"+t+" "+at[t].objectNumber+" 0 R");rt(">>")}(),function(){if(0>")}}(),function(){if(0>")}}(),function(){for(var t in rt("/XObject <<"),mt)mt.hasOwnProperty(t)&&0<=mt[t].objectNumber&&rt("/"+t+" "+mt[t].objectNumber+" 0 R");pt.publish("putXobjectDict"),rt(">>")}(),rt(">>")},Rt=function(){!function(){for(var t in at)at.hasOwnProperty(t)&&(!1===i||!0===i&&$.hasOwnProperty(t))&&(e=at[t],n=function(t,e){return-1!==t.indexOf(" ")?"("+Ut(t,e)+")":Ut(t,e)},pt.publish("putFont",{font:e,out:rt,newObject:Lt,putStream:It,pdfEscapeWithNeededParanthesis:n}),!0!==e.isAlreadyPutted&&(e.objectNumber=Lt(),rt("<<"),rt("/Type /Font"),rt("/BaseFont /"+n(e.postScriptName)),rt("/Subtype /Type1"),"string"==typeof e.encoding&&rt("/Encoding /"+e.encoding),rt("/FirstChar 32"),rt("/LastChar 255"),rt(">>"),rt("endobj")));var e,n}(),function(){var t;for(t in ut)ut.hasOwnProperty(t)&&Et(ut[t])}(),function(){for(var t in mt)mt.hasOwnProperty(t)&&Ot(mt[t])}(),function(){var t,e,n;for(t in Q)Q.hasOwnProperty(t)&&(Q[t]instanceof l.ShadingPattern?Mt(Q[t]):Q[t]instanceof l.TilingPattern&&(e=Q[t],n=Lt(),Tt(),rt("endobj"),e.objectNumber=Lt(),rt("<< /Type /Pattern"),rt("/PatternType 1"),rt("/PaintType 1"),rt("/TilingType 1"),rt("/BBox ["+e.boundingBox.map(b).join(" ")+"]"),rt("/XStep "+b(e.xStep)),rt("/YStep "+b(e.yStep)),rt("/Length "+e.stream.length),rt("/Resources "+n+" 0 R"),e.matrix&&rt("/Matrix ["+e.matrix.toString()+"]"),rt(">>"),It(e.stream),rt("endobj")))}(),pt.publish("putResources"),Nt(Pt,!0),Tt(),rt("endobj"),pt.publish("postPutResources")},Dt=function(t,e,n){K.hasOwnProperty(e)||(K[e]={}),K[e][n]=t},qt=function(t,e,n,r,i){i=i||!1;var o="F"+(Object.keys(at).length+1).toString(10),a={id:o,postScriptName:t,fontName:e,fontStyle:n,encoding:r,isStandardFont:i,metadata:{}};return pt.publish("addFont",{font:a,instance:this}),void 0!==o&&(at[o]=a,Dt(o,e,n)),o},Ut=l.__private__.pdfEscape=l.pdfEscape=function(t,e){return function(t,e){var n,r,i,o,a,s,u,l,c;if(i=(e=e||{}).sourceEncoding||"Unicode",a=e.outputEncoding,(e.autoencode||a)&&at[nt].metadata&&at[nt].metadata[i]&&at[nt].metadata[i].encoding&&(o=at[nt].metadata[i].encoding,!a&&at[nt].encoding&&(a=at[nt].encoding),!a&&o.codePages&&(a=o.codePages[0]),"string"==typeof a&&(a=o[a]),a)){for(u=!1,s=[],n=0,r=t.length;n>8&&(u=!0);t=s.join("")}for(n=t.length;void 0===u&&0!==n;)t.charCodeAt(n-1)>>8&&(u=!0),n--;if(!u)return t;for(s=e.noBOM?[]:[254,255],n=0,r=t.length;n>8)>>8)throw new Error("Character at position "+n+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");s.push(c),s.push(l-(c<<8))}return String.fromCharCode.apply(void 0,s)}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},zt=l.__private__.beginPage=function(t,e){var n,r,i;if("string"==typeof t&&(n=d(t.toLowerCase()))&&(r=n[0],i=n[1]),Array.isArray(t)&&(r=t[0]*C,i=t[1]*C),isNaN(r)&&(r=o[0],i=o[1]),e){switch(e.substr(0,1)){case"l":r>"),rt("endobj")},Jt=l.__private__.putCatalog=function(t){var e=(t=t||{}).rootDictionaryObjId||_t;switch(Lt(),rt("<<"),rt("/Type /Catalog"),rt("/Pages "+e+" 0 R"),P||(P="fullwidth"),P){case"fullwidth":rt("/OpenAction [3 0 R /FitH null]");break;case"fullheight":rt("/OpenAction [3 0 R /FitV null]");break;case"fullpage":rt("/OpenAction [3 0 R /Fit]");break;case"original":rt("/OpenAction [3 0 R /XYZ null null 1]");break;default:var n=""+P;"%"===n.substr(n.length-1)&&(P=parseInt(P)/100),"number"==typeof P&&rt("/OpenAction [3 0 R /XYZ null null "+tt(P)+"]")}switch(F||(F="continuous"),F){case"continuous":rt("/PageLayout /OneColumn");break;case"single":rt("/PageLayout /SinglePage");break;case"two":case"twoleft":rt("/PageLayout /TwoColumnLeft");break;case"tworight":rt("/PageLayout /TwoColumnRight")}k&&rt("/PageMode /"+k),pt.publish("putCatalog"),rt(">>"),rt("endobj")},Xt=l.__private__.putTrailer=function(){rt("trailer"),rt("<<"),rt("/Size "+(J+1)),rt("/Root "+J+" 0 R"),rt("/Info "+(J-1)+" 0 R"),rt("/ID [ <"+v+"> <"+v+"> ]"),rt(">>")},Kt=l.__private__.putHeader=function(){rt("%PDF-"+c),rt("%ºß¬à")},Zt=l.__private__.putXRef=function(){var t=1,e="0000000000";for(rt("xref"),rt("0 "+(J+1)),rt("0000000000 65535 f "),t=1;t<=J;t++){"function"==typeof X[t]?rt((e+X[t]()).slice(-10)+" 00000 n "):void 0!==X[t]?rt((e+X[t]).slice(-10)+" 00000 n "):rt("0000000000 00000 n ")}},Qt=l.__private__.buildDocument=function(){E=!1,D=J=0,R=[],X=[],dt=[],_t=At(),Pt=At(),pt.publish("buildDocument"),Kt(),Bt(),function(){pt.publish("putAdditionalObjects");for(var t=0;t<\/script> + + + + + + + + + + + + + + + +
    + +

    GState

    + + + + + + + +
    + +
    + +

    + GState +

    + + +
    + +
    + +
    + + + + + +

    new GState(parameters)

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +

    An object representing a pdf graphics state.

    +
    + + + + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    parameters + +

    A parameter object that contains all properties this graphics state wants to set. +Supported are: opacity, stroke-opacity

    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + +
    + +
    + +
    + Documentation generated by JSDoc 3.5.5 on Tue Apr 02 2019 00:25:07 GMT+0200 (GMT+02:00) using the docdash theme. +
    + + + + + + + \ No newline at end of file diff --git a/docs/Matrix.html b/docs/Matrix.html new file mode 100644 index 000000000..cc7edcd34 --- /dev/null +++ b/docs/Matrix.html @@ -0,0 +1,1763 @@ + + + + + + Matrix - Documentation + + + + + + + + + + + + + + + + + + +
    + +

    Matrix

    + + + + + + + +
    + +
    + +

    + Matrix +

    + + +
    + +
    + +
    + + + + + +

    new Matrix(a, b, c, d, e, f)

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +

    A matrix object for 2D homogenous transformations:
    +| a b 0 |
    +| c d 0 |
    +| e f 1 |
    +pdf multiplies matrices righthand: v' = v x m1 x m2 x ...

    +
    + + + + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    c + + +number + + + +
    d + + +number + + + +
    e + + +number + + + +
    f + + +number + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +

    Members

    + + + +

    isIdentity

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    rotation

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    scaleX

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    scaleY

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    shx

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    shy

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    sx

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    sy

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    tx

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +

    ty

    + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +

    Methods

    + + + + + + +

    applyToPoint()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    applyToRectangle()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    clone()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +

    Clone the Matrix

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    decompose()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    inversed()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    join(separator) → {string}

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +

    Multiply the matrix with given Matrix

    +
    + + + + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    separator + + +string + + + +

    Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them.

    + + + + + + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string with all array elements joined.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + + + + + + +

    multiply(matrix) → {Matrix}

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +

    Multiply the matrix with given Matrix

    +
    + + + + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    matrix + +
    + + + + + + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +Matrix + + +
    +
    + + + + + + + + + + +

    toString()

    + + + + + + +
    + + +
    Source:
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + +
    + +
    + +
    + Documentation generated by JSDoc 3.5.5 on Tue Apr 02 2019 00:25:07 GMT+0200 (GMT+02:00) using the docdash theme. +
    + + + + + + + \ No newline at end of file diff --git a/docs/deprecated_addhtml.js.html b/docs/deprecated_addhtml.js.html index dff862252..8d2681237 100644 --- a/docs/deprecated_addhtml.js.html +++ b/docs/deprecated_addhtml.js.html @@ -24,9 +24,9 @@ -