From 0afa08994406d22dee7fb10dd221e44b029597e5 Mon Sep 17 00:00:00 2001
From: arasabbasi
Date: Thu, 28 Mar 2019 08:19:37 +0100
Subject: [PATCH 1/9] alot of minor changes
---
.eslintrc | 213 -
.eslintrc.js | 18 +
build.js | 8 +-
definitely_typed/index.d.ts | 492 +-
definitely_typed/jspdf-tests.ts | 376 +-
dist/jspdf.debug.js | 15222 +++++++++++-----
dist/jspdf.min.js | 153 +-
examples/MathJax/MathJax.html | 55 +-
examples/annotation/test_annotation.html | 28 +-
examples/annotation/test_annotation_2.html | 114 +-
examples/basic.html | 472 +-
.../bar_graph_with_text_and_lines.html | 1499 +-
examples/context2d/test_context2d.html | 796 +-
examples/context2d/test_context2d_paths.html | 70 +-
examples/html2pdf/acid.html | 279 +-
examples/html2pdf/auto_break.html | 32 +-
examples/html2pdf/lists.html | 30 +-
examples/html2pdf/page_break.html | 48 +-
examples/html2pdf/pdf2.html | 82 +-
examples/html2pdf/showcase.html | 40 +-
.../html2pdf/showcase_supported_html.html | 73 +-
examples/html2pdf/tables.html | 312 +-
examples/html2pdf/total_mess.html | 110 +-
examples/images.html | 159 +-
examples/js/acroforms.js | 7 +-
examples/js/autoprint.js | 1 +
examples/js/basic.js | 286 +-
examples/js/circles.js | 1 +
examples/js/editor.js | 53 +-
examples/js/font-faces.js | 2 +-
examples/js/from-html.js | 6 +-
examples/js/html2canvas.js | 7 +-
examples/js/kitchen-sink.js | 3 -
examples/js/lines.js | 18 +-
examples/js/test_harness.js | 40 +-
examples/js/user-input.js | 2 +-
examples/jspdf.PLUGINTEMPLATE.js | 3 +-
examples/node/arabic.js | 26 +-
examples/node/japanese.js | 2 +-
examples/runner.html | 89 +-
fontconverter/fontconverter.html | 133 +-
karma.conf.js | 93 +-
karma.config.js | 81 +
karma.dist.conf.js | 2 +-
package-lock.json | 591 +-
package.json | 2 +
saucelabs.karma.conf.js | 94 +-
src/jspdf.js | 88 +-
src/libs/BMPDecoder.js | 34 +-
src/libs/Deflater.js | 132 +-
src/libs/adler32cs.js | 26 +-
src/libs/png.js | 11 +-
src/libs/rgbcolor.js | 7 +-
src/modules/acroform.js | 43 +-
src/modules/addimage.js | 12 +-
src/modules/annotations.js | 33 +-
src/modules/arabic.js | 16 +-
src/modules/autoprint.js | 1 +
src/modules/bmp_support.js | 33 +-
src/modules/canvas.js | 7 +-
src/modules/cell.js | 12 +-
src/modules/context2d.js | 619 +-
src/modules/fileloading.js | 6 +-
src/modules/filters.js | 15 +-
src/modules/gif_support.js | 38 +-
src/modules/html.js | 1533 +-
src/modules/javascript.js | 4 +-
src/modules/jpeg_support.js | 5 +-
src/modules/outline.js | 8 +-
src/modules/png_support.js | 957 +-
src/modules/setlanguage.js | 1 +
src/modules/split_text_to_size.js | 14 +-
src/modules/standard_fonts_metrics.js | 3 +-
src/modules/svg.js | 3 +-
src/modules/total_pages.js | 1 +
src/modules/ttfsupport.js | 4 +-
src/modules/utf8.js | 33 +-
src/modules/vfs.js | 1 +
src/modules/viewerpreferences.js | 1 +
src/modules/webp_support.js | 10 +-
src/modules/xmp_metadata.js | 4 +-
tests/setlanguage/standard.spec.js | 2 +-
tests/shapes/standard.spec.js | 8 +-
tests/utils/compare.js | 42 +-
tests/utils/polyfill.js | 5 +-
tests/utils/reference-server.js | 14 +-
86 files changed, 16337 insertions(+), 9672 deletions(-)
delete mode 100644 .eslintrc
create mode 100644 .eslintrc.js
delete mode 100644 examples/js/kitchen-sink.js
create mode 100644 karma.config.js
diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index 9faa37508..000000000
--- a/.eslintrc
+++ /dev/null
@@ -1,213 +0,0 @@
-ecmaFeatures:
- modules: true
- jsx: true
-
-env:
- amd: true
- browser: true
- es6: true
- jquery: true
- node: true
-
-# http://eslint.org/docs/rules/
-rules:
- # Possible Errors
- comma-dangle: [2, never]
- no-cond-assign: 2
- no-console: 0
- no-constant-condition: 2
- no-control-regex: 2
- no-debugger: 2
- no-dupe-args: 2
- no-dupe-keys: 2
- no-duplicate-case: 2
- no-empty: 2
- no-empty-character-class: 2
- no-ex-assign: 2
- no-extra-boolean-cast: 2
- no-extra-parens: 0
- no-extra-semi: 2
- no-func-assign: 2
- no-inner-declarations: [2, functions]
- no-invalid-regexp: 2
- no-irregular-whitespace: 2
- no-negated-in-lhs: 2
- no-obj-calls: 2
- no-regex-spaces: 2
- no-sparse-arrays: 2
- no-unexpected-multiline: 2
- no-unreachable: 2
- use-isnan: 2
- valid-jsdoc: 0
- valid-typeof: 2
-
- # Best Practices
- accessor-pairs: 2
- block-scoped-var: 0
- complexity: [2, 6]
- consistent-return: 0
- curly: 0
- default-case: 0
- dot-location: 0
- dot-notation: 0
- eqeqeq: 2
- guard-for-in: 2
- no-alert: 2
- no-caller: 2
- no-case-declarations: 2
- no-div-regex: 2
- no-else-return: 0
- no-empty-label: 2
- no-empty-pattern: 2
- no-eq-null: 2
- no-eval: 2
- no-extend-native: 2
- no-extra-bind: 2
- no-fallthrough: 2
- no-floating-decimal: 0
- no-implicit-coercion: 0
- no-implied-eval: 2
- no-invalid-this: 0
- no-iterator: 2
- no-labels: 0
- no-lone-blocks: 2
- no-loop-func: 2
- no-magic-number: 0
- no-multi-spaces: 0
- no-multi-str: 0
- no-native-reassign: 2
- no-new-func: 2
- no-new-wrappers: 2
- no-new: 2
- no-octal-escape: 2
- no-octal: 2
- no-proto: 2
- no-redeclare: 2
- no-return-assign: 2
- no-script-url: 2
- no-self-compare: 2
- no-sequences: 0
- no-throw-literal: 0
- no-unused-expressions: 2
- no-useless-call: 2
- no-useless-concat: 2
- no-void: 2
- no-warning-comments: 0
- no-with: 2
- radix: 2
- vars-on-top: 0
- wrap-iife: 2
- yoda: 0
-
- # Strict
- strict: 0
-
- # Variables
- init-declarations: 0
- no-catch-shadow: 2
- no-delete-var: 2
- no-label-var: 2
- no-shadow-restricted-names: 2
- no-shadow: 0
- no-undef-init: 2
- no-undef: 0
- no-undefined: 0
- no-unused-vars: 0
- no-use-before-define: 0
-
- # Node.js and CommonJS
- callback-return: 2
- global-require: 2
- handle-callback-err: 2
- no-mixed-requires: 0
- no-new-require: 0
- no-path-concat: 2
- no-process-exit: 2
- no-restricted-modules: 0
- no-sync: 0
-
- # Stylistic Issues
- array-bracket-spacing: 0
- block-spacing: 0
- brace-style: 0
- camelcase: 0
- comma-spacing: 0
- comma-style: 0
- computed-property-spacing: 0
- consistent-this: 0
- eol-last: 0
- func-names: 0
- func-style: 0
- id-length: 0
- id-match: 0
- indent: 0
- jsx-quotes: 0
- key-spacing: 0
- linebreak-style: 0
- lines-around-comment: 0
- max-depth: 0
- max-len: 0
- max-nested-callbacks: 0
- max-params: 0
- max-statements: [2, 30]
- new-cap: 0
- new-parens: 0
- newline-after-var: 0
- no-array-constructor: 0
- no-bitwise: 0
- no-continue: 0
- no-inline-comments: 0
- no-lonely-if: 0
- no-mixed-spaces-and-tabs: 0
- no-multiple-empty-lines: 0
- no-negated-condition: 0
- no-nested-ternary: 0
- no-new-object: 0
- no-plusplus: 0
- no-restricted-syntax: 0
- no-spaced-func: 0
- no-ternary: 0
- no-trailing-spaces: 0
- no-underscore-dangle: 0
- no-unneeded-ternary: 0
- object-curly-spacing: 0
- one-var: 0
- operator-assignment: 0
- operator-linebreak: 0
- padded-blocks: 0
- quote-props: 0
- quotes: 0
- require-jsdoc: 0
- semi-spacing: 0
- semi: 0
- sort-vars: 0
- space-after-keywords: 0
- space-before-blocks: 0
- space-before-function-paren: 0
- space-before-keywords: 0
- space-in-parens: 0
- space-infix-ops: 0
- space-return-throw-case: 0
- space-unary-ops: 0
- spaced-comment: 0
- wrap-regex: 0
-
- # ECMAScript 6
- arrow-body-style: 0
- arrow-parens: 0
- arrow-spacing: 0
- constructor-super: 0
- generator-star-spacing: 0
- no-arrow-condition: 0
- no-class-assign: 0
- no-const-assign: 0
- no-dupe-class-members: 0
- no-this-before-super: 0
- no-var: 0
- object-shorthand: 0
- prefer-arrow-callback: 0
- prefer-const: 0
- prefer-reflect: 0
- prefer-spread: 0
- prefer-template: 0
- require-yield: 0
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 000000000..0263497d0
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,18 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "commonjs": true,
+ "es6": true,
+ "node": true
+ },
+ "extends": "eslint:recommended",
+ "globals": {
+ "Atomics": "readonly",
+ "SharedArrayBuffer": "readonly"
+ },
+ "parserOptions": {
+ "ecmaVersion": 2018
+ },
+ "rules": {
+ }
+};
\ No newline at end of file
diff --git a/build.js b/build.js
index 5b5bb3ddb..b4892e4bc 100644
--- a/build.js
+++ b/build.js
@@ -1,3 +1,5 @@
+/* eslint-disable no-empty */
+/* eslint-disable no-console */
'use strict'
var fs = require('fs')
@@ -19,7 +21,7 @@ switch (args.type) {
bundle({
distFolder : 'dist',
config: './build.node.conf.js',
- context: 'global',
+ context: 'global',
minify: true,
format: 'cjs',
filename: 'jspdf.node'
@@ -32,7 +34,7 @@ switch (args.type) {
config: './build.browser.conf.js',
minify: true,
format: 'umd',
- context: 'window',
+ context: 'window',
filename: 'jspdf'
});
break;
@@ -47,7 +49,7 @@ function bundle(options) {
}).then((bundle) => {
return bundle.generate({
format: options.format,
- name: 'jsPDF'
+ name: 'jsPDF'
})
}).then(output => {
let code = output['output'][0].code;
diff --git a/definitely_typed/index.d.ts b/definitely_typed/index.d.ts
index e3ef92639..df7cc03f6 100644
--- a/definitely_typed/index.d.ts
+++ b/definitely_typed/index.d.ts
@@ -5,231 +5,323 @@
// Jackie Weng
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-interface Annotation {
- type: 'text'|'freetext';
- title?: string;
- bounds: {
- x: number,
- y: number,
- w: number,
- h: number
- };
- contents: string;
- open?: boolean;
- color?: string;
- name?: string;
- top?: number;
- pageNumber?: number;
-}
+declare module 'jspdf' {
-//jsPDF plugin:AutoPrint
+ interface Annotation {
+ type: 'text' | 'freetext' | 'link';
+ title?: string;
+ bounds: {
+ x: number,
+ y: number,
+ w: number,
+ h: number
+ };
+ contents: string;
+ open?: boolean;
+ color?: string;
+ name?: string;
+ top?: number;
+ pageNumber?: number;
+ }
-interface AutoPrintInput {
- variant: 'non-conform'|'javascript'
-}
+ interface TextWithLinkOptions {
+ pageNumber?: number;
+ magFactor?: 'Fit'|'FitH' | 'FitV' | 'XYZ';
+ zoom?: number;
+ }
-//jsPDF plugin: viewerPreferences
-
-interface ViewerPreferencesInput {
- HideToolbar?: boolean;
- HideMenubar?: boolean;
- HideWindowUI?: boolean;
- FitWindow?: boolean;
- CenterWindow?: boolean;
- DisplayDocTitle?: boolean;
- NonFullScreenPageMode?: 'UseNone'|'UseOutlines'|'UseThumbs'|'UseOC';
- Direction?: 'L2R'|'R2L';
- ViewArea?: 'MediaBox'|'CropBox'|'TrimBox'|'BleedBox'|'ArtBox';
- ViewClip?: 'MediaBox'|'CropBox'|'TrimBox'|'BleedBox'|'ArtBox';
- PrintArea?: 'MediaBox'|'CropBox'|'TrimBox'|'BleedBox'|'ArtBox';
- PrintClip?: 'MediaBox'|'CropBox'|'TrimBox'|'BleedBox'|'ArtBox';
- PrintScaling?: 'AppDefault'|'None';
- Duplex?: 'Simplex'|'DuplexFlipShortEdge'|'DuplexFlipLongEdge'|'none';
- PickTrayByPDFSize?: boolean;
- PrintPageRange?: number[][];
- NumCopies?: number;
-}
+ //jsPDF plugin:AutoPrint
-//jsPDF plugin: Outline
+ interface AutoPrintInput {
+ variant: 'non-conform' | 'javascript'
+ }
-interface Outline {
- add(parent:any,title:string,options:OutlineOptions):OutlineItem;
-}
-interface OutlineItem{
- title : string,
- options : any,
- children : any[]
-}
-interface OutlineOptions {
- pageNumber: number
-}
-// jsPDF plugin: AcroForm
-interface AcroFormField {
- constructor():AcroFormField;
- showWhenPrinted: boolean;
- x: number;
- y: number;
- width: number;
- height: number;
- fieldName: string;
- fontName: string;
- fontStyle: string;
- fontSize: number;
- maxFontSize: number;
- color: string;
- defaultValue: string;
- value: string;
- hasAnnotation: boolean;
- readOnly: boolean;
- required: boolean;
- noExport: boolean;
- textAlign: 'left' | 'center' | 'right';
-}
+ //jsPDF plugn: HTML
+ interface Html2CanvasOptions {
+ /** Whether to parse and render the element asynchronously */
+ async?: boolean;
-interface AcroFormChoiceField extends AcroFormField {
- topIndex: number;
- getOptions(): string[];
- setOptions(value: string[]): void;
- addOption(value: string): void;
- removeOption(value: string, allEntries: boolean): void;
- combo: boolean;
- edit: boolean;
- sort: boolean;
- multiSelect: boolean;
- doNotSpellCheck: boolean;
- commitOnSelChange: boolean;
-}
+ /** Whether to allow cross-origin images to taint the canvas */
+ allowTaint?: boolean;
-interface AcroFormListBox extends AcroFormChoiceField { }
+ /** Canvas background color, if none is specified in DOM. Set null for transparent */
+ backgroundColor?: string | null;
-interface AcroFormComboBox extends AcroFormListBox { }
+ /** Existing canvas element to use as a base for drawing on */
+ canvas?: any;
-interface AcroFormEditBox extends AcroFormComboBox { }
+ /** Whether to use ForeignObject rendering if the browser supports it */
+ foreignObjectRendering?: boolean;
-interface AcroFormButton extends AcroFormField {
- noToggleToOff: boolean;
- radio: boolean;
- pushButton: boolean;
- radioIsUnison: boolean;
- caption: string;
- appearanceState: any;
-}
+ /** Predicate function which removes the matching elements from the render. */
+ ignoreElements?: (element: HTMLElement) => boolean;
-interface AcroFormPushButton extends AcroFormButton { }
+ /** Timeout for loading images, in milliseconds. Setting it to 0 will result in no timeout. */
+ imageTimeout?: number;
-interface AcroFormChildClass extends AcroFormField {
- Parent: any;
- optionName: string;
- caption: string;
- appearanceState: 'On' | 'Off';
-}
+ /** Whether to render each letter seperately. Necessary if letter-spacing is used. */
+ letterRendering?: boolean;
-interface AcroFormRadioButton extends AcroFormButton {
- setAppearance(appearance: string): void;
- createOption(name: string): AcroFormChildClass;
-}
+ /** Whether to log events in the console. */
+ logging?: boolean;
-interface AcroFormCheckBox extends AcroFormButton {
- appearanceState: 'On' | 'Off';
-}
+ /** Callback function which is called when the Document has been cloned for rendering, can be used to modify the contents that will be rendered without affecting the original source document. */
+ onclone?: { (doc: HTMLDocument): void };
-interface AcroFormTextField extends AcroFormField {
- multiline: boolean;
- fileSelect: boolean;
- doNotSpellCheck: boolean;
- doNotScroll: boolean;
- comb: boolean;
- richText: boolean;
- maxLength: number;
- hasAppearanceStream: boolean;
-}
+ /** Url to the proxy which is to be used for loading cross-origin images. If left empty, cross-origin images won't be loaded. */
+ proxy?: string;
-interface AcroFormPasswordField extends AcroFormTextField { }
-// jsPDF plugin: Context2D
+ /** Whether to cleanup the cloned DOM elements html2canvas creates temporarily */
+ removeContainer?: boolean;
-interface Gradient {
- addColorStop(position:number, color:string):void;
- getColor():string;
-}
+ /** The scale to use for rendering. Defaults to the browsers device pixel ratio. */
+ scale?: number;
-interface Context2d {
- autoPaging: boolean;
- fillStyle: string|Gradient;
- filter: string;
- font: string;
- globalAlpha: number;
- globalCompositeOperation:'source-over';
- imageSmoothingEnabled:boolean;
- imageSmoothingQuality:'low'|'high';
- ignoreClearRect: boolean;
- lastBreak: number;
- lineCap: 'butt'|'round'|'square';
- lineDashOffset:number;
- lineJoin: 'bevel'|'round'|'miter';
- lineWidth: number;
- miterLimit: number;
- pageBreaks: number[];
- pageWrapXEnabled: boolean;
- pageWrapYEnabled: boolean;
- posX: number;
- posY: number;
- shadowBlur: number;
- shadowColor: string;
- shadowOffsetX:number;
- shadowOffsetY:number;
- strokeStyle: string|Gradient;
- textAlign: 'right'|'end'|'center'|'left'|'start';
- textBaseline: 'alphabetic'|'bottom'|'top'|'hanging'|'middle'|'ideographic';
- arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise: boolean): void;
- arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
- beginPath(): void;
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
- clearRect(x: number, y: number, w: number, h: number): void;
- clip(): void;
- closePath(): void;
- createLinearGradient(x0:number, y0:number, x1:number, y1:number): Gradient;
- createPattern(): Gradient;
- createRadialGradient(): Gradient;
- drawImage(img: string, x: number, y: number, width: number, height: number): void;
- drawImage(img: string, sx: number, sy: number, swidth: number, sheight: number, x: number, y: number, width: number, height: number): void;
- fill(): void;
- fillRect(x: number, y: number, w: number, h: number): void;
- fillText(text: string, x: number, y: number, maxWidth?: number): void;
- lineTo(x: number, y: number): void;
- measureText(text: string): number;
- moveTo(x: number, y: number): void;
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
- rect(x: number, y: number, w: number, h: number): void;
- restore(): void;
- rotate(angle: number): void;
- save(): void;
- scale(scalewidth: number, scaleheight: number): void;
- setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
- stroke(): void;
- strokeRect(x: number, y: number, w: number, h: number): void;
- strokeText(text: string, x: number, y: number, maxWidth?: number): void;
- transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
- translate(x: number, y: number): void;
-}
+ /** Use svg powered rendering where available (FF11+). */
+ svgRendering?: boolean;
-declare module 'jspdf' {
+ /** Whether to test each image if it taints the canvas before drawing them */
+ taintTest?: boolean;
+
+ /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */
+ useCORS?: boolean;
+
+ /** Define the width of the canvas in pixels. If null, renders with full width of the window. */
+ width?: number;
+
+ /** Define the heigt of the canvas in pixels. If null, renders with full height of the window. */
+ height?: number;
+
+ /** Crop canvas x-coordinate */
+ x?: number;
+
+ /** Crop canvas y-coordinate */
+ y?: number;
+
+ /** The x-scroll position to used when rendering element, (for example if the Element uses position: fixed ) */
+ scrollX?: number;
+
+ /** The y-scroll position to used when rendering element, (for example if the Element uses position: fixed ) */
+ scrollY?: number;
+
+ /** Window width to use when rendering Element, which may affect things like Media queries */
+ windowWidth?: number;
+
+ /** Window height to use when rendering Element, which may affect things like Media queries */
+ windowHeight?: number;
+ }
+
+ interface HTMLWorker {
+ progress: number;
+ }
+
+ interface HTMLOptions {
+ callback?: (doc: jsPDF) => void;
+ html2canvas?: Html2CanvasOptions;
+ jsPDF?: jsPDF
+ }
+
+ //jsPDF plugin: viewerPreferences
+
+ interface ViewerPreferencesInput {
+ HideToolbar?: boolean;
+ HideMenubar?: boolean;
+ HideWindowUI?: boolean;
+ FitWindow?: boolean;
+ CenterWindow?: boolean;
+ DisplayDocTitle?: boolean;
+ NonFullScreenPageMode?: 'UseNone' | 'UseOutlines' | 'UseThumbs' | 'UseOC';
+ Direction?: 'L2R' | 'R2L';
+ ViewArea?: 'MediaBox' | 'CropBox' | 'TrimBox' | 'BleedBox' | 'ArtBox';
+ ViewClip?: 'MediaBox' | 'CropBox' | 'TrimBox' | 'BleedBox' | 'ArtBox';
+ PrintArea?: 'MediaBox' | 'CropBox' | 'TrimBox' | 'BleedBox' | 'ArtBox';
+ PrintClip?: 'MediaBox' | 'CropBox' | 'TrimBox' | 'BleedBox' | 'ArtBox';
+ PrintScaling?: 'AppDefault' | 'None';
+ Duplex?: 'Simplex' | 'DuplexFlipShortEdge' | 'DuplexFlipLongEdge' | 'none';
+ PickTrayByPDFSize?: boolean;
+ PrintPageRange?: number[][];
+ NumCopies?: number;
+ }
+
+ //jsPDF plugin: Outline
+
+ interface Outline {
+ add(parent: any, title: string, options: OutlineOptions): OutlineItem;
+ }
+ interface OutlineItem {
+ title: string,
+ options: any,
+ children: any[]
+ }
+ interface OutlineOptions {
+ pageNumber: number
+ }
+ // jsPDF plugin: AcroForm
+ interface AcroFormField {
+ constructor(): AcroFormField;
+ showWhenPrinted: boolean;
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+ fieldName: string;
+ fontName: string;
+ fontStyle: string;
+ fontSize: number;
+ maxFontSize: number;
+ color: string;
+ defaultValue: string;
+ value: string;
+ hasAnnotation: boolean;
+ readOnly: boolean;
+ required: boolean;
+ noExport: boolean;
+ textAlign: 'left' | 'center' | 'right';
+ }
+
+ interface AcroFormChoiceField extends AcroFormField {
+ topIndex: number;
+ getOptions(): string[];
+ setOptions(value: string[]): void;
+ addOption(value: string): void;
+ removeOption(value: string, allEntries: boolean): void;
+ combo: boolean;
+ edit: boolean;
+ sort: boolean;
+ multiSelect: boolean;
+ doNotSpellCheck: boolean;
+ commitOnSelChange: boolean;
+ }
+
+ interface AcroFormListBox extends AcroFormChoiceField { }
+
+ interface AcroFormComboBox extends AcroFormListBox { }
+
+ interface AcroFormEditBox extends AcroFormComboBox { }
+
+ interface AcroFormButton extends AcroFormField {
+ noToggleToOff: boolean;
+ radio: boolean;
+ pushButton: boolean;
+ radioIsUnison: boolean;
+ caption: string;
+ appearanceState: any;
+ }
+
+ interface AcroFormPushButton extends AcroFormButton { }
+
+ interface AcroFormChildClass extends AcroFormField {
+ Parent: any;
+ optionName: string;
+ caption: string;
+ appearanceState: 'On' | 'Off';
+ }
+
+ interface AcroFormRadioButton extends AcroFormButton {
+ setAppearance(appearance: string): void;
+ createOption(name: string): AcroFormChildClass;
+ }
+
+ interface AcroFormCheckBox extends AcroFormButton {
+ appearanceState: 'On' | 'Off';
+ }
+
+ interface AcroFormTextField extends AcroFormField {
+ multiline: boolean;
+ fileSelect: boolean;
+ doNotSpellCheck: boolean;
+ doNotScroll: boolean;
+ comb: boolean;
+ richText: boolean;
+ maxLength: number;
+ hasAppearanceStream: boolean;
+ }
+
+ interface AcroFormPasswordField extends AcroFormTextField { }
+ // jsPDF plugin: Context2D
+
+ interface Gradient {
+ addColorStop(position: number, color: string): void;
+ getColor(): string;
+ }
+
+ interface Context2d {
+ autoPaging: boolean;
+ fillStyle: string | Gradient;
+ filter: string;
+ font: string;
+ globalAlpha: number;
+ globalCompositeOperation: 'source-over';
+ imageSmoothingEnabled: boolean;
+ imageSmoothingQuality: 'low' | 'high';
+ ignoreClearRect: boolean;
+ lastBreak: number;
+ lineCap: 'butt' | 'round' | 'square';
+ lineDashOffset: number;
+ lineJoin: 'bevel' | 'round' | 'miter';
+ lineWidth: number;
+ miterLimit: number;
+ pageBreaks: number[];
+ pageWrapXEnabled: boolean;
+ pageWrapYEnabled: boolean;
+ posX: number;
+ posY: number;
+ shadowBlur: number;
+ shadowColor: string;
+ shadowOffsetX: number;
+ shadowOffsetY: number;
+ strokeStyle: string | Gradient;
+ textAlign: 'right' | 'end' | 'center' | 'left' | 'start';
+ textBaseline: 'alphabetic' | 'bottom' | 'top' | 'hanging' | 'middle' | 'ideographic';
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise: boolean): void;
+ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
+ beginPath(): void;
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
+ clearRect(x: number, y: number, w: number, h: number): void;
+ clip(): void;
+ closePath(): void;
+ createLinearGradient(x0: number, y0: number, x1: number, y1: number): Gradient;
+ createPattern(): Gradient;
+ createRadialGradient(): Gradient;
+ drawImage(img: string, x: number, y: number, width: number, height: number): void;
+ drawImage(img: string, sx: number, sy: number, swidth: number, sheight: number, x: number, y: number, width: number, height: number): void;
+ fill(): void;
+ fillRect(x: number, y: number, w: number, h: number): void;
+ fillText(text: string, x: number, y: number, maxWidth?: number): void;
+ lineTo(x: number, y: number): void;
+ measureText(text: string): number;
+ moveTo(x: number, y: number): void;
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
+ rect(x: number, y: number, w: number, h: number): void;
+ restore(): void;
+ rotate(angle: number): void;
+ save(): void;
+ scale(scalewidth: number, scaleheight: number): void;
+ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
+ stroke(): void;
+ strokeRect(x: number, y: number, w: number, h: number): void;
+ strokeText(text: string, x: number, y: number, maxWidth?: number): void;
+ transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
+ translate(x: number, y: number): void;
+ }
class jsPDF {
constructor(options?: any);
constructor(orientation?: 'p' | 'portrait' | 'l' | 'landscape',
- unit?: 'pt'|'px'|'in'|'mm'|'cm'|'ex'|'em'|'pc',
- format?: string|number[],
+ unit?: 'pt' | 'px' | 'in' | 'mm' | 'cm' | 'ex' | 'em' | 'pc',
+ format?: string | number[],
compressPdf?: boolean);
CapJoinStyles: any;
version: string;
- addFont(postScriptName: string, id: string, fontStyle: string, encoding: 'StandardEncoding'|'MacRomanEncoding'|'Identity-H'|'WinAnsiEncoding', isStandardFont?: boolean): string;
+ addFont(postScriptName: string, id: string, fontStyle: string, encoding: 'StandardEncoding' | 'MacRomanEncoding' | 'Identity-H' | 'WinAnsiEncoding', isStandardFont?: boolean): string;
addGState(key: any, gState: any): jsPDF;
addPage(format?: string | number[], orientation?: 'p' | 'portrait' | 'l' | 'landscape'): jsPDF;
beginFormObject(x: number, y: number, width: number, height: number, matrix: any): jsPDF;
circle(x: number, y: number, r: number, style: string): jsPDF;
- clip(rule?: string): jsPDF;
+ clip(rule?: 'evenodd'): jsPDF;
+ discardPath(): jsPDF;
deletePage(targetPage: number): jsPDF;
doFormObject(key: any, matrix: any): jsPDF;
ellipse(x: number, y: number, rx: number, ry: number, style?: string): jsPDF;
@@ -267,7 +359,7 @@ declare module 'jspdf' {
setCharSpace(charSpace: number): jsPDF;
setCreationDate(date?: any): jsPDF;
setCurrentTransformationMatrix(matrix: any): jsPDF;
- setDisplayMode(zoom: number|'fullheight'|'fullwidth'|'fullpage'|'original'|string, layout?: 'continuous' | 'single' | 'twoleft' | 'tworight'|'two', pmode?: 'UseOutlines' | 'UseThumbs' | 'FullScreen'): jsPDF;
+ setDisplayMode(zoom: number | 'fullheight' | 'fullwidth' | 'fullpage' | 'original' | string, layout?: 'continuous' | 'single' | 'twoleft' | 'tworight' | 'two', pmode?: 'UseOutlines' | 'UseThumbs' | 'FullScreen'): jsPDF;
setDocumentProperties(properties: any): jsPDF;
setProperties(properties: any): jsPDF;
setDrawColor(ch1: string): jsPDF;
@@ -293,7 +385,7 @@ declare module 'jspdf' {
setTextColor(ch1: number): jsPDF;
setTextColor(ch1: number, ch2: number, ch3: number, ch4?: number): jsPDF;
text(text: string | string[], x: number, y: number, options?: any, transform?: number | any): jsPDF;
- text(x: number, y: number, text: string|string[], flags?: any, angle?:number, align?:'left'|'center'|'right'): jsPDF;
+ text(x: number, y: number, text: string | string[], flags?: any, angle?: number, align?: 'left' | 'center' | 'right'): jsPDF;
triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, style: string): jsPDF;
getHorizontalCoordinateString(value: number): number;
getVerticalCoordinateString(value: number): number;
@@ -354,7 +446,7 @@ declare module 'jspdf' {
createImageInfo(data: any, wd: number, ht: number, cs: any, bpc: number, imageIndex: number, alias: any, f?: any, dp?: any, trns?: any, pal?: any, smask?: any): any;
addImage(imageData: string | Uint8Array, format: string, x: number, y: number, w: number, h: number, alias?: string, compression?: any, rotation?: number): jsPDF;
addImage(imageData: string | Uint8Array, x: number, y: number, w: number, h: number, alias?: string, compression?: any, rotation?: number): jsPDF;
- addImage(options:any): jsPDF;
+ addImage(options: any): jsPDF;
convertStringToImageData(stringData: string, throwError: boolean): any;
getImageProperties(imageData: any): any;
@@ -395,7 +487,7 @@ declare module 'jspdf' {
pdf: jsPDF;
width: number;
height: number;
- getContext(type?:string): Context2d;
+ getContext(type?: string): Context2d;
style: any;
};
@@ -419,7 +511,7 @@ declare module 'jspdf' {
loadFile(url: string): string;
// jsPDF plugin: html
- html(src: string, options: any): jsPDF;
+ html(src: string | HTMLElement, options: HTMLOptions): Promise;
// jsPDF plugin: fromHTML
fromHTML(HTML: string | HTMLElement, x: number, y: number, settings?: any, callback?: Function, margins?: any): jsPDF;
@@ -436,14 +528,14 @@ declare module 'jspdf' {
addSVG(svgtext: string, x: number, y: number, w?: number, h?: number): jsPDF;
addSvgAsImage(svg: string, x: number, y: number, w: number, h: number, alias?: string, compression?: boolean, rotation?: number): jsPDF;
// jsPDF plugin: setlanguage
- setLanguage(langCode: 'af'|'sq'|'ar'|'ar-DZ'|'ar-BH'|'ar-EG'|'ar-IQ'|'ar-JO'|'ar-KW'|'ar-LB'|'ar-LY'|'ar-MA'|'ar-OM'|'ar-QA'|'ar-SA'|'ar-SY'|'ar-TN'|'ar-AE'|'ar-YE'|'an'|'hy'|'as'|'ast'|'az'|'eu'|'be'|'bn'|'bs'|'br'|'bg'|'my'|'ca'|'ch'|'ce'|'zh'|'zh-HK'|'zh-CN'|'zh-SG'|'zh-TW'|'cv'|'co'|'cr'|'hr'|'cs'|'da'|'nl'|'nl-BE'|'en'|'en-AU'|'en-BZ'|'en-CA'|'en-IE'|'en-JM'|'en-NZ'|'en-PH'|'en-ZA'|'en-TT'|'en-GB'|'en-US'|'en-ZW'|'eo'|'et'|'fo'|'fj'|'fi'|'fr'|'fr-BE'|'fr-CA'|'fr-FR'|'fr-LU'|'fr-MC'|'fr-CH'|'fy'|'fur'|'gd'|'gd-IE'|'gl'|'ka'|'de'|'de-AT'|'de-DE'|'de-LI'|'de-LU'|'de-CH'|'el'|'gu'|'ht'|'he'|'hi'|'hu'|'is'|'id'|'iu'|'ga'|'it'|'it-CH'|'ja'|'kn'|'ks'|'kk'|'km'|'ky'|'tlh'|'ko'|'ko-KP'|'ko-KR'|'la'|'lv'|'lt'|'lb'|'mk'|'ms'|'ml'|'mt'|'mi'|'mr'|'mo'|'nv'|'ng'|'ne'|'no'|'nb'|'nn'|'oc'|'or'|'om'|'fa'|'fa-IR'|'pl'|'pt'|'pt-BR'|'pa'|'pa-IN'|'pa-PK'|'qu'|'rm'|'ro'|'ro-MO'|'ru'|'ru-MO'|'sz'|'sg'|'sa'|'sc'|'sd'|'si'|'sr'|'sk'|'sl'|'so'|'sb'|'es'|'es-AR'|'es-BO'|'es-CL'|'es-CO'|'es-CR'|'es-DO'|'es-EC'|'es-SV'|'es-GT'|'es-HN'|'es-MX'|'es-NI'|'es-PA'|'es-PY'|'es-PE'|'es-PR'|'es-ES'|'es-UY'|'es-VE'|'sx'|'sw'|'sv'|'sv-FI'|'sv-SV'|'ta'|'tt'|'te'|'th'|'tig'|'ts'|'tn'|'tr'|'tk'|'uk'|'hsb'|'ur'|'ve'|'vi'|'vo'|'wa'|'cy'|'xh'|'ji'|'zu'): jsPDF;
+ setLanguage(langCode: 'af' | 'sq' | 'ar' | 'ar-DZ' | 'ar-BH' | 'ar-EG' | 'ar-IQ' | 'ar-JO' | 'ar-KW' | 'ar-LB' | 'ar-LY' | 'ar-MA' | 'ar-OM' | 'ar-QA' | 'ar-SA' | 'ar-SY' | 'ar-TN' | 'ar-AE' | 'ar-YE' | 'an' | 'hy' | 'as' | 'ast' | 'az' | 'eu' | 'be' | 'bn' | 'bs' | 'br' | 'bg' | 'my' | 'ca' | 'ch' | 'ce' | 'zh' | 'zh-HK' | 'zh-CN' | 'zh-SG' | 'zh-TW' | 'cv' | 'co' | 'cr' | 'hr' | 'cs' | 'da' | 'nl' | 'nl-BE' | 'en' | 'en-AU' | 'en-BZ' | 'en-CA' | 'en-IE' | 'en-JM' | 'en-NZ' | 'en-PH' | 'en-ZA' | 'en-TT' | 'en-GB' | 'en-US' | 'en-ZW' | 'eo' | 'et' | 'fo' | 'fj' | 'fi' | 'fr' | 'fr-BE' | 'fr-CA' | 'fr-FR' | 'fr-LU' | 'fr-MC' | 'fr-CH' | 'fy' | 'fur' | 'gd' | 'gd-IE' | 'gl' | 'ka' | 'de' | 'de-AT' | 'de-DE' | 'de-LI' | 'de-LU' | 'de-CH' | 'el' | 'gu' | 'ht' | 'he' | 'hi' | 'hu' | 'is' | 'id' | 'iu' | 'ga' | 'it' | 'it-CH' | 'ja' | 'kn' | 'ks' | 'kk' | 'km' | 'ky' | 'tlh' | 'ko' | 'ko-KP' | 'ko-KR' | 'la' | 'lv' | 'lt' | 'lb' | 'mk' | 'ms' | 'ml' | 'mt' | 'mi' | 'mr' | 'mo' | 'nv' | 'ng' | 'ne' | 'no' | 'nb' | 'nn' | 'oc' | 'or' | 'om' | 'fa' | 'fa-IR' | 'pl' | 'pt' | 'pt-BR' | 'pa' | 'pa-IN' | 'pa-PK' | 'qu' | 'rm' | 'ro' | 'ro-MO' | 'ru' | 'ru-MO' | 'sz' | 'sg' | 'sa' | 'sc' | 'sd' | 'si' | 'sr' | 'sk' | 'sl' | 'so' | 'sb' | 'es' | 'es-AR' | 'es-BO' | 'es-CL' | 'es-CO' | 'es-CR' | 'es-DO' | 'es-EC' | 'es-SV' | 'es-GT' | 'es-HN' | 'es-MX' | 'es-NI' | 'es-PA' | 'es-PY' | 'es-PE' | 'es-PR' | 'es-ES' | 'es-UY' | 'es-VE' | 'sx' | 'sw' | 'sv' | 'sv-FI' | 'sv-SV' | 'ta' | 'tt' | 'te' | 'th' | 'tig' | 'ts' | 'tn' | 'tr' | 'tk' | 'uk' | 'hsb' | 'ur' | 've' | 'vi' | 'vo' | 'wa' | 'cy' | 'xh' | 'ji' | 'zu'): jsPDF;
// jsPDF plugin: total_pages
putTotalPages(pageExpression: string): jsPDF;
// jsPDF plugin: viewerpreferences
viewerPreferences(options: ViewerPreferencesInput, doReset?: boolean): jsPDF
- viewerPreferences(arg:'reset'): jsPDF
+ viewerPreferences(arg: 'reset'): jsPDF
// jsPDF plugin: vfs
existsFileInVFS(filename: string): boolean;
diff --git a/definitely_typed/jspdf-tests.ts b/definitely_typed/jspdf-tests.ts
index 767f0c85a..dfa9eff20 100644
--- a/definitely_typed/jspdf-tests.ts
+++ b/definitely_typed/jspdf-tests.ts
@@ -98,11 +98,11 @@ function test_text_colors() {
function test_font_metrics_based_line_sizing_split() {
var pdf = new jsPDF('p', 'in', 'letter');
- var sizes:number[] = [12, 16, 20];
+ var sizes: number[] = [12, 16, 20];
var fonts = [['Times', 'Roman'], ['Helvetica', ''], ['Times', 'Italic']];
- var font:string[];
- var size:number;
- var lines:any[];
+ var font: string[];
+ var size: number;
+ var lines: any[];
var verticalOffset = 0.5; // inches on a 8.5 x 11 inch sheet.
var loremipsum = 'Lorem ipsum dolor sit amet, ...';
for (var i in fonts) {
@@ -123,10 +123,10 @@ function test_from_html() {
var pdf = new jsPDF('p', 'pt', 'letter')
, source = document.getElementById('#fromHTMLtestdiv')
, specialElementHandlers = {
- '#bypassme': function (element:HTMLElement, renderer:any) {
- return true
- }
- };
+ '#bypassme': function (element: HTMLElement, renderer: any) {
+ return true
+ }
+ };
var margins = {
top: 80,
bottom: 60,
@@ -142,7 +142,7 @@ function test_from_html() {
'width': margins.width // max width of content on PDF
, 'elementHandlers': specialElementHandlers
},
- function (dispose:any) {
+ function (dispose: any) {
pdf.save('Test.pdf');
},
margins
@@ -213,7 +213,7 @@ function test_triangles() {
}
function test_images() {
- var getImageFromUrl = function (url:string, callback:Function) {
+ var getImageFromUrl = function (url: string, callback: Function) {
var img = new Image();
img.onerror = function () {
alert('Cannot load image: "' + url + '"');
@@ -224,7 +224,7 @@ function test_images() {
img.src = url;
};
- var createPDF = function (imgData:string) {
+ var createPDF = function (imgData: string) {
var doc = new jsPDF();
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50, 'monkey'); // Cache the image using the alias 'monkey'
doc.addImage('monkey', 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless
@@ -251,9 +251,9 @@ function test_add_html() {
function test_context2d_smiley() {
var doc = new jsPDF('p', 'pt', 'a4');
- var ctx = doc.context2d;
+ var ctx = doc.context2d;
+
-
ctx.beginPath();
ctx.arc(75, 75, 50, 0, Math.PI * 2, true); // Outer circle
ctx.moveTo(110, 75);
@@ -266,141 +266,141 @@ function test_context2d_smiley() {
}
function test_context2d_warnsign() {
-
- var doc = new jsPDF('p', 'pt', 'a4');
- var context = doc.context2d;
-
- var primaryColor = "#ffc821";
- var secondaryColor = "black";
- var tertiaryColor = "black";
- var lineWidth = 10;
- // Dimensions of the triangle
- var width = 125;
- var height = 100;
- var padding = 20;
-
- // Create a triangluar path
- context.beginPath();
- context.moveTo(padding + width/2, padding);
- context.lineTo(padding + width, height + padding);
- context.lineTo(padding, height + padding);
- context.closePath();
-
- // Create fill gradient
- var gradient = context.createLinearGradient(0,0,0,height);
- gradient.addColorStop(0, primaryColor);
- gradient.addColorStop(1, secondaryColor);
-
- // Add a shadow around the object
- context.shadowBlur = 10;
- context.shadowColor = "black";
-
- // Stroke the outer outline
- context.lineWidth = lineWidth * 2;
- context.lineJoin = "round";
- context.strokeStyle = gradient;
- context.stroke();
-
- // Turn off the shadow, or all future fills will have shadows
- context.shadowColor = "transparent";
-
- // Fill the path
- context.fillStyle = gradient;
- context.fill();
-
- // Add a horizon reflection with a gradient to transparent
- gradient=context.createLinearGradient(0,padding,0,padding+height);
- gradient.addColorStop(0, "transparent");
- gradient.addColorStop(0.5, "transparent");
- gradient.addColorStop(0.5, tertiaryColor);
- gradient.addColorStop(1, secondaryColor);
-
- context.fillStyle = gradient;
- context.fill();
-
- // Stroke the inner outline
- context.lineWidth = lineWidth;
- context.lineJoin = "round";
- context.strokeStyle = "#333";
- context.stroke();
-
- // Draw the text exclamation point
- context.textAlign = "center";
- context.textBaseline = "middle";
- context.font = "bold 60px 'Times New Roman', Times, serif";
- context.fillStyle = "#333";
- context.fillText("!", padding + width/2, padding + height/1.5);
-}
-
-function test_context2d_fields () {
-
- var doc = new jsPDF();
-
- var ctx = doc.canvas.getContext('2d');
-
- ctx.fillStyle='#000000';
- ctx.filter='none';
- ctx.font='10px sans-serif';
- ctx.globalAlpha=1;
- ctx.globalCompositeOperation="source-over";
- ctx.imageSmoothingEnabled=true;
- ctx.imageSmoothingQuality="low";
- ctx.lineCap="butt";
- ctx.lineDashOffset=0;
- ctx.lineJoin="miter";
- ctx.lineWidth=1;
- ctx.miterLimit=10;
- ctx.shadowBlur=0;
- ctx.shadowColor="rgba(0, 0, 0, 0)";
- ctx.shadowOffsetX=0;
- ctx.shadowOffsetY=0;
- ctx.strokeStyle='#000000';
- ctx.textAlign='start';
- ctx.textBaseline='alphabetic';
-}
-
-function test_context2d_functions () {
+
+ var doc = new jsPDF('p', 'pt', 'a4');
+ var context = doc.context2d;
+
+ var primaryColor = "#ffc821";
+ var secondaryColor = "black";
+ var tertiaryColor = "black";
+ var lineWidth = 10;
+ // Dimensions of the triangle
+ var width = 125;
+ var height = 100;
+ var padding = 20;
+
+ // Create a triangluar path
+ context.beginPath();
+ context.moveTo(padding + width / 2, padding);
+ context.lineTo(padding + width, height + padding);
+ context.lineTo(padding, height + padding);
+ context.closePath();
+
+ // Create fill gradient
+ var gradient = context.createLinearGradient(0, 0, 0, height);
+ gradient.addColorStop(0, primaryColor);
+ gradient.addColorStop(1, secondaryColor);
+
+ // Add a shadow around the object
+ context.shadowBlur = 10;
+ context.shadowColor = "black";
+
+ // Stroke the outer outline
+ context.lineWidth = lineWidth * 2;
+ context.lineJoin = "round";
+ context.strokeStyle = gradient;
+ context.stroke();
+
+ // Turn off the shadow, or all future fills will have shadows
+ context.shadowColor = "transparent";
+
+ // Fill the path
+ context.fillStyle = gradient;
+ context.fill();
+
+ // Add a horizon reflection with a gradient to transparent
+ gradient = context.createLinearGradient(0, padding, 0, padding + height);
+ gradient.addColorStop(0, "transparent");
+ gradient.addColorStop(0.5, "transparent");
+ gradient.addColorStop(0.5, tertiaryColor);
+ gradient.addColorStop(1, secondaryColor);
+
+ context.fillStyle = gradient;
+ context.fill();
+
+ // Stroke the inner outline
+ context.lineWidth = lineWidth;
+ context.lineJoin = "round";
+ context.strokeStyle = "#333";
+ context.stroke();
+
+ // Draw the text exclamation point
+ context.textAlign = "center";
+ context.textBaseline = "middle";
+ context.font = "bold 60px 'Times New Roman', Times, serif";
+ context.fillStyle = "#333";
+ context.fillText("!", padding + width / 2, padding + height / 1.5);
+}
+
+function test_context2d_fields() {
+
var doc = new jsPDF();
- doc.context2d.moveTo(1,1);
- doc.context2d.lineTo (1,1);
- doc.context2d.quadraticCurveTo (1,1,1,1);
- doc.context2d.bezierCurveTo(1,1,1,1,1,1);
- doc.context2d.arc(1,1,1,1,1,false);
- doc.context2d.rect (1,1,1,1);
- doc.context2d.fillRect (1,1,1,1);
- doc.context2d.strokeRect (1,1,1,1);
- doc.context2d.clearRect (1,1,1,1);
- doc.context2d.fillText ('valid',1,1,1);
- doc.context2d.strokeText ('valid',1,1,1);
- doc.context2d.measureText ('valid');
- doc.context2d.scale (1,1);
- doc.context2d.rotate (1);
- doc.context2d.translate (1,1);
- doc.context2d.transform(1,1,1,1,1,1);
+
+ var ctx = doc.canvas.getContext('2d');
+
+ ctx.fillStyle = '#000000';
+ ctx.filter = 'none';
+ ctx.font = '10px sans-serif';
+ ctx.globalAlpha = 1;
+ ctx.globalCompositeOperation = "source-over";
+ ctx.imageSmoothingEnabled = true;
+ ctx.imageSmoothingQuality = "low";
+ ctx.lineCap = "butt";
+ ctx.lineDashOffset = 0;
+ ctx.lineJoin = "miter";
+ ctx.lineWidth = 1;
+ ctx.miterLimit = 10;
+ ctx.shadowBlur = 0;
+ ctx.shadowColor = "rgba(0, 0, 0, 0)";
+ ctx.shadowOffsetX = 0;
+ ctx.shadowOffsetY = 0;
+ ctx.strokeStyle = '#000000';
+ ctx.textAlign = 'start';
+ ctx.textBaseline = 'alphabetic';
+}
+
+function test_context2d_functions() {
+ var doc = new jsPDF();
+ doc.context2d.moveTo(1, 1);
+ doc.context2d.lineTo(1, 1);
+ doc.context2d.quadraticCurveTo(1, 1, 1, 1);
+ doc.context2d.bezierCurveTo(1, 1, 1, 1, 1, 1);
+ doc.context2d.arc(1, 1, 1, 1, 1, false);
+ doc.context2d.rect(1, 1, 1, 1);
+ doc.context2d.fillRect(1, 1, 1, 1);
+ doc.context2d.strokeRect(1, 1, 1, 1);
+ doc.context2d.clearRect(1, 1, 1, 1);
+ doc.context2d.fillText('valid', 1, 1, 1);
+ doc.context2d.strokeText('valid', 1, 1, 1);
+ doc.context2d.measureText('valid');
+ doc.context2d.scale(1, 1);
+ doc.context2d.rotate(1);
+ doc.context2d.translate(1, 1);
+ doc.context2d.transform(1, 1, 1, 1, 1, 1);
}
function test_add_font() {
-
- var doc = new jsPDF('p','pt', 'a4');
+
+ var doc = new jsPDF('p', 'pt', 'a4');
doc.addFont('helvetica', 'helvetica', 'normal', 'StandardEncoding');
}
function test_vfs() {
-
- var doc = new jsPDF('p','pt', 'a4');
- doc.addFileToVFS('test.pdf', 'BADFACE');
+
+ var doc = new jsPDF('p', 'pt', 'a4');
+ doc.addFileToVFS('test.pdf', 'BADFACE');
doc.getFileFromVFS('test.pdf');
doc.existsFileInVFS('test.pdf');
}
function test_outline() {
- var doc = new jsPDF({unit: 'pt'})
- doc.outline.add(null, "Page 1", {pageNumber:1});
+ var doc = new jsPDF({ unit: 'pt' })
+ doc.outline.add(null, "Page 1", { pageNumber: 1 });
doc.addPage();
}
function test_page_operations() {
-
+
var doc = new jsPDF()
doc.text('Text that will end up on page 2', 20, 20)
doc.addPage()
@@ -412,8 +412,8 @@ function test_page_operations() {
doc.deletePage(3)
}
-function test_displayMode (){
-
+function test_displayMode() {
+
const doc = new jsPDF();
doc.setDisplayMode('fullheight');
doc.setDisplayMode('fullwidth');
@@ -434,42 +434,42 @@ function test_displayMode (){
function test_put_total_pages() {
const doc = new jsPDF();
- const totalPagesExp = '{totalPages}';
-
+ const totalPagesExp = '{totalPages}';
- doc.text(10, 10, "Page 1 of {totalPages}");
- doc.addPage();
- doc.text(10, 10, "Page 2 of {totalPages}");
+ doc.text(10, 10, "Page 1 of {totalPages}");
+ doc.addPage();
+
+ doc.text(10, 10, "Page 2 of {totalPages}");
- if (typeof doc.putTotalPages === 'function') {
- doc.putTotalPages(totalPagesExp);
- }
+ if (typeof doc.putTotalPages === 'function') {
+ doc.putTotalPages(totalPagesExp);
+ }
}
function test_autoprint() {
-
+
const doc = new jsPDF()
doc.text(10, 10, 'This is a test')
doc.autoPrint()
- doc.autoPrint({variant: 'javascript'})
+ doc.autoPrint({ variant: 'javascript' })
}
function test_viewerpreferences() {
-
+
const doc = new jsPDF()
doc.text(10, 10, 'This is a test')
- doc.viewerPreferences({'HideToolbar': true})
- doc.viewerPreferences({'HideMenubar': true})
- doc.viewerPreferences({'HideWindowUI': true})
- doc.viewerPreferences({ NumCopies:9})
- doc.viewerPreferences({'HideWindowUI': true})
- doc.viewerPreferences({'FitWindow': true}, true)
- doc.viewerPreferences({'ViewArea' : 'MediaBox'})
- doc.viewerPreferences({'PrintPageRange' : [[1,3],[5,9]]})
- doc.viewerPreferences({'HideWindowUI': true})
+ doc.viewerPreferences({ 'HideToolbar': true })
+ doc.viewerPreferences({ 'HideMenubar': true })
+ doc.viewerPreferences({ 'HideWindowUI': true })
+ doc.viewerPreferences({ NumCopies: 9 })
+ doc.viewerPreferences({ 'HideWindowUI': true })
+ doc.viewerPreferences({ 'FitWindow': true }, true)
+ doc.viewerPreferences({ 'ViewArea': 'MediaBox' })
+ doc.viewerPreferences({ 'PrintPageRange': [[1, 3], [5, 9]] })
+ doc.viewerPreferences({ 'HideWindowUI': true })
doc.viewerPreferences('reset')
- doc.viewerPreferences({'FitWindow': true})
+ doc.viewerPreferences({ 'FitWindow': true })
}
function test_arabic() {
@@ -489,51 +489,61 @@ function test_split_text_to_size() {
}
function test_setlanguage() {
-
+
var doc = new jsPDF();
doc.setLanguage("en-US");
doc.setLanguage('de-DE')
-
+
}
function test_annotations() {
const doc = new jsPDF()
doc.createAnnotation({
- type: 'text',
- title: 'note',
- bounds: {
- x: 10,
- y: 10,
- w: 200,
- h: 80
- },
- contents: 'This is text annotation (closed by default)',
- open: false
+ type: 'text',
+ title: 'note',
+ bounds: {
+ x: 10,
+ y: 10,
+ w: 200,
+ h: 80
+ },
+ contents: 'This is text annotation (closed by default)',
+ open: false
})
doc.createAnnotation({
type: 'text',
title: 'note',
bounds: {
- x: 10,
- y: 10,
- w: 200,
- h: 80
+ x: 10,
+ y: 10,
+ w: 200,
+ h: 80
},
contents: 'This is text annotation (open by default)',
open: true
- })
-
+ })
+
doc.createAnnotation({
type: 'freetext',
bounds: {
- x: 0,
- y: 10,
- w: 200,
- h: 20
+ x: 0,
+ y: 10,
+ w: 200,
+ h: 20
},
contents: 'This is a freetext annotation',
color: '#ff0000'
- })
+ })
+
+ var pdf = new jsPDF();
+ var x = 1, y = 1, i = 1;
+ var width = pdf.textWithLink(" [100%]", x, y, { pageNumber: i, magFactor: 'XYZ', zoom: 1 });
+ var width = pdf.textWithLink(" [200%]", x, y, { pageNumber: i, magFactor: 'XYZ', zoom: 2 });
+ var width = pdf.textWithLink(" [50%]", x, y, { pageNumber: i, magFactor: 'XYZ', zoom: .5 });
+ var width = pdf.textWithLink(" [Fit]", x, y, { pageNumber: i, magFactor: 'Fit' });
+ var width = pdf.textWithLink(" [FitH]", x, y, { pageNumber: i, magFactor: 'FitH' });
+ var width = pdf.textWithLink(" [FitV]", x, y, { pageNumber: i, magFactor: 'FitV' });
+
}
function test_AcroForm() {
@@ -547,4 +557,16 @@ function test_AcroForm() {
var textField = doc.AcroForm.TextField();
textField.value = 'Test';
textField.defaultValue = '';
+}
+
+function test_html() {
+ var doc = new jsPDF();
+
+ doc.html(document.body, {
+ callback: function (doc) {},
+ html2canvas: {
+ allowTaint: false
+ },
+ jsPDF: doc
+ })
}
\ No newline at end of file
diff --git a/dist/jspdf.debug.js b/dist/jspdf.debug.js
index d5a782e2e..b266d4fef 100644
--- a/dist/jspdf.debug.js
+++ b/dist/jspdf.debug.js
@@ -5,10 +5,13 @@
/** @license
* jsPDF - PDF Document creation from JavaScript
- * Version 1.5.3 Built on 2018-12-27T14:11:42.696Z
- * CommitID d93d28db14
+ * Version 1.5.3 Built on 2019-03-28T02:02:22.223Z
+ * CommitID cf389e836e
*
- * Copyright (c) 2010-2016 James Hall , https://github.com/MrRio/jsPDF
+ * Copyright (c) 2010-2018 James Hall , https://github.com/MrRio/jsPDF
+ * 2015-2018 yWorks GmbH, http://www.yworks.com
+ * 2015-2018 Lukas Holländer , https://github.com/HackbrettXXX
+ * 2016-2018 Aras Abbasi
* 2010 Aaron Spike, https://github.com/acspike
* 2012 Willow Systems Corporation, willow-systems.com
* 2012 Pablo Hess, https://github.com/pablohess
@@ -46,10 +49,10 @@
return _typeof(obj);
}
- /**
- * JavaScript Polyfill functions for jsPDF
- * Collected from public resources by
- * https://github.com/diegocr
+ /**
+ * JavaScript Polyfill functions for jsPDF
+ * Collected from public resources by
+ * https://github.com/diegocr
*/
(function (global) {
if (_typeof(global.console) !== "object") {
@@ -66,11 +69,11 @@
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' + 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
while (prop = properties.pop()) {
- if (!con[prop]) con[prop] = {};
+ if (!con[prop]) { con[prop] = {}; }
}
while (method = methods.pop()) {
- if (!con[method]) con[method] = dummy;
+ if (!con[method]) { con[method] = dummy; }
}
}
@@ -187,7 +190,7 @@
Array.prototype.map = function (fun
/*, thisArg */
) {
- if (this === void 0 || this === null || typeof fun !== "function") throw new TypeError();
+ if (this === void 0 || this === null || typeof fun !== "function") { throw new TypeError(); }
var t = Object(this),
len = t.length >>> 0,
res = new Array(len);
@@ -199,7 +202,7 @@
// possible only if Object.prototype or Array.prototype
// has a property |i| (very unlikely), so use a less-correct
// but more portable alternative.
- if (i in t) res[i] = fun.call(thisArg, t[i], i, t);
+ if (i in t) { res[i] = fun.call(thisArg, t[i], i, t); }
}
return res;
@@ -210,17 +213,140 @@
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
+ } // Production steps of ECMA-262, Edition 5, 15.4.4.21
+ // Reference: http://es5.github.io/#x15.4.4.21
+ // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
+
+
+ if (!Array.prototype.reduce) {
+ Object.defineProperty(Array.prototype, 'reduce', {
+ value: function value(callback
+ /*, initialValue*/
+ ) {
+ if (this === null) {
+ throw new TypeError('Array.prototype.reduce ' + 'called on null or undefined');
+ }
+
+ if (typeof callback !== 'function') {
+ throw new TypeError(callback + ' is not a function');
+ } // 1. Let O be ? ToObject(this value).
+
+
+ var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
+
+ var len = o.length >>> 0; // Steps 3, 4, 5, 6, 7
+
+ var k = 0;
+ var value;
+
+ if (arguments.length >= 2) {
+ value = arguments[1];
+ } else {
+ while (k < len && !(k in o)) {
+ k++;
+ } // 3. If len is 0 and initialValue is not present,
+ // throw a TypeError exception.
+
+
+ if (k >= len) {
+ throw new TypeError('Reduce of empty array ' + 'with no initial value');
+ }
+
+ value = o[k++];
+ } // 8. Repeat, while k < len
+
+
+ while (k < len) {
+ // a. Let Pk be ! ToString(k).
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ // c. If kPresent is true, then
+ // i. Let kValue be ? Get(O, Pk).
+ // ii. Let accumulator be ? Call(
+ // callbackfn, undefined,
+ // « accumulator, kValue, k, O »).
+ if (k in o) {
+ value = callback(value, o[k], k, o);
+ } // d. Increase k by 1.
+
+
+ k++;
+ } // 9. Return accumulator.
+
+
+ return value;
+ }
+ });
+ }
+
+ if (!Uint8Array.prototype.reduce) {
+ Object.defineProperty(Uint8Array.prototype, 'reduce', {
+ value: function value(callback
+ /*, initialValue*/
+ ) {
+ if (this === null) {
+ throw new TypeError('Array.prototype.reduce ' + 'called on null or undefined');
+ }
+
+ if (typeof callback !== 'function') {
+ throw new TypeError(callback + ' is not a function');
+ } // 1. Let O be ? ToObject(this value).
+
+
+ var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
+
+ var len = o.length >>> 0; // Steps 3, 4, 5, 6, 7
+
+ var k = 0;
+ var value;
+
+ if (arguments.length >= 2) {
+ value = arguments[1];
+ } else {
+ while (k < len && !(k in o)) {
+ k++;
+ } // 3. If len is 0 and initialValue is not present,
+ // throw a TypeError exception.
+
+
+ if (k >= len) {
+ throw new TypeError('Reduce of empty array ' + 'with no initial value');
+ }
+
+ value = o[k++];
+ } // 8. Repeat, while k < len
+
+
+ while (k < len) {
+ // a. Let Pk be ! ToString(k).
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ // c. If kPresent is true, then
+ // i. Let kValue be ? Get(O, Pk).
+ // ii. Let accumulator be ? Call(
+ // callbackfn, undefined,
+ // « accumulator, kValue, k, O »).
+ if (k in o) {
+ value = callback(value, o[k], k, o);
+ } // d. Increase k by 1.
+
+
+ k++;
+ } // 9. Return accumulator.
+
+
+ return value;
+ }
+ });
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (fun, thisArg) {
- if (this === void 0 || this === null || typeof fun !== "function") throw new TypeError();
+ if (this === void 0 || this === null || typeof fun !== "function") { throw new TypeError(); }
var t = Object(this),
len = t.length >>> 0;
for (var i = 0; i < len; i++) {
- if (i in t) fun.call(thisArg, t[i], i, t);
+ if (i in t) { fun.call(thisArg, t[i], i, t); }
}
};
} // https://tc39.github.io/ecma262/#sec-array.prototype.find
@@ -309,6 +435,8 @@
if (typeof Object.assign != 'function') {
Object.assign = function (target) {
+ var arguments$1 = arguments;
+
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object');
@@ -317,7 +445,7 @@
target = Object(target);
for (var index = 1; index < arguments.length; index++) {
- var source = arguments[index];
+ var source = arguments$1[index];
if (source != null) {
for (var key in source) {
@@ -357,37 +485,16 @@
// while `this` is nsIContentFrameMessageManager
// with an attribute `content` that corresponds to the window
- /**
- * Creates new jsPDF document object instance.
- * @name jsPDF
- * @class
- * @param orientation {string/Object} Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l").
- * Can also be an options object.
- * @param unit {string} Measurement unit to be used when coordinates are specified.
- * Possible values are "pt" (points), "mm" (Default), "cm", "in" or "px".
- * @param format {string/Array} The format of the first page. Can be:a0 - a10 b0 - b10 c0 - c10 dl letter government-letter legal junior-legal ledger tabloid credit-card
- * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
- * @returns {jsPDF} jsPDF-instance
- * @description
- * If the first parameter (orientation) is an object, it will be interpreted as an object of named parameters
- * ```
- * {
- * orientation: 'p',
- * unit: 'mm',
- * format: 'a4',
- * hotfixes: [] // an array of hotfix strings to enable
- * }
- * ```
- */
- var jsPDF = function (global) {
- /**
- * jsPDF's Internal PubSub Implementation.
- * Backward compatible rewritten on 2014 by
- * Diego Casorran, https://github.com/diegocr
- *
- * @class
- * @name PubSub
- * @ignore
+ /* global saveAs, define, RGBColor */
+ (function (global) {
+ /**
+ * jsPDF's Internal PubSub Implementation.
+ * Backward compatible rewritten on 2014 by
+ * Diego Casorran, https://github.com/diegocr
+ *
+ * @class
+ * @name PubSub
+ * @ignore
*/
function PubSub(context) {
@@ -445,10 +552,10 @@
}
}
- if (sub[1]) tokens.push(token);
+ if (sub[1]) { tokens.push(token); }
}
- if (tokens.length) tokens.forEach(this.unsubscribe);
+ if (tokens.length) { tokens.forEach(this.unsubscribe); }
}
};
@@ -456,25 +563,53 @@
return topics;
};
}
- /**
- * @constructor
- * @private
- */
+ /**
+ * Creates new jsPDF document object instance.
+ * @name jsPDF
+ * @class
+ * @param {Object} [options] - Collection of settings initializing the jsPDF-instance
+ * @param {string} [options.orientation=portrait] - Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" or "l").
+ * @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.
+ * Possible values are "pt" (points), "mm", "cm", "m", "in" or "px".
+ * @param {string/Array} [options.format=a4] The format of the first page. Can be:a0 - a10 b0 - b10 c0 - c10 dl letter government-letter legal junior-legal ledger tabloid credit-card
+ * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
+ * @param {boolean} [options.putOnlyUsedFonts=true] Only put fonts into the PDF, which were used.
+ * @param {boolean} [options.compress=false] Compress the generated PDF.
+ * @param {number} [options.precision=2] Precision of the element-positions.
+ * @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.
+ * @returns {jsPDF} jsPDF-instance
+ * @description
+ * ```
+ * {
+ * orientation: 'p',
+ * unit: 'mm',
+ * format: 'a4',
+ * putOnlyUsedFonts:true
+ * }
+ * ```
+ *
+ * @constructor
+ */
- function jsPDF(orientation, unit, format, compressPdf) {
- var options = {};
+ function jsPDF(options) {
+ var unit = arguments[1];
+ var format = arguments[2];
+ var compressPdf = arguments[3];
var filters = [];
var userUnit = 1.0;
+ var precision;
+ var orientation = typeof options === 'string' ? options : 'p';
+ options = options || {};
- if (_typeof(orientation) === 'object') {
- options = orientation;
+ if (_typeof(options) === 'object') {
orientation = options.orientation;
unit = options.unit || unit;
format = options.format || format;
compressPdf = options.compress || options.compressPdf || compressPdf;
filters = options.filters || (compressPdf === true ? ['FlateEncode'] : filters);
userUnit = typeof options.userUnit === "number" ? Math.abs(options.userUnit) : 1.0;
+ precision = options.precision;
}
unit = unit || 'mm';
@@ -549,18 +684,44 @@
return pageFormats[value];
};
- if (typeof format === "string") {
- format = getPageFormat(format);
- }
+ format = format || 'a4';
+
+ var roundToPrecision = API.roundToPrecision = API.__private__.roundToPrecision = function (number, parmPrecision) {
+ var tmpPrecision = precision || parmPrecision;
+
+ if (isNaN(number) || isNaN(tmpPrecision)) {
+ throw new Error('Invalid argument passed to jsPDF.roundToPrecision');
+ }
- format = format || getPageFormat('a4');
+ if (precision >= 16) {
+ return number.toFixed(precision).replace(/0+$/, "");
+ } else {
+ return number.toFixed(tmpPrecision);
+ }
+ };
+
+ var scale = API.scale = API.__private__.scale = function (number) {
+ if (isNaN(number)) {
+ throw new Error('Invalid argument passed to jsPDF.scale');
+ }
+
+ return number * k;
+ };
+
+ var hpf = API.hpf = API.__private__.hpf = function (number) {
+ if (isNaN(number)) {
+ throw new Error('Invalid argument passed to jsPDF.hpf');
+ }
+
+ return roundToPrecision(number, 16);
+ };
var f2 = API.f2 = API.__private__.f2 = function (number) {
if (isNaN(number)) {
throw new Error('Invalid argument passed to jsPDF.f2');
}
- return number.toFixed(2); // Ie, %.2f
+ return roundToPrecision(number, 2);
};
var f3 = API.__private__.f3 = function (number) {
@@ -568,7 +729,7 @@
throw new Error('Invalid argument passed to jsPDF.f3');
}
- return number.toFixed(3); // Ie, %.3f
+ return roundToPrecision(number, 3);
};
var fileId = '00000000000000000000000000000000';
@@ -584,13 +745,13 @@
fileId = value;
return fileId;
};
- /**
- * @name setFileId
- * @memberOf jsPDF
- * @function
- * @instance
- * @param {string} value GUID.
- * @returns {jsPDF}
+ /**
+ * @name setFileId
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ * @param {string} value GUID.
+ * @returns {jsPDF}
*/
@@ -598,13 +759,13 @@
setFileId(value);
return this;
};
- /**
- * @name getFileId
- * @memberOf jsPDF
- * @function
- * @instance
- *
- * @returns {string} GUID.
+ /**
+ * @name getFileId
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ *
+ * @returns {string} GUID.
*/
@@ -667,13 +828,13 @@
return result;
};
- /**
- * @name setCreationDate
- * @memberOf jsPDF
- * @function
- * @instance
- * @param {Object} date
- * @returns {jsPDF}
+ /**
+ * @name setCreationDate
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ * @param {Object} date
+ * @returns {jsPDF}
*/
@@ -681,13 +842,13 @@
setCreationDate(date);
return this;
};
- /**
- * @name getCreationDate
- * @memberOf jsPDF
- * @function
- * @instance
- * @param {Object} type
- * @returns {Object}
+ /**
+ * @name getCreationDate
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ * @param {Object} type
+ * @returns {Object}
*/
@@ -699,6 +860,11 @@
return ('0' + parseInt(number)).slice(-2);
};
+ var padd2Hex = API.__private__.padd2Hex = function (hexString) {
+ hexString = hexString.toString();
+ return ("00" + hexString).substr(hexString.length);
+ };
+
var outToPages = !1; // switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
var pages = [];
@@ -711,7 +877,7 @@
customOutputDestination = destination;
};
- var resetOutputDestination = API.__private__.resetCustomOutputDestination = function (destination) {
+ var resetOutputDestination = API.__private__.resetCustomOutputDestination = function () {
customOutputDestination = undefined;
};
@@ -752,34 +918,34 @@
var standardFonts = [['Helvetica', "helvetica", "normal", 'WinAnsiEncoding'], ['Helvetica-Bold', "helvetica", "bold", 'WinAnsiEncoding'], ['Helvetica-Oblique', "helvetica", "italic", 'WinAnsiEncoding'], ['Helvetica-BoldOblique', "helvetica", "bolditalic", 'WinAnsiEncoding'], ['Courier', "courier", "normal", 'WinAnsiEncoding'], ['Courier-Bold', "courier", "bold", 'WinAnsiEncoding'], ['Courier-Oblique', "courier", "italic", 'WinAnsiEncoding'], ['Courier-BoldOblique', "courier", "bolditalic", 'WinAnsiEncoding'], ['Times-Roman', "times", "normal", 'WinAnsiEncoding'], ['Times-Bold', "times", "bold", 'WinAnsiEncoding'], ['Times-Italic', "times", "italic", 'WinAnsiEncoding'], ['Times-BoldItalic', "times", "bolditalic", 'WinAnsiEncoding'], ['ZapfDingbats', "zapfdingbats", "normal", null], ['Symbol', "symbol", "normal", null]];
- var getStandardFonts = API.__private__.getStandardFonts = function (data) {
+ var getStandardFonts = API.__private__.getStandardFonts = function () {
return standardFonts;
};
var activeFontSize = options.fontSize || 16;
- /**
- * Sets font size for upcoming text elements.
- *
- * @param {number} size Font size in points.
- * @function
- * @instance
- * @returns {jsPDF}
- * @memberOf jsPDF
- * @name setFontSize
+ /**
+ * Sets font size for upcoming text elements.
+ *
+ * @param {number} size Font size in points.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberof jsPDF#
+ * @name setFontSize
*/
var setFontSize = API.__private__.setFontSize = API.setFontSize = function (size) {
activeFontSize = size;
return this;
};
- /**
- * Gets the fontsize for upcoming text elements.
- *
- * @function
- * @instance
- * @returns {number}
- * @memberOf jsPDF
- * @name getFontSize
+ /**
+ * Gets the fontsize for upcoming text elements.
+ *
+ * @function
+ * @instance
+ * @returns {number}
+ * @memberof jsPDF#
+ * @name getFontSize
*/
@@ -788,33 +954,33 @@
};
var R2L = options.R2L || false;
- /**
- * Set value of R2L functionality.
- *
- * @param {boolean} value
- * @function
- * @instance
- * @returns {jsPDF} jsPDF-instance
- * @memberOf jsPDF
- * @name setR2L
+ /**
+ * Set value of R2L functionality.
+ *
+ * @param {boolean} value
+ * @function
+ * @instance
+ * @returns {jsPDF} jsPDF-instance
+ * @memberof jsPDF#
+ * @name setR2L
*/
var setR2L = API.__private__.setR2L = API.setR2L = function (value) {
R2L = value;
return this;
};
- /**
- * Get value of R2L functionality.
- *
- * @function
- * @instance
- * @returns {boolean} jsPDF-instance
- * @memberOf jsPDF
- * @name getR2L
+ /**
+ * Get value of R2L functionality.
+ *
+ * @function
+ * @instance
+ * @returns {boolean} jsPDF-instance
+ * @memberof jsPDF#
+ * @name getR2L
*/
- var getR2L = API.__private__.getR2L = API.getR2L = function (value) {
+ var getR2L = API.__private__.getR2L = API.getR2L = function () {
return R2L;
};
@@ -869,30 +1035,30 @@
var getLayoutMode = API.__private__.getLayoutMode = function () {
return layoutMode;
};
- /**
- * Set the display mode options of the page like zoom and layout.
- *
- * @name setDisplayMode
- * @memberOf jsPDF
- * @function
- * @instance
- * @param {integer|String} zoom You can pass an integer or percentage as
- * a string. 2 will scale the document up 2x, '200%' will scale up by the
- * same amount. You can also set it to 'fullwidth', 'fullheight',
- * 'fullpage', or 'original'.
- *
- * Only certain PDF readers support this, such as Adobe Acrobat.
- *
- * @param {string} layout Layout mode can be: 'continuous' - this is the
- * default continuous scroll. 'single' - the single page mode only shows one
- * page at a time. 'twoleft' - two column left mode, first page starts on
- * the left, and 'tworight' - pages are laid out in two columns, with the
- * first page on the right. This would be used for books.
- * @param {string} pmode 'UseOutlines' - it shows the
- * outline of the document on the left. 'UseThumbs' - shows thumbnails along
- * the left. 'FullScreen' - prompts the user to enter fullscreen mode.
- *
- * @returns {jsPDF}
+ /**
+ * Set the display mode options of the page like zoom and layout.
+ *
+ * @name setDisplayMode
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ * @param {integer|String} zoom You can pass an integer or percentage as
+ * a string. 2 will scale the document up 2x, '200%' will scale up by the
+ * same amount. You can also set it to 'fullwidth', 'fullheight',
+ * 'fullpage', or 'original'.
+ *
+ * Only certain PDF readers support this, such as Adobe Acrobat.
+ *
+ * @param {string} layout Layout mode can be: 'continuous' - this is the
+ * default continuous scroll. 'single' - the single page mode only shows one
+ * page at a time. 'twoleft' - two column left mode, first page starts on
+ * the left, and 'tworight' - pages are laid out in two columns, with the
+ * first page on the right. This would be used for books.
+ * @param {string} pmode 'UseOutlines' - it shows the
+ * outline of the document on the left. 'UseThumbs' - shows thumbnails along
+ * the left. 'FullScreen' - prompts the user to enter fullscreen mode.
+ *
+ * @returns {jsPDF}
*/
@@ -919,18 +1085,18 @@
return documentProperties[key];
};
- var getDocumentProperties = API.__private__.getDocumentProperties = function (properties) {
+ var getDocumentProperties = API.__private__.getDocumentProperties = function () {
return documentProperties;
};
- /**
- * Adds a properties to the PDF document.
- *
- * @param {Object} A property_name-to-property_value object structure.
- * @function
- * @instance
- * @returns {jsPDF}
- * @memberOf jsPDF
- * @name setDocumentProperties
+ /**
+ * Adds a properties to the PDF document.
+ *
+ * @param {Object} A property_name-to-property_value object structure.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberof jsPDF#
+ * @name setDocumentProperties
*/
@@ -963,6 +1129,17 @@
var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle
+ var fontStateStack = []; //
+
+ var patterns = {}; // collection of pattern objects
+
+ var patternMap = {}; // see fonts
+
+ var gStates = {}; // collection of graphic state objects
+
+ var gStatesMap = {}; // see fonts
+
+ var activeGState = null;
var k; // Scale factor
var page = 0;
@@ -970,6 +1147,414 @@
var additionalObjects = [];
var events = new PubSub(API);
var hotfixes = options.hotfixes || [];
+ var renderTargets = {};
+ var renderTargetMap = {};
+ var renderTargetStack = [];
+ var pageX;
+ var pageY;
+ var pageMatrix; // only used for FormObjects
+
+ /**
+ * A matrix object for 2D homogenous transformations:
+ * | a b 0 |
+ * | c d 0 |
+ * | e f 1 |
+ * pdf multiplies matrices righthand: v' = v x m1 x m2 x ...
+ *
+ * @class
+ * @name Matrix
+ * @param {number} a
+ * @param {number} b
+ * @param {number} c
+ * @param {number} d
+ * @param {number} e
+ * @param {number} f
+ * @constructor
+ */
+
+ var Matrix = function Matrix(sx, shy, shx, sy, tx, ty) {
+ var round = function round(number) {
+ if (precision >= 16) {
+ return number;
+ } else {
+ return Math.round(number * 100000) / 100000;
+ }
+ };
+
+ var _matrix = [];
+ /**
+ * @name sx
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'sx', {
+ get: function get() {
+ return _matrix[0];
+ },
+ set: function set(value) {
+ _matrix[0] = round(value);
+ }
+ });
+ /**
+ * @name shy
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'shy', {
+ get: function get() {
+ return _matrix[1];
+ },
+ set: function set(value) {
+ _matrix[1] = round(value);
+ }
+ });
+ /**
+ * @name shx
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'shx', {
+ get: function get() {
+ return _matrix[2];
+ },
+ set: function set(value) {
+ _matrix[2] = round(value);
+ }
+ });
+ /**
+ * @name sy
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'sy', {
+ get: function get() {
+ return _matrix[3];
+ },
+ set: function set(value) {
+ _matrix[3] = round(value);
+ }
+ });
+ /**
+ * @name tx
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'tx', {
+ get: function get() {
+ return _matrix[4];
+ },
+ set: function set(value) {
+ _matrix[4] = round(value);
+ }
+ });
+ /**
+ * @name ty
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'ty', {
+ get: function get() {
+ return _matrix[5];
+ },
+ set: function set(value) {
+ _matrix[5] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'a', {
+ get: function get() {
+ return _matrix[0];
+ },
+ set: function set(value) {
+ _matrix[0] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'b', {
+ get: function get() {
+ return _matrix[1];
+ },
+ set: function set(value) {
+ _matrix[1] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'c', {
+ get: function get() {
+ return _matrix[2];
+ },
+ set: function set(value) {
+ _matrix[2] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'd', {
+ get: function get() {
+ return _matrix[3];
+ },
+ set: function set(value) {
+ _matrix[3] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'e', {
+ get: function get() {
+ return _matrix[4];
+ },
+ set: function set(value) {
+ _matrix[4] = round(value);
+ }
+ });
+ Object.defineProperty(this, 'f', {
+ get: function get() {
+ return _matrix[5];
+ },
+ set: function set(value) {
+ _matrix[5] = round(value);
+ }
+ });
+ /**
+ * @name rotation
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'rotation', {
+ get: function get() {
+ return Math.atan2(this.shx, this.sx);
+ }
+ });
+ /**
+ * @name scaleX
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'scaleX', {
+ get: function get() {
+ return this.decompose().scale.sx;
+ }
+ });
+ /**
+ * @name scaleY
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'scaleY', {
+ get: function get() {
+ return this.decompose().scale.sy;
+ }
+ });
+ /**
+ * @name isIdentity
+ * @memberof Matrix#
+ */
+
+ Object.defineProperty(this, 'isIdentity', {
+ get: function get() {
+ if (this.sx !== 1) {
+ return false;
+ }
+
+ if (this.shy !== 0) {
+ return false;
+ }
+
+ if (this.shx !== 0) {
+ return false;
+ }
+
+ if (this.sy !== 1) {
+ return false;
+ }
+
+ if (this.tx !== 0) {
+ return false;
+ }
+
+ if (this.ty !== 0) {
+ return false;
+ }
+
+ return true;
+ }
+ });
+ this.sx = !isNaN(sx) ? sx : 1;
+ this.shy = !isNaN(shy) ? shy : 0;
+ this.shx = !isNaN(shx) ? shx : 0;
+ this.sy = !isNaN(sy) ? sy : 1;
+ this.tx = !isNaN(tx) ? tx : 0;
+ this.ty = !isNaN(ty) ? ty : 0;
+ return this;
+ };
+ /**
+ * Multiply the matrix with given Matrix
+ *
+ * @function join
+ * @param {string} separator Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them.
+ * @returns {string} A string with all array elements joined.
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.join = function (parm1) {
+ return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty].join(parm1);
+ };
+ /**
+ * Multiply the matrix with given Matrix
+ *
+ * @function multiply
+ * @param matrix
+ * @returns {Matrix}
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.multiply = function (matrix) {
+ var sx = matrix.sx * this.sx + matrix.shy * this.shx;
+ var shy = matrix.sx * this.shy + matrix.shy * this.sy;
+ var shx = matrix.shx * this.sx + matrix.sy * this.shx;
+ var sy = matrix.shx * this.shy + matrix.sy * this.sy;
+ var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx;
+ var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty;
+ return new Matrix(sx, shy, shx, sy, tx, ty);
+ };
+ /**
+ * @function decompose
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.decompose = function () {
+ var a = this.sx;
+ var b = this.shy;
+ var c = this.shx;
+ var d = this.sy;
+ var e = this.tx;
+ var f = this.ty;
+ var scaleX = Math.sqrt(a * a + b * b);
+ a /= scaleX;
+ b /= scaleX;
+ var shear = a * c + b * d;
+ c -= a * shear;
+ d -= b * shear;
+ var scaleY = Math.sqrt(c * c + d * d);
+ c /= scaleY;
+ d /= scaleY;
+ shear /= scaleY;
+
+ if (a * d < b * c) {
+ a = -a;
+ b = -b;
+ shear = -shear;
+ scaleX = -scaleX;
+ }
+
+ return {
+ scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),
+ translate: new Matrix(1, 0, 0, 1, e, f),
+ rotate: new Matrix(a, b, -b, a, 0, 0),
+ skew: new Matrix(1, 0, shear, 1, 0, 0)
+ };
+ };
+ /**
+ * @function toString
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.toString = function (parmPrecision) {
+ var tmpPrecision = precision || parmPrecision || 5;
+
+ var round = function round(number) {
+ if (precision >= 16) {
+ return hpf(number);
+ } else {
+ return Math.round(number * Math.pow(10, tmpPrecision)) / Math.pow(10, tmpPrecision);
+ }
+ };
+
+ return [round(this.sx), round(this.shy), round(this.shx), round(this.sy), round(this.tx), round(this.ty)].join(" ");
+ };
+ /**
+ * @function inversed
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.inversed = function () {
+ var a = this.sx,
+ b = this.shy,
+ c = this.shx,
+ d = this.sy,
+ e = this.tx,
+ f = this.ty;
+ var quot = 1 / (a * d - b * c);
+ var aInv = d * quot;
+ var bInv = -b * quot;
+ var cInv = -c * quot;
+ var dInv = a * quot;
+ var eInv = -aInv * e - cInv * f;
+ var fInv = -bInv * e - dInv * f;
+ return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);
+ };
+ /**
+ * @function applyToPoint
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.applyToPoint = function (pt) {
+ var x = pt.x * this.sx + pt.y * this.shx + this.tx;
+ var y = pt.x * this.shy + pt.y * this.sy + this.ty;
+ return new Point(x, y);
+ };
+ /**
+ * @function applyToRectangle
+ * @memberof Matrix#
+ */
+
+
+ Matrix.prototype.applyToRectangle = function (rect) {
+ var pt1 = this.applyToPoint(rect);
+ var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));
+ return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);
+ };
+ /**
+ * Clone the Matrix
+ *
+ * @function clone
+ * @memberof Matrix#
+ * @name clone
+ * @instance
+ */
+
+
+ Matrix.prototype.clone = function () {
+ var sx = this.sx;
+ var shy = this.shy;
+ var shx = this.shx;
+ var sy = this.sy;
+ var tx = this.tx;
+ var ty = this.ty;
+ return new Matrix(sx, shy, shx, sy, tx, ty);
+ };
+
+ API.Matrix = Matrix;
+ /**
+ * Multiplies two matrices. (see {@link Matrix})
+ * @param {Matrix} m1
+ * @param {Matrix} m2
+ * @memberof jsPDF#
+ * @name matrixMult
+ */
+
+ var matrixMult = API.matrixMult = function (m1, m2) {
+ return m1.multiply(m2);
+ };
+ /**
+ * The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)).
+ * @type {Matrix}
+ * @memberof! jsPDF#
+ * @name identityMatrix
+ */
+
+
+ var identityMatrix = new Matrix(1, 0, 0, 1, 0, 0);
+ API.unitMatrix = API.identityMatrix = identityMatrix;
var newObject = API.__private__.newObject = function () {
var oid = newObjectDeferred();
@@ -1025,6 +1610,12 @@
// convert grayscale value to rgb so that it can be converted to hex for consistency
var floatVal = parseFloat(colorEncoded[0]);
colorEncoded = [floatVal, floatVal, floatVal, 'r'];
+ } else if (colorEncoded.length === 5 && (colorEncoded[4] === 'k' || colorEncoded[4] === 'K')) {
+ // convert CMYK values to rbg so that it can be converted to hex for consistency
+ var red = (1.0 - colorEncoded[0]) * (1.0 - colorEncoded[3]);
+ var green = (1.0 - colorEncoded[1]) * (1.0 - colorEncoded[3]);
+ var blue = (1.0 - colorEncoded[2]) * (1.0 - colorEncoded[3]);
+ colorEncoded = [red, green, blue, 'r'];
}
var colorAsRGB = '#';
@@ -1049,7 +1640,6 @@
var ch2 = options.ch2;
var ch3 = options.ch3;
var ch4 = options.ch4;
- var precision = options.precision;
var letterArray = options.pdfColorType === "draw" ? ['G', 'RG', 'K'] : ['g', 'rg', 'k'];
if (typeof ch1 === "string" && ch1.charAt(0) !== '#') {
@@ -1121,12 +1711,12 @@
} else {
switch (options.precision) {
case 2:
- color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), f2(ch4 / 255), letterArray[2]].join(" ");
+ color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), letterArray[2]].join(" ");
break;
case 3:
default:
- color = [f3(ch1 / 255), f3(ch2 / 255), f3(ch3 / 255), f3(ch4 / 255), letterArray[2]].join(" ");
+ color = [f3(ch1), f3(ch2), f3(ch3), f3(ch4), letterArray[2]].join(" ");
}
}
}
@@ -1209,14 +1799,11 @@
};
var putPage = API.__private__.putPage = function (page) {
- var mediaBox = page.mediaBox;
var pageNumber = page.number;
var data = page.data;
var pageObjectNumber = page.objId;
var pageContentsObjId = page.contentsObjId;
newObjectDeferredBegin(pageObjectNumber, true);
- var wPt = pagesContext[currentPage].mediaBox.topRightX - pagesContext[currentPage].mediaBox.bottomLeftX;
- var hPt = pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY;
out('<>");
+ putStream(p);
+ out("endobj");
+ };
+
+ var putXObjects = function putXObjects() {
+ for (var xObjectKey in renderTargets) {
+ if (renderTargets.hasOwnProperty(xObjectKey)) {
+ putXObject(renderTargets[xObjectKey]);
}
}
-
- out('>>');
- out('/XObject <<');
- events.publish('putXobjectDict');
- out('>>');
};
- var putResources = function putResources() {
- putFonts();
- events.publish('putResources');
- newObjectDeferredBegin(resourceDictionaryObjId, true);
- out('<<');
- putResourceDictionary();
- out('>>');
- out('endobj');
- events.publish('postPutResources');
+ var interpolateAndEncodeRGBStream = function interpolateAndEncodeRGBStream(colors, numberSamples) {
+ var tValues = [];
+ var t;
+ var dT = 1.0 / (numberSamples - 1);
+
+ for (t = 0.0; t < 1.0; t += dT) {
+ tValues.push(t);
+ }
+
+ tValues.push(1.0); // add first and last control point if not present
+
+ if (colors[0].offset != 0.0) {
+ var c0 = {
+ offset: 0.0,
+ color: colors[0].color
+ };
+ colors.unshift(c0);
+ }
+
+ if (colors[colors.length - 1].offset != 1.0) {
+ var c1 = {
+ offset: 1.0,
+ color: colors[colors.length - 1].color
+ };
+ colors.push(c1);
+ }
+
+ var out = "";
+ var index = 0;
+
+ for (var i = 0; i < tValues.length; i++) {
+ t = tValues[i];
+
+ while (t > colors[index + 1].offset) {
+ index++;
+ }
+
+ var a = colors[index].offset;
+ var b = colors[index + 1].offset;
+ var d = (t - a) / (b - a);
+ var aColor = colors[index].color;
+ var bColor = colors[index + 1].color;
+ out += padd2Hex(Math.round((1 - d) * aColor[0] + d * bColor[0]).toString(16)) + padd2Hex(Math.round((1 - d) * aColor[1] + d * bColor[1]).toString(16)) + padd2Hex(Math.round((1 - d) * aColor[2] + d * bColor[2]).toString(16));
+ }
+
+ return out.trim();
+ };
+
+ var putShadingPattern = function putShadingPattern(pattern, numberSamples) {
+ /*
+ Axial patterns shade between the two points specified in coords, radial patterns between the inner
+ and outer circle.
+ The user can specify an array (colors) that maps t-Values in [0, 1] to RGB colors. These are now
+ interpolated to equidistant samples and written to pdf as a sample (type 0) function.
+ */
+ out("/Shading <<"); // The number of color samples that should be used to describe the shading.
+ // The higher, the more accurate the gradient will be.
+
+ numberSamples || (numberSamples = 21);
+ var funcObjectNumber = newObject();
+ var stream = interpolateAndEncodeRGBStream(pattern.colors, numberSamples);
+ out("<< /FunctionType 0");
+ out("/Domain [0.0 1.0]");
+ out("/Size [" + numberSamples + "]");
+ out("/BitsPerSample 8");
+ out("/Range [0.0 1.0 0.0 1.0 0.0 1.0]");
+ out("/Decode [0.0 1.0 0.0 1.0 0.0 1.0]");
+ out("/Length " + stream.length); // The stream is Hex encoded
+
+ out("/Filter /ASCIIHexDecode");
+ out(">>");
+ putStream(stream);
+ out("endobj");
+ pattern.objectNumber = newObject();
+ out("<< /ShadingType " + pattern.type);
+ out("/ColorSpace /DeviceRGB");
+ var coords = "/Coords [" + hpf(parseFloat(pattern.coords[0])) + " " + // x1
+ hpf(parseFloat(pattern.coords[1])) + " "; // y1
+
+ if (pattern.type === 2) {
+ // axial
+ coords += hpf(parseFloat(pattern.coords[2])) + " " + // x2
+ hpf(parseFloat(pattern.coords[3])); // y2
+ } else {
+ // radial
+ coords += hpf(parseFloat(pattern.coords[2])) + " " + // r1
+ hpf(parseFloat(pattern.coords[3])) + " " + // x2
+ hpf(parseFloat(pattern.coords[4])) + " " + // y2
+ hpf(parseFloat(pattern.coords[5])); // r2
+ }
+
+ coords += "]";
+ out(coords);
+
+ if (pattern.matrix) {
+ out("/Matrix [" + pattern.matrix.toString() + "]");
+ }
+
+ out("/Function " + funcObjectNumber + " 0 R");
+ out("/Extend [true true]");
+ out(">>");
+ out("endobj");
+ out(">>");
+ };
+
+ var putTilingPattern = function putTilingPattern(pattern) {
+ var resourcesObjectNumber = newObject();
+ putResourceDictionary();
+ out("endobj");
+ pattern.objectNumber = newObject();
+ out("<< /Type /Pattern");
+ out("/PatternType 1"); // tiling pattern
+
+ out("/PaintType 1"); // colored tiling pattern
+
+ out("/TilingType 1"); // constant spacing
+
+ out("/BBox [" + pattern.boundingBox.map(hpf).join(" ") + "]");
+ out("/XStep " + hpf(pattern.xStep));
+ out("/YStep " + hpf(pattern.yStep));
+ out("/Length " + pattern.stream.length);
+ out("/Resources " + resourcesObjectNumber + " 0 R"); // TODO: resources
+
+ pattern.matrix && out("/Matrix [" + pattern.matrix.toString() + "]");
+ out(">>");
+ putStream(pattern.stream);
+ out("endobj");
+ };
+
+ var putPatterns = function putPatterns() {
+ var patternKey;
+
+ for (patternKey in patterns) {
+ if (patterns.hasOwnProperty(patternKey)) {
+ if (patterns[patternKey] instanceof API.ShadingPattern) {
+ putShadingPattern(patterns[patternKey]);
+ } else if (patterns[patternKey] instanceof API.TilingPattern) {
+ putTilingPattern(patterns[patternKey]);
+ }
+ }
+ }
+ };
+
+ var putGState = function putGState(gState) {
+ gState.objectNumber = newObject();
+ out("<<");
+
+ for (var p in gState) {
+ switch (p) {
+ case "opacity":
+ out("/ca " + f2(gState[p]));
+ break;
+
+ case "stroke-opacity":
+ out("/CA " + f2(gState[p]));
+ break;
+ }
+ }
+
+ out(">>");
+ out("endobj");
+ };
+
+ var putGStates = function putGStates() {
+ var gStateKey;
+
+ for (gStateKey in gStates) {
+ if (gStates.hasOwnProperty(gStateKey)) {
+ putGState(gStates[gStateKey]);
+ }
+ }
+ };
+
+ var putXobjectDict = function putXobjectDict() {
+ out("/XObject <<");
+
+ for (var xObjectKey in renderTargets) {
+ if (renderTargets.hasOwnProperty(xObjectKey) && renderTargets[xObjectKey].objectNumber >= 0) {
+ out("/" + xObjectKey + " " + renderTargets[xObjectKey].objectNumber + " 0 R");
+ }
+ } // Loop through images, or other data objects
+
+
+ events.publish("putXobjectDict");
+ out(">>");
+ };
+
+ var putFontDict = function putFontDict() {
+ out('/Font <<'); // Do this for each font, the '1' bit is the index of the font
+
+ for (var fontKey in fonts) {
+ if (fonts.hasOwnProperty(fontKey)) {
+ if (putOnlyUsedFonts === false || putOnlyUsedFonts === true && usedFonts.hasOwnProperty(fontKey)) {
+ out('/' + fontKey + ' ' + fonts[fontKey].objectNumber + ' 0 R');
+ }
+ }
+ }
+
+ out('>>');
+ };
+
+ var putShadingPatternDict = function putShadingPatternDict() {
+ if (Object.keys(patterns).length > 0) {
+ out("/Shading <<");
+
+ for (var patternKey in patterns) {
+ if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.ShadingPattern && patterns[patternKey].objectNumber >= 0) {
+ out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
+ }
+ }
+
+ events.publish("putShadingPatternDict");
+ out(">>");
+ }
+ };
+
+ var putTilingPatternDict = function putTilingPatternDict() {
+ if (Object.keys(patterns).length > 0) {
+ out("/Pattern <<");
+
+ for (var patternKey in patterns) {
+ if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0) {
+ out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
+ }
+ }
+
+ events.publish("putTilingPatternDict");
+ }
+ };
+
+ var putGStatesDict = function putGStatesDict() {
+ if (Object.keys(gStates).length > 0) {
+ var gStateKey;
+ out("/ExtGState <<");
+
+ for (gStateKey in gStates) {
+ if (gStates.hasOwnProperty(gStateKey) && gStates[gStateKey].objectNumber >= 0) {
+ out("/" + gStateKey + " " + gStates[gStateKey].objectNumber + " 0 R");
+ }
+ }
+
+ events.publish("putGStateDict");
+ out(">>");
+ }
+ };
+
+ var putResourceDictionary = function putResourceDictionary() {
+ out('<<');
+ out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
+ putFontDict();
+ putShadingPatternDict();
+ putTilingPatternDict();
+ putGStatesDict();
+ putXobjectDict();
+ out('>>');
+ };
+
+ var putResources = function putResources() {
+ putFonts();
+ putGStates();
+ putXObjects();
+ putPatterns();
+ events.publish('putResources');
+ newObjectDeferredBegin(resourceDictionaryObjId, true);
+ putResourceDictionary();
+ out('endobj');
+ events.publish('postPutResources');
};
var putAdditionalObjects = function putAdditionalObjects() {
@@ -1441,12 +2297,12 @@
return fn.apply(this, arguments);
} catch (e) {
var stack = e.stack || '';
- if (~stack.indexOf(' at ')) stack = stack.split(" at ")[1];
+ if (~stack.indexOf(' at ')) { stack = stack.split(" at ")[1]; }
var m = "Error in function " + stack.split("\n")[0].split('<')[0] + ": " + e.message;
if (global.console) {
global.console.error(m, e);
- if (global.alert) alert(m);
+ if (global.alert) { alert(m); }
} else {
throw new Error(m);
}
@@ -1458,52 +2314,52 @@
};
var to8bitStream = function to8bitStream(text, flags) {
- /**
- * PDF 1.3 spec:
- * "For text strings encoded in Unicode, the first two bytes must be 254 followed by
- * 255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts
- * with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely
- * to be a meaningful beginning of a word or phrase.) The remainder of the
- * string consists of Unicode character codes, according to the UTF-16 encoding
- * specified in the Unicode standard, version 2.0. Commonly used Unicode values
- * are represented as 2 bytes per character, with the high-order byte appearing first
- * in the string."
- *
- * In other words, if there are chars in a string with char code above 255, we
- * recode the string to UCS2 BE - string doubles in length and BOM is prepended.
- *
- * HOWEVER!
- * Actual *content* (body) text (as opposed to strings used in document properties etc)
- * does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)
- *
- * Because of Adobe's focus on "you subset your fonts!" you are not supposed to have
- * a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could
- * fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode
- * code page. There, however, all characters in the stream are treated as GIDs,
- * including BOM, which is the reason we need to skip BOM in content text (i.e. that
- * that is tied to a font).
- *
- * To signal this "special" PDFEscape / to8bitStream handling mode,
- * API.text() function sets (unless you overwrite it with manual values
- * given to API.text(.., flags) )
- * flags.autoencode = true
- * flags.noBOM = true
- *
- * ===================================================================================
- * `flags` properties relied upon:
- * .sourceEncoding = string with encoding label.
- * "Unicode" by default. = encoding of the incoming text.
- * pass some non-existing encoding name
- * (ex: 'Do not touch my strings! I know what I am doing.')
- * to make encoding code skip the encoding step.
- * .outputEncoding = Either valid PDF encoding name
- * (must be supported by jsPDF font metrics, otherwise no encoding)
- * or a JS object, where key = sourceCharCode, value = outputCharCode
- * missing keys will be treated as: sourceCharCode === outputCharCode
- * .noBOM
- * See comment higher above for explanation for why this is important
- * .autoencode
- * See comment higher above for explanation for why this is important
+ /**
+ * PDF 1.3 spec:
+ * "For text strings encoded in Unicode, the first two bytes must be 254 followed by
+ * 255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts
+ * with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely
+ * to be a meaningful beginning of a word or phrase.) The remainder of the
+ * string consists of Unicode character codes, according to the UTF-16 encoding
+ * specified in the Unicode standard, version 2.0. Commonly used Unicode values
+ * are represented as 2 bytes per character, with the high-order byte appearing first
+ * in the string."
+ *
+ * In other words, if there are chars in a string with char code above 255, we
+ * recode the string to UCS2 BE - string doubles in length and BOM is prepended.
+ *
+ * HOWEVER!
+ * Actual *content* (body) text (as opposed to strings used in document properties etc)
+ * does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)
+ *
+ * Because of Adobe's focus on "you subset your fonts!" you are not supposed to have
+ * a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could
+ * fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode
+ * code page. There, however, all characters in the stream are treated as GIDs,
+ * including BOM, which is the reason we need to skip BOM in content text (i.e. that
+ * that is tied to a font).
+ *
+ * To signal this "special" PDFEscape / to8bitStream handling mode,
+ * API.text() function sets (unless you overwrite it with manual values
+ * given to API.text(.., flags) )
+ * flags.autoencode = true
+ * flags.noBOM = true
+ *
+ * ===================================================================================
+ * `flags` properties relied upon:
+ * .sourceEncoding = string with encoding label.
+ * "Unicode" by default. = encoding of the incoming text.
+ * pass some non-existing encoding name
+ * (ex: 'Do not touch my strings! I know what I am doing.')
+ * to make encoding code skip the encoding step.
+ * .outputEncoding = Either valid PDF encoding name
+ * (must be supported by jsPDF font metrics, otherwise no encoding)
+ * or a JS object, where key = sourceCharCode, value = outputCharCode
+ * missing keys will be treated as: sourceCharCode === outputCharCode
+ * .noBOM
+ * See comment higher above for explanation for why this is important
+ * .autoencode
+ * See comment higher above for explanation for why this is important
*/
var i, l, sourceEncoding, encodingBlock, outputEncoding, newtext, isUnicode, ch, bch;
flags = flags || {};
@@ -1596,52 +2452,50 @@
};
var pdfEscape = API.__private__.pdfEscape = API.pdfEscape = function (text, flags) {
- /**
- * Replace '/', '(', and ')' with pdf-safe versions
- *
- * Doing to8bitStream does NOT make this PDF display unicode text. For that
- * we also need to reference a unicode font and embed it - royal pain in the rear.
- *
- * There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,
- * which JavaScript Strings are happy to provide. So, while we still cannot display
- * 2-byte characters property, at least CONDITIONALLY converting (entire string containing)
- * 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF
- * is still parseable.
- * This will allow immediate support for unicode in document properties strings.
+ /**
+ * Replace '/', '(', and ')' with pdf-safe versions
+ *
+ * Doing to8bitStream does NOT make this PDF display unicode text. For that
+ * we also need to reference a unicode font and embed it - royal pain in the rear.
+ *
+ * There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,
+ * which JavaScript Strings are happy to provide. So, while we still cannot display
+ * 2-byte characters property, at least CONDITIONALLY converting (entire string containing)
+ * 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF
+ * is still parseable.
+ * This will allow immediate support for unicode in document properties strings.
*/
return to8bitStream(text, flags).replace(/\\/g, '\\\\').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
};
- var beginPage = API.__private__.beginPage = function (width, height) {
- var tmp; // Dimensions are stored as user units and converted to points on output
-
- var orientation = typeof height === 'string' && height.toLowerCase();
+ var beginPage = API.__private__.beginPage = function (parmFormat, parmOrientation) {
+ var tmp, width, height;
- if (typeof width === 'string') {
- if (tmp = getPageFormat(width.toLowerCase())) {
+ if (typeof parmFormat === 'string') {
+ if (tmp = getPageFormat(parmFormat.toLowerCase())) {
width = tmp[0];
height = tmp[1];
}
}
- if (Array.isArray(width)) {
- height = width[1];
- width = width[0];
+ if (Array.isArray(parmFormat)) {
+ width = parmFormat[0] * k;
+ height = parmFormat[1] * k;
}
- if (isNaN(width) || isNaN(height)) {
+ if (isNaN(width)) {
width = format[0];
height = format[1];
}
- if (orientation) {
- switch (orientation.substr(0, 1)) {
+ if (parmOrientation) {
+ switch (parmOrientation.substr(0, 1)) {
case 'l':
- if (height > width) orientation = 's';
+ if (height > width) { orientation = 's'; }
break;
case 'p':
- if (width > height) orientation = 's';
+ if (width > height) { orientation = 's'; }
break;
}
@@ -1703,6 +2557,7 @@
var _deletePage = function _deletePage(n) {
if (n > 0 && n <= page) {
pages.splice(n, 1);
+ pagesContext.splice(n, 1);
page--;
if (currentPage > page) {
@@ -1722,23 +2577,23 @@
var getNumberOfPages = API.__private__.getNumberOfPages = API.getNumberOfPages = function () {
return pages.length - 1;
};
- /**
- * Returns a document-specific font key - a label assigned to a
- * font name + font type combination at the time the font was added
- * to the font inventory.
- *
- * Font key is used as label for the desired font for a block of text
- * to be added to the PDF document stream.
- * @private
- * @function
- * @param fontName {string} can be undefined on "falthy" to indicate "use current"
- * @param fontStyle {string} can be undefined on "falthy" to indicate "use current"
- * @returns {string} Font key.
- * @ignore
+ /**
+ * Returns a document-specific font key - a label assigned to a
+ * font name + font type combination at the time the font was added
+ * to the font inventory.
+ *
+ * Font key is used as label for the desired font for a block of text
+ * to be added to the PDF document stream.
+ * @private
+ * @function
+ * @param fontName {string} can be undefined on "falthy" to indicate "use current"
+ * @param fontStyle {string} can be undefined on "falthy" to indicate "use current"
+ * @returns {string} Font key.
+ * @ignore
*/
- var _getFont = function getFont(fontName, fontStyle, options) {
+ var getFont = function getFont(fontName, fontStyle, options) {
var key = undefined,
fontNameLowerCase;
options = options || {};
@@ -1791,7 +2646,7 @@
out('/Type /Catalog');
out('/Pages ' + tmpRootDictionaryObjId + ' 0 R'); // PDF13ref Section 7.2.1
- if (!zoomMode) zoomMode = 'fullwidth';
+ if (!zoomMode) { zoomMode = 'fullwidth'; }
switch (zoomMode) {
case 'fullwidth':
@@ -1812,7 +2667,7 @@
default:
var pcn = '' + zoomMode;
- if (pcn.substr(pcn.length - 1) === '%') zoomMode = parseInt(zoomMode) / 100;
+ if (pcn.substr(pcn.length - 1) === '%') { zoomMode = parseInt(zoomMode) / 100; }
if (typeof zoomMode === 'number') {
out('/OpenAction [3 0 R /XYZ null null ' + f2(zoomMode) + ']');
@@ -1820,7 +2675,7 @@
}
- if (!layoutMode) layoutMode = 'continuous';
+ if (!layoutMode) { layoutMode = 'continuous'; }
switch (layoutMode) {
case 'continuous':
@@ -1842,12 +2697,12 @@
}
if (pageMode) {
- /**
- * A name object specifying how the document should be displayed when opened:
- * UseNone : Neither document outline nor thumbnail images visible -- DEFAULT
- * UseOutlines : Document outline visible
- * UseThumbs : Thumbnail images visible
- * FullScreen : Full-screen mode, with no menu bar, window controls, or any other window visible
+ /**
+ * A name object specifying how the document should be displayed when opened:
+ * UseNone : Neither document outline nor thumbnail images visible -- DEFAULT
+ * UseOutlines : Document outline visible
+ * UseThumbs : Thumbnail images visible
+ * FullScreen : Full-screen mode, with no menu bar, window controls, or any other window visible
*/
out('/PageMode /' + pageMode);
}
@@ -1927,25 +2782,24 @@
type: "application/pdf"
});
};
- /**
- * Generates the PDF document.
- *
- * If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
- *
- * @param {string} type A string identifying one of the possible output types. Possible values are 'arraybuffer', 'blob', 'bloburi'/'bloburl', 'datauristring'/'dataurlstring', 'datauri'/'dataurl', 'dataurlnewwindow'.
- * @param {Object} options An object providing some additional signalling to PDF generator. Possible options are 'filename'.
- *
- * @function
- * @instance
- * @returns {jsPDF}
- * @memberOf jsPDF
- * @name output
+ /**
+ * Generates the PDF document.
+ *
+ * If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
+ *
+ * @param {string} type A string identifying one of the possible output types. Possible values are 'arraybuffer', 'blob', 'bloburi'/'bloburl', 'datauristring'/'dataurlstring', 'datauri'/'dataurl', 'dataurlnewwindow', 'pdfobjectnewwindow', 'pdfjsnewwindow'.
+ * @param {Object} options An object providing some additional signalling to PDF generator. Possible options are 'filename'.
+ *
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberof jsPDF#
+ * @name output
*/
var output = API.output = API.__private__.output = SAFE(function output(type, options) {
options = options || {};
- var pdfDocument = buildDocument();
if (typeof options === "string") {
options = {
@@ -1957,23 +2811,23 @@
switch (type) {
case undefined:
- return pdfDocument;
+ return buildDocument();
case 'save':
API.save(options.filename);
break;
case 'arraybuffer':
- return getArrayBuffer(pdfDocument);
+ return getArrayBuffer(buildDocument());
case 'blob':
- return getBlob(pdfDocument);
+ return getBlob(buildDocument());
case 'bloburi':
case 'bloburl':
// Developer is responsible of calling revokeObjectURL
if (typeof global.URL !== "undefined" && typeof global.URL.createObjectURL === "function") {
- return global.URL && global.URL.createObjectURL(getBlob(pdfDocument)) || void 0;
+ return global.URL && global.URL.createObjectURL(getBlob(buildDocument())) || void 0;
} else {
console.warn('bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.');
}
@@ -1982,32 +2836,67 @@
case 'datauristring':
case 'dataurlstring':
- return 'data:application/pdf;filename=' + options.filename + ';base64,' + btoa(pdfDocument);
+ var dataURI = '';
+ var pdfDocument = buildDocument();
- case 'dataurlnewwindow':
- var htmlForNewWindow = '' + '' + '' + '' + '';
+ try {
+ dataURI = btoa(pdfDocument);
+ } catch (e) {
+ dataURI = btoa(unescape(encodeURIComponent(pdfDocument)));
+ }
+
+ return 'data:application/pdf;filename=' + options.filename + ';base64,' + dataURI;
+
+ case 'pdfobjectnewwindow':
+ var pdfObjectUrl = options.pdfObjectUrl || 'https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js';
+ var htmlForNewWindow = '' + '' + '' + '' + '' + '';
+ 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 nW = global.open();
if (nW !== null) {
nW.document.write(htmlForNewWindow);
+ var scope = this;
+
+ nW.document.documentElement.querySelector('#pdfViewer').onload = function () {
+ nW.document.documentElement.querySelector('#pdfViewer').contentWindow.PDFViewerApplication.open(scope.output('bloburl'));
+ };
}
- if (nW || typeof safari === "undefined") return nW;
+ return nW;
+
+ case 'dataurlnewwindow':
+ var htmlForNewWindow = '' + '' + '' + '' + '';
+ var nW = global.open();
+
+ if (nW !== null) {
+ nW.document.write(htmlForNewWindow);
+ }
- /* pass through */
+ if (nW || typeof safari === "undefined") { return nW; }
+ // eslint-disable-next-line no-fallthrough
case 'datauri':
case 'dataurl':
- return global.document.location.href = 'data:application/pdf;filename=' + options.filename + ';base64,' + btoa(pdfDocument);
+ return global.document.location.href = this.output('datauristring', options);
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) {
@@ -2060,7 +2949,7 @@
setFileId(); //---------------------------------------
// Public API
- var getPageInfo = API.__private__.getPageInfo = function (pageNumberOneBased) {
+ var getPageInfo = API.__private__.getPageInfo = API.getPageInfo = function (pageNumberOneBased) {
if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) {
throw new Error('Invalid argument passed to jsPDF.getPageInfo');
}
@@ -2088,24 +2977,24 @@
return getPageInfo(pageNumber);
};
- var getCurrentPageInfo = API.__private__.getCurrentPageInfo = function () {
+ var getCurrentPageInfo = API.__private__.getCurrentPageInfo = API.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: a0 - a10 b0 - b10 c0 - c10 dl letter government-letter legal junior-legal ledger tabloid credit-card
- * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
- * @param 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: a0 - a10 b0 - b10 c0 - c10 dl letter government-letter legal junior-legal ledger tabloid credit-card
+ * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
+ * @param 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
*/
@@ -2114,22 +3003,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)
*/
@@ -2138,14 +3027,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}
*/
@@ -2154,21 +3043,23 @@
this.movePage(currentPage, beforePage);
return this;
};
- /**
- * @name movePage
- * @memberOf jsPDF
- * @function
- * @instance
- * @param {Object} targetPage
- * @param {Object} beforePage
- * @returns {jsPDF}
+ /**
+ * @name movePage
+ * @memberof jsPDF#
+ * @function
+ * @instance
+ * @param {number} targetPage
+ * @param {number} beforePage
+ * @returns {jsPDF}
*/
API.movePage = function (targetPage, beforePage) {
+ var tmpPages, tmpPagesContext;
+
if (targetPage > beforePage) {
- var tmpPages = pages[targetPage];
- var tmpPagesContext = pagesContext[targetPage];
+ tmpPages = pages[targetPage];
+ tmpPagesContext = pagesContext[targetPage];
for (var i = targetPage; i > beforePage; i--) {
pages[i] = pages[i - 1];
@@ -2179,12 +3070,12 @@
pagesContext[beforePage] = tmpPagesContext;
this.setPage(beforePage);
} else if (targetPage < beforePage) {
- var tmpPages = pages[targetPage];
- var tmpPagesContext = pagesContext[targetPage];
+ tmpPages = pages[targetPage];
+ tmpPagesContext = pagesContext[targetPage];
- for (var i = targetPage; i < beforePage; i++) {
- pages[i] = pages[i + 1];
- pagesContext[i] = pagesContext[i + 1];
+ for (var j = targetPage; j < beforePage; j++) {
+ pages[j] = pages[j + 1];
+ pagesContext[j] = pagesContext[j + 1];
}
pages[beforePage] = tmpPages;
@@ -2194,13 +3085,14 @@
return this;
};
- /**
- * Deletes a page from the PDF.
- * @name deletePage
- * @memberOf jsPDF
- * @function
- * @instance
- * @returns {jsPDF}
+ /**
+ * Deletes a page from the PDF.
+ * @name deletePage
+ * @memberof jsPDF#
+ * @function
+ * @param {number} targetPage
+ * @instance
+ * @returns {jsPDF}
*/
@@ -2209,45 +3101,54 @@
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.
- * @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
+ /**
+ * 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
*/
- 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
+ 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
*/
- //backwardsCompatibility
+ options = options || {};
+ var scope = options.scope || this; //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)
@@ -2261,36 +3162,38 @@
text = tmp;
}
- var flags = arguments[3];
- var angle = arguments[4];
- var align = arguments[5];
+ var transformationMatrix;
- if (_typeof(flags) !== "object" || flags === null) {
- if (typeof angle === 'string') {
- align = angle;
- angle = null;
- }
+ if (arguments[3] instanceof Matrix === false) {
+ var flags = arguments[3];
+ var angle = arguments[4];
+ var align = arguments[5];
- 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;
+ }
- flags = flags || {};
- flags.noBOM = flags.noBOM || true;
- flags.autoencode = flags.autoencode || true;
+ options = {
+ flags: flags,
+ angle: angle,
+ align: align
+ };
+ }
+ } else {
+ transformationMatrix = arguments[3];
+ }
if (isNaN(x) || isNaN(y) || typeof text === "undefined" || text === null) {
throw new Error('Invalid arguments passed to jsPDF.text');
@@ -2303,7 +3206,7 @@
var xtra = '';
var isHex = false;
var lineHeight = typeof options.lineHeightFactor === 'number' ? options.lineHeightFactor : lineHeightFactor;
- var scope = options.scope || this;
+ var k = scope.internal.scaleFactor;
function ESC(s) {
s = s.split("\t").join(Array(options.TabLen || 9).join(" "));
@@ -2324,7 +3227,7 @@
if (typeof curDa === "string") {
da.push(curDa);
} else {
- if (Array.isArray(text) && curDa.length === 1) {
+ if (Array.isArray(text) && (curDa.length === 1 || curDa[1] === undefined && curDa[2] === undefined)) {
da.push(curDa[0]);
} else {
da.push([curDa[0], curDa[1], curDa[2]]);
@@ -2354,7 +3257,7 @@
if (typeof curDa === "string") {
da.push(processingFunction(curDa)[0]);
- } else if (Array.isArray(curDa) && curDa[0] === "string") {
+ } else if (Array.isArray(curDa) && typeof curDa[0] === "string") {
tmpResult = processingFunction(curDa[0], curDa[1], curDa[2]);
da.push([tmpResult[0], tmpResult[1], tmpResult[2]]);
}
@@ -2393,15 +3296,6 @@
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,
@@ -2475,26 +3369,35 @@
options = payload.options; //angle
var angle = options.angle;
- var k = scope.internal.scaleFactor;
- var transformationMatrix = [];
- if (angle) {
+ if (transformationMatrix instanceof Matrix === false && angle && typeof angle === "number") {
angle *= Math.PI / 180;
- var c = Math.cos(angle),
- s = Math.sin(angle);
- transformationMatrix = [f2(c), f2(s), f2(s * -1), f2(c)];
+
+ 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;
} //charSpace
- var charSpace = options.charSpace;
+ var charSpace = options.charSpace || activeCharSpace;
if (typeof charSpace !== 'undefined') {
xtra += f3(charSpace * k) + " Tc\n";
+ this.setCharSpace(this.getCharSpace() || 0);
} //lang
var lang = options.lang;
- var tmpRenderingMode = -1;
+ //renderingMode
+
+
+ var renderingMode = -1;
var parmRenderingMode = typeof options.renderingMode !== "undefined" ? options.renderingMode : options.stroke;
var pageContext = scope.internal.getCurrentPageInfo().pageContext;
@@ -2502,65 +3405,64 @@
case 0:
case false:
case 'fill':
- tmpRenderingMode = 0;
+ renderingMode = 0;
break;
case 1:
case true:
case 'stroke':
- tmpRenderingMode = 1;
+ renderingMode = 1;
break;
case 2:
case 'fillThenStroke':
- tmpRenderingMode = 2;
+ renderingMode = 2;
break;
case 3:
case 'invisible':
- tmpRenderingMode = 3;
+ renderingMode = 3;
break;
case 4:
case 'fillAndAddForClipping':
- tmpRenderingMode = 4;
+ renderingMode = 4;
break;
case 5:
case 'strokeAndAddPathForClipping':
- tmpRenderingMode = 5;
+ renderingMode = 5;
break;
case 6:
case 'fillThenStrokeAndAddToPathForClipping':
- tmpRenderingMode = 6;
+ renderingMode = 6;
break;
case 7:
case 'addToPathForClipping':
- tmpRenderingMode = 7;
+ renderingMode = 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 (tmpRenderingMode !== -1) {
- xtra += tmpRenderingMode + " Tr\n"; //otherwise check if we used the rendering Mode already
+ if (renderingMode !== -1) {
+ xtra += renderingMode + " 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 (tmpRenderingMode !== -1) {
- pageContext.usedRenderingMode = tmpRenderingMode;
+ if (renderingMode !== -1) {
+ pageContext.usedRenderingMode = renderingMode;
} //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;
@@ -2646,7 +3548,7 @@
newX = i === 0 ? getHorizontalCoordinate(x) : 0;
if (i < len - 1) {
- wordSpacingPerLine.push(((maxWidth - lineWidths[i]) / (da[i].split(" ").length - 1) * k).toFixed(2));
+ wordSpacingPerLine.push(f2((maxWidth - lineWidths[i]) / (da[i].split(" ").length - 1) * k));
}
text.push([da[i], newX, newY]);
@@ -2680,53 +3582,78 @@
};
events.publish('postProcessText', payload);
text = payload.text;
- isHex = payload.mutex.isHex;
+ 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];
+ });
+ }
+
var da = transformTextToSpecialArray(text);
text = [];
- var variant = 0;
- var len = da.length;
+ var STRING = 0;
+ var ARRAY = 1;
+ var variant = Array.isArray(da[0]) ? ARRAY : STRING;
var posX;
var posY;
var content;
var wordSpacing = '';
- for (var i = 0; i < len; i++) {
- wordSpacing = '';
+ var generatePosition = function generatePosition(parmPosX, parmPosY, parmTransformationMatrix) {
+ var position = '';
- if (!Array.isArray(da[i])) {
- posX = getHorizontalCoordinate(x);
- posY = getVerticalCoordinate(y);
- content = (isHex ? "<" : "(") + da[i] + (isHex ? ">" : ")");
+ if (parmTransformationMatrix instanceof Matrix) {
+ parmTransformationMatrix.tx = parseFloat(f2(parmPosX));
+ parmTransformationMatrix.ty = parseFloat(f2(parmPosY));
+ position = parmTransformationMatrix.join(" ") + " Tm\n";
} else {
- posX = parseFloat(da[i][1]);
- posY = parseFloat(da[i][2]);
- content = (isHex ? "<" : "(") + da[i][0] + (isHex ? ">" : ")");
- variant = 1;
+ position = f2(parmPosX) + " " + f2(parmPosY) + " Td\n";
}
- if (wordSpacingPerLine !== undefined && wordSpacingPerLine[i] !== undefined) {
- wordSpacing = wordSpacingPerLine[i] + " Tw\n";
+ return position;
+ };
+
+ for (var lineIndex = 0; lineIndex < da.length; lineIndex++) {
+ 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 (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);
+ if (wordSpacingPerLine !== undefined && wordSpacingPerLine[lineIndex] !== undefined) {
+ wordSpacing = wordSpacingPerLine[lineIndex] + " Tw\n";
}
- }
- if (variant === 0) {
- text = text.join(" Tj\nT* ");
- } else {
- text = text.join(" Tj\n");
+ if (lineIndex === 0) {
+ text.push(wordSpacing + generatePosition(posX, posY, transformationMatrix) + content);
+ } else if (variant === STRING) {
+ 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/' + activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size
- (activeFontSize * lineHeight).toFixed(2) + ' TL\n' + // line spacing
- textColor + '\n';
+ var result = 'BT\n/';
+ result += activeFontKey + ' ' + activeFontSize + ' Tf\n'; // font face, style, size
+
+ result += f2(activeFontSize * lineHeight) + ' TL\n'; // line spacing
+
+ result += textColor + '\n';
result += xtra;
result += text;
result += "ET";
@@ -2734,37 +3661,52 @@
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
});
- };
- /**
- *
- * @name clip
- * @function
- * @instance
- * @param {string} rule
- * @returns {jsPDF}
- * @memberOf jsPDF
- * @description All .clip() after calling drawing ops with a style argument of null.
+ }; // 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.
*/
@@ -2775,25 +3717,48 @@
out('W*');
} else {
out('W');
- } // 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”)
+ }
+ };
+ /**
+ * 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
+ */
- out('n');
+ var clipEvenOdd = API.clipEvenOdd = function () {
+ clip('evenodd');
+ return this;
};
- /**
- * 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
+ /**
+ * 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
*/
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*'];
@@ -2806,7 +3771,7 @@
return result;
};
- var getStyle = API.__private__.getStyle = function (style) {
+ var getStyle = API.__private__.getStyle = API.getStyle = function (style) {
// see path-painting operators in PDF spec
var op = 'S'; // stroke
@@ -2815,103 +3780,312 @@
} 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;
};
- /**
- * 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
+ /**
+ * Close the current path. The PDF "h" operator.
+ * @return jsPDF
+ * @memberof jsPDF#
+ * @name close
*/
- 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');
- }
-
- return this.lines([[x2 - x1, y2 - y1]], x1, y1);
+ var close = API.close = function () {
+ out("h");
+ return this;
};
- /**
- * 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
+ /**
+ * Stroke the path. The PDF "S" operator.
+ * @return jsPDF
+ * @memberof jsPDF#
+ * @name stroke
*/
- 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.
+ var stroke = API.stroke = function () {
+ out("S");
+ return this;
+ };
+ /**
+ * 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
+ */
- if (typeof lines === 'number') {
- tmp = y;
- y = x;
- x = lines;
- lines = tmp;
- }
- scale = scale || [1, 1];
- closed = closed || false;
+ 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
+ */
- 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 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
+ */
- 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.
+ 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
+ */
- y4 = y; // last / ending point = starting point for first item.
- for (i = 0; i < l; i++) {
- leg = lines[i];
+ var fillStrokeEvenOdd = API.fillStrokeEvenOdd = function (pattern) {
+ fillWithOptionalPattern("B*", pattern);
+ return this;
+ };
- if (leg.length === 2) {
- // simple line
- x4 = leg[0] * scalex + x4; // here last x4 was prior ending point
+ var fillWithOptionalPattern = function fillWithOptionalPattern(style, pattern) {
+ if (_typeof(pattern) === "object") {
+ fillWithPattern(pattern, style);
+ } else {
+ out(style);
+ }
+ };
- y4 = leg[1] * scaley + y4; // here last y4 was prior ending point
+ var putStyle = function putStyle(style, patternKey, patternData) {
+ if (style === null || style === undefined) {
+ return;
+ }
+
+ style = getStyle(style); // stroking / filling / both the path
+
+ if (!patternKey) {
+ out(style);
+ return;
+ }
+
+ if (!patternData) {
+ patternData = {
+ matrix: identityMatrix
+ };
+ }
+
+ 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 {
@@ -2943,19 +4117,62 @@
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
+ /**
+ * 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
*/
@@ -2972,21 +4189,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
*/
@@ -3002,21 +4219,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
*/
@@ -3030,19 +4247,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
*/
@@ -3064,18 +4281,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
*/
@@ -3086,55 +4303,70 @@
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;
};
- /**
- * 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
+ /**
+ * 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
*/
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
*/
@@ -3159,17 +4391,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
*/
@@ -3180,32 +4412,34 @@
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((width * k).toFixed(2) + ' w');
+ out(f2(width * k) + ' w');
return this;
};
- /**
- * 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
+ /**
+ * 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
*/
@@ -3218,9 +4452,9 @@
}
dashArray = dashArray.map(function (x) {
- return (x * k).toFixed(3);
+ return f3(x * k);
}).join(' ');
- dashPhase = parseFloat((dashPhase * k).toFixed(3));
+ dashPhase = f3(dashPhase * k);
out('[' + dashArray + '] ' + dashPhase + ' d');
return this;
};
@@ -3236,15 +4470,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
*/
@@ -3257,14 +4491,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
*/
@@ -3275,72 +4509,72 @@
setLineHeightFactor(options.lineHeight);
var getHorizontalCoordinate = API.__private__.getHorizontalCoordinate = function (value) {
- return value * k;
+ return scale(value);
};
var getVerticalCoordinate = API.__private__.getVerticalCoordinate = function (value) {
- return pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - value * k;
+ return pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - scale(value);
};
- var getHorizontalCoordinateString = API.__private__.getHorizontalCoordinateString = function (value) {
- return f2(value * k);
+ var getHorizontalCoordinateString = API.__private__.getHorizontalCoordinateString = API.getHorizontalCoordinateString = function (value) {
+ return f2(scale(value));
};
- var getVerticalCoordinateString = API.__private__.getVerticalCoordinateString = function (value) {
- return f2(pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - value * k);
+ var getVerticalCoordinateString = API.__private__.getVerticalCoordinateString = API.getVerticalCoordinateString = function (value) {
+ return f2(pagesContext[currentPage].mediaBox.topRightY - pagesContext[currentPage].mediaBox.bottomLeftY - scale(value));
};
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|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
+ /**
+ * 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
*/
@@ -3359,56 +4593,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|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
+ /**
+ * 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
*/
@@ -3427,56 +4661,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|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
+ /**
+ * 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
*/
@@ -3493,29 +4727,29 @@
return this;
};
- var activeCharSpace = options.charSpace || 0;
- /**
- * Get global value of CharSpace.
- *
- * @function
- * @instance
- * @returns {number} charSpace
- * @memberOf jsPDF
- * @name getCharSpace
+ var activeCharSpace = options.charSpace;
+ /**
+ * Get global value of CharSpace.
+ *
+ * @function
+ * @instance
+ * @returns {number} charSpace
+ * @memberof jsPDF#
+ * @name getCharSpace
*/
var getCharSpace = API.__private__.getCharSpace = API.getCharSpace = function () {
- return activeCharSpace;
- };
- /**
- * Set global value of CharSpace.
- *
- * @param {number} charSpace
- * @function
- * @instance
- * @returns {jsPDF} jsPDF-instance
- * @memberOf jsPDF
- * @name setCharSpace
+ return parseFloat(activeCharSpace || 0);
+ };
+ /**
+ * Set global value of CharSpace.
+ *
+ * @param {number} charSpace
+ * @function
+ * @instance
+ * @returns {jsPDF} jsPDF-instance
+ * @memberof jsPDF#
+ * @name setCharSpace
*/
@@ -3529,13 +4763,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 = {
@@ -3553,16 +4787,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) {
@@ -3578,16 +4812,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) {
@@ -3603,39 +4837,453 @@
};
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 setMiterLimit
+ /**
+ * 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
*/
- var setMiterLimit = API.__private__.setMiterLimit = API.setMiterLimit = function (length) {
+ var setLineMiterLimit = API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function (length) {
length = length || 0;
if (isNaN(length)) {
- throw new Error('Invalid argument passed to jsPDF.setMiterLimit');
+ throw new Error('Invalid argument passed to jsPDF.setLineMiterLimit');
}
miterLimit = parseFloat(f2(length * k));
out(miterLimit + ' M');
return this;
};
- /**
- * 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
+ /**
+ * 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
*/
@@ -3701,19 +5349,26 @@
}
}
}
- /**
- * Object exposing internal API to plugins
- * @public
- * @ignore
+
+ API.advancedAPI = function (body) {
+ if (typeof body !== "function") {
+ return this;
+ }
+
+ body(this);
+ return this;
+ };
+ /**
+ * Object exposing internal API to plugins
+ * @public
+ * @ignore
*/
API.internal = {
'pdfEscape': pdfEscape,
'getStyle': getStyle,
- 'getFont': function getFont() {
- return fonts[_getFont.apply(API, arguments)];
- },
+ 'getFont': getFontEntry,
'getFontSize': getFontSize,
'getCharSpace': getCharSpace,
'getTextColor': getTextColor,
@@ -3763,6 +5418,9 @@
'getPageInfoByObjId': getPageInfoByObjId,
'getCurrentPageInfo': getCurrentPageInfo,
'getPDFVersion': getPdfVersion,
+ 'Point': Point,
+ 'Rectangle': Rectangle,
+ 'Matrix': Matrix,
'hasHotfix': hasHotfix //Expose the hasHotfix check so plugins can also check them.
};
@@ -3798,39 +5456,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';
@@ -3847,30 +5505,27 @@
}
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
- /*rollup-keeper-start*/
-
+ /* global jsPDF */
- 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
+ /**
+ * @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 (jsPDFAPI, globalObj) {
+ (function (jsPDF, globalObj) {
+ var jsPDFAPI = jsPDF.API;
var scope;
var scaleFactor = 1;
@@ -3921,8 +5576,8 @@
xobj.BBox = [0, 0, Number(f2(width)), Number(f2(height))];
return xobj;
};
- /**
- * Bit-Operations
+ /**
+ * Bit-Operations
*/
@@ -3959,8 +5614,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
*/
@@ -3980,7 +5635,7 @@
return setBit(number, bitPosition - 1);
};
- var clearBitForPdf = jsPDFAPI.__acroform__.clearBitForPdf = function (number, bitPosition, value) {
+ var clearBitForPdf = jsPDFAPI.__acroform__.clearBitForPdf = function (number, bitPosition) {
if (isNaN(number) || isNaN(bitPosition)) {
throw new Error('Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf');
}
@@ -4038,7 +5693,6 @@
var calculateX = function calculateX(formObject, text) {
var maxFontSize = formObject.maxFontSize || 12;
- var font = formObject.fontName;
var returnValue = {
text: "",
fontSize: ""
@@ -4048,9 +5702,6 @@
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;
@@ -4179,12 +5830,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)
*/
@@ -4210,17 +5861,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,
@@ -4259,9 +5910,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)
*/
@@ -4290,9 +5941,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
*/
@@ -4302,11 +5953,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...)
*/
@@ -4379,7 +6030,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 {
@@ -4392,7 +6043,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 += ">>";
@@ -4528,17 +6179,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}
*/
@@ -4560,8 +6211,8 @@
}
});
};
- /**
- * @function AcroFormPDFObject.toString
+ /**
+ * @function AcroFormPDFObject.toString
*/
@@ -4577,11 +6228,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}
*/
@@ -4690,7 +6341,7 @@
if (_Kids.length > 0) {
return _Kids;
} else {
- return;
+ return undefined;
}
}
});
@@ -4709,7 +6360,7 @@
configurable: false,
get: function get() {
if (!_DA) {
- return;
+ return undefined;
}
return '(' + _DA + ')';
@@ -4721,11 +6372,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() {
@@ -4746,13 +6397,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', {
@@ -4790,7 +6441,7 @@
configurable: false,
get: function get() {
if (_Rect.length === 0) {
- return;
+ return undefined;
}
return _Rect;
@@ -4803,12 +6454,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', {
@@ -4825,12 +6476,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', {
@@ -4847,12 +6498,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', {
@@ -4869,12 +6520,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', {
@@ -4920,7 +6571,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;
+ return undefined;
}
_T = "FieldObject" + AcroFormField.FieldNum++;
@@ -4932,12 +6583,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', {
@@ -4951,12 +6602,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', {
@@ -4970,12 +6621,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', {
@@ -4989,12 +6640,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', {
@@ -5008,12 +6659,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', {
@@ -5027,12 +6678,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', {
@@ -5052,7 +6703,7 @@
configurable: false,
get: function get() {
if (!_DA || this instanceof AcroFormChildClass || this instanceof AcroFormTextField) {
- return;
+ return undefined;
}
return toPdfString(_DA);
@@ -5068,7 +6719,7 @@
configurable: false,
get: function get() {
if (!_DV) {
- return;
+ return undefined;
}
if (this instanceof AcroFormButton === false) {
@@ -5091,12 +6742,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', {
@@ -5125,7 +6776,7 @@
configurable: false,
get: function get() {
if (!_V) {
- return;
+ return undefined;
}
if (this instanceof AcroFormButton === false) {
@@ -5148,12 +6799,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', {
@@ -5176,12 +6827,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', {
@@ -5206,12 +6857,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', {
@@ -5226,11 +6877,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;
@@ -5241,7 +6892,7 @@
writeable: true,
get: function get() {
if (!_page) {
- return;
+ return undefined;
}
return _page;
@@ -5250,12 +6901,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', {
@@ -5272,12 +6923,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', {
@@ -5294,12 +6945,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', {
@@ -5322,7 +6973,7 @@
configurable: false,
get: function get() {
if (_Q === null) {
- return;
+ return undefined;
}
return _Q;
@@ -5335,13 +6986,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', {
@@ -5389,9 +7040,9 @@
};
inherit(AcroFormField, AcroFormPDFObject);
- /**
- * @class AcroFormChoiceField
- * @extends AcroFormField
+ /**
+ * @class AcroFormChoiceField
+ * @extends AcroFormField
*/
var AcroFormChoiceField = function AcroFormChoiceField() {
@@ -5413,12 +7064,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', {
@@ -5442,23 +7093,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
*/
@@ -5469,12 +7120,12 @@
_Opt.sort();
}
};
- /**
- * @memberof AcroFormChoiceField
- * @name addOption
- * @function
- * @instance
- * @param {string} value
+ /**
+ * @memberof AcroFormChoiceField
+ * @name addOption
+ * @function
+ * @instance
+ * @param {string} value
*/
@@ -5488,13 +7139,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)
*/
@@ -5511,12 +7162,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}
*/
@@ -5534,12 +7185,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', {
@@ -5559,12 +7210,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', {
@@ -5583,12 +7234,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', {
@@ -5605,12 +7256,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', {
@@ -5627,13 +7278,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', {
@@ -5654,10 +7305,10 @@
};
inherit(AcroFormChoiceField, AcroFormField);
- /**
- * @class AcroFormListBox
- * @extends AcroFormChoiceField
- * @extends AcroFormField
+ /**
+ * @class AcroFormListBox
+ * @extends AcroFormChoiceField
+ * @extends AcroFormField
*/
var AcroFormListBox = function AcroFormListBox() {
@@ -5668,11 +7319,11 @@
};
inherit(AcroFormListBox, AcroFormChoiceField);
- /**
- * @class AcroFormComboBox
- * @extends AcroFormListBox
- * @extends AcroFormChoiceField
- * @extends AcroFormField
+ /**
+ * @class AcroFormComboBox
+ * @extends AcroFormListBox
+ * @extends AcroFormChoiceField
+ * @extends AcroFormField
*/
var AcroFormComboBox = function AcroFormComboBox() {
@@ -5681,12 +7332,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() {
@@ -5695,19 +7346,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', {
@@ -5724,11 +7375,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', {
@@ -5745,11 +7396,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', {
@@ -5766,11 +7417,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', {
@@ -5805,7 +7456,7 @@
return result.join('\n');
}
- return;
+ return undefined;
},
set: function set(value) {
if (_typeof(value) === "object") {
@@ -5813,16 +7464,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', {
@@ -5850,11 +7501,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', {
@@ -5870,10 +7521,10 @@
};
inherit(AcroFormButton, AcroFormField);
- /**
- * @class AcroFormPushButton
- * @extends AcroFormButton
- * @extends AcroFormField
+ /**
+ * @class AcroFormPushButton
+ * @extends AcroFormButton
+ * @extends AcroFormField
*/
var AcroFormPushButton = function AcroFormPushButton() {
@@ -5882,10 +7533,10 @@
};
inherit(AcroFormPushButton, AcroFormButton);
- /**
- * @class AcroFormRadioButton
- * @extends AcroFormButton
- * @extends AcroFormField
+ /**
+ * @class AcroFormRadioButton
+ * @extends AcroFormButton
+ * @extends AcroFormField
*/
var AcroFormRadioButton = function AcroFormRadioButton() {
@@ -5910,12 +7561,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() {
@@ -5968,16 +7619,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', {
@@ -6005,11 +7656,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', {
@@ -6037,7 +7688,6 @@
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) {
@@ -6050,8 +7700,7 @@
};
AcroFormRadioButton.prototype.createOption = function (name) {
- var kidCount = this.Kids.length; // Create new Child for RadioGroup
-
+ // Create new Child for RadioGroup
var child = new AcroFormChildClass();
child.Parent = this;
child.optionName = name; // Add to Parent
@@ -6060,10 +7709,10 @@
addField.call(this, child);
return child;
};
- /**
- * @class AcroFormCheckBox
- * @extends AcroFormButton
- * @extends AcroFormField
+ /**
+ * @class AcroFormCheckBox
+ * @extends AcroFormButton
+ * @extends AcroFormField
*/
@@ -6078,19 +7727,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', {
@@ -6107,11 +7756,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', {
@@ -6128,11 +7777,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', {
@@ -6149,11 +7798,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', {
@@ -6170,11 +7819,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', {
@@ -6191,11 +7840,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', {
@@ -6223,11 +7872,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', {
@@ -6252,20 +7901,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', {
@@ -6302,10 +7951,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);
@@ -6358,10 +8007,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);
@@ -6398,8 +8047,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");
@@ -6473,12 +8122,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 = {
@@ -6543,10 +8192,10 @@
}
},
- /**
- * Returns the standard Appearance
- *
- * @returns {AcroFormXObject}
+ /**
+ * Returns the standard Appearance
+ *
+ * @returns {AcroFormXObject}
*/
createDefaultAppearanceStream: function createDefaultAppearanceStream(formObject) {
// Set Helvetica to Standard Font (size: auto)
@@ -6566,7 +8215,6 @@
var width = AcroFormAppearance.internal.getWidth(formObject);
var height = AcroFormAppearance.internal.getHeight(formObject);
var a = Math.min(width, height);
-
var cross = {
x1: {
// upperLeft
@@ -6617,14 +8265,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}
*/
@@ -6640,13 +8288,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
*/
@@ -6657,13 +8305,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
*/
@@ -6674,13 +8322,13 @@
return addField.call(this, textField);
};
- /**
- * @name addChoiceField
- * @function
- * @instance
- * @param {AcroFormChoiceField}
- * @returns {jsPDF}
- * @deprecated
+ /**
+ * @name addChoiceField
+ * @function
+ * @instance
+ * @param {AcroFormChoiceField}
+ * @returns {jsPDF}
+ * @deprecated
*/
@@ -6735,24 +8383,39 @@
PasswordField: AcroFormPasswordField,
Appearance: AcroFormAppearance
};
- })(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global);
+ 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);
- /** @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
- *
- *
+ /* global jsPDF */
+
+ /** @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) {
@@ -6763,11 +8426,14 @@
[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, 0xE1, undefined, undefined, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00], //Exif
+ [0xFF, 0xD8, 0xFF, 0xDB], //JPEG RAW
+ [0xFF, 0xD8, 0xFF, 0xEE] //EXIF RAW
],
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
@@ -6776,18 +8442,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) {
@@ -6938,7 +8604,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
@@ -6971,7 +8637,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() {
@@ -7042,13 +8708,15 @@
}
}
+ var canvas;
+
if (element.nodeName === 'CANVAS') {
- var canvas = element;
+ canvas = element;
return element.toDataURL('image/jpeg', 1.0);
} //absolute fallback method
- var canvas = document.createElement('canvas');
+ canvas = document.createElement('canvas');
canvas.width = element.clientWidth || element.width;
canvas.height = element.clientHeight || element.height;
var ctx = canvas.getContext('2d');
@@ -7134,8 +8802,8 @@
this.internal.write('Q'); //Restore graphics state
};
- /**
- * COLOR SPACES
+ /**
+ * COLOR SPACES
*/
@@ -7152,8 +8820,8 @@
SEPARATION: 'Separation',
DEVICE_N: 'DeviceN'
};
- /**
- * DECODE METHODS
+ /**
+ * DECODE METHODS
*/
jsPDFAPI.decode = {
@@ -7167,8 +8835,8 @@
RUN_LENGTH_DECODE: 'RunLengthDecode',
CCITT_FAX_DECODE: 'CCITTFaxDecode'
};
- /**
- * IMAGE COMPRESSION TYPES
+ /**
+ * IMAGE COMPRESSION TYPES
*/
jsPDFAPI.image_compression = {
@@ -7177,11 +8845,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) {
@@ -7189,7 +8857,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);
@@ -7199,26 +8867,15 @@
return hash;
};
- /**
- * @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}
+ /**
+ * Validates if given String is a valid Base64-String
+ *
+ * @name validateStringAsBase64
+ * @public
+ * @function
+ * @param {String} possible Base64-String
+ *
+ * @returns {boolean}
*/
@@ -7245,34 +8902,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]
*/
@@ -7295,63 +8952,60 @@
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) {
- 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}
+ 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}
*/
jsPDFAPI.isArrayBufferView = function (object) {
- 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}
+ 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}
*/
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);
@@ -7362,15 +9016,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}
*/
@@ -7384,19 +9038,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}
*/
@@ -7449,26 +9103,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}
*/
@@ -7483,32 +9137,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
*/
@@ -7559,12 +9213,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 (this.isString(imageData)) {
- tmpImageData = this.convertStringToImageData(imageData);
+ if (typeof imageData === 'string') {
+ tmpImageData = this.convertStringToImageData(imageData, false);
if (tmpImageData !== '') {
imageData = tmpImageData;
@@ -7577,11 +9231,11 @@
}
}
- 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?
+ 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?
*/
if (this.supportsArrayBuffer()) {
@@ -7603,180 +9257,50 @@
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) {
+ jsPDFAPI.convertStringToImageData = function (stringData, throwError) {
+ throwError = typeof throwError === "boolean" ? throwError : true;
var base64Info;
var imageData = '';
var rawData;
- if (this.isString(stringData)) {
- var base64Info = this.extractImageFromDataUrl(stringData);
+ if (typeof stringData === 'string') {
+ base64Info = this.extractImageFromDataUrl(stringData);
rawData = base64Info !== null ? base64Info.data : stringData;
try {
imageData = atob(rawData);
} catch (e) {
if (!jsPDFAPI.validateStringAsBase64(rawData)) {
- throw new Error('Supplied Data is not a valid base64-String jsPDF.convertStringToImageData ');
+ 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 ');
+ }
} else {
- throw new Error('atob-Error in jsPDF.convertStringToImageData ' + e.message);
+ if (throwError) {
+ throw new Error('atob-Error in jsPDF.convertStringToImageData ' + e.message);
+ } else {
+ console.log('atob-Error in jsPDF.convertStringToImageData ' + e.message);
+ }
}
}
}
return imageData;
};
- /**
- * 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}
+ /**
+ * @name getImageProperties
+ * @function
+ * @param {Object} imageData
+ * @returns {Object}
*/
@@ -7789,18 +9313,14 @@
imageData = createDataURIFromElement(imageData);
}
- if (this.isString(imageData)) {
- tmpImageData = this.convertStringToImageData(imageData);
-
- if (tmpImageData !== '') {
- imageData = tmpImageData;
- } else {
- tmpImageData = jsPDFAPI.loadFile(imageData);
+ if (typeof imageData === "string") {
+ tmpImageData = this.convertStringToImageData(imageData, false);
- if (tmpImageData !== undefined) {
- imageData = tmpImageData;
- }
+ if (tmpImageData === '') {
+ tmpImageData = jsPDFAPI.loadFile(imageData) || '';
}
+
+ imageData = tmpImageData;
}
format = this.getImageFileTypeByImageData(imageData);
@@ -7808,9 +9328,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?
*/
@@ -7838,78 +9358,81 @@
};
})(jsPDF.API);
- /**
- * @license
- * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * @license
+ * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
- /**
- * jsPDF 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++) {
@@ -7919,9 +9442,10 @@
case 'link':
if (notEmpty(anno.options.url) || notEmpty(anno.options.pageNumber)) {
found = true;
- break;
}
+ break;
+
case 'reference':
case 'text':
case 'freetext':
@@ -7935,12 +9459,9 @@
}
this.internal.write("/Annots [");
- var pageHeight = this.internal.pageSize.height;
- var getHorizontalCoordinateString = this.internal.getCoordinateString;
- var getVerticalCoordinateString = this.internal.getVerticalCoordinateString;
- for (var a = 0; a < pageAnnos.length; a++) {
- var anno = pageAnnos[a];
+ for (var i = 0; i < pageAnnos.length; i++) {
+ var anno = pageAnnos[i];
switch (anno.type) {
case 'reference':
@@ -8044,10 +9565,10 @@
this.internal.write("]");
}]);
- /**
- * @name createAnnotation
- * @function
- * @param {Object} options
+ /**
+ * @name createAnnotation
+ * @function
+ * @param {Object} options
*/
jsPDFAPI.createAnnotation = function (options) {
@@ -8064,19 +9585,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
*/
@@ -8091,24 +9612,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); //TODO We really need the text baseline height to do this correctly.
+ this.text(text, x, y, options); //TODO We really need the text baseline height to do this correctly.
// Or ability to draw text on top, bottom, center, or baseline.
y += height * .2;
@@ -8116,11 +9637,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
*/
@@ -8133,24 +9654,26 @@
return this;
})(jsPDF.API);
- /**
- * @license
- * Copyright (c) 2017 Aras Abbasi
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * @license
+ * Copyright (c) 2017 Aras Abbasi
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
- /**
- * jsPDF arabic parser PlugIn
- *
- * @name arabic
- * @module
+ /**
+ * 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 = {
@@ -8443,7 +9966,6 @@
};
var getCorrectForm = jsPDFAPI.__arabicParser__.getCorrectForm = function (currentChar, beforeChar, nextChar) {
-
if (!isArabicLetter(currentChar)) {
return -1;
}
@@ -8466,12 +9988,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}
*/
@@ -8517,11 +10039,6 @@
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]') {
@@ -8545,31 +10062,32 @@
jsPDFAPI.events.push(['preProcessText', arabicParserFunction]);
})(jsPDF.API);
- /** @license
- * jsPDF Autoprint Plugin
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /** @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 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');
+ /**
+ * Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer.
+ *
+ * @name autoPrint
+ * @function
+ * @param {Object} options (optional) Set the attribute variant to 'non-conform' (default) or 'javascript' to activate different methods of automatic printing when opening in a PDF-viewer .
+ * @returns {jsPDF}
+ * @example
+ * var doc = new jsPDF();
+ * doc.text(10, 10, 'This is a test');
+ * doc.autoPrint({variant: 'non-conform'});
+ * doc.save('autoprint.pdf');
*/
jsPDFAPI.autoPrint = function (options) {
@@ -8605,26 +10123,28 @@
};
})(jsPDF.API);
- /**
- * @license
- * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * @license
+ * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
- /**
- * jsPDF Canvas PlugIn
- * This plugin mimics the HTML5 Canvas
- *
- * The goal is to provide a way for current canvas users to print directly to a PDF.
- * @name canvas
- * @module
+ /**
+ * 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() {
@@ -8638,11 +10158,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', {
@@ -8662,11 +10182,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', {
@@ -8703,19 +10223,15 @@
_style = value;
}
});
- 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
+ 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
*/
@@ -8736,11 +10252,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
*/
@@ -8755,28 +10271,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 document: false, jsPDF */
+ /*global jsPDF */
var padding = 3,
margin = 13,
@@ -8806,27 +10322,26 @@
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;
@@ -8863,9 +10378,9 @@
h: height
};
};
- /**
- * @name cellAddPage
- * @function
+ /**
+ * @name cellAddPage
+ * @function
*/
@@ -8876,9 +10391,9 @@
pages += 1;
};
- /**
- * @name cellInitialize
- * @function
+ /**
+ * @name cellInitialize
+ * @function
*/
@@ -8892,17 +10407,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
*/
@@ -8930,7 +10445,7 @@
y = getLastCellPosition().y + getLastCellPosition().h;
- if (pgAdded) y = margin + 10;
+ if (pgAdded) { y = margin + 10; }
}
}
@@ -8959,14 +10474,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}
*/
@@ -8992,19 +10507,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
*/
@@ -9058,9 +10573,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
*/
@@ -9139,7 +10654,6 @@
for (i = 0, ln = data.length; i < ln; i += 1) {
- var lineHeight;
model = data[i];
lineHeight = this.calculateLineHeight(headerNames, columnWidths, model);
@@ -9154,15 +10668,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
*/
@@ -9174,32 +10688,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
*/
@@ -9242,21 +10756,25 @@
};
})(jsPDF.API);
- /**
- * jsPDF Context2D PlugIn Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
- *
- * Licensed under the MIT License. http://opensource.org/licenses/mit-license
+ /* 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
*/
- /**
- * 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, globalObj) {
+ (function (jsPDFAPI) {
var ContextLayer = function ContextLayer(ctx) {
ctx = ctx || {};
@@ -9285,15 +10803,19 @@
}; //stub
- var f2, f3, getHorizontalCoordinateString, getVerticalCoordinateString, getHorizontalCoordinate, getVerticalCoordinate;
+ var f2, getHorizontalCoordinateString, getVerticalCoordinateString, getHorizontalCoordinate, getVerticalCoordinate, Point, Rectangle, Matrix, _ctx;
+
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) {
@@ -9311,10 +10833,10 @@
}
});
var _pageWrapXEnabled = false;
- /**
- * @name pageWrapXEnabled
- * @type {boolean}
- * @default false
+ /**
+ * @name pageWrapXEnabled
+ * @type {boolean}
+ * @default false
*/
Object.defineProperty(this, 'pageWrapXEnabled', {
@@ -9326,10 +10848,10 @@
}
});
var _pageWrapYEnabled = false;
- /**
- * @name pageWrapYEnabled
- * @type {boolean}
- * @default true
+ /**
+ * @name pageWrapYEnabled
+ * @type {boolean}
+ * @default true
*/
Object.defineProperty(this, 'pageWrapYEnabled', {
@@ -9341,10 +10863,10 @@
}
});
var _posX = 0;
- /**
- * @name posX
- * @type {number}
- * @default 0
+ /**
+ * @name posX
+ * @type {number}
+ * @default 0
*/
Object.defineProperty(this, 'posX', {
@@ -9358,10 +10880,10 @@
}
});
var _posY = 0;
- /**
- * @name posY
- * @type {number}
- * @default 0
+ /**
+ * @name posY
+ * @type {number}
+ * @default 0
*/
Object.defineProperty(this, 'posY', {
@@ -9375,10 +10897,10 @@
}
});
var _autoPaging = false;
- /**
- * @name autoPaging
- * @type {boolean}
- * @default true
+ /**
+ * @name autoPaging
+ * @type {boolean}
+ * @default true
*/
Object.defineProperty(this, 'autoPaging', {
@@ -9390,10 +10912,10 @@
}
});
var lastBreak = 0;
- /**
- * @name lastBreak
- * @type {number}
- * @default 0
+ /**
+ * @name lastBreak
+ * @type {number}
+ * @default 0
*/
Object.defineProperty(this, 'lastBreak', {
@@ -9405,11 +10927,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', {
@@ -9420,15 +10942,12 @@
pageBreaks = value;
}
});
-
- var _ctx = new ContextLayer();
- /**
- * @name ctx
- * @type {object}
- * @default {}
+ /**
+ * @name ctx
+ * @type {object}
+ * @default {}
*/
-
Object.defineProperty(this, 'ctx', {
get: function get() {
return _ctx;
@@ -9439,10 +10958,10 @@
}
}
});
- /**
- * @name path
- * @type {array}
- * @default []
+ /**
+ * @name path
+ * @type {array}
+ * @default []
*/
Object.defineProperty(this, 'path', {
@@ -9453,10 +10972,10 @@
_ctx.path = value;
}
});
- /**
- * @name ctxStack
- * @type {array}
- * @default []
+ /**
+ * @name ctxStack
+ * @type {array}
+ * @default []
*/
var _ctxStack = [];
@@ -9468,14 +10987,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', {
@@ -9496,14 +11015,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', {
@@ -9525,14 +11044,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', {
@@ -9546,12 +11065,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', {
@@ -9565,8 +11084,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', {
@@ -9580,11 +11099,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', {
@@ -9623,6 +11142,7 @@
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);
@@ -9702,9 +11222,9 @@
}
if (jsPdfFontName === '') {
- for (var i = 0; i < parts.length; i++) {
- if (fallbackFonts[parts[i]]) {
- jsPdfFontName = fallbackFonts[parts[i]];
+ for (var j = 0; j < parts.length; j++) {
+ if (fallbackFonts[parts[j]]) {
+ jsPdfFontName = fallbackFonts[parts[j]];
break;
}
}
@@ -9744,24 +11264,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.
*/
@@ -9770,13 +11290,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
*/
@@ -9794,12 +11314,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.
*/
@@ -9830,14 +11350,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).
*/
@@ -9855,12 +11375,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.
*/
@@ -9868,16 +11388,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.
*/
@@ -9898,18 +11418,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.
*/
@@ -9933,18 +11453,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).
*/
@@ -9980,33 +11500,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.
*/
@@ -10024,16 +11544,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.
*/
@@ -10071,16 +11591,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.
*/
@@ -10098,20 +11618,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.
+ *
*/
@@ -10128,11 +11648,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
*/
@@ -10154,11 +11674,11 @@
this.ctx = ctx;
}
};
- /**
- * Returns previously saved path state and attributes
- *
- * @name restore
- * @function
+ /**
+ * Returns previously saved path state and attributes
+ *
+ * @name restore
+ * @function
*/
@@ -10183,9 +11703,9 @@
this.lineJoin = this.ctx.lineJoin;
}
};
- /**
- * @name toDataURL
- * @function
+ /**
+ * @name toDataURL
+ * @function
*/
@@ -10193,13 +11713,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
*/
@@ -10285,40 +11805,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.
*/
@@ -10348,16 +11868,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.
*/
@@ -10386,14 +11906,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}
*/
@@ -10427,14 +11947,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.
*/
@@ -10447,14 +11967,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
*/
@@ -10467,14 +11987,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.
*/
@@ -10487,18 +12007,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.
*/
@@ -10511,18 +12031,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.
*/
@@ -10535,19 +12055,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)
*/
@@ -10592,7 +12112,6 @@
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 = [];
@@ -10778,14 +12297,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
*/
@@ -10903,9 +12422,7 @@
if (typeof arc.startAngle !== 'undefined') {
var start = rad2deg(arc.startAngle);
var end = rad2deg(arc.endAngle);
- var x = arc.x;
- var y = arc.y;
- drawArc.call(this, x, y, arc.radius, start, end, arc.counterclockwise, style, isClip);
+ drawArc.call(this, arc.x, arc.y, arc.radius, start, end, arc.counterclockwise, style, isClip);
} else {
drawLine.call(this, arc.x, arc.y);
}
@@ -10985,16 +12502,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
*/
@@ -11010,6 +12527,7 @@
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);
}
@@ -11034,6 +12552,7 @@
var doClip = function doClip() {
this.pdf.clip();
+ this.pdf.discardPath();
};
var doMove = function doMove(x, y) {
@@ -11147,11 +12666,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
*/
@@ -11187,12 +12706,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.
*/
@@ -11253,9 +12772,9 @@
var todx = dx - cx;
var tody = dy - cy;
var precision = 40;
- 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;
+ 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;
- for (var i = 0; i < precision + 1; i++) {
+ for (i = 0; i < precision + 1; i++) {
d = i / precision;
px = ax + d * tobx;
py = ay + d * toby;
@@ -11291,304 +12810,29 @@
return new Rectangle(Math.round(minx), Math.round(miny), Math.round(maxx - minx), Math.round(maxy - miny));
};
+ })(jsPDF.API);
- var Point = function Point(x, y) {
- var _x = x || 0;
+ /* global jsPDF, Deflater */
- Object.defineProperty(this, 'x', {
- enumerable: true,
- get: function get() {
- return _x;
- },
- set: function set(value) {
- if (!isNaN(value)) {
- _x = parseFloat(value);
- }
- }
- });
+ /**
+ * jsPDF filters PlugIn
+ * Copyright (c) 2014 Aras Abbasi
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
+ */
+ (function (jsPDFAPI) {
- var _y = y || 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, '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;
- };
-
- 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();
+ 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) + "~>";
};
@@ -11616,80 +12860,9 @@
}
}(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.length + 2);
- data = String.fromCharCode.apply(null, arr);
+ data = deflater.append(new Uint8Array(arr));
+ data = appendBuffer(data, deflater.flush());
+ arr = new Uint8Array(data.byteLength + 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.byteLength + 2);
+ data = arr.reduce(function (data, byte) {
+ return data + String.fromCharCode(byte);
+ }, '');
return data;
};
@@ -11795,19 +12984,6 @@
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";
}
@@ -11820,26 +12996,28 @@
};
})(jsPDF.API);
- /**
- * jsPDF fileloading PlugIn
- * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com)
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* 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
*/
- /**
- * @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) {
@@ -11867,17 +13045,18 @@
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 () {
- return sanitizeUnicode(this.responseText);
+ callback(sanitizeUnicode(this.responseText));
};
}
req.send(null);
if (req.status !== 200) {
+ // eslint-disable-next-line no-console
console.warn('Unable to load file "' + url + '"');
return;
}
@@ -11895,56 +13074,65 @@
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);
- /**
- * Copyright (c) 2018 Erik Koopmans
- * Released under the MIT License.
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF html2canvas */
+
+ /**
+ * 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) {
- /**
- * Determine the type of a variable/object.
- *
- * @private
- * @ignore
+
+ 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
*/
+
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;
@@ -11961,11 +13149,11 @@
return el;
};
- /**
- * Deep-clone a node and preserve contents/properties.
- *
- * @private
- * @ignore
+ /**
+ * Deep-clone a node and preserve contents/properties.
+ *
+ * @private
+ * @ignore
*/
@@ -12292,16 +13480,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, options) {
+ Worker.prototype.outputImg = function outputImg(type) {
// Set up function prerequisites.
var prereqs = [function checkImg() {
return this.prop.img || this.toImg();
@@ -12331,7 +13519,7 @@
var result = typeof global.html2canvas !== "undefined";
if (!result) {
- console.error("html2canvas not loaded.");
+ throw new Error("html2canvas not loaded.");
}
return result;
@@ -12355,7 +13543,7 @@
});
};
- Worker.prototype.doCallback = function doCallback(filename) {
+ Worker.prototype.doCallback = function doCallback() {
// Set up function prerequisites.
var prereqs = [function checkPdf() {
return this.prop.pdf || this.toPdf();
@@ -12429,6 +13617,7 @@
switch (objType(margin)) {
case 'number':
margin = [margin, margin, margin, margin];
+ // eslint-disable-next-line no-fallthrough
case 'array':
if (margin.length === 2) {
@@ -12439,6 +13628,8 @@
break;
}
+ // eslint-disable-next-line no-fallthrough
+
default:
return this.error('Invalid margin array.');
} // Set the margin property, then update pageSize.
@@ -12476,10 +13667,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;
@@ -12630,64 +13821,68 @@
'ledger': [1224, 792],
'tabloid': [792, 1224],
'credit-card': [153, 243]
- }; // Unit conversion
+ };
+ var k = 1; // Unit conversion
switch (unit) {
case 'pt':
- var k = 1;
+ k = 1;
break;
case 'mm':
- var k = 72 / 25.4;
+ k = 72 / 25.4;
break;
case 'cm':
- var k = 72 / 2.54;
+ k = 72 / 2.54;
break;
case 'in':
- var k = 72;
+ k = 72;
break;
case 'px':
- var k = 72 / 96;
+ k = 72 / 96;
break;
case 'pc':
- var k = 12;
+ k = 12;
break;
case 'em':
- var k = 12;
+ k = 12;
break;
case 'ex':
- var k = 6;
+ 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)) {
- var pageHeight = pageFormats[format_as_string][1] / k;
- var pageWidth = pageFormats[format_as_string][0] / k;
+ pageHeight = pageFormats[format_as_string][1] / k;
+ pageWidth = pageFormats[format_as_string][0] / k;
} else {
try {
- var pageHeight = format[1];
- var pageWidth = format[0];
+ pageHeight = format[1];
+ 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) {
- var tmp = pageWidth;
+ tmp = pageWidth;
pageWidth = pageHeight;
pageHeight = tmp;
}
@@ -12695,7 +13890,7 @@
orientation = 'l';
if (pageHeight > pageWidth) {
- var tmp = pageWidth;
+ tmp = pageWidth;
pageWidth = pageHeight;
pageHeight = tmp;
}
@@ -12712,14 +13907,23 @@
};
return info;
};
- /**
- * 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
+ /**
+ * 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();
+ * }
+ * });
*/
@@ -12733,7 +13937,6 @@
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) {
@@ -12743,41 +13946,39 @@
// Otherwise, return the worker for new Promise-based operation.
return worker;
}
-
- return this;
};
})(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global);
- /**
- * @license
- * ====================================================================
- * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
- *
- *
- * ====================================================================
- */
-
/*global jsPDF */
- /**
- * jsPDF JavaScript plugin
- *
- * @name javascript
- * @module
+ /**
+ * @license
+ * ====================================================================
+ * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
+ *
+ *
+ * ====================================================================
+ */
+
+ /**
+ * 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 (javascript) {
+ this.internal.events.subscribe('postPutResources', function () {
jsNamesObj = this.internal.newObject();
this.internal.out('<<');
this.internal.out('/Names [(EmbeddedJS) ' + (jsNamesObj + 1) + ' 0 R]');
@@ -12799,14 +14000,23 @@
};
})(jsPDF.API);
- /**
- * @license
- * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * @license
+ * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
+ /**
+ * jsPDF Outline PlugIn
+ *
+ * Generates a PDF Outline
+ * @name outline
+ * @module
+ */
(function (jsPDFAPI) {
jsPDFAPI.events.push(['postPutResources', function () {
@@ -12896,8 +14106,8 @@
children: []
}
};
- /**
- * Options: pageNumber
+ /**
+ * Options: pageNumber
*/
pdf.outline.add = function (parent, title, options) {
@@ -12949,7 +14159,6 @@
};
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++) {
@@ -12999,8 +14208,7 @@
}
for (var i = 0; i < node.children.length; i++) {
- var item = node.children[i];
- this.renderItems(item);
+ this.renderItems(node.children[i]);
}
};
@@ -13020,7 +14228,7 @@
this.ctx.val += '\r\n' + node.id + ' 0 obj' + '\r\n<<\r\n';
};
- pdf.outline.objEnd = function (node) {
+ pdf.outline.objEnd = function () {
this.ctx.val += '>> \r\n' + 'endobj' + '\r\n';
};
@@ -13036,109 +14244,260 @@
return this;
})(jsPDF.API);
- /**
- * @license
- *
- * Copyright (c) 2014 James Robb, https://github.com/jamesbrobb
- *
- *
- * ====================================================================
+ /* global jsPDF */
+
+ /**
+ * @license
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
- /**
- * jsPDF PNG PlugIn
- * @name png_support
- * @module
+ /**
+ * jsPDF jpeg Support PlugIn
+ *
+ * @name jpeg_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
- */
+ //a jpeg image and returns [width, height]
+ //Algorithm from: http://www.64lines.com/jpeg-width-height
- 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;
+ var getJpegSize = function getJpegSize(imgData) {
- switch (compression) {
- case jsPDFAPI.image_compression.FAST:
- level = 3;
- filter_method = filterSub;
- break;
+ var width, height, numcomponents;
+ var blockLength = imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5);
+ var i = 4,
+ len = imgData.length;
- case jsPDFAPI.image_compression.MEDIUM:
- level = 6;
- filter_method = filterAverage;
- break;
+ while (i < len) {
+ i += blockLength;
- case jsPDFAPI.image_compression.SLOW:
- level = 9;
- filter_method = filterPaeth; //uses to sum to choose best filter for each line
+ if (imgData.charCodeAt(i) !== 0xff) {
+ throw new Error('getJpegSize could not find the size of the image');
+ }
- 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);
+ }
}
+ };
- bytes = applyPngFilterMethod(bytes, lineLength, colorsPerPixel, filter_method);
- var header = new Uint8Array(createZlibHeader(level));
- var checksum = adler32(bytes);
- var deflate = new Deflater(level);
- var a = deflate.append(bytes);
- var cBytes = deflate.flush();
- var len = header.length + a.length + cBytes.length;
- var cmpd = new Uint8Array(len + 4);
- cmpd.set(header);
- cmpd.set(a, header.length);
- cmpd.set(cBytes, header.length + a.length);
- cmpd[len++] = checksum >>> 24 & 0xff;
- cmpd[len++] = checksum >>> 16 & 0xff;
- cmpd[len++] = checksum >>> 8 & 0xff;
- cmpd[len++] = checksum & 0xff;
- return jsPDFAPI.arrayBufferToBinaryString(cmpd);
- },
- createZlibHeader = function createZlibHeader(bytes, level) {
- /*
- * @see http://www.ietf.org/rfc/rfc1950.txt for zlib header
- */
- var cm = 8;
+ 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;
+
+ 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;
+ }
+
+ bytes = applyPngFilterMethod(bytes, lineLength, colorsPerPixel, filter_method);
+ var header = new Uint8Array(createZlibHeader(level));
+ var checksum = adler32(bytes);
+ var deflate = new Deflater(level);
+ var a = deflate.append(bytes);
+ var cBytes = deflate.flush();
+ var len = header.length + a.length + cBytes.length;
+ var cmpd = new Uint8Array(len + 4);
+ cmpd.set(header);
+ cmpd.set(a, header.length);
+ cmpd.set(cBytes, header.length + a.length);
+ cmpd[len++] = checksum >>> 24 & 0xff;
+ cmpd[len++] = checksum >>> 16 & 0xff;
+ cmpd[len++] = checksum >>> 8 & 0xff;
+ cmpd[len++] = checksum & 0xff;
+ return jsPDFAPI.arrayBufferToBinaryString(cmpd);
+ },
+ createZlibHeader = function createZlibHeader(bytes, level) {
+ /*
+ * @see http://www.ietf.org/rfc/rfc1950.txt for zlib header
+ */
+ var cm = 8;
var cinfo = Math.LOG2E * Math.log(0x8000) - 8;
var cmf = cinfo << 4 | cm;
var hdr = cmf << 8;
@@ -13205,15 +14564,15 @@
return result;
},
- filterNone = function filterNone(line, colorsPerPixel, prevLine) {
- /*var result = new Uint8Array(line.length + 1);
- result[0] = 0;
+ filterNone = function filterNone(line) {
+ /*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, prevLine) {
+ filterSub = function filterSub(line, colorsPerPixel) {
var result = [],
i = 0,
len = line.length,
@@ -13341,15 +14700,14 @@
return predictor;
};
- /**
- *
- * @name processPNG
- * @function
- * @ignore
+ /**
+ * @name processPNG
+ * @function
+ * @ignore
*/
- jsPDFAPI.processPNG = function (imageData, imageIndex, alias, compression, dataAsBinaryString) {
+ jsPDFAPI.processPNG = function (imageData, imageIndex, alias, compression) {
var colorSpace = this.color_spaces.DEVICE_RGB,
decode = this.decode.FLATE_DECODE,
@@ -13359,42 +14717,45 @@
trns,
colors,
pal,
- smask;
- /* if(this.isString(imageData)) {
- }*/
-
- if (this.isArrayBuffer(imageData)) imageData = new Uint8Array(imageData);
+ smask,
+ pixels,
+ len,
+ alphaData,
+ imgData,
+ hasColors,
+ pixel,
+ i,
+ n;
+ 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; //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
+ 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
*/
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) {
- 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;
+ 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;
for (; i < len; i++) {
pixel = pixels[i];
@@ -13408,21 +14769,20 @@
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) {
- 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;
+ 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;
while (i < len) {
pixel = pixels[i++];
@@ -13449,8 +14809,8 @@
decode = null;
}
}
- /*
- * Indexed png. Each pixel is a palette index.
+ /*
+ * Indexed png. Each pixel is a palette index.
*/
@@ -13460,31 +14820,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) {
- var pixels = img.decodePixels(),
- alphaData = new Uint8Array(pixels.length),
- i = 0,
- len = pixels.length;
+ pixels = img.decodePixels();
+ alphaData = new Uint8Array(pixels.length);
+ i = 0;
+ len = pixels.length;
for (; i < len; i++) {
alphaData[i] = trans[pixels[i]];
@@ -13496,10 +14856,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);
}
@@ -13507,23 +14867,25 @@
};
})(jsPDF.API);
- /**
- * @license
- * Copyright (c) 2017 Aras Abbasi
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF, GifReader, JPEGEncoder */
+
+ /**
+ * @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, dataAsBinaryString) {
+ jsPDFAPI.processGIF89A = function (imageData, imageIndex, alias, compression) {
var reader = new GifReader(imageData);
var width = reader.width,
height = reader.height;
@@ -13543,21 +14905,23 @@
jsPDFAPI.processGIF87A = jsPDFAPI.processGIF89A;
})(jsPDF.API);
- /**
- * Copyright (c) 2018 Aras Abbasi
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF, BmpDecoder, JPEGEncoder */
+
+ /**
+ * 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, dataAsBinaryString) {
+ jsPDFAPI.processBMP = function (imageData, imageIndex, alias, compression) {
var reader = new BmpDecoder(imageData, false);
var width = reader.width,
height = reader.height;
@@ -13574,31 +14938,68 @@
};
})(jsPDF.API);
- /**
- * @license
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* 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
*/
- /**
- * 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) {
@@ -13822,31 +15223,33 @@
};
})(jsPDF.API);
- /** @license
- * MIT license.
- * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
- * 2014 Diego Casorran, https://github.com/diegocr
- *
- *
- * ====================================================================
+ /* global jsPDF */
+
+ /** @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) {
@@ -13880,14 +15283,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}
*/
@@ -13902,21 +15305,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
*/
@@ -13935,8 +15338,8 @@
return result;
};
- /**
- returns array of lines
+ /**
+ returns array of lines
*/
@@ -14067,34 +15470,36 @@
}
}
+ var postProcess;
+
if (lineIndent) {
- var postProcess = function postProcess(ln, idx) {
+ postProcess = function postProcess(ln, idx) {
return (idx ? pad : '') + ln.join(" ");
};
} else {
- var postProcess = function postProcess(ln) {
+ 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.
*/
@@ -14132,13 +15537,7 @@
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
@@ -14175,149 +15574,170 @@
};
})(jsPDF.API);
- /** @license
- jsPDF standard_fonts_metrics plugin
- * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
- * MIT license.
- *
- * ====================================================================
+ /* global jsPDF */
+
+ /** @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) {
@@ -14461,16 +15881,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) {
@@ -14510,17 +15930,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, global) {
+ (function (jsPDF) {
jsPDF.API.events.push(['addFont', function (data) {
var font = data.font;
@@ -14544,32 +15964,40 @@
throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('" + font.postScriptName + "').");
}
}]); // end of adding event handler
- })(jsPDF, typeof self !== "undefined" && self || typeof global !== "undefined" && global || typeof window !== "undefined" && window || Function("return this")());
+ })(jsPDF);
- /** @license
- * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
- *
- *
- * ====================================================================
+ /* global jsPDF, canvg */
+
+ /** @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) {
@@ -14697,24 +16125,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) {
@@ -14747,26 +16175,28 @@
};
})(jsPDF.API);
- /**
- * @license
- * ====================================================================
- * Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
- *
- *
- * ====================================================================
+ /* global jsPDF */
+
+ /**
+ * @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) {
@@ -14792,109 +16222,111 @@
};
})(jsPDF.API);
- /**
- * jsPDF viewerPreferences Plugin
- * @author Aras Abbasi (github.com/arasabbasi)
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * 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) {
@@ -15145,33 +16577,33 @@
};
})(jsPDF.API);
- /** ====================================================================
- * jsPDF XMP metadata plugin
- * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi
- *
- *
- * ====================================================================
- */
+ /* global jsPDF */
- /*global jsPDF */
+ /** ====================================================================
+ * jsPDF XMP metadata plugin
+ * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi
+ *
+ *
+ * ====================================================================
+ */
- /**
- * @name xmp_metadata
- * @module
+ /**
+ * @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) {
@@ -15209,11 +16641,13 @@
};
})(jsPDF.API);
- /**
- * @name utf8
- * @module
+ /* global jsPDF */
+
+ /**
+ * @name utf8
+ * @module
*/
- (function (jsPDF, global) {
+ (function (jsPDF) {
var jsPDFAPI = jsPDF.API;
/**************************************************/
@@ -15288,9 +16722,11 @@
range = [];
}
- unicode = ('0000' + map[code].toString(16)).slice(-4);
- code = ('0000' + (+code).toString(16)).slice(-4);
- range.push("<" + code + "><" + unicode + ">");
+ 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 + ">");
+ }
}
if (range.length) {
@@ -15301,7 +16737,13 @@
return unicodeMap;
};
- var identityHFunction = function identityHFunction(font, out, newObject, putStream) {
+ 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;
+
if (font.metadata instanceof jsPDF.API.TTFFont && font.encoding === 'Identity-H') {
//Tag with Identity-H
var widths = font.metadata.Unicode.widths;
@@ -15329,7 +16771,7 @@
var fontDescriptor = newObject();
out('<<');
out('/Type /FontDescriptor');
- out('/FontName /' + font.fontName);
+ out('/FontName /' + pdfEscapeWithNeededParanthesis(font.fontName));
out('/FontFile2 ' + fontTable + ' 0 R');
out('/FontBBox ' + jsPDF.API.PDFObject.convert(font.metadata.bbox));
out('/Flags ' + font.metadata.flags);
@@ -15343,7 +16785,7 @@
var DescendantFont = newObject();
out('<<');
out('/Type /Font');
- out('/BaseFont /' + font.fontName);
+ out('/BaseFont /' + pdfEscapeWithNeededParanthesis(font.fontName));
out('/FontDescriptor ' + fontDescriptor + ' 0 R');
out('/W ' + jsPDF.API.PDFObject.convert(widths));
out('/CIDToGIDMap /Identity');
@@ -15372,13 +16814,18 @@
};
jsPDFAPI.events.push(['putFont', function (args) {
- identityHFunction(args.font, args.out, args.newObject, args.putStream);
+ identityHFunction(args);
}]);
- var winAnsiEncodingFunction = function winAnsiEncodingFunction(font, out, newObject, 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;
+
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 = "";
@@ -15409,15 +16856,15 @@
out('/FontFile2 ' + fontTable + ' 0 R');
out('/Flags 96');
out('/FontBBox ' + jsPDF.API.PDFObject.convert(font.metadata.bbox));
- out('/FontName /' + font.fontName);
+ out('/FontName /' + pdfEscapeWithNeededParanthesis(font.fontName));
out('/ItalicAngle ' + font.metadata.italicAngle);
out('/Ascent ' + font.metadata.ascender);
out('>>');
out('endobj');
font.objectNumber = newObject();
- 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.
+ 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.
}
out('<>');
@@ -15427,7 +16874,7 @@
};
jsPDFAPI.events.push(['putFont', function (args) {
- winAnsiEncodingFunction(args.font, args.out, args.newObject, args.putStream);
+ winAnsiEncodingFunction(args);
}]);
var utf8TextFunction = function utf8TextFunction(args) {
@@ -15439,13 +16886,11 @@
var pdfEscape = mutex.pdfEscape;
var activeFontKey = mutex.activeFontKey;
var fonts = mutex.fonts;
- var key,
- fontSize = mutex.activeFontSize;
+ var key = activeFontKey;
var str = '',
s = 0,
cmapConfirm;
var strText = '';
- var key = activeFontKey;
var encoding = fonts[key].encoding;
if (fonts[key].encoding !== 'Identity-H') {
@@ -15457,6 +16902,7 @@
mutex: mutex
};
}
+
strText = text;
key = activeFontKey;
@@ -15467,19 +16913,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
}*/
}
@@ -15519,7 +16965,6 @@
y = parms.y,
options = parms.options,
mutex = parms.mutex;
- var lang = options.lang;
var tmpText = [];
var args = {
text: text,
@@ -15559,20 +17004,22 @@
};
jsPDFAPI.events.push(['postProcessText', utf8EscapeFunction]);
- })(jsPDF, typeof self !== "undefined" && self || typeof global !== "undefined" && global || typeof window !== "undefined" && window || Function("return this")());
+ })(jsPDF);
- /**
- * jsPDF virtual FileSystem functionality
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /* global jsPDF */
+
+ /**
+ * 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) {
@@ -15587,15 +17034,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");
*/
@@ -15606,16 +17053,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");
*/
@@ -15625,15 +17072,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");
*/
@@ -15648,37 +17095,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;
@@ -15840,18 +17287,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;
@@ -16377,7 +17824,7 @@
}
function loadImage(url, width, height) {
- if (!url) return;
+ if (!url) { return; }
var img = new Image();
found_images = ++x;
img.crossOrigin = '';
@@ -16484,8 +17931,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) {
@@ -16517,7 +17964,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,
@@ -16915,24 +18362,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) {
@@ -16941,18 +18388,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) {
@@ -17075,20 +18522,15 @@
});
};
})(jsPDF.API, typeof window !== "undefined" && window || typeof global !== "undefined" && global);
- /*rollup-keeper-start*/
-
- 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
+ /* 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) {
@@ -17116,10 +18558,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.
*/
@@ -17166,7 +18608,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);
@@ -17243,7 +18685,7 @@
}
function encodeByteArray(input) {
- var byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ var byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var output = [];
for (var i = 0; i < input.length; i += 3) {
@@ -17345,7 +18787,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) {}
@@ -17362,13 +18804,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);
};
@@ -17376,7 +18818,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;
@@ -17500,7 +18942,7 @@
return '[object File]';
};
- if (strTag) blob[strTag] = 'File';
+ if (strTag) { blob[strTag] = 'File'; }
return blob;
};
@@ -17520,217 +18962,32 @@
}
})(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
- */
+ // (c) Dean McNamee , 2013.
+ //
+ // https://github.com/deanm/omggif
+ //
+ //
+ //
+ // omggif is a JavaScript implementation of a GIF 89a encoder and decoder,
+ // including animation and compression. It does not rely on any specific
+ // underlying system, so should run in the browser, Node, or Plask.
+ function GifWriter(buf, width, height, gopts) {
+ var p = 0;
+ 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."; }
- /*global self */
+ 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."; }
+ return num_colors;
+ } // - Header.
- /*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
- //
- //
- //
- // omggif is a JavaScript implementation of a GIF 89a encoder and decoder,
- // including animation and compression. It does not rely on any specific
- // underlying system, so should run in the browser, Node, or Plask.
- function GifWriter(buf, width, height, gopts) {
- var p = 0;
- 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.";
-
- 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.";
- return num_colors;
- } // - Header.
-
-
- buf[p++] = 0x47;
- buf[p++] = 0x49;
- buf[p++] = 0x46; // GIF
+ buf[p++] = 0x47;
+ buf[p++] = 0x49;
+ buf[p++] = 0x46; // GIF
buf[p++] = 0x38;
buf[p++] = 0x39;
@@ -17743,19 +19000,21 @@
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.
@@ -17785,7 +19044,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;
@@ -17822,9 +19081,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;
@@ -17833,12 +19092,14 @@
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.
@@ -17858,14 +19119,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) {
@@ -18049,7 +19310,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.
}
@@ -18137,7 +19398,7 @@
while (true) {
// Seek through subblocks.
var block_size = buf[p++];
- if (block_size === 0) break;
+ if (block_size === 0) { break; }
p += block_size;
}
}
@@ -18146,11 +19407,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.
@@ -18161,7 +19422,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;
}
@@ -18200,7 +19461,7 @@
while (true) {
var block_size = buf[p++];
- if (block_size === 0) break;
+ if (block_size === 0) { break; }
p += block_size;
}
@@ -18240,7 +19501,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];
};
@@ -18255,7 +19516,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.
@@ -18321,7 +19582,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.
@@ -18401,7 +19662,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;
@@ -18416,7 +19677,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,
@@ -18479,7 +19740,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--) {
@@ -18517,17 +19778,11 @@
exports.GifReader = GifReader;
} catch (e) {} // CommonJS.
- /*rollup-keeper-start*/
-
-
- window.tmp = GifReader;
- /*rollup-keeper-end*/
-
- /*
- * Copyright (c) 2012 chick307
- *
- * Licensed under the MIT License.
- * http://opensource.org/licenses/mit-license
+ /*
+ * Copyright (c) 2012 chick307
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
*/
(function (jsPDF, callback) {
jsPDF.API.adler32cs = callback();
@@ -18536,13 +19791,13 @@
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) {
@@ -18596,7 +19851,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.');
}
@@ -18614,7 +19869,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());
});
@@ -18626,7 +19881,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());
@@ -18642,20 +19897,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());
@@ -18664,7 +19919,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);
};
@@ -18678,12 +19933,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());
@@ -18692,7 +19947,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);
};
@@ -18701,58 +19956,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) {
@@ -19239,16 +20494,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),
*/
@@ -19302,42 +20557,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;
@@ -19913,7 +21168,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;
@@ -19971,10 +21226,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)
@@ -20015,7 +21270,7 @@
quality = 100;
}
- if (currentQuality == quality) return; // don't recalc if unchanged
+ if (currentQuality == quality) { return; } // don't recalc if unchanged
var sf = 0;
@@ -20031,7 +21286,7 @@
function init() {
var time_start = new Date().getTime();
- if (!quality) quality = 50; // Create tables
+ if (!quality) { quality = 50; } // Create tables
initCharLookupTable();
initHuffmanTbl();
@@ -20043,16 +21298,16 @@
init();
}
- /*rollup-keeper-start*/
- window.tmp = JPEGEncoder;
- /*rollup-keeper-end*/
+ try {
+ exports.JPEGEncoder = JPEGEncoder;
+ } catch (e) {} // CommonJS.
- /**
- * @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;
@@ -20062,7 +21317,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();
}
@@ -20163,7 +21418,7 @@
}
}
- if (mode != 0) {
+ if (mode !== 0) {
this.pos += 4 - mode;
}
}
@@ -20186,7 +21441,7 @@
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;
@@ -20194,190 +21449,4688 @@
this.data[location + 4 + 3] = 0xFF;
}
- if (mode != 0) {
+ 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.bit8 = function () {
- var mode = this.width % 4;
+ 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;
+ }
- for (var y = this.height - 1; y >= 0; y--) {
- var line = this.bottom_up ? y : this.height - 1 - y;
+ d && (b = a.a);
+ } else { b = a.a; }
+ } else {
+ a = new Ce();
- 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 (null == a) {
+ g = 1;
+ break b;
+ }
- 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;
- }
- }
+ a.Fa = e.na;
+ a.P = e.P;
+ a.qc = e.Sa;
- if (mode != 0) {
- this.pos += 4 - mode;
- }
- }
- };
+ 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);
- BmpDecoder.prototype.bit15 = function () {
- var dif_w = this.width % 3;
+ if (null != c) {
+ k = c.Md;
+ k = 0 > k ? 0 : 100 < k ? 255 : 255 * k / 100;
- var _11111 = parseInt("11111", 2),
- _1_5 = _11111;
+ 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;
+ }
- for (var y = this.height - 1; y >= 0; y--) {
- var line = this.bottom_up ? y : this.height - 1 - y;
+ m && (alert("todo:VP8InitRandom"), e.ia = 1);
+ }
- 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
+ e.Ga = c.Id;
+ 100 < e.Ga ? e.Ga = 100 : 0 > e.Ga && (e.Ga = 0);
+ }
+ Me(a, d) || (b = a.a);
+ }
+ } else { b = a.a; }
+ }
- this.pos += dif_w;
- }
- };
+ 0 == b && null != g.Oa && g.Oa.fd && (b = Bd(g.ba));
+ }
- BmpDecoder.prototype.bit16 = function () {
- var dif_w = this.width % 3;
+ g = b;
+ }
- var _11111 = parseInt("11111", 2),
- _1_5 = _11111;
+ f = 0 != g ? null : 11 > f ? h.f.RGBA.eb : h.f.kb.y;
+ } else { f = null; }
- var _111111 = parseInt("111111", 2),
- _1_6 = _111111;
+ return f;
+ };
- for (var y = this.height - 1; y >= 0; y--) {
- var line = this.bottom_up ? y : this.height - 1 - y;
+ var Dd = [3, 4, 3, 4, 4, 2, 2, 4, 4, 4, 2, 1, 1];
+ };
- 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
+ new WebPDecoder();
+ /*Copyright (c) 2017 Dominik Homberger
+
+
+
+ https://webpjs.appspot.com
+ WebPRiffParser dominikhlbg@gmail.com
+ */
+ function memcmp(data, data_off, str, size) {
+ for (var i = 0; i < size; i++) {
+ if (data[data_off + i] != str.charCodeAt(i)) { return true; }
+ }
- this.pos += dif_w;
+ return false;
}
- };
- 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;
+ function GetTag(data, data_off) {
+ var str = '';
- 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
+ for (var i = 0; i < 4; i++) {
+ str += String.fromCharCode(data[data_off++]);
+ }
+ return str;
+ }
- this.pos += this.width % 4;
+ function GetLE16(data, data_off) {
+ return data[data_off + 0] << 0 | data[data_off + 1] << 8;
}
- };
- /**
- * add 32bit decode func
- * @author soubok
- */
+ function GetLE24(data, data_off) {
+ return (data[data_off + 0] << 0 | data[data_off + 1] << 8 | data[data_off + 2] << 16) >>> 0;
+ }
- 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;
+ 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;
+ }
- 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);
+ 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]};
- }
- };
+ i++;
- BmpDecoder.prototype.getData = function () {
- return this.data;
- };
- /*rollup-keeper-start*/
+ if (alpha_chunk) {
+ alpha_chunk = false;
+ alpha_size = 0;
+ alpha_offset = 0;
+ }
+
+ 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;
+
+ 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;
+
+ 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;
+
+ default:
+ }
+
+ if (fourcc != "ANMF") { src_off += payload_size_padded; }
+ }
+ return imagearray;
+ }
- window.tmp = BmpDecoder;
- /*rollup-keeper-end*/
+ 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;
+ }
+ }
+ }
- /*
- Copyright (c) 2013 Gildas Lormeau. All rights reserved.
+ 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];
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ for (var i = 0; i < width[0] * height[0] * 4; i++) {
+ pixels[i] = rgba[i];
+ }
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this.width = width;
+ this.height = height;
+ this.data = pixels;
+ return this;
+ }
- 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.
+ WebPDecoder.prototype.getData = function () {
+ return this.data;
+ };
- 3. The names of the authors may not be used to endorse or promote products
- derived from this software without specific prior written permission.
+ try {
+ exports.WebPDecoder = WebPDecoder;
+ } catch (e) {} // CommonJS.
- 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.
+ /*
+ 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 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) {
@@ -20472,17 +26225,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 {
@@ -20507,9 +26260,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;
}
@@ -20563,14 +26316,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
@@ -21133,14 +26886,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--;
}
@@ -21161,7 +26914,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 {
@@ -21193,7 +26946,7 @@
function bi_flush() {
- if (bi_valid == 16) {
+ if (bi_valid === 16) {
put_short(bi_buf);
bi_buf = 0;
bi_valid = 0;
@@ -21263,10 +27016,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
@@ -21393,21 +27146,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 {
@@ -21450,10 +27203,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
@@ -21491,15 +27244,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);
@@ -21539,8 +27292,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;
@@ -21553,20 +27306,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) {
@@ -21599,13 +27352,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
@@ -21615,7 +27368,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;
@@ -21623,13 +27376,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.
@@ -21652,11 +27405,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:
@@ -21675,7 +27428,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
@@ -21718,17 +27471,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.
@@ -21750,11 +27503,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:
@@ -21776,12 +27529,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;
@@ -21818,7 +27571,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
@@ -21832,7 +27585,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.
@@ -21847,13 +27600,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) {
@@ -21870,19 +27623,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;
}
@@ -21911,7 +27664,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:
@@ -21922,13 +27675,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;
}
@@ -21936,12 +27689,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;
@@ -21957,8 +27710,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;
@@ -21990,7 +27743,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;
}
@@ -22005,12 +27758,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);
@@ -22034,19 +27787,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) {
@@ -22065,16 +27818,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
@@ -22082,8 +27835,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
@@ -22091,7 +27844,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*/
@@ -22112,7 +27865,7 @@
}
}
- if (flush != Z_FINISH) return Z_OK;
+ if (flush !== Z_FINISH) { return Z_OK; }
return Z_STREAM_END;
};
} // ZStream
@@ -22139,7 +27892,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) {
@@ -22153,19 +27906,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
@@ -22176,8 +27929,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;
@@ -22191,8 +27944,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 + ", " +
@@ -22220,7 +27973,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;
@@ -22231,7 +27984,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;
@@ -22240,11 +27993,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;
}
@@ -22269,8 +28022,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);
@@ -22291,11 +28044,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) {
@@ -22458,14 +28211,7 @@
yellow: 'ffff00',
yellowgreen: '9acd32'
};
-
- 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
-
+ color_string = simple_colors[color_string] || color_string; // array of color definition objects
var color_defs = [{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
@@ -22514,9 +28260,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;
};
}
@@ -22526,14 +28272,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) {
@@ -22609,15 +28355,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 () {
@@ -22926,9 +28672,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);
};*/
@@ -22979,8 +28725,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);
};*/
@@ -23132,7 +28878,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() {
@@ -23625,26 +29371,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;
};*/
@@ -23737,8 +29483,8 @@
}
}
};
- /*OS2Table.prototype.encode = function () {
- return this.raw();
+ /*OS2Table.prototype.encode = function () {
+ return this.raw();
};*/
@@ -23909,52 +29655,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;
@@ -23987,25 +29733,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;
};*/
@@ -24093,16 +29839,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;
};*/
@@ -24389,51 +30135,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;
};*/
@@ -24444,28 +30190,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;
};*/
/***************************************************************/
@@ -24491,19 +30237,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();
};*/
/******************************************************************/
@@ -24682,14 +30428,15 @@
}();
})(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;
@@ -24818,9 +30565,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;
@@ -24896,8 +30643,6 @@
throw new Error("Incomplete or corrupt PNG file");
}
}
-
- return;
}
PNG.prototype.read = function (bytes) {
@@ -25050,22 +30795,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
@@ -25096,7 +30841,7 @@
length = palette.length;
c = 0;
- for (i = _i = 0, _ref = palette.length; _i < _ref; i = _i += 3) {
+ for (i = _i = 0, _ref = length; _i < _ref; i = _i += 3) {
ret[pos++] = palette[i];
ret[pos++] = palette[i + 1];
ret[pos++] = palette[i + 2];
@@ -25277,20 +31022,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() {
@@ -25304,7 +31049,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) {
@@ -25323,7 +31068,7 @@
var pos = this.pos;
while (this.bufferLength <= pos) {
- if (this.eof) return null;
+ if (this.eof) { return null; }
this.readBlock();
}
@@ -25341,7 +31086,7 @@
}
var bufEnd = this.bufferLength;
- if (end > bufEnd) end = bufEnd;
+ if (end > bufEnd) { end = bufEnd; }
} else {
while (!this.eof) {
this.readBlock();
@@ -25357,7 +31102,7 @@
var pos = this.pos;
while (this.bufferLength <= pos) {
- if (this.eof) return null;
+ if (this.eof) { return null; }
this.readBlock();
}
@@ -25367,7 +31112,7 @@
var pos = this.pos;
while (this.bufferLength <= pos) {
- if (this.eof) return null;
+ if (this.eof) { return null; }
this.readBlock();
}
@@ -25383,7 +31128,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() {
@@ -25413,10 +31158,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;
@@ -25434,7 +31179,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;
}
@@ -25456,7 +31201,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;
}
@@ -25464,7 +31209,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;
@@ -25477,7 +31222,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
@@ -25520,7 +31265,7 @@
var hdr = this.getBits(3);
- if (hdr & 1) this.eof = true;
+ if (hdr & 1) { this.eof = true; }
hdr >>= 1;
if (hdr == 0) {
@@ -25528,15 +31273,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;
@@ -25629,12 +31374,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) {
@@ -25650,11 +31395,186 @@
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;
- window.tmp = FlateStream;
- /*rollup-keeper-end*/
+ if (typeof module !== 'undefined') {
+ module.exports = saveAs;
+ }
+ });
}));
diff --git a/dist/jspdf.min.js b/dist/jspdf.min.js
index 36b245641..282314144 100644
--- a/dist/jspdf.min.js
+++ b/dist/jspdf.min.js
@@ -1,10 +1,13 @@
!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 2018-12-27T14:11:42.696Z
- * CommitID d93d28db14
+ * Version 1.5.3 Built on 2019-03-28T02:02:22.223Z
+ * CommitID cf389e836e
*
- * Copyright (c) 2010-2016 James Hall , https://github.com/MrRio/jsPDF
+ * Copyright (c) 2010-2018 James Hall , https://github.com/MrRio/jsPDF
+ * 2015-2018 yWorks GmbH, http://www.yworks.com
+ * 2015-2018 Lukas Holländer , https://github.com/HackbrettXXX
+ * 2016-2018 Aras Abbasi
* 2010 Aaron Spike, https://github.com/acspike
* 2012 Willow Systems Corporation, willow-systems.com
* 2012 Pablo Hess, https://github.com/pablohess
@@ -26,15 +29,7 @@
* Contributor(s):
* siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
* kim3er, mfo, alnorth, Flamenco
- */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