# Table of Contents - [Home - Documentation](#home-documentation) - [ShadingPattern - Documentation](#shadingpattern-documentation) - [jsPDF - Documentation](#jspdf-documentation) - [GState - Documentation](#gstate-documentation) - [AcroFormButton - Documentation](#acroformbutton-documentation) - [AcroFormCheckBox - Documentation](#acroformcheckbox-documentation) - [AcroFormChoiceField - Documentation](#acroformchoicefield-documentation) - [AcroFormComboBox - Documentation](#acroformcombobox-documentation) - [GState - Documentation](#gstate-documentation) - [Matrix - Documentation](#matrix-documentation) - [TilingPattern - Documentation](#tilingpattern-documentation) - [AcroFormField - Documentation](#acroformfield-documentation) - [AcroFormPDFObject - Documentation](#acroformpdfobject-documentation) - [AcroForm - Documentation](#acroform-documentation) - [canvas - Documentation](#canvas-documentation) - [AcroFormTextField - Documentation](#acroformtextfield-documentation) - [AcroFormEditBox - Documentation](#acroformeditbox-documentation) - [AcroFormListBox - Documentation](#acroformlistbox-documentation) - [AcroFormPushButton - Documentation](#acroformpushbutton-documentation) - [AcroFormRadioButton - Documentation](#acroformradiobutton-documentation) - [Canvas - Documentation](#canvas-documentation) - [addImage - Documentation](#addimage-documentation) - [autoprint - Documentation](#autoprint-documentation) - [annotations - Documentation](#annotations-documentation) - [arabic - Documentation](#arabic-documentation) - [bmp_support - Documentation](#bmp-support-documentation) - [cell - Documentation](#cell-documentation) - [fileloading - Documentation](#fileloading-documentation) - [context2d - Documentation](#context2d-documentation) - [AcroFormPasswordField - Documentation](#acroformpasswordfield-documentation) - [gif_support - Documentation](#gif-support-documentation) - [html - Documentation](#html-documentation) - [javascript - Documentation](#javascript-documentation) - [outline - Documentation](#outline-documentation) - [jpeg_support - Documentation](#jpeg-support-documentation) - [png_support - Documentation](#png-support-documentation) - [setLanguage - Documentation](#setlanguage-documentation) - [split_text_to_size - Documentation](#split-text-to-size-documentation) - [rgba_support - Documentation](#rgba-support-documentation) - [svg - Documentation](#svg-documentation) - [ttfsupport - Documentation](#ttfsupport-documentation) - [webp_support - Documentation](#webp-support-documentation) - [vFS - Documentation](#vfs-documentation) - [total_pages - Documentation](#total-pages-documentation) - [standard_fonts_metrics - Documentation](#standard-fonts-metrics-documentation) - [utf8 - Documentation](#utf8-documentation) - [viewerpreferences - Documentation](#viewerpreferences-documentation) - [xmp_metadata - Documentation](#xmp-metadata-documentation) - [modules/canvas.js - Documentation](#modules-canvas-js-documentation) - [modules/bmp_support.js - Documentation](#modules-bmp-support-js-documentation) - [modules/cell.js - Documentation](#modules-cell-js-documentation) - [libs/bidiEngine.js - Documentation](#libs-bidiengine-js-documentation) - [modules/autoprint.js - Documentation](#modules-autoprint-js-documentation) - [modules/addimage.js - Documentation](#modules-addimage-js-documentation) - [modules/arabic.js - Documentation](#modules-arabic-js-documentation) - [modules/fileloading.js - Documentation](#modules-fileloading-js-documentation) - [modules/annotations.js - Documentation](#modules-annotations-js-documentation) - [modules/gif_support.js - Documentation](#modules-gif-support-js-documentation) - [modules/javascript.js - Documentation](#modules-javascript-js-documentation) - [modules/jpeg_support.js - Documentation](#modules-jpeg-support-js-documentation) - [modules/acroform.js - Documentation](#modules-acroform-js-documentation) - [modules/html.js - Documentation](#modules-html-js-documentation) - [modules/outline.js - Documentation](#modules-outline-js-documentation) - [modules/rgba_support.js - Documentation](#modules-rgba-support-js-documentation) - [modules/setlanguage.js - Documentation](#modules-setlanguage-js-documentation) - [modules/png_support.js - Documentation](#modules-png-support-js-documentation) - [jspdf.js - Documentation](#jspdf-js-documentation) - [modules/svg.js - Documentation](#modules-svg-js-documentation) - [modules/webp_support.js - Documentation](#modules-webp-support-js-documentation) - [modules/vfs.js - Documentation](#modules-vfs-js-documentation) - [modules/total_pages.js - Documentation](#modules-total-pages-js-documentation) - [modules/split_text_to_size.js - Documentation](#modules-split-text-to-size-js-documentation) - [modules/xmp_metadata.js - Documentation](#modules-xmp-metadata-js-documentation) - [modules/standard_fonts_metrics.js - Documentation](#modules-standard-fonts-metrics-js-documentation) - [modules/viewerpreferences.js - Documentation](#modules-viewerpreferences-js-documentation) - [modules/context2d.js - Documentation](#modules-context2d-js-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) --- # Home - Documentation ![jsPDF](https://parall.ax/parallax-2016/img/svg/jspdf-logo.svg) ================================================================ [![Continous Integration](https://github.com/MrRio/jsPDF/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/MrRio/jsPDF/actions/workflows/continuous-integration.yml?query=branch%3Amaster) [![Code Climate](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/gpa.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/feed) [![Test Coverage](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/coverage.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/coverage) [![GitHub license](https://img.shields.io/github/license/MrRio/jsPDF.svg)](https://github.com/MrRio/jsPDF/blob/master/LICENSE) [![Total alerts](https://img.shields.io/lgtm/alerts/g/MrRio/jsPDF.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MrRio/jsPDF/alerts/) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/MrRio/jsPDF.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MrRio/jsPDF/context:javascript) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/) **A library to generate PDFs in JavaScript.** You can [catch me on twitter](https://twitter.com/MrRio) : [@MrRio](https://twitter.com/MrRio) or head over to [my company's website](http://parall.ax/) for consultancy. jsPDF is now co-maintained by [yWorks - the diagramming experts](https://www.yworks.com/) . [Live Demo](https://raw.githack.com/MrRio/jsPDF/master/) | [Documentation](https://raw.githack.com/MrRio/jsPDF/master/docs/) ------------------------------------------------------------------------------------------------------------------------------ Install ------- Recommended: get jsPDF from npm: npm install jspdf --save # or yarn add jspdf Alternatively, load it from a CDN: Or always get latest version via [unpkg](https://unpkg.com/browse/jspdf/) The `dist` folder of this package contains different kinds of files: * **jspdf.es.\*.js**: Modern ES2015 module format. * **jspdf.node.\*.js**: For running in Node. Uses file operations for loading/saving files instead of browser APIs. * **jspdf.umd.\*.js**: UMD module format. For AMD or script-tag loading. * **polyfills\*.js**: Required polyfills for older browsers like Internet Explorer. The es variant simply imports all required polyfills from `core-js`, the umd variant is self-contained. Usually it is not necessary to specify the exact file in the import statement. Build tools or Node automatically figure out the right file, so importing "jspdf" is enough. Usage ----- Then you're ready to start making your document: import { jsPDF } from "jspdf"; // Default export is a4 paper, portrait, using millimeters for units const doc = new jsPDF(); doc.text("Hello world!", 10, 10); doc.save("a4.pdf"); If you want to change the paper size, orientation, or units, you can do: // Landscape export, 2×4 inches const doc = new jsPDF({ orientation: "landscape", unit: "in", format: [4, 2] }); doc.text("Hello world!", 1, 1); doc.save("two-by-four.pdf"); ### Running in Node.js const { jsPDF } = require("jspdf"); // will automatically load the node version const doc = new jsPDF(); doc.text("Hello world!", 10, 10); doc.save("a4.pdf"); // will save the file in the current working directory ### Other Module Formats **AMD** require(["jspdf"], ({ jsPDF }) => { const doc = new jsPDF(); doc.text("Hello world!", 10, 10); doc.save("a4.pdf"); }); **Globals** const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.text("Hello world!", 10, 10); doc.save("a4.pdf"); ### Optional dependencies Some functions of jsPDF require optional dependencies. E.g. the `html` method, which depends on `html2canvas` and, when supplied with a string HTML document, `dompurify`. JsPDF loads them dynamically when required (using the respective module format, e.g. dynamic imports). Build tools like Webpack will automatically create separate chunks for each of the optional dependencies. If your application does not use any of the optional dependencies, you can prevent Webpack from generating the chunks by defining them as external dependencies: // webpack.config.js module.exports = { // ... externals: { // only define the dependencies you are NOT using as externals! canvg: "canvg", html2canvas: "html2canvas", dompurify: "dompurify" } }; In **Vue CLI** projects, externals can be defined via the [configureWebpack](https://cli.vuejs.org/config/#configurewebpack) or [chainWebpack](https://cli.vuejs.org/config/#chainwebpack) properties of the `vue.config.js` file (needs to be created, first, in fresh projects). In **Angular** projects, externals can be defined using [custom webpack builders](https://github.com/just-jeb/angular-builders/tree/master/packages/custom-webpack) . In **React** (`create-react-app`) projects, externals can be defined by either using [react-app-rewired](https://github.com/timarney/react-app-rewired) or ejecting. ### TypeScript/Angular/Webpack/React/etc. Configuration: jsPDF can be imported just like any other 3rd party library. This works with all major toolkits and frameworks. jsPDF also offers a typings file for TypeScript projects. import { jsPDF } from "jspdf"; You can add jsPDF to your meteor-project as follows: meteor add jspdf:core ### Polyfills jsPDF requires modern browser APIs in order to function. To use jsPDF in older browsers like Internet Explorer, polyfills are required. You can load all required polyfills as follows: import "jspdf/dist/polyfills.es.js"; Alternatively, you can load the prebundled polyfill file. This is not recommended, since you might end up loading polyfills multiple times. Might still be nifty for small applications or quick POCs. Use of Unicode Characters / UTF-8: ---------------------------------- The 14 standard fonts in PDF are limited to the ASCII-codepage. If you want to use UTF-8 you have to integrate a custom font, which provides the needed glyphs. jsPDF supports .ttf-files. So if you want to have for example Chinese text in your pdf, your font has to have the necessary Chinese glyphs. So, check if your font supports the wanted glyphs or else it will show garbled characters instead of the right text. To add the font to jsPDF use our fontconverter in [/fontconverter/fontconverter.html](https://rawgit.com/MrRio/jsPDF/master/fontconverter/fontconverter.html) . The fontconverter will create a js-file with the content of the provided ttf-file as base64 encoded string and additional code for jsPDF. You just have to add this generated js-File to your project. You are then ready to go to use setFont-method in your code and write your UTF-8 encoded text. Alternatively you can just load the content of the \*.ttf file as a binary string using `fetch` or `XMLHttpRequest` and add the font to the PDF file: const doc = new jsPDF(); const myFont = ... // load the *.ttf font file as binary string // add the font to jsPDF doc.addFileToVFS("MyFont.ttf", myFont); doc.addFont("MyFont.ttf", "MyFont", "normal"); doc.setFont("MyFont"); Advanced Functionality ---------------------- Since the merge with the [yWorks fork](https://github.com/yWorks/jsPDF) there are a lot of new features. However, some of them are API breaking, which is why there is an API-switch between two API modes: * In "compat" API mode, jsPDF has the same API as MrRio's original version, which means full compatibility with plugins. However, some advanced features like transformation matrices and patterns won't work. This is the default mode. * In "advanced" API mode, jsPDF has the API you're used from the yWorks-fork version. This means the availability of all advanced features like patterns, FormObjects, and transformation matrices. You can switch between the two modes by calling doc.advancedAPI(doc => { // your code }); // or doc.compatAPI(doc => { // your code }); JsPDF will automatically switch back to the original API mode after the callback has run. Support ------- Please check if your question is already handled at Stackoverflow [https://stackoverflow.com/questions/tagged/jspdf](https://raw.githack.com/MrRio/jsPDF/master/docs/%5C/%5C/stackoverflow.com/questions/tagged/jspdf) . Feel free to ask a question there with the tag `jspdf`. Feature requests, bug reports, etc. are very welcome as issues. Note that bug reports should follow these guidelines: * A bug should be reported as an [mcve](https://stackoverflow.com/help/mcve) * Make sure code is properly indented and [formatted](https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code) (Use \`\`\` around code blocks) * Provide a runnable example. * Try to make sure and show in your issue that the issue is actually related to jspdf and not your framework of choice. Contributing ------------ jsPDF cannot live without help from the community! If you think a feature is missing or you found a bug, please consider if you can spare one or two hours and prepare a pull request. If you're simply interested in this project and want to help, have a look at the open issues, especially those labeled with "bug". You can find information about building and testing jsPDF in the [contribution guide](https://github.com/MrRio/jsPDF/blob/master/CONTRIBUTING.md#pull-requests) Credits ------- * Big thanks to Daniel Dotsenko from [Willow Systems Corporation](https://github.com/willowsystems) for making huge contributions to the codebase. * Thanks to Ajaxian.com for [featuring us back in 2009](http://web.archive.org/web/20111011192314/http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript) . (Internet Archive Wayback Machine reference) * Our special thanks to GH Lee ([sphilee](https://github.com/sphilee) ) for programming the ttf-file-support and providing a large and long sought after feature * Everyone else that's contributed patches or bug reports. You rock. License (MIT) ------------- Copyright (c) 2010-2021 James Hall, https://github.com/MrRio/jsPDF (c) 2015-2021 yWorks GmbH, https://www.yworks.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- # ShadingPattern - Documentation ShadingPattern ============== #### new ShadingPattern(type, coords, colors, gStateopt, matrixopt) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1496](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1496) A pattern describing a shading pattern. Only available in "advanced" API mode. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `type` | String | | One of "axial" or "radial" | | `coords` | Array. | | Either \[x1, y1, x2, y2\] for "axial" type describing the two interpolation points or \[x1, y1, r, x2, y2, r2\] for "radial" describing inner and the outer circle. | | `colors` | Array. | | An array of objects with the fields "offset" and "color". "offset" describes the offset in parameter space \[0, 1\]. "color" is an array of length 3 describing RGB values in \[0, 255\]. | | `gState` | [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) | | An additional graphics state that gets applied to the pattern (optional). | | `matrix` | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) | | A matrix that describes the transformation between the pattern coordinate system and the use coordinate system (optional). | ### Extends * API.Pattern --- # jsPDF - Documentation jsPDF ===== #### new jsPDF(optionsopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 174](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line174) { orientation: 'p', unit: 'mm', format: 'a4', putOnlyUsedFonts:true, floatPrecision: 16 // or "smart", default is 16 } ##### Parameters: NameTypeAttributesDescription`options`Object Collection of settings initializing the jsPDF-instance ###### Properties NameTypeAttributesDefaultDescription`orientation`string `portrait` Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" or "l"). `unit`string `mm` Measurement unit (base unit) to be used when coordinates are specified. Possible values are "pt" (points), "mm", "cm", "in", "px", "pc", "em" or "ex". Note that in order to get the correct scaling for "px" units, you need to enable the hotfix "px\_scaling" by setting options.hotfixes = \["px\_scaling"\]. `format`string/Array `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\] `putOnlyUsedFonts`boolean `false` Only put fonts into the PDF, which were used. `compress`boolean `false` Compress the generated PDF. `precision`number `16` Precision of the element-positions. `userUnit`number `1.0` Not to be confused with the base unit. Please inform yourself before you use it. `hotfixes`Array. An array of strings to enable hotfixes such as correct pixel scaling. `encryption`Object ###### Properties | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `userPassword` | string | | Password for the user bound by the given permissions list. | | `ownerPassword` | string | | Both userPassword and ownerPassword should be set for proper authentication. | | `userPermissions` | Array. | | Array of permissions "print", "modify", "copy", "annot-forms", accessible by the user. | `floatPrecision`number | "smart" `16` ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) ### Members #### (static) \_\_bidiEngine\_\_ Source: * [libs/bidiEngine.js](https://raw.githack.com/MrRio/jsPDF/master/docs/libs_bidiEngine.js.html) , [line 2109](https://raw.githack.com/MrRio/jsPDF/master/docs/libs_bidiEngine.js.html#line2109) constructor ( options ) Initializes Bidi engine #### advancedAPI Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 399](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line399) For compatibility reasons jsPDF offers two API modes which differ in the way they convert between the the usual screen coordinates and the PDF coordinate system. * "compat": Offers full compatibility across all plugins but does not allow arbitrary transforms * "advanced": Allows arbitrary transforms and more advanced features like pattern fills. Some plugins might not support this mode, though. Initial mode is "compat". You can either provide a callback to the body argument, which means that jsPDF will automatically switch back to the original API mode afterwards; or you can omit the callback and switch back manually using compatAPI. Note, that the calls to saveGraphicsState and restoreGraphicsState need to be balanced within the callback or between calls of this method and its counterpart compatAPI. Calls to beginFormObject or beginTilingPattern need to be closed by their counterparts before switching back to "compat" API mode. #### API Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 6080](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line6080) 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. ##### 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() // <- !!!!!! #### beginTilingPattern Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1530](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1530) Begins a new tiling pattern. All subsequent render calls are drawn to this pattern until API.endTilingPattern gets called. Only available in "advanced" API mode. #### CapJoinStyles Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5370](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5370) Is an Object providing a mapping from human-readable to integer flag values designating the varieties of line cap and join styles. #### compatApi Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 440](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line440) Switches to "compat" API mode. See advancedAPI for more details. #### endTilingPattern Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1549](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1549) Ends a tiling pattern and sets the render target to the one active before API.beginTilingPattern has been called. Only available in "advanced" API mode. #### #identityMatrix :[Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1452](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1452) The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)). ##### Type: * [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) #### isAdvancedAPI Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 469](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line469) #### matrixMult Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1441](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1441) Multiplies two matrices. (see [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) ) #### version :string Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 6106](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line6106) The version of jsPDF. ##### Type: * string ### Methods #### addFont(postScriptName, id, fontStyle, fontWeight, encoding) → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4939](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4939) Add a custom font to the current instance. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `postScriptName` | string | PDF specification full name for the font. | | `id` | string | PDF-document-instance-specific label assinged to the font. | | `fontStyle` | string | Style of the Font. | | `fontWeight` | number \| string | Weight of the Font. | | `encoding` | Object | Encoding\_name-to-Font\_metrics\_object mapping. | ##### Returns: fontId Type string #### addGState(key, gState) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5539](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5539) Adds a new [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) for later use. See setGState. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | | | `gState` | [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### addPage(format, orientation) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3299](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3299) Adds (and transfers the focus to) new page to the PDF document. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `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\] | | `orientation` | string | Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l"). | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### addPattern(key, pattern) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1514](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1514) Adds a new API.ShadingPattern for later use. Only available in "advanced" API mode. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | | | `pattern` | Pattern | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### beginFormObject(x, y, width, height, matrix) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5773](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5773) Starts a new pdf form object, which means that all consequent draw calls target a new independent object until endFormObject is called. The created object can be referenced and drawn later using doFormObject. Nested form objects are possible. x, y, width, height set the bounding box that is used to clip the content. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | number | | | `y` | number | | | `width` | number | | | `height` | number | | | `matrix` | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) | The matrix that will be applied to convert the form objects coordinate system to the parent's. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### circle(x, y, r, styleopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4847](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4847) Adds an circle to PDF. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `r` | number | | Radius (in units declared at inception of PDF document) | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### clip(rule) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4095](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4095) All .clip() after calling drawing ops with a style argument of null. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `rule` | string | Only possible value is 'evenodd' | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### clipEvenOdd() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4116](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4116) 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 API.discardPath afterwards. ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### close() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4208](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4208) Close the current path. The PDF "h" operator. ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### comment(text) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5610](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5610) Inserts a debug comment into the generated pdf. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | String | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### curveTo(x1, y1, x2, y2, x3, y3) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4429](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4429) Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as Bézier control points. The new current point shall be (x3, x3). ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x1` | number | | | `y1` | number | | | `x2` | number | | | `y2` | number | | | `x3` | number | | | `y3` | number | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### deletePage(targetPage) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3388](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3388) Deletes a page from the PDF. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `targetPage` | number | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### discardPath() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4130](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4130) Consumes the current path without any effect. Mainly used in combination with clip or clipEvenOdd. The PDF "n" operator. ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### doFormObject(key, matrix) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5815](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5815) Draws the specified form object by referencing to the respective pdf XObject created with API.beginFormObject and endFormObject. The location is determined by matrix. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | The key to the form object. | | `matrix` | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) | The matrix applied before drawing the form object. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### ellipse(x, y, rx, ry, styleopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4803](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4803) Adds an ellipse to PDF. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `rx` | number | | Radius along x axis (in units declared at inception of PDF document) | | `ry` | number | | Radius along y axis (in units declared at inception of PDF document) | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### endFormObject(key) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5802](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5802) Completes and saves the form object. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | The key by which this form object can be referenced. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### fill(patternopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4234](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4234) 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. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `pattern` | [PatternData](https://raw.githack.com/MrRio/jsPDF/master/docs/global.html#PatternData) | | If provided the path will be filled with this pattern | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### fillEvenOdd(patternopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4249](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4249) See: * API.fill Fill the current path using the even-odd rule. The PDF f\* operator. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `pattern` | [PatternData](https://raw.githack.com/MrRio/jsPDF/master/docs/global.html#PatternData) | | If provided the path will be filled with this pattern | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### fillStroke(patternopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4264](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4264) See: * API.fill Fill using the nonzero winding number rule and then stroke the current Path. The PDF "B" operator. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `pattern` | [PatternData](https://raw.githack.com/MrRio/jsPDF/master/docs/global.html#PatternData) | | If provided the path will be stroked with this pattern | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### fillStrokeEvenOdd(patternopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4279](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4279) See: * API.fill Fill using the even-odd rule and then stroke the current Path. The PDF "B" operator. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `pattern` | [PatternData](https://raw.githack.com/MrRio/jsPDF/master/docs/global.html#PatternData) | | If provided the path will be fill-stroked with this pattern | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### getCharSpace() → {number} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5338](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5338) Get global value of CharSpace. ##### Returns: charSpace Type number #### getCreationDate(type) → {Object} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 712](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line712) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `type` | Object | | ##### Returns: Type Object #### getDrawColor() → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5122](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5122) Gets the stroke color for upcoming elements. ##### Returns: colorAsHex Type string #### getFileId() → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 620](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line620) ##### Returns: GUID. Type string #### getFillColor() → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5195](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5195) Gets the fill color for upcoming elements. ##### Returns: colorAsHex Type string #### getFont() → {Object} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4897](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4897) Gets text font face, variant for upcoming text elements. ##### Returns: Type Object #### getFontList() → {Object} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4910](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4910) Returns an object - a tree of fontName to fontStyle relationships available to active PDF document. ##### Returns: Like {'times':\['normal', 'italic', ... \], 'arial':\['normal', 'bold', ... \], ... } Type Object #### getFontSize() → {number} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 838](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line838) Gets the fontsize for upcoming text elements. ##### Returns: Type number #### getFormObject(key) → {Object|[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5836](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5836) Returns the form object specified by key. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | | ##### Returns: * Type Object * Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### getLineHeightFactor() → {number} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5074](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5074) Gets the LineHeightFactor, default: 1.15. ##### Returns: lineHeightFactor Type number #### getLineWidth() → {number} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4977](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4977) Gets the line width, default: 0.200025. ##### Returns: lineWidth Type number #### getR2L() → {boolean} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 872](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line872) Get value of R2L functionality. ##### Returns: jsPDF-instance Type boolean #### getTextColor() → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5267](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5267) Gets the text color for upcoming elements. ##### Returns: colorAsHex Type string #### insertPage(beforePage) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3338](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3338) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `beforePage` | Object | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### line(x1, y1, x2, y2, style) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4460](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4460) Draw a line on the current page. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x1` | number | | | `y1` | number | | | `x2` | number | | | `y2` | number | | | `style` | string | 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: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### lines(lines, x, y, scale, styleopt, closedopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4499](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4499) 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 ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `lines` | Array | | Array of _vector_ shifts as pairs (lines) or sextets (cubic bezier curves). | | `x` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `scale` | number | | (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. | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | | `closed` | Boolean | | If true, the path is closed with a straight line from the end of the last curve to the starting point. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### lineTo(x, y) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4413](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4413) Append a straight line segment from the current point to the point (x, y). The PDF "l" operator. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | number | | | `y` | number | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### movePage(targetPage, beforePage) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3353](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3353) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `targetPage` | number | | | `beforePage` | number | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### moveTo(x, y) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4398](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4398) Begin a new subpath by moving the current point to coordinates (x, y). The PDF "m" operator. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | number | | | `y` | number | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### output(type, options) → {string|window|ArrayBuffer|Blob|[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) |null|undefined} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3010](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3010) Generates the PDF document. If `type` argument is undefined, output is raw body of resulting PDF returned as a string. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `type` | string | A string identifying one of the possible output types.
Possible values are:
'arraybuffer' -> (ArrayBuffer)
'blob' -> (Blob)
'bloburi'/'bloburl' -> (string)
'datauristring'/'dataurlstring' -> (string)
'datauri'/'dataurl' -> (undefined) -> change location to generated datauristring/dataurlstring
'dataurlnewwindow' -> (window \| null \| undefined) throws error if global isn't a window object(node)
'pdfobjectnewwindow' -> (window \| null) throws error if global isn't a window object(node)
'pdfjsnewwindow' -> (wind \| null) | | `options` | Object \| string | An object providing some additional signalling to PDF generator.
Possible options are 'filename'.
A string can be passed instead of {filename:string} and defaults to 'generated.pdf' | ##### Returns: Type string | window | ArrayBuffer | Blob | [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) | null | undefined #### path(lines) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4601](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4601) Similar to API.lines but all coordinates are interpreted as absolute coordinates instead of relative. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `lines` | Array. | 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). | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### rect(x, y, w, h, styleopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4634](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4634) Adds a rectangle to PDF. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `w` | number | | Width (in units declared at inception of PDF document) | | `h` | number | | Height (in units declared at inception of PDF document) | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### restoreGraphicsState() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5575](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5575) Restores a previously saved graphics state saved by saveGraphicsState ("pops the stack"). ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### roundedRect(x, y, w, h, rx, ry, styleopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4735](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4735) Adds a rectangle with rounded corners to PDF. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `w` | number | | Width (in units declared at inception of PDF document) | | `h` | number | | Height (in units declared at inception of PDF document) | | `rx` | number | | Radius along x axis (in units declared at inception of PDF document) | | `ry` | number | | Radius along y axis (in units declared at inception of PDF document) | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### save(filename, options) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) |Promise} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5856](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5856) Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf'). Uses FileSaver.js-method saveAs. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `filename` | string | The filename including extension. | | `options` | Object | An Object with additional options, possible options: 'returnPromise'. | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) | Promise #### saveGraphicsState() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5555](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5555) Saves the current graphics state ("pushes it on the stack"). It can be restored by restoreGraphicsState later. Here, the general pdf graphics state is meant, also including the current transformation matrix, fill and stroke colors etc. ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setCharSpace(charSpace) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5351](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5351) Set global value of CharSpace. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `charSpace` | number | | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setCreationDate(date) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 699](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line699) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `date` | Object | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setCurrentTransformationMatrix(matrix) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5596](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5596) Appends this matrix to the left of all previously applied matrices. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `matrix` | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setDisplayMode(zoom, layout, pmode) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 967](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line967) Set the display mode options of the page like zoom and layout. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `zoom` | integer \| String | 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. | | `layout` | string | 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. | | `pmode` | string | '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: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setDocumentProperties(A) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1022](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1022) Adds a properties to the PDF document. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `A` | Object | property\_name-to-property\_value object structure. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setDrawColor(ch1, ch2, ch3, ch4) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5135](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5135) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `ch1` | Number \| String | Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. | | `ch2` | Number | Color channel value. | | `ch3` | Number | Color channel value. | | `ch4` | Number | Color channel value. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setFileId(value) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 607](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line607) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | GUID. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setFillColor(ch1, ch2, ch3, ch4) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5208](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5208) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `ch1` | Number \| String | Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. | | `ch2` | Number | Color channel value. | | `ch3` | Number | Color channel value. | | `ch4` | Number | Color channel value. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setFont(fontName, fontStyle, fontWeight) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4874](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4874) Sets text font face, variant for upcoming text elements. See output of jsPDF.getFontList() for possible font names, styles. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `fontName` | string | Font name or family. Example: "times". | | `fontStyle` | string | Font style or variant. Example: "italic". | | `fontWeight` | number \| string | Weight of the Font. Example: "normal" \| 400 | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setFontSize(size) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 819](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line819) Sets font size for upcoming text elements. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `size` | number | Font size in points. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setGState(gState) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5483](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5483) Sets a either previously added [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) (via addGState) or a new [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) . ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `gState` | String \| [GState](https://raw.githack.com/MrRio/jsPDF/master/docs/GState.html) | If type is string, a previously added GState is used, if type is GState it will be added before use. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineCap(style) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5394](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5394) Sets the line cap styles. See {jsPDF.CapJoinStyles} for variants. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `style` | String \| Number | A string or number identifying the type of line cap. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineDashPattern(dashArray, dashPhase) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5008](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5008) Sets the dash pattern for upcoming lines. To reset the settings simply call the method without any parameters. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `dashArray` | Array. | 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. | | `dashPhase` | number | The phase lines start with. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineHeightFactor(value) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5054](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5054) Sets the LineHeightFactor of proportion. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | number | LineHeightFactor value. Default: 1.15. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineJoin(style) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5421](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5421) Sets the line join styles. See {jsPDF.CapJoinStyles} for variants. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `style` | String \| Number | A string or number identifying the type of line join. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineMiterLimit(length) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5448](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5448) Sets the miterLimit property, which effects the maximum miter length. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `length` | number | The length of the miter | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setLineWidth(width) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4990](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4990) Sets line width for upcoming lines. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `width` | number | Line width (in units declared at inception of PDF document). | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setPage(page) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3315](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3315) Adds (and transfers the focus to) new page to the PDF document. ##### 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) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `page` | number | Switch the active page to the page number specified (indexed starting at 1). | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setPrecision(precision) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 564](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line564) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `precision` | string | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setR2L(value) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 857](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line857) Set value of R2L functionality. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | boolean | | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### setTextColor(ch1, ch2, ch3, ch4) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5279](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5279) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `ch1` | Number \| String | Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'. | | `ch2` | Number | Color channel value. | | `ch3` | Number | Color channel value. | | `ch4` | Number | Color channel value. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### stroke() → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4221](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4221) Stroke the path. The PDF "S" operator. ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### text(text, x, y, optionsopt, transform) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3402](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3402) Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings. ##### Parameters: NameTypeAttributesDescription`text`String | Array 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. `x`number Coordinate (in units declared at inception of PDF document) against left edge of the page. `y`number Coordinate (in units declared at inception of PDF document) against upper edge of the page. `options`Object Collection of settings signaling how the text must be encoded. ###### Properties NameTypeAttributesDefaultDescription`align`string `left` The alignment of the text, possible values: left, center, right, justify. `baseline`string `alphabetic` Sets text baseline used when drawing the text, possible values: alphabetic, ideographic, bottom, top, middle, hanging `angle`number | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) `0` Rotate the text clockwise or counterclockwise. Expects the angle in degree. `rotationDirection`number `1` Direction of the rotation. 0 = clockwise, 1 = counterclockwise. `charSpace`number `0` The space between each letter. `horizontalScale`number `1` Horizontal scale of the text as a factor of the regular size. `lineHeightFactor`number `1.15` The lineheight of each line. `flags`Object Flags for to8bitStream. ###### Properties | Name | Type | Attributes | Default | Description | | --- | --- | --- | --- | --- | | `noBOM` | boolean | | `true` | Don't add BOM to Unicode-text. | | `autoencode` | boolean | | `true` | Autoencode the Text. | `maxWidth`number `0` Split the text by given width, 0 = no split. `renderingMode`string `fill` Set how the text should be rendered, possible values: fill, stroke, fillThenStroke, invisible, fillAndAddForClipping, strokeAndAddPathForClipping, fillThenStrokeAndAddToPathForClipping, addToPathForClipping. `isInputVisual`boolean Option for the BidiEngine `isOutputVisual`boolean Option for the BidiEngine `isInputRtl`boolean Option for the BidiEngine `isOutputRtl`boolean Option for the BidiEngine `isSymmetricSwapping`boolean Option for the BidiEngine `transform`number | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) 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: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### triangle(x1, y1, x2, y2, x3, y3, styleopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 4677](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line4677) Adds a triangle to PDF. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x1` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y1` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `x2` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y2` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `x3` | number | | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y3` | number | | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `style` | string | | A string specifying the painting style or null. Valid styles include: 'S' \[default\] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. In "compat" API mode, 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.

In "advanced" API mode this parameter is deprecated. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### (inner) addGState(key, gState) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5510](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5510) Adds a new Graphics State. Duplicates are automatically eliminated. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | Might also be null, if no later reference to this gState is needed | | `gState` | Object | The gState object | #### (inner) addPattern(key, pattern) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1466](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1466) Adds a new pattern for later use. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `key` | String | The key by it can be referenced later. The keys must be unique! | | `pattern` | API.Pattern | The pattern | #### (inner) hasHotfix(hotfixName) → {boolean} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 3204](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line3204) Used to see if a supplied hotfix was requested when the pdf instance was created. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `hotfixName` | string | The name of the hotfix to check. | ##### Returns: Type boolean #### (inner) Point() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5627](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5627) Point #### (inner) Rectangle() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5670](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5670) Rectangle #### (inner) RenderTarget() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5707](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5707) FormObject/RenderTarget --- # GState - Documentation GState ====== #### new GState() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5470](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5470) An object representing a pdf graphics state. ### Members #### id :string Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 108](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line108) ##### Type: * string #### objectNumber :number Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 113](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line113) ##### Type: * number #### opacity :any Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 94](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line94) ##### Type: * any #### stroke-opacity :any Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 98](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line98) ##### Type: * any --- # AcroFormButton - Documentation AcroFormButton ============== #### new AcroFormButton() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1976](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1976) ### Extends * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # AcroFormCheckBox - Documentation AcroFormCheckBox ================ #### new AcroFormCheckBox() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2343](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2343) ### Extends * [AcroFormButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### appearanceState :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2132](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2132) Overrides: * [AcroFormButton#appearanceState](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#appearanceState) (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") ##### Type: * any #### caption :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2096](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2096) Overrides: * [AcroFormButton#caption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#caption) 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 ##### Type: * string #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Overrides: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### noToggleToOff :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1984](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1984) Inherited From: * [AcroFormButton#noToggleToOff](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#noToggleToOff) (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. ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### pushButton :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2026](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2026) Inherited From: * [AcroFormButton#pushButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#pushButton) If set, the field is a pushbutton that does not retain a permanent value. ##### Type: * boolean #### radio :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2005](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2005) Inherited From: * [AcroFormButton#radio](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radio) 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. ##### Type: * boolean #### radioIsUnison :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2047](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2047) Inherited From: * [AcroFormButton#radioIsUnison](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radioIsUnison) (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). ##### Type: * boolean #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Overrides: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Overrides: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # AcroFormChoiceField - Documentation AcroFormChoiceField =================== #### new AcroFormChoiceField() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1678](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1678) ### Extends * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Overrides: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Overrides: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # AcroFormComboBox - Documentation AcroFormComboBox ================ #### new AcroFormComboBox() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1951](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1951) ### Extends * AcroFormListBox * [AcroFormChoiceField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### combo :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1796](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1796) Overrides: * [AcroFormChoiceField#combo](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#combo) Default Value: * false If set, the field is a combo box; if clear, the field is a list box. ##### Type: * boolean #### commitOnSelChange :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1910](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1910) Inherited From: * [AcroFormChoiceField#commitOnSelChange](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#commitOnSelChange) Default Value: * false (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. ##### Type: * boolean #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### doNotSpellCheck :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1888](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1888) Inherited From: * [AcroFormChoiceField#doNotSpellCheck](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#doNotSpellCheck) Default Value: * false (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. ##### Type: * boolean #### edit :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1818](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1818) Inherited From: * [AcroFormChoiceField#edit](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#edit) Default Value: * false 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. ##### Type: * boolean #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### multiSelect :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1866](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1866) Inherited From: * [AcroFormChoiceField#multiSelect](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#multiSelect) Default Value: * false (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 ##### Type: * boolean #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### sort :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1843](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1843) Inherited From: * [AcroFormChoiceField#sort](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#sort) Default Value: * false 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). ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### topIndex :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1704](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1704) Inherited From: * [AcroFormChoiceField#topIndex](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#topIndex) Default Value: * 0 (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. ##### Type: * number #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number ### Methods #### addOption(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1759](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1759) Inherited From: * [AcroFormChoiceField#addOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#addOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | #### getOptions() → {array} Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1734](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1734) Inherited From: * [AcroFormChoiceField#getOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#getOptions) ##### Returns: array of Options Type array #### removeOption(value, allEntries) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1775](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1775) Inherited From: * [AcroFormChoiceField#removeOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#removeOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | | `allEntries` | boolean | (default: false) | #### setOptions(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1745](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1745) Inherited From: * [AcroFormChoiceField#setOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#setOptions) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | array | | --- # GState - Documentation GState ====== #### new GState(parameters) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 5481](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line5481) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `parameters` | | A parameter object that contains all properties this graphics state wants to set. Supported are: opacity, stroke-opacity | --- # Matrix - Documentation Matrix ====== #### new Matrix(sx, shy, shx, sy, tx, ty) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1073](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1073) A matrix object for 2D homogenous transformations: | a b 0 | | c d 0 | | e f 1 | pdf multiplies matrices righthand: v' = v x m1 x m2 x ... ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `sx` | number | | | `shy` | number | | | `shx` | number | | | `sy` | number | | | `tx` | number | | | `ty` | number | | ### Members #### isIdentity Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1267) #### rotation Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1237](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1237) #### scaleX Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1247](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1247) #### scaleY Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1257](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1257) #### shx Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1131](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1131) #### shy Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1118](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1118) #### sx Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1105](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1105) #### sy Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1144](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1144) #### tx Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1157](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1157) #### ty Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1170](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1170) ### Methods #### applyToPoint() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1400](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1400) #### applyToRectangle() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1410](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1410) #### clone() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1420](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1420) Clone the Matrix #### decompose() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1328](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1328) #### inversed() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1376](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1376) #### join(separator) → {string} Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1295](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1295) Join the Matrix Values to a String ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `separator` | string | Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them. | ##### Returns: A string with all array elements joined. Type string #### multiply(matrix) → {[Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) } Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1309](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1309) Multiply the matrix with given Matrix ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `matrix` | | | ##### Returns: Type [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) #### toString() Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1368](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1368) --- # TilingPattern - Documentation TilingPattern ============= #### new TilingPattern(boundingBox, xStep, yStep, gStateopt, matrixopt) Source: * [jspdf.js](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html) , [line 1512](https://raw.githack.com/MrRio/jsPDF/master/docs/jspdf.js.html#line1512) A PDF Tiling pattern. Only available in "advanced" API mode. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `boundingBox` | Array. | | The bounding box at which one pattern cell gets clipped. | | `xStep` | Number | | Horizontal spacing between pattern cells. | | `yStep` | Number | | Vertical spacing between pattern cells. | | `gState` | API.GState | | An additional graphics state that gets applied to the pattern (optional). | | `matrix` | [Matrix](https://raw.githack.com/MrRio/jsPDF/master/docs/Matrix.html) | | A matrix that describes the transformation between the pattern coordinate system and the use coordinate system (optional). | ### Extends * API.Pattern --- # AcroFormField - Documentation AcroFormField ============= Constructor ----------- #### new AcroFormField() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 991](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line991) The Field Object contains the Variables, that every Field needs --- # AcroFormPDFObject - Documentation AcroFormPDFObject ================= Constructor ----------- #### new AcroFormPDFObject() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 795](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line795) --- # AcroForm - Documentation AcroForm ======== jsPDF AcroForm Plugin Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 10](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line10) ### Classes [AcroFormButton](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormButton.html) [AcroFormCheckBox](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormCheckBox.html) [AcroFormChoiceField](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormChoiceField.html) [AcroFormComboBox](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormComboBox.html) [AcroFormEditBox](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormEditBox.html) [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormField.html) [AcroFormListBox](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormListBox.html) [AcroFormPasswordField](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormPasswordField.html) [AcroFormPDFObject](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormPDFObject.html) [AcroFormPushButton](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormPushButton.html) [AcroFormRadioButton](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormRadioButton.html) [AcroFormTextField](https://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormTextField.html) ### Members #### (inner) getKeyValueListForStream Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 844](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line844) Returns an key-value-List of all non-configurable Variables from the Object #### (inner) setBit Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 62](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line62) Bit-Operations ### Methods #### addField(fieldObject) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 3101](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line3101) Add an AcroForm-Field to the jsPDF-instance ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `fieldObject` | Object | | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### (inner) AcroFormDictionaryCallback() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 525](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line525) Adds /Acroform X 0 R to Document Catalog, and creates the AcroForm Dictionary #### (inner) calculateFontSpace(text, fontsize) → {TextMetrics} Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 409](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line409) Small workaround for calculating the TextMetric approximately. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | | | | `fontsize` | | | ##### Returns: (Has Height and Width) Type TextMetrics #### (inner) createAnnotationReference() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 482](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line482) Create the Reference to the widgetAnnotation, so that it gets referenced in the Annot\[\] int the+ (Requires the Annotation Plugin) #### (inner) createFieldCallback() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 540](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line540) 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...) --- # canvas - Documentation canvas ====== 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. Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 11](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line11) ### Classes [Canvas](https://raw.githack.com/MrRio/jsPDF/master/docs/module-canvas-Canvas.html) ### Members #### (inner) height Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 61](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line61) 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. #### (inner) width Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 38](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line38) 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. ### Methods #### (inner) getContext(contextType, contextAttributes) Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 106](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line106) The getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `contextType` | string | 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. | | `contextAttributes` | object | | #### (inner) toDataURL() Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 130](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line130) The toDataURL() method is just a stub to throw an error if accidently called. --- # AcroFormTextField - Documentation AcroFormTextField ================= #### new AcroFormTextField() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2360](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2360) ### Extends * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # AcroFormEditBox - Documentation AcroFormEditBox =============== #### new AcroFormEditBox() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1963](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1963) ### Extends * AcroFormComboBox * AcroFormListBox * [AcroFormChoiceField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### combo :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1796](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1796) Inherited From: * [AcroFormChoiceField#combo](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#combo) Default Value: * false If set, the field is a combo box; if clear, the field is a list box. ##### Type: * boolean #### commitOnSelChange :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1910](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1910) Inherited From: * [AcroFormChoiceField#commitOnSelChange](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#commitOnSelChange) Default Value: * false (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. ##### Type: * boolean #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### doNotSpellCheck :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1888](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1888) Inherited From: * [AcroFormChoiceField#doNotSpellCheck](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#doNotSpellCheck) Default Value: * false (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. ##### Type: * boolean #### edit :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1818](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1818) Overrides: * [AcroFormChoiceField#edit](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#edit) Default Value: * false 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. ##### Type: * boolean #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### multiSelect :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1866](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1866) Inherited From: * [AcroFormChoiceField#multiSelect](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#multiSelect) Default Value: * false (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 ##### Type: * boolean #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### sort :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1843](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1843) Inherited From: * [AcroFormChoiceField#sort](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#sort) Default Value: * false 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). ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### topIndex :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1704](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1704) Inherited From: * [AcroFormChoiceField#topIndex](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#topIndex) Default Value: * 0 (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. ##### Type: * number #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number ### Methods #### addOption(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1759](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1759) Inherited From: * [AcroFormChoiceField#addOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#addOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | #### getOptions() → {array} Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1734](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1734) Inherited From: * [AcroFormChoiceField#getOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#getOptions) ##### Returns: array of Options Type array #### removeOption(value, allEntries) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1775](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1775) Inherited From: * [AcroFormChoiceField#removeOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#removeOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | | `allEntries` | boolean | (default: false) | #### setOptions(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1745](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1745) Inherited From: * [AcroFormChoiceField#setOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#setOptions) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | array | | --- # AcroFormListBox - Documentation AcroFormListBox =============== #### new AcroFormListBox() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1937](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1937) ### Extends * [AcroFormChoiceField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### combo :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1796](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1796) Overrides: * [AcroFormChoiceField#combo](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#combo) Default Value: * false If set, the field is a combo box; if clear, the field is a list box. ##### Type: * boolean #### commitOnSelChange :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1910](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1910) Inherited From: * [AcroFormChoiceField#commitOnSelChange](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#commitOnSelChange) Default Value: * false (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. ##### Type: * boolean #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### doNotSpellCheck :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1888](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1888) Inherited From: * [AcroFormChoiceField#doNotSpellCheck](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#doNotSpellCheck) Default Value: * false (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. ##### Type: * boolean #### edit :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1818](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1818) Inherited From: * [AcroFormChoiceField#edit](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#edit) Default Value: * false 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. ##### Type: * boolean #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Overrides: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### multiSelect :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1866](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1866) Inherited From: * [AcroFormChoiceField#multiSelect](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#multiSelect) Default Value: * false (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 ##### Type: * boolean #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### sort :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1843](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1843) Inherited From: * [AcroFormChoiceField#sort](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#sort) Default Value: * false 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). ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### topIndex :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1704](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1704) Inherited From: * [AcroFormChoiceField#topIndex](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#topIndex) Default Value: * 0 (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. ##### Type: * number #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number ### Methods #### addOption(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1759](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1759) Inherited From: * [AcroFormChoiceField#addOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#addOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | #### getOptions() → {array} Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1734](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1734) Inherited From: * [AcroFormChoiceField#getOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#getOptions) ##### Returns: array of Options Type array #### removeOption(value, allEntries) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1775](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1775) Inherited From: * [AcroFormChoiceField#removeOption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#removeOption) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | string | | | `allEntries` | boolean | (default: false) | #### setOptions(value) Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1745](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1745) Inherited From: * [AcroFormChoiceField#setOptions](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormChoiceField.html#setOptions) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `value` | array | | --- # AcroFormPushButton - Documentation AcroFormPushButton ================== #### new AcroFormPushButton() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2151](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2151) ### Extends * [AcroFormButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### appearanceState :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2132](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2132) Overrides: * [AcroFormButton#appearanceState](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#appearanceState) (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") ##### Type: * any #### caption :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2096](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2096) Overrides: * [AcroFormButton#caption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#caption) 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 ##### Type: * string #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### noToggleToOff :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1984](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1984) Inherited From: * [AcroFormButton#noToggleToOff](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#noToggleToOff) (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. ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### pushButton :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2026](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2026) Overrides: * [AcroFormButton#pushButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#pushButton) If set, the field is a pushbutton that does not retain a permanent value. ##### Type: * boolean #### radio :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2005](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2005) Inherited From: * [AcroFormButton#radio](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radio) 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. ##### Type: * boolean #### radioIsUnison :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2047](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2047) Inherited From: * [AcroFormButton#radioIsUnison](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radioIsUnison) (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). ##### Type: * boolean #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # AcroFormRadioButton - Documentation AcroFormRadioButton =================== #### new AcroFormRadioButton() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2162](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2162) ### Extends * [AcroFormButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### appearanceState :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2132](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2132) Overrides: * [AcroFormButton#appearanceState](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#appearanceState) (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") ##### Type: * any #### caption :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2096](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2096) Overrides: * [AcroFormButton#caption](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#caption) 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 ##### Type: * string #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### noToggleToOff :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1984](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1984) Inherited From: * [AcroFormButton#noToggleToOff](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#noToggleToOff) (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. ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### pushButton :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2026](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2026) Overrides: * [AcroFormButton#pushButton](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#pushButton) If set, the field is a pushbutton that does not retain a permanent value. ##### Type: * boolean #### radio :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2005](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2005) Overrides: * [AcroFormButton#radio](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radio) 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. ##### Type: * boolean #### radioIsUnison :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2047](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2047) Inherited From: * [AcroFormButton#radioIsUnison](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormButton.html#radioIsUnison) (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). ##### Type: * boolean #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # Canvas - Documentation Canvas ====== Constructor ----------- #### new Canvas() Source: * [modules/canvas.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html) , [line 22](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_canvas.js.html#line22) --- # addImage - Documentation addImage ======== ### Methods #### (inner) addImage(imageData, format, x, y, width, height, alias, compression, rotation) Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 785](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line785) Adds an Image to the PDF. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `imageData` | string \| HTMLImageElement \| HTMLCanvasElement \| Uint8Array \| RGBAData | imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement or object containing RGBA array (like output from canvas.getImageData). | | `format` | string | format of file if filetype-recognition fails or in case of a Canvas-Element needs to be specified (default for Canvas is JPEG), e.g. 'JPEG', 'PNG', 'WEBP' | | `x` | number | x Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | y Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `width` | number | width of the image (in units declared at inception of PDF document) | | `height` | number | height of the Image (in units declared at inception of PDF document) | | `alias` | string | alias of the image (if used multiple times) | | `compression` | string | compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' | | `rotation` | number | rotation of the image in degrees (0-359) | ##### Returns: jsPDF #### (inner) arrayBufferToBinaryString(ArrayBuffer) → {String} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 747](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line747) Convert the Buffer to a Binary String ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `ArrayBuffer` | ArrayBuffer \| ArrayBufferView | buffer or bufferView with ImageData | ##### Returns: Type String #### (inner) binaryStringToUint8Array(BinaryString) → {Uint8Array} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 727](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line727) Convert Binary String to ArrayBuffer ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `BinaryString` | string | with ImageData | ##### Returns: Type Uint8Array #### (inner) convertBase64ToBinaryString(stringData) → {string} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 936](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line936) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `stringData` | string | | ##### Returns: binary string Type string #### (inner) extractImageFromDataUrl(dataUrl) → {string} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 638](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line638) Strips out and returns info from a valid base64 data URI ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `dataUrl` | string | a valid data URI of format 'data:\[\]\[;base64\],' | ##### Returns: The raw Base64-encoded data. Type string #### (inner) getImageFileTypeByImageData(imageData, format) → {string} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 117](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line117) Recognize filetype of Image by magic-bytes https://en.wikipedia.org/wiki/List\_of\_file\_signatures ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `imageData` | string \| arraybuffer | imageData as binary String or arraybuffer | | `format` | string | format of file if filetype-recognition fails, e.g. 'JPEG' | ##### Returns: filetype of Image Type string #### (inner) getImageProperties(imageData) → {Object} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 972](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line972) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `imageData` | Object | | ##### Returns: Type Object #### (inner) isArrayBuffer(object) → {boolean} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 687](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line687) Tests supplied object to determine if ArrayBuffer ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `object` | Object | an Object | ##### Returns: Type boolean #### (inner) isArrayBufferView(object) → {boolean} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 700](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line700) Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `object` | Object | an Object | ##### Returns: Type boolean #### (inner) sHashCode(data) → {string} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 567](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line567) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `data` | string | | ##### Returns: Type string #### (inner) supportsArrayBuffer() → {boolean} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 674](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line674) Check to see if ArrayBuffer is supported ##### Returns: Type boolean #### (inner) validateStringAsBase64(possible) → {boolean} Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 594](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line594) Validates if given String is a valid Base64-String ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `possible` | String | Base64-String | ##### Returns: Type boolean ### Type Definitions #### RGBAData Source: * [modules/addimage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html) , [line 776](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_addimage.js.html#line776) ##### Properties: | Name | Type | Description | | --- | --- | --- | | `data` | Uint8ClampedArray | Single dimensional array of RGBA values. For example from canvas getImageData. | | `width` | number | Image width as the data does not carry this information in itself. | | `height` | number | Image height as the data does not carry this information in itself. | Possible parameter for addImage, an RGBA buffer with size. ##### Type: * Object --- # autoprint - Documentation autoprint ========= ### Methods #### (inner) autoPrint(options) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/autoprint.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_autoprint.js.html) , [line 17](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_autoprint.js.html#line17) Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer. ##### Example var doc = new jsPDF(); doc.text(10, 10, 'This is a test'); doc.autoPrint({variant: 'non-conform'}); doc.save('autoprint.pdf'); ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `options` | Object | (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: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # annotations - Documentation annotations =========== 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 Source: * [modules/annotations.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html) , [line 9](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html#line9) ### Methods #### (inner) createAnnotation(options) Source: * [modules/annotations.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html) , [line 292](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html#line292) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `options` | Object | | #### (inner) getTextWidth(text) → {number} Source: * [modules/annotations.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html) , [line 392](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html#line392) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | | ##### Returns: txtWidth Type number #### (inner) link(x, y, w, h, options) Source: * [modules/annotations.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html) , [line 316](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html#line316) Create a link valid options * pageNumber or url \[required\] If pageNumber is specified, top and zoom may also be specified ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | number | | | `y` | number | | | `w` | number | | | `h` | number | | | `options` | Object | | #### (inner) textWithLink(text, x, y, options) → {number} Source: * [modules/annotations.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html) , [line 347](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_annotations.js.html#line347) Currently only supports single line text. Returns the width of the text/link ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | | | `x` | number | | | `y` | number | | | `options` | Object | | ##### Returns: width the width of the text/link Type number --- # arabic - Documentation arabic ====== jsPDF arabic parser PlugIn Source: * [modules/arabic.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_arabic.js.html) , [line 11](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_arabic.js.html#line11) ### Methods #### (inner) processArabic(text) → {string} Source: * [modules/arabic.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_arabic.js.html) , [line 303](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_arabic.js.html#line303) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | | ##### Returns: Type string --- # bmp_support - Documentation bmp\_support ============ jsPDF bmp Support PlugIn Source: * [modules/bmp\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_bmp_support.js.html) , [line 13](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_bmp_support.js.html#line13) --- # cell - Documentation cell ==== ### Methods #### (inner) cell(x, y, width, height, text, lineNumber, align) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 257](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line257) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | number | | | `y` | number | | | `width` | number | | | `height` | number | | | `text` | string | | | `lineNumber` | number | lineNumber | | `align` | string | | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### (inner) cellAddPage() Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 236](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line236) #### (inner) getTextDimensions(txt) → {Object} Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 173](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line173) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `txt` | string | | ##### Returns: dimensions Type Object #### (inner) printHeaderRow(lineNumber, new\_page) Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 624](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line624) Output the store header row ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `lineNumber` | number | The line number to output the header at | | `new_page` | boolean | | #### (inner) setHeaderFunction(func) Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 161](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line161) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `func` | function | | #### (inner) setTableHeaderRow(config) Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 610](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line610) Store the config for outputting a table header ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `config` | Array. | An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell except the lineNumber parameter is excluded | #### (inner) table(xopt, yopt, dataopt, headersopt) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/cell.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html) , [line 357](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_cell.js.html#line357) Create a table from a set of data. ##### Parameters: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `x` | Integer | | : left-position for top-left corner of table | | `y` | Integer | | top-position for top-left corner of table | | `data` | Array. | | An array of objects containing key-value pairs corresponding to a row of data. | | `headers` | Array. | | Omit or null to auto-generate headers at a performance cost | | `config.printHeaders` | Object | | True to print column headers at the top of every page | | `config.autoSize` | Object | | True to dynamically set the column widths to match the widest cell value | | `config.margins` | Object | | margin values for left, top, bottom, and width | | `config.fontSize` | Object | | Integer fontSize to use (optional) | | `config.padding` | Object | | cell-padding in pt to use (optional) | | `config.headerBackgroundColor` | Object | | default is #c8c8c8 (optional) | | `config.headerTextColor` | Object | | default is #000 (optional) | | `config.rowStart` | Object | | callback to handle before print each row (optional) | | `config.cellStart` | Object | | callback to handle before print each cell (optional) | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # fileloading - Documentation fileloading =========== ### Methods #### (inner) loadFile(url, sync, callback) → {string|undefined} Source: * [modules/fileloading.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_fileloading.js.html) , [line 19](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_fileloading.js.html#line19) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `url` | string | | | `sync` | boolean | | | `callback` | function | | ##### Returns: result Type string | undefined #### (inner) loadImageFile(path, sync, callback) Source: * [modules/fileloading.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_fileloading.js.html) , [line 38](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_fileloading.js.html#line38) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `path` | string | | | `sync` | boolean | | | `callback` | function | | --- # context2d - Documentation context2d ========= This plugin mimics the HTML5 CanvasRenderingContext2D. The goal is to provide a way for current canvas implementations to print directly to a PDF. Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 19](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line19) ### Members #### (inner) ctx :object Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 258](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line258) Default Value: * {} ##### Type: * object #### (inner) ctxStack :array Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 288](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line288) Default Value: * \[\] ##### Type: * array #### (inner) fillStyle Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 303](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line303) Default Value: * #000000 ##### Properties: | Name | Type | Description | | --- | --- | --- | | `value` | color \| gradient \| pattern | 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 #### (inner) lastBreak :number Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 228](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line228) Default Value: * 0 ##### Type: * number #### (inner) lineCap Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 359](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line359) Default Value: * butt ##### Properties: | Name | Type | Description | | --- | --- | --- | | `lineCap` | butt \| round \| square | 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 #### (inner) lineDashOffset Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 691](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line691) Default Value: * 0.0 A float specifying the amount of the line dash offset. The default value is 0.0. #### (inner) lineWidth Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 380](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line380) Default Value: * 1 ##### Properties: | Name | Type | Description | | --- | --- | --- | | `lineWidth` | number | The current line width, in pixels | Sets or returns the current line width #### (inner) margin :number|Array. Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 169](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line169) Default Value: * \[0, 0, 0, 0\] Gets or sets the page margin when using auto paging. Has no effect when autoPaging is off. ##### Type: * number | Array. #### (inner) miterLimit Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 414](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line414) Default Value: * 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. #### (inner) pageBreaks :number Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 243](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line243) Default Value: * 0 Y Position of page breaks. ##### Type: * number #### (inner) pageWrapXEnabled :boolean Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 106](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line106) Default Value: * false ##### Type: * boolean #### (inner) pageWrapYEnabled :boolean Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line121) Default Value: * true ##### Type: * boolean #### (inner) path :array Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 274](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line274) Default Value: * \[\] ##### Type: * array #### (inner) posX :number Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 136](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line136) Default Value: * 0 ##### Type: * number #### (inner) posY :number Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 153](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line153) Default Value: * 0 ##### Type: * number #### (inner) strokeStyle Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 329](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line329) Default Value: * #000000 ##### Properties: | Name | Type | Description | | --- | --- | --- | | `color` | color | A CSS color value that indicates the stroke color of the drawing. Default value is #000000 (not supported by context2d) | | `gradient` | gradient | A gradient object (linear or radial) used to create a gradient stroke (not supported by context2d) | | `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 ### Methods #### (inner) arc(x, y, radius, startAngle, endAngle, counterclockwise) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 954](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line954) The arc() method creates an arc/curve (used to create circles, or parts of circles). ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of the center of the circle | | `y` | Number | The y-coordinate of the center of the circle | | `radius` | Number | The radius of the circle | | `startAngle` | Number | The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) | | `endAngle` | Number | The ending angle, in radians | | `counterclockwise` | Boolean | Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. | #### (inner) arcTo(x1, y1, x2, y2, radius) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1016](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1016) The arcTo() method creates an arc/curve between two tangents on the canvas. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x1` | Number | The x-coordinate of the first tangent | | `y1` | Number | The y-coordinate of the first tangent | | `x2` | Number | The x-coordinate of the second tangent | | `y2` | Number | The y-coordinate of the second tangent | | `radius` | | The radius of the arc | #### (inner) beginPath() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 770](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line770) The beginPath() method begins a path, or resets the current path. #### (inner) bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 908](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line908) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `cp1x` | Number | The x-coordinate of the first Bézier control point | | `cp1y` | Number | The y-coordinate of the first Bézier control point | | `cp2x` | Number | The x-coordinate of the second Bézier control point | | `cp2y` | Number | The y-coordinate of the second Bézier control point | | `x` | Number | The x-coordinate of the ending point | | `y` | Number | The y-coordinate of the ending point | #### (inner) clearRect(x, y, w, h) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1123](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1123) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of the upper-left corner of the rectangle | | `y` | Number | The y-coordinate of the upper-left corner of the rectangle | | `w` | Number | The width of the rectangle to clear, in pixels | | `h` | Number | The height of the rectangle to clear, in pixels | #### (inner) clip() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 861](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line861) The clip() method clips a region of any shape and size from the original canvas. #### (inner) closePath() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 809](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line809) The closePath() method creates a path from the current point back to the starting point. #### (inner) createArc() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 2480](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line2480) 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. #### (inner) fillRect(x, y, w, h) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1058](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1058) The fillRect() method draws a "filled" rectangle. The default color of the fill is black. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of the upper-left corner of the rectangle | | `y` | Number | The y-coordinate of the upper-left corner of the rectangle | | `w` | Number | The width of the rectangle, in pixels | | `h` | Number | The height of the rectangle, in pixels | #### (inner) fillText(text, x, y, maxWidth) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1309](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1309) The fillText() method draws filled text on the canvas. The default color of the text is black. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | String | Specifies the text that will be written on the canvas | | `x` | Number | The x coordinate where to start painting the text (relative to the canvas) | | `y` | Number | The y coordinate where to start painting the text (relative to the canvas) | | `maxWidth` | Number | Optional. The maximum allowed width of the text, in pixels | #### (inner) getLineDash() → {Array} Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 739](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line739) gets the current line dash pattern. ##### Returns: An Array of numbers that specify distances to alternately draw a line and a gap (in coordinate space units). If the number, when setting the elements, is odd, the elements of the array get copied and concatenated. For example, setting the line dash to \[5, 15, 25\] will result in getting back \[5, 15, 25, 5, 15, 25\]. Type Array #### (inner) lineTo(x, y) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 836](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line836) 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). ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | | The x-coordinate of where to create the line to | | `y` | | The y-coordinate of where to create the line to | #### (inner) measureText(text) → {Number} Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1383](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1383) The measureText() method returns an object that contains the width of the specified text, in pixels. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | String | The text to be measured | ##### Returns: Type Number #### (inner) moveTo(x, y) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 785](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line785) Moves the path to the specified point in the canvas, without creating a line ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of where to move the path to | | `y` | Number | The y-coordinate of where to move the path to | #### (inner) quadraticCurveTo(cpx, cpy, x, y) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 873](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line873) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `cpx` | Number | The x-coordinate of the Bézier control point | | `cpy` | Number | The y-coordinate of the Bézier control point | | `x` | Number | The x-coordinate of the ending point | | `y` | Number | The y-coordinate of the ending point | #### (inner) rect(x, y, w, h) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1033](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1033) The rect() method creates a rectangle. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of the upper-left corner of the rectangle | | `y` | Number | The y-coordinate of the upper-left corner of the rectangle | | `w` | Number | The width of the rectangle, in pixels | | `h` | Number | The height of the rectangle, in pixels | #### (inner) restore() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1174](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1174) Returns previously saved path state and attributes #### (inner) rotate(angle) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1443](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1443) To calculate from degrees to radians: degrees_Math.PI/180. Example: to rotate 5 degrees, specify the following: 5_Math.PI/180 ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `angle` | Number | The rotation angle, in radians. | #### (inner) save() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1151](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1151) Saves the state of the current context #### (inner) scale(scalewidth, scaleheight) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1425](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1425) The scale() method scales the current drawing, bigger or smaller. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `scalewidth` | Number | Scales the width of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) | | `scaleheight` | Number | Scales the height of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) | #### (inner) setLineDash() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 729](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line729) It uses an array of values that specify alternating lengths of lines and gaps which describe the pattern. #### (inner) setTransform(a, b, c, d, e, f) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1508](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1508) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `a` | Number | Horizontal scaling | | `b` | Number | Horizontal skewing | | `c` | Number | Vertical skewing | | `d` | Number | Vertical scaling | | `e` | Number | Horizontal moving | | `f` | Number | Vertical moving | #### (inner) stroke() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 759](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line759) The stroke() method actually draws the path you have defined with all those moveTo() and lineTo() methods. The default color is black. #### (inner) strokeRect(x, y, w, h) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1099](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1099) The strokeRect() method draws a rectangle (no fill). The default color of the stroke is black. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The x-coordinate of the upper-left corner of the rectangle | | `y` | Number | The y-coordinate of the upper-left corner of the rectangle | | `w` | Number | The width of the rectangle, in pixels | | `h` | Number | The height of the rectangle, in pixels | #### (inner) strokeText(text, x, y, maxWidth) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1346](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1346) The strokeText() method draws text (with no fill) on the canvas. The default color of the text is black. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | String | Specifies the text that will be written on the canvas | | `x` | Number | The x coordinate where to start painting the text (relative to the canvas) | | `y` | Number | The y coordinate where to start painting the text (relative to the canvas) | | `maxWidth` | Number | Optional. The maximum allowed width of the text, in pixels | #### (inner) toDataURL() Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1202](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1202) #### (inner) transform(a, b, c, d, e, f) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1486](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1486) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `a` | Number | Horizontal scaling | | `b` | Number | Horizontal skewing | | `c` | Number | Vertical skewing | | `d` | Number | Vertical scaling | | `e` | Number | Horizontal moving | | `f` | Number | Vertical moving | #### (inner) translate(x, y) Source: * [modules/context2d.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html) , [line 1468](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_context2d.js.html#line1468) The translate() method remaps the (0,0) position on the canvas. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `x` | Number | The value to add to horizontal (x) coordinates | | `y` | Number | The value to add to vertical (y) coordinates | --- # AcroFormPasswordField - Documentation AcroFormPasswordField ===================== #### new AcroFormPasswordField() Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2535](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2535) ### Extends * [AcroFormTextField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html) * [AcroFormField](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html) ### Members #### color :string|rgba Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1311](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1311) Inherited From: * [AcroFormField#color](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#color) Default Value: * 'black' The color of the text ##### Type: * string | rgba #### comb :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2452](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2452) Inherited From: * [AcroFormTextField#comb](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#comb) (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. ##### Type: * boolean #### defaultValue :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1377](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1377) Inherited From: * [AcroFormField#defaultValue](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#defaultValue) Default Value: * null (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. ##### Type: * any #### doNotScroll :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2431](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2431) Inherited From: * [AcroFormTextField#doNotScroll](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#doNotScroll) (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. ##### Type: * boolean #### doNotSpellCheck :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2410](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2410) Inherited From: * [AcroFormTextField#doNotSpellCheck](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#doNotSpellCheck) (PDF 1.4) If set, text entered in the field shall not be spell-checked. ##### Type: * boolean #### fieldName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1210](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1210) Inherited From: * [AcroFormField#fieldName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fieldName) Default Value: * null (Optional) The partial field name (see 12.7.3.2, “Field Names”). ##### Type: * string #### fileSelect :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2389](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2389) Inherited From: * [AcroFormTextField#fileSelect](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#fileSelect) (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. ##### Type: * boolean #### fontName :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1229](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1229) Inherited From: * [AcroFormField#fontName](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontName) Default Value: * 'helvetica' The fontName of the font to be used. ##### Type: * string #### fontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1267](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1267) Inherited From: * [AcroFormField#fontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontSize) Default Value: * 0 (for auto) The fontSize of the font to be used. ##### Type: * number #### fontStyle :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1248](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1248) Inherited From: * [AcroFormField#fontStyle](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#fontStyle) Default Value: * 'normal' The fontStyle of the font to be used. ##### Type: * string #### (readonly) hasAnnotation :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1471](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1471) Inherited From: * [AcroFormField#hasAnnotation](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAnnotation) Check if field has annotations ##### Type: * boolean #### (readonly) hasAppearanceStream :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1503](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1503) Inherited From: * [AcroFormField#hasAppearanceStream](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#hasAppearanceStream) true if field has an appearanceStream ##### Type: * boolean #### height :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1142](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1142) Inherited From: * [AcroFormField#height](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#height) Default Value: * null The height of the field. ##### Type: * number #### maxFontSize :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1286](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1286) Inherited From: * [AcroFormField#maxFontSize](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#maxFontSize) Default Value: * 0 (for auto) The maximum fontSize of the font to be used. ##### Type: * number #### maxLength :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2506](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2506) Inherited From: * [AcroFormTextField#maxLength](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#maxLength) (Optional; inheritable) The maximum length of the field’s text, in characters. ##### Type: * number #### multiline :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2368](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2368) Inherited From: * [AcroFormTextField#multiline](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#multiline) If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line. ##### Type: * boolean #### noExport :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1587](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1587) Inherited From: * [AcroFormField#noExport](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#noExport) Default Value: * false If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) ##### Type: * boolean #### page :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1522](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1522) Inherited From: * [AcroFormField#page](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#page) The page on which the AcroFormField is placed ##### Type: * number #### password :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2543) Overrides: * [AcroFormTextField#password](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#password) 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. ##### Type: * boolean #### readOnly :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1543](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1543) Inherited From: * [AcroFormField#readOnly](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#readOnly) Default Value: * false 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. ##### Type: * boolean #### required :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1565](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1565) Inherited From: * [AcroFormField#required](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#required) Default Value: * false 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”). ##### Type: * boolean #### richText :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 2473](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line2473) Inherited From: * [AcroFormTextField#richText](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormTextField.html#richText) (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. ##### Type: * boolean #### showWhenPrinted :boolean Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1019](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1019) Inherited From: * [AcroFormField#showWhenPrinted](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#showWhenPrinted) Default Value: * true (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. ##### Type: * boolean #### textAlign :string Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1630](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1630) Inherited From: * [AcroFormField#textAlign](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#textAlign) Default Value: * 'left' (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: 'left', 'center', 'right' ##### Type: * string #### value :any Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1444](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1444) Inherited From: * [AcroFormField#value](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#value) Default Value: * null (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. ##### Type: * any #### width :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1121](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1121) Inherited From: * [AcroFormField#width](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#width) Default Value: * null The width of the field. ##### Type: * number #### x :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1079](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1079) Inherited From: * [AcroFormField#x](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#x) Default Value: * null The x-position of the field. ##### Type: * number #### y :number Source: * [modules/acroform.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html) , [line 1100](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_acroform.js.html#line1100) Inherited From: * [AcroFormField#y](https://raw.githack.com/MrRio/jsPDF/master/docs/AcroFormField.html#y) Default Value: * null The y-position of the field. ##### Type: * number --- # gif_support - Documentation gif\_support ============ jsPDF Gif Support PlugIn Source: * [modules/gif\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_gif_support.js.html) , [line 13](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_gif_support.js.html#line13) --- # html - Documentation html ==== jsPDF html PlugIn Source: * [modules/html.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html) , [line 14](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html#line14) ### Methods #### (inner) html(source, optionsopt) Source: * [modules/html.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html) , [line 1021](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html#line1021) Generate a PDF from an HTML element or string using. ##### Example var doc = new jsPDF(); doc.html(document.body, { callback: function (doc) { doc.save(); }, x: 10, y: 10 }); ##### Parameters: NameTypeAttributesDescription`source`HTMLElement | string The source HTMLElement or a string containing HTML. `options`Object Collection of settings ###### Properties | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `callback` | function | | The mandatory callback-function gets as first parameter the current jsPDF instance | | `margin` | number \| Array. | | Page margins \[top, right, bottom, left\]. Default is 0. | | `autoPaging` | boolean \| 'slice' \| 'text' | | The auto paging mode.

* `false`: Auto paging is disabled.
* `true` or `'slice'`: Will cut shapes or text chunks across page breaks. Will possibly slice text in half, making it difficult to read.
* `'text'`: Trys not to cut text in half across page breaks. Works best for documents consisting mostly of a single column of text.

Default is `true`. | | `filename` | string | | name of the file | | `image` | HTMLOptionImage | | image settings when converting HTML to image | | `html2canvas` | Html2CanvasOptions | | html2canvas options | | `fontFaces` | Array. | | A list of font-faces to match when resolving fonts. Fonts will be added to the PDF based on the specified URL. If omitted, the font match algorithm falls back to old algorithm. | | `jsPDF` | [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) | | jsPDF instance | | `x` | number | | x position on the PDF document in jsPDF units. | | `y` | number | | y position on the PDF document in jsPDF units. | | `width` | number | | The target width in the PDF document in jsPDF units. The rendered element will be scaled such that it fits into the specified width. Has no effect if either the ``` html2canvas.scale ``is specified or the `windowWidth` option is NOT specified.`` ``` | | `windowWidth` | number | | The window width in CSS pixels. In contrast to the `html2canvas.windowWidth` option, this option affects the actual container size while rendering and does NOT affect CSS media queries. This option only has an effect, if the `` width `option is also specified.` `` | ### Type Definitions #### FontFace Source: * [modules/html.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html) , [line 1001](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_html.js.html#line1001) ##### Properties: | Name | Type | Attributes | Description | | --- | --- | --- | --- | | `family` | string | | The name of the font-family. | | `style` | string \| undefined | | The style that this font-face defines, e.g. 'italic'. | | `weight` | string \| number \| undefined | | The weight of the font, either as a string or a number (400, 500, 600, e.g.) | | `stretch` | string \| undefined | | The stretch of the font, e.g. condensed, normal, expanded. | | `src` | Array. | | A list of URLs from where fonts of various formats can be fetched. | | `src` | string | | url A URL to a font of a specific format. | | `src` | string | | format Format of the font referenced by the URL. | --- # javascript - Documentation javascript ========== jsPDF JavaScript plugin Source: * [modules/javascript.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_javascript.js.html) , [line 29](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_javascript.js.html#line29) ### Methods #### (inner) addJS(javascript) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/javascript.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_javascript.js.html) , [line 38](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_javascript.js.html#line38) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `javascript` | string | The javascript to be embedded into the PDF-file. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # outline - Documentation outline ======= jsPDF Outline PlugIn Generates a PDF Outline Source: * [modules/outline.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_outline.js.html) , [line 11](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_outline.js.html#line11) --- # jpeg_support - Documentation jpeg\_support ============= jsPDF jpeg Support PlugIn Source: * [modules/jpeg\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_jpeg_support.js.html) , [line 10](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_jpeg_support.js.html#line10) --- # png_support - Documentation png\_support ============ jsPDF PNG PlugIn Source: * [modules/png\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_png_support.js.html) , [line 31](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_png_support.js.html#line31) --- # setLanguage - Documentation setLanguage =========== jsPDF setLanguage Plugin Source: * [modules/setlanguage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_setlanguage.js.html) , [line 9](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_setlanguage.js.html#line9) ### Methods #### (inner) setLanguage(langCode) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/setlanguage.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_setlanguage.js.html) , [line 18](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_setlanguage.js.html#line18) Add Language Tag to the generated PDF ##### Example var doc = new jsPDF() doc.text(10, 10, 'This is a test') doc.setLanguage("en-US") doc.save('english.pdf') ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `langCode` | string | The Language code as ISO-639-1 (e.g. 'en') or as country language code (e.g. 'en-GB'). | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # split_text_to_size - Documentation split\_text\_to\_size ===================== jsPDF split\_text\_to\_size plugin Source: * [modules/split\_text\_to\_size.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html) , [line 29](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html#line29) ### Methods #### (inner) getCharWidthsArray(text, options) → {Array} Source: * [modules/split\_text\_to\_size.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html) , [line 37](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html#line37) Returns an array of length matching length of the 'word' string, with each cell occupied by the width of the char in that position. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | | | `options` | Object | | ##### Returns: Type Array #### (inner) getStringUnitWidth(text, options) → {number} Source: * [modules/split\_text\_to\_size.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html) , [line 104](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html#line104) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | | | `options` | string | | ##### Returns: result Type number #### (inner) splitTextToSize(text, size, options) → {Array} Source: * [modules/split\_text\_to\_size.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html) , [line 299](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_split_text_to_size.js.html#line299) 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. ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `text` | string | Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string. | | `size` | number | Nominal number, measured in units default to this instance of jsPDF. | | `options` | Object | Optional flags needed for chopper to do the right thing. | ##### Returns: array Array with strings chopped to size. Type Array --- # rgba_support - Documentation rgba\_support ============= jsPDF RGBA array PlugIn Source: * [modules/rgba\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_rgba_support.js.html) , [line 29](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_rgba_support.js.html#line29) --- # svg - Documentation svg === jsPDF SVG plugin Source: * [modules/svg.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_svg.js.html) , [line 29](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_svg.js.html#line29) ### Methods #### (inner) addSvgAsImage(SVG-Data, x, y, width, height, alias, compression, rotation) Source: * [modules/svg.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_svg.js.html) , [line 78](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_svg.js.html#line78) Parses SVG XML and saves it as image into the PDF. Depends on canvas-element and canvg ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `SVG-Data` | string | as Text | | `x` | number | Coordinate (in units declared at inception of PDF document) against left edge of the page | | `y` | number | Coordinate (in units declared at inception of PDF document) against upper edge of the page | | `width` | number | of SVG-Image (in units declared at inception of PDF document) | | `height` | number | of SVG-Image (in units declared at inception of PDF document) | | `alias` | string | of SVG-Image (if used multiple times) | | `compression` | string | of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW' | | `rotation` | number | of the image in degrees (0-359) | ##### Returns: jsPDF jsPDF-instance --- # ttfsupport - Documentation ttfsupport ========== --- # webp_support - Documentation webp\_support ============= jsPDF webp Support PlugIn Source: * [modules/webp\_support.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_webp_support.js.html) , [line 13](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_webp_support.js.html#line13) --- # vFS - Documentation vFS === Use the vFS to handle files Source: * [modules/vfs.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html) , [line 11](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html#line11) ### Methods #### (inner) addFileToVFS(filename, filecontent) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/vfs.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html) , [line 42](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html#line42) Add a file to the vFS ##### Example doc.addFileToVFS("someFile.txt", "BADFACE1"); ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `filename` | string | The name of the file which should be added. | | `filecontent` | string | The content of the file. | ##### Returns: Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) #### (inner) existsFileInVFS(Possible) → {boolean} Source: * [modules/vfs.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html) , [line 27](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html#line27) Check if the file exists in the vFS ##### Example doc.existsFileInVFS("someFile.txt"); ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `Possible` | string | filename in the vFS. | ##### Returns: Type boolean #### (inner) getFileFromVFS(The) → {string} Source: * [modules/vfs.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html) , [line 59](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_vfs.js.html#line59) Get the file from the vFS ##### Example doc.getFileFromVFS("someFile.txt"); ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `The` | string | name of the file which gets requested. | ##### Returns: Type string --- # total_pages - Documentation total\_pages ============ jsPDF total\_pages plugin Source: * [modules/total\_pages.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_total_pages.js.html) , [line 29](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_total_pages.js.html#line29) ### Methods #### (inner) putTotalPages(pageExpression) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/total\_pages.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_total_pages.js.html) , [line 36](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_total_pages.js.html#line36) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `pageExpression` | string | Regular Expression | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # standard_fonts_metrics - Documentation standard\_fonts\_metrics ======================== 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. Source: * [modules/standard\_fonts\_metrics.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_standard_fonts_metrics.js.html) , [line 28](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_standard_fonts_metrics.js.html#line28) --- # utf8 - Documentation utf8 ==== --- # viewerpreferences - Documentation viewerpreferences ================= Adds the ability to set ViewerPreferences and by thus controlling the way the document is to be presented on the screen or in print. Source: * [modules/viewerpreferences.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_viewerpreferences.js.html) , [line 11](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_viewerpreferences.js.html#line11) ### Methods #### (inner) viewerPreferences(options, doReset) Source: * [modules/viewerpreferences.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_viewerpreferences.js.html) , [line 20](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_viewerpreferences.js.html#line20) Set the ViewerPreferences of the generated PDF ##### 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 }) ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `options` | Object | 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 | | `doReset` | boolean | True to reset the settings | ##### Returns: jsPDF jsPDF-instance --- # xmp_metadata - Documentation xmp\_metadata ============= ### Methods #### (inner) addMetadata(metadata, namespaceuri) → {[jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) } Source: * [modules/xmp\_metadata.js](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_xmp_metadata.js.html) , [line 87](https://raw.githack.com/MrRio/jsPDF/master/docs/modules_xmp_metadata.js.html#line87) Adds XMP formatted metadata to PDF ##### Parameters: | Name | Type | Description | | --- | --- | --- | | `metadata` | String | 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. | | `namespaceuri` | String | Sets the namespace URI for the metadata. Last character should be slash or hash. | ##### Returns: jsPDF-instance Type [jsPDF](https://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html) --- # modules/canvas.js - Documentation modules/canvas.js ================= 1. `/**` 2. `* @license` 3. `* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 11. `/**` 12. `* jsPDF Canvas PlugIn` 13. `* This plugin mimics the HTML5 Canvas` 14. `*` 15. `* The goal is to provide a way for current canvas users to print directly to a PDF.` 16. `* @name canvas` 17. `* @module` 18. `*/` 19. `(function(jsPDFAPI) {` 20. `"use strict";` 22. `/**` 23. `* @class Canvas` 24. `* @classdesc A Canvas Wrapper for jsPDF` 25. `*/` 26. `var Canvas = function() {` 27. `var jsPdfInstance = undefined;` 28. `Object.defineProperty(this, "pdf", {` 29. `get: function() {` 30. `return jsPdfInstance;` 31. `},` 32. `set: function(value) {` 33. `jsPdfInstance = value;` 34. `}` 35. `});` 37. `var _width = 150;` 38. `/**` 39. `* 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.` 40. `* This is one of the two properties, the other being width, that controls the size of the canvas.` 41. `*` 42. `* @name width` 43. `*/` 44. `Object.defineProperty(this, "width", {` 45. `get: function() {` 46. `return _width;` 47. `},` 48. `set: function(value) {` 49. `if (isNaN(value) || Number.isInteger(value) === false || value < 0) {` 50. `_width = 150;` 51. `} else {` 52. `_width = value;` 53. `}` 54. `if (this.getContext("2d").pageWrapXEnabled) {` 55. `this.getContext("2d").pageWrapX = _width + 1;` 56. `}` 57. `}` 58. `});` 60. `var _height = 300;` 61. `/**` 62. `* 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.` 63. `* This is one of the two properties, the other being height, that controls the size of the canvas.` 64. `*` 65. `* @name height` 66. `*/` 67. `Object.defineProperty(this, "height", {` 68. `get: function() {` 69. `return _height;` 70. `},` 71. `set: function(value) {` 72. `if (isNaN(value) || Number.isInteger(value) === false || value < 0) {` 73. `_height = 300;` 74. `} else {` 75. `_height = value;` 76. `}` 77. `if (this.getContext("2d").pageWrapYEnabled) {` 78. `this.getContext("2d").pageWrapY = _height + 1;` 79. `}` 80. `}` 81. `});` 83. `var _childNodes = [];` 84. `Object.defineProperty(this, "childNodes", {` 85. `get: function() {` 86. `return _childNodes;` 87. `},` 88. `set: function(value) {` 89. `_childNodes = value;` 90. `}` 91. `});` 93. `var _style = {};` 94. `Object.defineProperty(this, "style", {` 95. `get: function() {` 96. `return _style;` 97. `},` 98. `set: function(value) {` 99. `_style = value;` 100. `}` 101. `});` 103. `Object.defineProperty(this, "parentNode", {});` 104. `};` 106. `/**` 107. `* The getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported.` 108. `*` 109. `* @name getContext` 110. `* @function` 111. `* @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.` 112. `* @param {object} contextAttributes` 113. `*/` 114. `Canvas.prototype.getContext = function(contextType, contextAttributes) {` 115. `contextType = contextType || "2d";` 116. `var key;` 118. `if (contextType !== "2d") {` 119. `return null;` 120. `}` 121. `for (key in contextAttributes) {` 122. `if (this.pdf.context2d.hasOwnProperty(key)) {` 123. `this.pdf.context2d[key] = contextAttributes[key];` 124. `}` 125. `}` 126. `this.pdf.context2d._canvas = this;` 127. `return this.pdf.context2d;` 128. `};` 130. `/**` 131. `* The toDataURL() method is just a stub to throw an error if accidently called.` 132. `*` 133. `* @name toDataURL` 134. `* @function` 135. `*/` 136. `Canvas.prototype.toDataURL = function() {` 137. `throw new Error("toDataURL is not implemented.");` 138. `};` 140. `jsPDFAPI.events.push([`\ 141. `"initialized",`\ 142. `function() {`\ 143. `this.canvas = new Canvas();`\ 144. `this.canvas.pdf = this;`\ 145. `}`\ 146. `]);` 148. `return this;` 149. `})(jsPDF.API);` --- # modules/bmp_support.js - Documentation modules/bmp\_support.js ======================= 1. `import { JPEGEncoder } from "../libs/JPEGEncoder.js";` 2. `import { BmpDecoder } from "../libs/BMPDecoder.js";` 3. `import { jsPDF } from "../jspdf.js";` 5. `/**` 6. `* @license` 7. `* Copyright (c) 2018 Aras Abbasi` 8. `*` 9. `* Licensed under the MIT License.` 10. `* http://opensource.org/licenses/mit-license` 11. `*/` 13. `/**` 14. `* jsPDF bmp Support PlugIn` 15. `* @name bmp_support` 16. `* @module` 17. `*/` 18. `(function(jsPDFAPI) {` 19. `"use strict";` 21. `jsPDFAPI.processBMP = function(imageData, index, alias, compression) {` 22. `var reader = new BmpDecoder(imageData, false);` 23. `var width = reader.width,` 24. `height = reader.height;` 25. `var qu = 100;` 26. `var pixels = reader.getData();` 28. `var rawImageData = {` 29. `data: pixels,` 30. `width: width,` 31. `height: height` 32. `};` 34. `var encoder = new JPEGEncoder(qu);` 35. `var data = encoder.encode(rawImageData, qu);` 36. `return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);` 37. `};` 38. `})(jsPDF.API);` --- # modules/cell.js - Documentation modules/cell.js =============== 1. `/**` 2. `* @license` 3. `* ====================================================================` 4. `* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com` 5. `* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br` 6. `* 2013 Lee Driscoll, https://github.com/lsdriscoll` 7. `* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria` 8. `* 2014 James Hall, james@parall.ax` 9. `* 2014 Diego Casorran, https://github.com/diegocr` 10. `*` 11. `* Permission is hereby granted, free of charge, to any person obtaining` 12. `* a copy of this software and associated documentation files (the` 13. `* "Software"), to deal in the Software without restriction, including` 14. `* without limitation the rights to use, copy, modify, merge, publish,` 15. `* distribute, sublicense, and/or sell copies of the Software, and to` 16. `* permit persons to whom the Software is furnished to do so, subject to` 17. `* the following conditions:` 18. `*` 19. `* The above copyright notice and this permission notice shall be` 20. `* included in all copies or substantial portions of the Software.` 21. `*` 22. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 23. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 24. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 25. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 26. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 27. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 28. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 29. `* ====================================================================` 30. `*/` 32. `import { jsPDF } from "../jspdf.js";` 34. `/**` 35. `* @name cell` 36. `* @module` 37. `*/` 38. `(function(jsPDFAPI) {` 39. `"use strict";` 41. `var NO_MARGINS = { left: 0, top: 0, bottom: 0, right: 0 };` 43. `var px2pt = (0.264583 * 72) / 25.4;` 44. `var printingHeaderRow = false;` 46. `var _initialize = function() {` 47. `if (typeof this.internal.__cell__ === "undefined") {` 48. `this.internal.__cell__ = {};` 49. `this.internal.__cell__.padding = 3;` 50. `this.internal.__cell__.headerFunction = undefined;` 51. `this.internal.__cell__.margins = Object.assign({}, NO_MARGINS);` 52. `this.internal.__cell__.margins.width = this.getPageWidth();` 53. `_reset.call(this);` 54. `}` 55. `};` 57. `var _reset = function() {` 58. `this.internal.__cell__.lastCell = new Cell();` 59. `this.internal.__cell__.pages = 1;` 60. `};` 62. `var Cell = function() {` 63. `var _x = arguments[0];` 64. `Object.defineProperty(this, "x", {` 65. `enumerable: true,` 66. `get: function() {` 67. `return _x;` 68. `},` 69. `set: function(value) {` 70. `_x = value;` 71. `}` 72. `});` 73. `var _y = arguments[1];` 74. `Object.defineProperty(this, "y", {` 75. `enumerable: true,` 76. `get: function() {` 77. `return _y;` 78. `},` 79. `set: function(value) {` 80. `_y = value;` 81. `}` 82. `});` 83. `var _width = arguments[2];` 84. `Object.defineProperty(this, "width", {` 85. `enumerable: true,` 86. `get: function() {` 87. `return _width;` 88. `},` 89. `set: function(value) {` 90. `_width = value;` 91. `}` 92. `});` 93. `var _height = arguments[3];` 94. `Object.defineProperty(this, "height", {` 95. `enumerable: true,` 96. `get: function() {` 97. `return _height;` 98. `},` 99. `set: function(value) {` 100. `_height = value;` 101. `}` 102. `});` 103. `var _text = arguments[4];` 104. `Object.defineProperty(this, "text", {` 105. `enumerable: true,` 106. `get: function() {` 107. `return _text;` 108. `},` 109. `set: function(value) {` 110. `_text = value;` 111. `}` 112. `});` 113. `var _lineNumber = arguments[5];` 114. `Object.defineProperty(this, "lineNumber", {` 115. `enumerable: true,` 116. `get: function() {` 117. `return _lineNumber;` 118. `},` 119. `set: function(value) {` 120. `_lineNumber = value;` 121. `}` 122. `});` 123. `var _align = arguments[6];` 124. `Object.defineProperty(this, "align", {` 125. `enumerable: true,` 126. `get: function() {` 127. `return _align;` 128. `},` 129. `set: function(value) {` 130. `_align = value;` 131. `}` 132. `});` 134. `return this;` 135. `};` 137. `Cell.prototype.clone = function() {` 138. `return new Cell(` 139. `this.x,` 140. `this.y,` 141. `this.width,` 142. `this.height,` 143. `this.text,` 144. `this.lineNumber,` 145. `this.align` 146. `);` 147. `};` 149. `Cell.prototype.toArray = function() {` 150. `return [`\ 151. `this.x,`\ 152. `this.y,`\ 153. `this.width,`\ 154. `this.height,`\ 155. `this.text,`\ 156. `this.lineNumber,`\ 157. `this.align`\ 158. `];` 159. `};` 161. `/**` 162. `* @name setHeaderFunction` 163. `* @function` 164. `* @param {function} func` 165. `*/` 166. `jsPDFAPI.setHeaderFunction = function(func) {` 167. `_initialize.call(this);` 168. `this.internal.__cell__.headerFunction =` 169. `typeof func === "function" ? func : undefined;` 170. `return this;` 171. `};` 173. `/**` 174. `* @name getTextDimensions` 175. `* @function` 176. `* @param {string} txt` 177. `* @returns {Object} dimensions` 178. `*/` 179. `jsPDFAPI.getTextDimensions = function(text, options) {` 180. `_initialize.call(this);` 181. `options = options || {};` 182. `var fontSize = options.fontSize || this.getFontSize();` 183. `var font = options.font || this.getFont();` 184. `var scaleFactor = options.scaleFactor || this.internal.scaleFactor;` 185. `var width = 0;` 186. `var amountOfLines = 0;` 187. `var height = 0;` 188. `var tempWidth = 0;` 189. `var scope = this;` 191. `if (!Array.isArray(text) && typeof text !== "string") {` 192. `if (typeof text === "number") {` 193. `text = String(text);` 194. `} else {` 195. `throw new Error(` 196. `"getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings."` 197. `);` 198. `}` 199. `}` 201. `const maxWidth = options.maxWidth;` 202. `if (maxWidth > 0) {` 203. `if (typeof text === "string") {` 204. `text = this.splitTextToSize(text, maxWidth);` 205. `} else if (Object.prototype.toString.call(text) === "[object Array]") {` 206. `text = text.reduce(function(acc, textLine) {` 207. `return acc.concat(scope.splitTextToSize(textLine, maxWidth));` 208. `}, []);` 209. `}` 210. `} else {` 211. `// Without the else clause, it will not work if you do not pass along maxWidth` 212. `text = Array.isArray(text) ? text : [text];` 213. `}` 215. `for (var i = 0; i < text.length; i++) {` 216. `tempWidth = this.getStringUnitWidth(text[i], { font: font }) * fontSize;` 217. `if (width < tempWidth) {` 218. `width = tempWidth;` 219. `}` 220. `}` 222. `if (width !== 0) {` 223. `amountOfLines = text.length;` 224. `}` 226. `width = width / scaleFactor;` 227. `height = Math.max(` 228. `(amountOfLines * fontSize * this.getLineHeightFactor() -` 229. `fontSize * (this.getLineHeightFactor() - 1)) /` 230. `scaleFactor,` 231. `0` 232. `);` 233. `return { w: width, h: height };` 234. `};` 236. `/**` 237. `* @name cellAddPage` 238. `* @function` 239. `*/` 240. `jsPDFAPI.cellAddPage = function() {` 241. `_initialize.call(this);` 243. `this.addPage();` 245. `var margins = this.internal.__cell__.margins || NO_MARGINS;` 246. `this.internal.__cell__.lastCell = new Cell(` 247. `margins.left,` 248. `margins.top,` 249. `undefined,` 250. `undefined` 251. `);` 252. `this.internal.__cell__.pages += 1;` 254. `return this;` 255. `};` 257. `/**` 258. `* @name cell` 259. `* @function` 260. `* @param {number} x` 261. `* @param {number} y` 262. `* @param {number} width` 263. `* @param {number} height` 264. `* @param {string} text` 265. `* @param {number} lineNumber lineNumber` 266. `* @param {string} align` 267. `* @return {jsPDF} jsPDF-instance` 268. `*/` 269. `var cell = (jsPDFAPI.cell = function() {` 270. `var currentCell;` 272. `if (arguments[0] instanceof Cell) {` 273. `currentCell = arguments[0];` 274. `} else {` 275. `currentCell = new Cell(` 276. `arguments[0],` 277. `arguments[1],` 278. `arguments[2],` 279. `arguments[3],` 280. `arguments[4],` 281. `arguments[5]` 282. `);` 283. `}` 284. `_initialize.call(this);` 285. `var lastCell = this.internal.__cell__.lastCell;` 286. `var padding = this.internal.__cell__.padding;` 287. `var margins = this.internal.__cell__.margins || NO_MARGINS;` 288. `var tableHeaderRow = this.internal.__cell__.tableHeaderRow;` 289. `var printHeaders = this.internal.__cell__.printHeaders;` 290. `// If this is not the first cell, we must change its position` 291. `if (typeof lastCell.lineNumber !== "undefined") {` 292. `if (lastCell.lineNumber === currentCell.lineNumber) {` 293. `//Same line` 294. `currentCell.x = (lastCell.x || 0) + (lastCell.width || 0);` 295. `currentCell.y = lastCell.y || 0;` 296. `} else {` 297. `//New line` 298. `if (` 299. `lastCell.y + lastCell.height + currentCell.height + margins.bottom >` 300. `this.getPageHeight()` 301. `) {` 302. `this.cellAddPage();` 303. `currentCell.y = margins.top;` 304. `if (printHeaders && tableHeaderRow) {` 305. `this.printHeaderRow(currentCell.lineNumber, true);` 306. `currentCell.y += tableHeaderRow[0].height;` 307. `}` 308. `} else {` 309. `currentCell.y = lastCell.y + lastCell.height || currentCell.y;` 310. `}` 311. `}` 312. `}` 314. `if (typeof currentCell.text[0] !== "undefined") {` 315. `this.rect(` 316. `currentCell.x,` 317. `currentCell.y,` 318. `currentCell.width,` 319. `currentCell.height,` 320. `printingHeaderRow === true ? "FD" : undefined` 321. `);` 322. `if (currentCell.align === "right") {` 323. `this.text(` 324. `currentCell.text,` 325. `currentCell.x + currentCell.width - padding,` 326. `currentCell.y + padding,` 327. `{ align: "right", baseline: "top" }` 328. `);` 329. `} else if (currentCell.align === "center") {` 330. `this.text(` 331. `currentCell.text,` 332. `currentCell.x + currentCell.width / 2,` 333. `currentCell.y + padding,` 334. `{` 335. `align: "center",` 336. `baseline: "top",` 337. `maxWidth: currentCell.width - padding - padding` 338. `}` 339. `);` 340. `} else {` 341. `this.text(` 342. `currentCell.text,` 343. `currentCell.x + padding,` 344. `currentCell.y + padding,` 345. `{` 346. `align: "left",` 347. `baseline: "top",` 348. `maxWidth: currentCell.width - padding - padding` 349. `}` 350. `);` 351. `}` 352. `}` 353. `this.internal.__cell__.lastCell = currentCell;` 354. `return this;` 355. `});` 357. `/**` 358. `* Create a table from a set of data.` 359. `* @name table` 360. `* @function` 361. `* @param {Integer} [x] : left-position for top-left corner of table` 362. `* @param {Integer} [y] top-position for top-left corner of table` 363. `* @param {Object[]} [data] An array of objects containing key-value pairs corresponding to a row of data.` 364. `* @param {String[]} [headers] Omit or null to auto-generate headers at a performance cost` 366. `* @param {Object} [config.printHeaders] True to print column headers at the top of every page` 367. `* @param {Object} [config.autoSize] True to dynamically set the column widths to match the widest cell value` 368. `* @param {Object} [config.margins] margin values for left, top, bottom, and width` 369. `* @param {Object} [config.fontSize] Integer fontSize to use (optional)` 370. `* @param {Object} [config.padding] cell-padding in pt to use (optional)` 371. `* @param {Object} [config.headerBackgroundColor] default is #c8c8c8 (optional)` 372. `* @param {Object} [config.headerTextColor] default is #000 (optional)` 373. `* @param {Object} [config.rowStart] callback to handle before print each row (optional)` 374. `* @param {Object} [config.cellStart] callback to handle before print each cell (optional)` 375. `* @returns {jsPDF} jsPDF-instance` 376. `*/` 378. `jsPDFAPI.table = function(x, y, data, headers, config) {` 379. `_initialize.call(this);` 380. `if (!data) {` 381. `throw new Error("No data for PDF table.");` 382. `}` 384. `config = config || {};` 386. `var headerNames = [],` 387. `headerLabels = [],` 388. `headerAligns = [],` 389. `i,` 390. `columnMatrix = {},` 391. `columnWidths = {},` 392. `column,` 393. `columnMinWidths = [],` 394. `j,` 395. `tableHeaderConfigs = [],` 396. `//set up defaults. If a value is provided in config, defaults will be overwritten:` 397. `autoSize = config.autoSize || false,` 398. `printHeaders = config.printHeaders === false ? false : true,` 399. `fontSize =` 400. `config.css && typeof config.css["font-size"] !== "undefined"` 401. `? config.css["font-size"] * 16` 402. `: config.fontSize || 12,` 403. `margins =` 404. `config.margins ||` 405. `Object.assign({ width: this.getPageWidth() }, NO_MARGINS),` 406. `padding = typeof config.padding === "number" ? config.padding : 3,` 407. `headerBackgroundColor = config.headerBackgroundColor || "#c8c8c8",` 408. `headerTextColor = config.headerTextColor || "#000";` 410. `_reset.call(this);` 412. `this.internal.__cell__.printHeaders = printHeaders;` 413. `this.internal.__cell__.margins = margins;` 414. `this.internal.__cell__.table_font_size = fontSize;` 415. `this.internal.__cell__.padding = padding;` 416. `this.internal.__cell__.headerBackgroundColor = headerBackgroundColor;` 417. `this.internal.__cell__.headerTextColor = headerTextColor;` 418. `this.setFontSize(fontSize);` 420. `// Set header values` 421. `if (headers === undefined || headers === null) {` 422. `// No headers defined so we derive from data` 423. `headerNames = Object.keys(data[0]);` 424. `headerLabels = headerNames;` 425. `headerAligns = headerNames.map(function() {` 426. `return "left";` 427. `});` 428. `} else if (Array.isArray(headers) && typeof headers[0] === "object") {` 429. `headerNames = headers.map(function(header) {` 430. `return header.name;` 431. `});` 432. `headerLabels = headers.map(function(header) {` 433. `return header.prompt || header.name || "";` 434. `});` 435. `headerAligns = headers.map(function(header) {` 436. `return header.align || "left";` 437. `});` 438. `// Split header configs into names and prompts` 439. `for (i = 0; i < headers.length; i += 1) {` 440. `columnWidths[headers[i].name] = headers[i].width * px2pt;` 441. `}` 442. `} else if (Array.isArray(headers) && typeof headers[0] === "string") {` 443. `headerNames = headers;` 444. `headerLabels = headerNames;` 445. `headerAligns = headerNames.map(function() {` 446. `return "left";` 447. `});` 448. `}` 450. `if (` 451. `autoSize ||` 452. `(Array.isArray(headers) && typeof headers[0] === "string")` 453. `) {` 454. `var headerName;` 455. `for (i = 0; i < headerNames.length; i += 1) {` 456. `headerName = headerNames[i];` 458. `// Create a matrix of columns e.g., {column_title: [row1_Record, row2_Record]}` 460. `columnMatrix[headerName] = data.map(function(rec) {` 461. `return rec[headerName];` 462. `});` 464. `// get header width` 465. `this.setFont(undefined, "bold");` 466. `columnMinWidths.push(` 467. `this.getTextDimensions(headerLabels[i], {` 468. `fontSize: this.internal.__cell__.table_font_size,` 469. `scaleFactor: this.internal.scaleFactor` 470. `}).w` 471. `);` 472. `column = columnMatrix[headerName];` 474. `// get cell widths` 475. `this.setFont(undefined, "normal");` 476. `for (j = 0; j < column.length; j += 1) {` 477. `columnMinWidths.push(` 478. `this.getTextDimensions(column[j], {` 479. `fontSize: this.internal.__cell__.table_font_size,` 480. `scaleFactor: this.internal.scaleFactor` 481. `}).w` 482. `);` 483. `}` 485. `// get final column width` 486. `columnWidths[headerName] =` 487. `Math.max.apply(null, columnMinWidths) + padding + padding;` 489. `//have to reset` 490. `columnMinWidths = [];` 491. `}` 492. `}` 494. `// -- Construct the table` 496. `if (printHeaders) {` 497. `var row = {};` 498. `for (i = 0; i < headerNames.length; i += 1) {` 499. `row[headerNames[i]] = {};` 500. `row[headerNames[i]].text = headerLabels[i];` 501. `row[headerNames[i]].align = headerAligns[i];` 502. `}` 504. `var rowHeight = calculateLineHeight.call(this, row, columnWidths);` 506. `// Construct the header row` 507. `tableHeaderConfigs = headerNames.map(function(value) {` 508. `return new Cell(` 509. `x,` 510. `y,` 511. `columnWidths[value],` 512. `rowHeight,` 513. `row[value].text,` 514. `undefined,` 515. `row[value].align` 516. `);` 517. `});` 519. `// Store the table header config` 520. `this.setTableHeaderRow(tableHeaderConfigs);` 522. `// Print the header for the start of the table` 523. `this.printHeaderRow(1, false);` 524. `}` 526. `// Construct the data rows` 528. `var align = headers.reduce(function(pv, cv) {` 529. `pv[cv.name] = cv.align;` 530. `return pv;` 531. `}, {});` 532. `for (i = 0; i < data.length; i += 1) {` 533. `if ("rowStart" in config && config.rowStart instanceof Function) {` 534. `config.rowStart(` 535. `{` 536. `row: i,` 537. `data: data[i]` 538. `},` 539. `this` 540. `);` 541. `}` 542. `var lineHeight = calculateLineHeight.call(this, data[i], columnWidths);` 544. `for (j = 0; j < headerNames.length; j += 1) {` 545. `var cellData = data[i][headerNames[j]];` 546. `if ("cellStart" in config && config.cellStart instanceof Function) {` 547. `config.cellStart(` 548. `{` 549. `row: i,` 550. `col: j,` 551. `data: cellData` 552. `},` 553. `this` 554. `);` 555. `}` 556. `cell.call(` 557. `this,` 558. `new Cell(` 559. `x,` 560. `y,` 561. `columnWidths[headerNames[j]],` 562. `lineHeight,` 563. `cellData,` 564. `i + 2,` 565. `align[headerNames[j]]` 566. `)` 567. `);` 568. `}` 569. `}` 570. `this.internal.__cell__.table_x = x;` 571. `this.internal.__cell__.table_y = y;` 572. `return this;` 573. `};` 575. `/**` 576. `* Calculate the height for containing the highest column` 577. `*` 578. `* @name calculateLineHeight` 579. `* @function` 580. `* @param {Object[]} model is the line of data we want to calculate the height of` 581. `* @param {Integer[]} columnWidths is size of each column` 582. `* @returns {number} lineHeight` 583. `* @private` 584. `*/` 585. `var calculateLineHeight = function calculateLineHeight(model, columnWidths) {` 586. `var padding = this.internal.__cell__.padding;` 587. `var fontSize = this.internal.__cell__.table_font_size;` 588. `var scaleFactor = this.internal.scaleFactor;` 590. `return Object.keys(model)` 591. `.map(function(key) {` 592. `var value = model[key];` 593. `return this.splitTextToSize(` 594. `value.hasOwnProperty("text") ? value.text : value,` 595. `columnWidths[key] - padding - padding` 596. `);` 597. `}, this)` 598. `.map(function(value) {` 599. `return (` 600. `(this.getLineHeightFactor() * value.length * fontSize) / scaleFactor +` 601. `padding +` 602. `padding` 603. `);` 604. `}, this)` 605. `.reduce(function(pv, cv) {` 606. `return Math.max(pv, cv);` 607. `}, 0);` 608. `};` 610. `/**` 611. `* Store the config for outputting a table header` 612. `*` 613. `* @name setTableHeaderRow` 614. `* @function` 615. `* @param {Object[]} config` 616. `* An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell` 617. `* except the lineNumber parameter is excluded` 618. `*/` 619. `jsPDFAPI.setTableHeaderRow = function(config) {` 620. `_initialize.call(this);` 621. `this.internal.__cell__.tableHeaderRow = config;` 622. `};` 624. `/**` 625. `* Output the store header row` 626. `*` 627. `* @name printHeaderRow` 628. `* @function` 629. `* @param {number} lineNumber The line number to output the header at` 630. `* @param {boolean} new_page` 631. `*/` 632. `jsPDFAPI.printHeaderRow = function(lineNumber, new_page) {` 633. `_initialize.call(this);` 634. `if (!this.internal.__cell__.tableHeaderRow) {` 635. `throw new Error("Property tableHeaderRow does not exist.");` 636. `}` 638. `var tableHeaderCell;` 640. `printingHeaderRow = true;` 641. `if (typeof this.internal.__cell__.headerFunction === "function") {` 642. `var position = this.internal.__cell__.headerFunction(` 643. `this,` 644. `this.internal.__cell__.pages` 645. `);` 646. `this.internal.__cell__.lastCell = new Cell(` 647. `position[0],` 648. `position[1],` 649. `position[2],` 650. `position[3],` 651. `undefined,` 652. `-1` 653. `);` 654. `}` 655. `this.setFont(undefined, "bold");` 657. `var tempHeaderConf = [];` 658. `for (var i = 0; i < this.internal.__cell__.tableHeaderRow.length; i += 1) {` 659. `tableHeaderCell = this.internal.__cell__.tableHeaderRow[i].clone();` 660. `if (new_page) {` 661. `tableHeaderCell.y = this.internal.__cell__.margins.top || 0;` 662. `tempHeaderConf.push(tableHeaderCell);` 663. `}` 664. `tableHeaderCell.lineNumber = lineNumber;` 665. `var currentTextColor = this.getTextColor();` 666. `this.setTextColor(this.internal.__cell__.headerTextColor);` 667. `this.setFillColor(this.internal.__cell__.headerBackgroundColor);` 668. `cell.call(this, tableHeaderCell);` 669. `this.setTextColor(currentTextColor);` 670. `}` 671. `if (tempHeaderConf.length > 0) {` 672. `this.setTableHeaderRow(tempHeaderConf);` 673. `}` 674. `this.setFont(undefined, "normal");` 675. `printingHeaderRow = false;` 676. `};` 677. `})(jsPDF.API);` --- # libs/bidiEngine.js - Documentation libs/bidiEngine.js ================== 1. `/**` 2. `* @license` 3. `* Unicode Bidi Engine based on the work of Alex Shensis (@asthensis)` 4. `* MIT License` 5. `*/` 7. `import { jsPDF } from "../jspdf.js";` 9. `(function(jsPDF) {` 10. `"use strict";` 11. `/**` 12. `* Table of Unicode types.` 13. `*` 14. `* Generated by:` 15. `*` 16. `* var bidi = require("./bidi/index");` 17. `* var bidi_accumulate = bidi.slice(0, 256).concat(bidi.slice(0x0500, 0x0500 + 256 * 3)).` 18. `* concat(bidi.slice(0x2000, 0x2000 + 256)).concat(bidi.slice(0xFB00, 0xFB00 + 256)).` 19. `* concat(bidi.slice(0xFE00, 0xFE00 + 2 * 256));` 20. `*` 21. `* for( var i = 0; i < bidi_accumulate.length; i++) {` 22. `* if(bidi_accumulate[i] === undefined || bidi_accumulate[i] === 'ON')` 23. `* bidi_accumulate[i] = 'N'; //mark as neutral to conserve space and substitute undefined` 24. `* }` 25. `* var bidiAccumulateStr = 'return [ "' + bidi_accumulate.toString().replace(/,/g, '", "') + '" ];';` 26. `* require("fs").writeFile('unicode-types.js', bidiAccumulateStr);` 27. `*` 28. `* Based on:` 29. `* https://github.com/mathiasbynens/unicode-8.0.0` 30. `*/` 31. `var bidiUnicodeTypes = [`\ 32. `"BN",`\ 33. `"BN",`\ 34. `"BN",`\ 35. `"BN",`\ 36. `"BN",`\ 37. `"BN",`\ 38. `"BN",`\ 39. `"BN",`\ 40. `"BN",`\ 41. `"S",`\ 42. `"B",`\ 43. `"S",`\ 44. `"WS",`\ 45. `"B",`\ 46. `"BN",`\ 47. `"BN",`\ 48. `"BN",`\ 49. `"BN",`\ 50. `"BN",`\ 51. `"BN",`\ 52. `"BN",`\ 53. `"BN",`\ 54. `"BN",`\ 55. `"BN",`\ 56. `"BN",`\ 57. `"BN",`\ 58. `"BN",`\ 59. `"BN",`\ 60. `"B",`\ 61. `"B",`\ 62. `"B",`\ 63. `"S",`\ 64. `"WS",`\ 65. `"N",`\ 66. `"N",`\ 67. `"ET",`\ 68. `"ET",`\ 69. `"ET",`\ 70. `"N",`\ 71. `"N",`\ 72. `"N",`\ 73. `"N",`\ 74. `"N",`\ 75. `"ES",`\ 76. `"CS",`\ 77. `"ES",`\ 78. `"CS",`\ 79. `"CS",`\ 80. `"EN",`\ 81. `"EN",`\ 82. `"EN",`\ 83. `"EN",`\ 84. `"EN",`\ 85. `"EN",`\ 86. `"EN",`\ 87. `"EN",`\ 88. `"EN",`\ 89. `"EN",`\ 90. `"CS",`\ 91. `"N",`\ 92. `"N",`\ 93. `"N",`\ 94. `"N",`\ 95. `"N",`\ 96. `"N",`\ 97. `"L",`\ 98. `"L",`\ 99. `"L",`\ 100. `"L",`\ 101. `"L",`\ 102. `"L",`\ 103. `"L",`\ 104. `"L",`\ 105. `"L",`\ 106. `"L",`\ 107. `"L",`\ 108. `"L",`\ 109. `"L",`\ 110. `"L",`\ 111. `"L",`\ 112. `"L",`\ 113. `"L",`\ 114. `"L",`\ 115. `"L",`\ 116. `"L",`\ 117. `"L",`\ 118. `"L",`\ 119. `"L",`\ 120. `"L",`\ 121. `"L",`\ 122. `"L",`\ 123. `"N",`\ 124. `"N",`\ 125. `"N",`\ 126. `"N",`\ 127. `"N",`\ 128. `"N",`\ 129. `"L",`\ 130. `"L",`\ 131. `"L",`\ 132. `"L",`\ 133. `"L",`\ 134. `"L",`\ 135. `"L",`\ 136. `"L",`\ 137. `"L",`\ 138. `"L",`\ 139. `"L",`\ 140. `"L",`\ 141. `"L",`\ 142. `"L",`\ 143. `"L",`\ 144. `"L",`\ 145. `"L",`\ 146. `"L",`\ 147. `"L",`\ 148. `"L",`\ 149. `"L",`\ 150. `"L",`\ 151. `"L",`\ 152. `"L",`\ 153. `"L",`\ 154. `"L",`\ 155. `"N",`\ 156. `"N",`\ 157. `"N",`\ 158. `"N",`\ 159. `"BN",`\ 160. `"BN",`\ 161. `"BN",`\ 162. `"BN",`\ 163. `"BN",`\ 164. `"BN",`\ 165. `"B",`\ 166. `"BN",`\ 167. `"BN",`\ 168. `"BN",`\ 169. `"BN",`\ 170. `"BN",`\ 171. `"BN",`\ 172. `"BN",`\ 173. `"BN",`\ 174. `"BN",`\ 175. `"BN",`\ 176. `"BN",`\ 177. `"BN",`\ 178. `"BN",`\ 179. `"BN",`\ 180. `"BN",`\ 181. `"BN",`\ 182. `"BN",`\ 183. `"BN",`\ 184. `"BN",`\ 185. `"BN",`\ 186. `"BN",`\ 187. `"BN",`\ 188. `"BN",`\ 189. `"BN",`\ 190. `"BN",`\ 191. `"BN",`\ 192. `"CS",`\ 193. `"N",`\ 194. `"ET",`\ 195. `"ET",`\ 196. `"ET",`\ 197. `"ET",`\ 198. `"N",`\ 199. `"N",`\ 200. `"N",`\ 201. `"N",`\ 202. `"L",`\ 203. `"N",`\ 204. `"N",`\ 205. `"BN",`\ 206. `"N",`\ 207. `"N",`\ 208. `"ET",`\ 209. `"ET",`\ 210. `"EN",`\ 211. `"EN",`\ 212. `"N",`\ 213. `"L",`\ 214. `"N",`\ 215. `"N",`\ 216. `"N",`\ 217. `"EN",`\ 218. `"L",`\ 219. `"N",`\ 220. `"N",`\ 221. `"N",`\ 222. `"N",`\ 223. `"N",`\ 224. `"L",`\ 225. `"L",`\ 226. `"L",`\ 227. `"L",`\ 228. `"L",`\ 229. `"L",`\ 230. `"L",`\ 231. `"L",`\ 232. `"L",`\ 233. `"L",`\ 234. `"L",`\ 235. `"L",`\ 236. `"L",`\ 237. `"L",`\ 238. `"L",`\ 239. `"L",`\ 240. `"L",`\ 241. `"L",`\ 242. `"L",`\ 243. `"L",`\ 244. `"L",`\ 245. `"L",`\ 246. `"L",`\ 247. `"N",`\ 248. `"L",`\ 249. `"L",`\ 250. `"L",`\ 251. `"L",`\ 252. `"L",`\ 253. `"L",`\ 254. `"L",`\ 255. `"L",`\ 256. `"L",`\ 257. `"L",`\ 258. `"L",`\ 259. `"L",`\ 260. `"L",`\ 261. `"L",`\ 262. `"L",`\ 263. `"L",`\ 264. `"L",`\ 265. `"L",`\ 266. `"L",`\ 267. `"L",`\ 268. `"L",`\ 269. `"L",`\ 270. `"L",`\ 271. `"L",`\ 272. `"L",`\ 273. `"L",`\ 274. `"L",`\ 275. `"L",`\ 276. `"L",`\ 277. `"L",`\ 278. `"L",`\ 279. `"N",`\ 280. `"L",`\ 281. `"L",`\ 282. `"L",`\ 283. `"L",`\ 284. `"L",`\ 285. `"L",`\ 286. `"L",`\ 287. `"L",`\ 288. `"L",`\ 289. `"L",`\ 290. `"L",`\ 291. `"L",`\ 292. `"L",`\ 293. `"L",`\ 294. `"L",`\ 295. `"L",`\ 296. `"L",`\ 297. `"L",`\ 298. `"L",`\ 299. `"L",`\ 300. `"L",`\ 301. `"L",`\ 302. `"L",`\ 303. `"L",`\ 304. `"L",`\ 305. `"L",`\ 306. `"L",`\ 307. `"L",`\ 308. `"L",`\ 309. `"L",`\ 310. `"L",`\ 311. `"L",`\ 312. `"L",`\ 313. `"L",`\ 314. `"L",`\ 315. `"L",`\ 316. `"L",`\ 317. `"L",`\ 318. `"L",`\ 319. `"L",`\ 320. `"L",`\ 321. `"L",`\ 322. `"L",`\ 323. `"L",`\ 324. `"L",`\ 325. `"L",`\ 326. `"L",`\ 327. `"L",`\ 328. `"L",`\ 329. `"L",`\ 330. `"L",`\ 331. `"L",`\ 332. `"L",`\ 333. `"L",`\ 334. `"L",`\ 335. `"L",`\ 336. `"N",`\ 337. `"L",`\ 338. `"L",`\ 339. `"L",`\ 340. `"L",`\ 341. `"L",`\ 342. `"L",`\ 343. `"L",`\ 344. `"L",`\ 345. `"L",`\ 346. `"L",`\ 347. `"L",`\ 348. `"L",`\ 349. `"L",`\ 350. `"L",`\ 351. `"L",`\ 352. `"L",`\ 353. `"L",`\ 354. `"L",`\ 355. `"L",`\ 356. `"L",`\ 357. `"L",`\ 358. `"L",`\ 359. `"L",`\ 360. `"L",`\ 361. `"L",`\ 362. `"L",`\ 363. `"L",`\ 364. `"L",`\ 365. `"L",`\ 366. `"L",`\ 367. `"L",`\ 368. `"L",`\ 369. `"L",`\ 370. `"L",`\ 371. `"L",`\ 372. `"L",`\ 373. `"L",`\ 374. `"L",`\ 375. `"N",`\ 376. `"N",`\ 377. `"L",`\ 378. `"L",`\ 379. `"L",`\ 380. `"L",`\ 381. `"L",`\ 382. `"L",`\ 383. `"L",`\ 384. `"N",`\ 385. `"L",`\ 386. `"L",`\ 387. `"L",`\ 388. `"L",`\ 389. `"L",`\ 390. `"L",`\ 391. `"L",`\ 392. `"L",`\ 393. `"L",`\ 394. `"L",`\ 395. `"L",`\ 396. `"L",`\ 397. `"L",`\ 398. `"L",`\ 399. `"L",`\ 400. `"L",`\ 401. `"L",`\ 402. `"L",`\ 403. `"L",`\ 404. `"L",`\ 405. `"L",`\ 406. `"L",`\ 407. `"L",`\ 408. `"L",`\ 409. `"L",`\ 410. `"L",`\ 411. `"L",`\ 412. `"L",`\ 413. `"L",`\ 414. `"L",`\ 415. `"L",`\ 416. `"L",`\ 417. `"L",`\ 418. `"L",`\ 419. `"L",`\ 420. `"L",`\ 421. `"L",`\ 422. `"L",`\ 423. `"L",`\ 424. `"N",`\ 425. `"L",`\ 426. `"N",`\ 427. `"N",`\ 428. `"N",`\ 429. `"N",`\ 430. `"N",`\ 431. `"ET",`\ 432. `"N",`\ 433. `"NSM",`\ 434. `"NSM",`\ 435. `"NSM",`\ 436. `"NSM",`\ 437. `"NSM",`\ 438. `"NSM",`\ 439. `"NSM",`\ 440. `"NSM",`\ 441. `"NSM",`\ 442. `"NSM",`\ 443. `"NSM",`\ 444. `"NSM",`\ 445. `"NSM",`\ 446. `"NSM",`\ 447. `"NSM",`\ 448. `"NSM",`\ 449. `"NSM",`\ 450. `"NSM",`\ 451. `"NSM",`\ 452. `"NSM",`\ 453. `"NSM",`\ 454. `"NSM",`\ 455. `"NSM",`\ 456. `"NSM",`\ 457. `"NSM",`\ 458. `"NSM",`\ 459. `"NSM",`\ 460. `"NSM",`\ 461. `"NSM",`\ 462. `"NSM",`\ 463. `"NSM",`\ 464. `"NSM",`\ 465. `"NSM",`\ 466. `"NSM",`\ 467. `"NSM",`\ 468. `"NSM",`\ 469. `"NSM",`\ 470. `"NSM",`\ 471. `"NSM",`\ 472. `"NSM",`\ 473. `"NSM",`\ 474. `"NSM",`\ 475. `"NSM",`\ 476. `"NSM",`\ 477. `"NSM",`\ 478. `"R",`\ 479. `"NSM",`\ 480. `"R",`\ 481. `"NSM",`\ 482. `"NSM",`\ 483. `"R",`\ 484. `"NSM",`\ 485. `"NSM",`\ 486. `"R",`\ 487. `"NSM",`\ 488. `"N",`\ 489. `"N",`\ 490. `"N",`\ 491. `"N",`\ 492. `"N",`\ 493. `"N",`\ 494. `"N",`\ 495. `"N",`\ 496. `"R",`\ 497. `"R",`\ 498. `"R",`\ 499. `"R",`\ 500. `"R",`\ 501. `"R",`\ 502. `"R",`\ 503. `"R",`\ 504. `"R",`\ 505. `"R",`\ 506. `"R",`\ 507. `"R",`\ 508. `"R",`\ 509. `"R",`\ 510. `"R",`\ 511. `"R",`\ 512. `"R",`\ 513. `"R",`\ 514. `"R",`\ 515. `"R",`\ 516. `"R",`\ 517. `"R",`\ 518. `"R",`\ 519. `"R",`\ 520. `"R",`\ 521. `"R",`\ 522. `"R",`\ 523. `"N",`\ 524. `"N",`\ 525. `"N",`\ 526. `"N",`\ 527. `"N",`\ 528. `"R",`\ 529. `"R",`\ 530. `"R",`\ 531. `"R",`\ 532. `"R",`\ 533. `"N",`\ 534. `"N",`\ 535. `"N",`\ 536. `"N",`\ 537. `"N",`\ 538. `"N",`\ 539. `"N",`\ 540. `"N",`\ 541. `"N",`\ 542. `"N",`\ 543. `"N",`\ 544. `"AN",`\ 545. `"AN",`\ 546. `"AN",`\ 547. `"AN",`\ 548. `"AN",`\ 549. `"AN",`\ 550. `"N",`\ 551. `"N",`\ 552. `"AL",`\ 553. `"ET",`\ 554. `"ET",`\ 555. `"AL",`\ 556. `"CS",`\ 557. `"AL",`\ 558. `"N",`\ 559. `"N",`\ 560. `"NSM",`\ 561. `"NSM",`\ 562. `"NSM",`\ 563. `"NSM",`\ 564. `"NSM",`\ 565. `"NSM",`\ 566. `"NSM",`\ 567. `"NSM",`\ 568. `"NSM",`\ 569. `"NSM",`\ 570. `"NSM",`\ 571. `"AL",`\ 572. `"AL",`\ 573. `"N",`\ 574. `"AL",`\ 575. `"AL",`\ 576. `"AL",`\ 577. `"AL",`\ 578. `"AL",`\ 579. `"AL",`\ 580. `"AL",`\ 581. `"AL",`\ 582. `"AL",`\ 583. `"AL",`\ 584. `"AL",`\ 585. `"AL",`\ 586. `"AL",`\ 587. `"AL",`\ 588. `"AL",`\ 589. `"AL",`\ 590. `"AL",`\ 591. `"AL",`\ 592. `"AL",`\ 593. `"AL",`\ 594. `"AL",`\ 595. `"AL",`\ 596. `"AL",`\ 597. `"AL",`\ 598. `"AL",`\ 599. `"AL",`\ 600. `"AL",`\ 601. `"AL",`\ 602. `"AL",`\ 603. `"AL",`\ 604. `"AL",`\ 605. `"AL",`\ 606. `"AL",`\ 607. `"AL",`\ 608. `"AL",`\ 609. `"AL",`\ 610. `"AL",`\ 611. `"AL",`\ 612. `"AL",`\ 613. `"AL",`\ 614. `"AL",`\ 615. `"AL",`\ 616. `"AL",`\ 617. `"AL",`\ 618. `"AL",`\ 619. `"NSM",`\ 620. `"NSM",`\ 621. `"NSM",`\ 622. `"NSM",`\ 623. `"NSM",`\ 624. `"NSM",`\ 625. `"NSM",`\ 626. `"NSM",`\ 627. `"NSM",`\ 628. `"NSM",`\ 629. `"NSM",`\ 630. `"NSM",`\ 631. `"NSM",`\ 632. `"NSM",`\ 633. `"NSM",`\ 634. `"NSM",`\ 635. `"NSM",`\ 636. `"NSM",`\ 637. `"NSM",`\ 638. `"NSM",`\ 639. `"NSM",`\ 640. `"AN",`\ 641. `"AN",`\ 642. `"AN",`\ 643. `"AN",`\ 644. `"AN",`\ 645. `"AN",`\ 646. `"AN",`\ 647. `"AN",`\ 648. `"AN",`\ 649. `"AN",`\ 650. `"ET",`\ 651. `"AN",`\ 652. `"AN",`\ 653. `"AL",`\ 654. `"AL",`\ 655. `"AL",`\ 656. `"NSM",`\ 657. `"AL",`\ 658. `"AL",`\ 659. `"AL",`\ 660. `"AL",`\ 661. `"AL",`\ 662. `"AL",`\ 663. `"AL",`\ 664. `"AL",`\ 665. `"AL",`\ 666. `"AL",`\ 667. `"AL",`\ 668. `"AL",`\ 669. `"AL",`\ 670. `"AL",`\ 671. `"AL",`\ 672. `"AL",`\ 673. `"AL",`\ 674. `"AL",`\ 675. `"AL",`\ 676. `"AL",`\ 677. `"AL",`\ 678. `"AL",`\ 679. `"AL",`\ 680. `"AL",`\ 681. `"AL",`\ 682. `"AL",`\ 683. `"AL",`\ 684. `"AL",`\ 685. `"AL",`\ 686. `"AL",`\ 687. `"AL",`\ 688. `"AL",`\ 689. `"AL",`\ 690. `"AL",`\ 691. `"AL",`\ 692. `"AL",`\ 693. `"AL",`\ 694. `"AL",`\ 695. `"AL",`\ 696. `"AL",`\ 697. `"AL",`\ 698. `"AL",`\ 699. `"AL",`\ 700. `"AL",`\ 701. `"AL",`\ 702. `"AL",`\ 703. `"AL",`\ 704. `"AL",`\ 705. `"AL",`\ 706. `"AL",`\ 707. `"AL",`\ 708. `"AL",`\ 709. `"AL",`\ 710. `"AL",`\ 711. `"AL",`\ 712. `"AL",`\ 713. `"AL",`\ 714. `"AL",`\ 715. `"AL",`\ 716. `"AL",`\ 717. `"AL",`\ 718. `"AL",`\ 719. `"AL",`\ 720. `"AL",`\ 721. `"AL",`\ 722. `"AL",`\ 723. `"AL",`\ 724. `"AL",`\ 725. `"AL",`\ 726. `"AL",`\ 727. `"AL",`\ 728. `"AL",`\ 729. `"AL",`\ 730. `"AL",`\ 731. `"AL",`\ 732. `"AL",`\ 733. `"AL",`\ 734. `"AL",`\ 735. `"AL",`\ 736. `"AL",`\ 737. `"AL",`\ 738. `"AL",`\ 739. `"AL",`\ 740. `"AL",`\ 741. `"AL",`\ 742. `"AL",`\ 743. `"AL",`\ 744. `"AL",`\ 745. `"AL",`\ 746. `"AL",`\ 747. `"AL",`\ 748. `"AL",`\ 749. `"AL",`\ 750. `"AL",`\ 751. `"AL",`\ 752. `"AL",`\ 753. `"AL",`\ 754. `"AL",`\ 755. `"AL",`\ 756. `"AL",`\ 757. `"AL",`\ 758. `"NSM",`\ 759. `"NSM",`\ 760. `"NSM",`\ 761. `"NSM",`\ 762. `"NSM",`\ 763. `"NSM",`\ 764. `"NSM",`\ 765. `"AN",`\ 766. `"N",`\ 767. `"NSM",`\ 768. `"NSM",`\ 769. `"NSM",`\ 770. `"NSM",`\ 771. `"NSM",`\ 772. `"NSM",`\ 773. `"AL",`\ 774. `"AL",`\ 775. `"NSM",`\ 776. `"NSM",`\ 777. `"N",`\ 778. `"NSM",`\ 779. `"NSM",`\ 780. `"NSM",`\ 781. `"NSM",`\ 782. `"AL",`\ 783. `"AL",`\ 784. `"EN",`\ 785. `"EN",`\ 786. `"EN",`\ 787. `"EN",`\ 788. `"EN",`\ 789. `"EN",`\ 790. `"EN",`\ 791. `"EN",`\ 792. `"EN",`\ 793. `"EN",`\ 794. `"AL",`\ 795. `"AL",`\ 796. `"AL",`\ 797. `"AL",`\ 798. `"AL",`\ 799. `"AL",`\ 800. `"AL",`\ 801. `"AL",`\ 802. `"AL",`\ 803. `"AL",`\ 804. `"AL",`\ 805. `"AL",`\ 806. `"AL",`\ 807. `"AL",`\ 808. `"AL",`\ 809. `"AL",`\ 810. `"AL",`\ 811. `"AL",`\ 812. `"AL",`\ 813. `"AL",`\ 814. `"N",`\ 815. `"AL",`\ 816. `"AL",`\ 817. `"NSM",`\ 818. `"AL",`\ 819. `"AL",`\ 820. `"AL",`\ 821. `"AL",`\ 822. `"AL",`\ 823. `"AL",`\ 824. `"AL",`\ 825. `"AL",`\ 826. `"AL",`\ 827. `"AL",`\ 828. `"AL",`\ 829. `"AL",`\ 830. `"AL",`\ 831. `"AL",`\ 832. `"AL",`\ 833. `"AL",`\ 834. `"AL",`\ 835. `"AL",`\ 836. `"AL",`\ 837. `"AL",`\ 838. `"AL",`\ 839. `"AL",`\ 840. `"AL",`\ 841. `"AL",`\ 842. `"AL",`\ 843. `"AL",`\ 844. `"AL",`\ 845. `"AL",`\ 846. `"AL",`\ 847. `"AL",`\ 848. `"NSM",`\ 849. `"NSM",`\ 850. `"NSM",`\ 851. `"NSM",`\ 852. `"NSM",`\ 853. `"NSM",`\ 854. `"NSM",`\ 855. `"NSM",`\ 856. `"NSM",`\ 857. `"NSM",`\ 858. `"NSM",`\ 859. `"NSM",`\ 860. `"NSM",`\ 861. `"NSM",`\ 862. `"NSM",`\ 863. `"NSM",`\ 864. `"NSM",`\ 865. `"NSM",`\ 866. `"NSM",`\ 867. `"NSM",`\ 868. `"NSM",`\ 869. `"NSM",`\ 870. `"NSM",`\ 871. `"NSM",`\ 872. `"NSM",`\ 873. `"NSM",`\ 874. `"NSM",`\ 875. `"N",`\ 876. `"N",`\ 877. `"AL",`\ 878. `"AL",`\ 879. `"AL",`\ 880. `"AL",`\ 881. `"AL",`\ 882. `"AL",`\ 883. `"AL",`\ 884. `"AL",`\ 885. `"AL",`\ 886. `"AL",`\ 887. `"AL",`\ 888. `"AL",`\ 889. `"AL",`\ 890. `"AL",`\ 891. `"AL",`\ 892. `"AL",`\ 893. `"AL",`\ 894. `"AL",`\ 895. `"AL",`\ 896. `"AL",`\ 897. `"AL",`\ 898. `"AL",`\ 899. `"AL",`\ 900. `"AL",`\ 901. `"AL",`\ 902. `"AL",`\ 903. `"AL",`\ 904. `"AL",`\ 905. `"AL",`\ 906. `"AL",`\ 907. `"AL",`\ 908. `"AL",`\ 909. `"AL",`\ 910. `"AL",`\ 911. `"AL",`\ 912. `"AL",`\ 913. `"AL",`\ 914. `"AL",`\ 915. `"AL",`\ 916. `"AL",`\ 917. `"AL",`\ 918. `"AL",`\ 919. `"AL",`\ 920. `"AL",`\ 921. `"AL",`\ 922. `"AL",`\ 923. `"AL",`\ 924. `"AL",`\ 925. `"AL",`\ 926. `"AL",`\ 927. `"AL",`\ 928. `"AL",`\ 929. `"AL",`\ 930. `"AL",`\ 931. `"AL",`\ 932. `"AL",`\ 933. `"AL",`\ 934. `"AL",`\ 935. `"AL",`\ 936. `"AL",`\ 937. `"AL",`\ 938. `"AL",`\ 939. `"AL",`\ 940. `"AL",`\ 941. `"AL",`\ 942. `"AL",`\ 943. `"AL",`\ 944. `"AL",`\ 945. `"AL",`\ 946. `"AL",`\ 947. `"AL",`\ 948. `"AL",`\ 949. `"AL",`\ 950. `"AL",`\ 951. `"AL",`\ 952. `"AL",`\ 953. `"AL",`\ 954. `"AL",`\ 955. `"AL",`\ 956. `"AL",`\ 957. `"AL",`\ 958. `"AL",`\ 959. `"AL",`\ 960. `"AL",`\ 961. `"AL",`\ 962. `"AL",`\ 963. `"AL",`\ 964. `"AL",`\ 965. `"AL",`\ 966. `"NSM",`\ 967. `"NSM",`\ 968. `"NSM",`\ 969. `"NSM",`\ 970. `"NSM",`\ 971. `"NSM",`\ 972. `"NSM",`\ 973. `"NSM",`\ 974. `"NSM",`\ 975. `"NSM",`\ 976. `"NSM",`\ 977. `"AL",`\ 978. `"N",`\ 979. `"N",`\ 980. `"N",`\ 981. `"N",`\ 982. `"N",`\ 983. `"N",`\ 984. `"N",`\ 985. `"N",`\ 986. `"N",`\ 987. `"N",`\ 988. `"N",`\ 989. `"N",`\ 990. `"N",`\ 991. `"N",`\ 992. `"R",`\ 993. `"R",`\ 994. `"R",`\ 995. `"R",`\ 996. `"R",`\ 997. `"R",`\ 998. `"R",`\ 999. `"R",`\ 1000. `"R",`\ 1001. `"R",`\ 1002. `"R",`\ 1003. `"R",`\ 1004. `"R",`\ 1005. `"R",`\ 1006. `"R",`\ 1007. `"R",`\ 1008. `"R",`\ 1009. `"R",`\ 1010. `"R",`\ 1011. `"R",`\ 1012. `"R",`\ 1013. `"R",`\ 1014. `"R",`\ 1015. `"R",`\ 1016. `"R",`\ 1017. `"R",`\ 1018. `"R",`\ 1019. `"R",`\ 1020. `"R",`\ 1021. `"R",`\ 1022. `"R",`\ 1023. `"R",`\ 1024. `"R",`\ 1025. `"R",`\ 1026. `"R",`\ 1027. `"R",`\ 1028. `"R",`\ 1029. `"R",`\ 1030. `"R",`\ 1031. `"R",`\ 1032. `"R",`\ 1033. `"R",`\ 1034. `"R",`\ 1035. `"NSM",`\ 1036. `"NSM",`\ 1037. `"NSM",`\ 1038. `"NSM",`\ 1039. `"NSM",`\ 1040. `"NSM",`\ 1041. `"NSM",`\ 1042. `"NSM",`\ 1043. `"NSM",`\ 1044. `"R",`\ 1045. `"R",`\ 1046. `"N",`\ 1047. `"N",`\ 1048. `"N",`\ 1049. `"N",`\ 1050. `"R",`\ 1051. `"N",`\ 1052. `"N",`\ 1053. `"N",`\ 1054. `"N",`\ 1055. `"N",`\ 1056. `"WS",`\ 1057. `"WS",`\ 1058. `"WS",`\ 1059. `"WS",`\ 1060. `"WS",`\ 1061. `"WS",`\ 1062. `"WS",`\ 1063. `"WS",`\ 1064. `"WS",`\ 1065. `"WS",`\ 1066. `"WS",`\ 1067. `"BN",`\ 1068. `"BN",`\ 1069. `"BN",`\ 1070. `"L",`\ 1071. `"R",`\ 1072. `"N",`\ 1073. `"N",`\ 1074. `"N",`\ 1075. `"N",`\ 1076. `"N",`\ 1077. `"N",`\ 1078. `"N",`\ 1079. `"N",`\ 1080. `"N",`\ 1081. `"N",`\ 1082. `"N",`\ 1083. `"N",`\ 1084. `"N",`\ 1085. `"N",`\ 1086. `"N",`\ 1087. `"N",`\ 1088. `"N",`\ 1089. `"N",`\ 1090. `"N",`\ 1091. `"N",`\ 1092. `"N",`\ 1093. `"N",`\ 1094. `"N",`\ 1095. `"N",`\ 1096. `"WS",`\ 1097. `"B",`\ 1098. `"LRE",`\ 1099. `"RLE",`\ 1100. `"PDF",`\ 1101. `"LRO",`\ 1102. `"RLO",`\ 1103. `"CS",`\ 1104. `"ET",`\ 1105. `"ET",`\ 1106. `"ET",`\ 1107. `"ET",`\ 1108. `"ET",`\ 1109. `"N",`\ 1110. `"N",`\ 1111. `"N",`\ 1112. `"N",`\ 1113. `"N",`\ 1114. `"N",`\ 1115. `"N",`\ 1116. `"N",`\ 1117. `"N",`\ 1118. `"N",`\ 1119. `"N",`\ 1120. `"N",`\ 1121. `"N",`\ 1122. `"N",`\ 1123. `"N",`\ 1124. `"CS",`\ 1125. `"N",`\ 1126. `"N",`\ 1127. `"N",`\ 1128. `"N",`\ 1129. `"N",`\ 1130. `"N",`\ 1131. `"N",`\ 1132. `"N",`\ 1133. `"N",`\ 1134. `"N",`\ 1135. `"N",`\ 1136. `"N",`\ 1137. `"N",`\ 1138. `"N",`\ 1139. `"N",`\ 1140. `"N",`\ 1141. `"N",`\ 1142. `"N",`\ 1143. `"N",`\ 1144. `"N",`\ 1145. `"N",`\ 1146. `"N",`\ 1147. `"N",`\ 1148. `"N",`\ 1149. `"N",`\ 1150. `"N",`\ 1151. `"WS",`\ 1152. `"BN",`\ 1153. `"BN",`\ 1154. `"BN",`\ 1155. `"BN",`\ 1156. `"BN",`\ 1157. `"N",`\ 1158. `"LRI",`\ 1159. `"RLI",`\ 1160. `"FSI",`\ 1161. `"PDI",`\ 1162. `"BN",`\ 1163. `"BN",`\ 1164. `"BN",`\ 1165. `"BN",`\ 1166. `"BN",`\ 1167. `"BN",`\ 1168. `"EN",`\ 1169. `"L",`\ 1170. `"N",`\ 1171. `"N",`\ 1172. `"EN",`\ 1173. `"EN",`\ 1174. `"EN",`\ 1175. `"EN",`\ 1176. `"EN",`\ 1177. `"EN",`\ 1178. `"ES",`\ 1179. `"ES",`\ 1180. `"N",`\ 1181. `"N",`\ 1182. `"N",`\ 1183. `"L",`\ 1184. `"EN",`\ 1185. `"EN",`\ 1186. `"EN",`\ 1187. `"EN",`\ 1188. `"EN",`\ 1189. `"EN",`\ 1190. `"EN",`\ 1191. `"EN",`\ 1192. `"EN",`\ 1193. `"EN",`\ 1194. `"ES",`\ 1195. `"ES",`\ 1196. `"N",`\ 1197. `"N",`\ 1198. `"N",`\ 1199. `"N",`\ 1200. `"L",`\ 1201. `"L",`\ 1202. `"L",`\ 1203. `"L",`\ 1204. `"L",`\ 1205. `"L",`\ 1206. `"L",`\ 1207. `"L",`\ 1208. `"L",`\ 1209. `"L",`\ 1210. `"L",`\ 1211. `"L",`\ 1212. `"L",`\ 1213. `"N",`\ 1214. `"N",`\ 1215. `"N",`\ 1216. `"ET",`\ 1217. `"ET",`\ 1218. `"ET",`\ 1219. `"ET",`\ 1220. `"ET",`\ 1221. `"ET",`\ 1222. `"ET",`\ 1223. `"ET",`\ 1224. `"ET",`\ 1225. `"ET",`\ 1226. `"ET",`\ 1227. `"ET",`\ 1228. `"ET",`\ 1229. `"ET",`\ 1230. `"ET",`\ 1231. `"ET",`\ 1232. `"ET",`\ 1233. `"ET",`\ 1234. `"ET",`\ 1235. `"ET",`\ 1236. `"ET",`\ 1237. `"ET",`\ 1238. `"ET",`\ 1239. `"ET",`\ 1240. `"ET",`\ 1241. `"ET",`\ 1242. `"ET",`\ 1243. `"ET",`\ 1244. `"ET",`\ 1245. `"ET",`\ 1246. `"ET",`\ 1247. `"N",`\ 1248. `"N",`\ 1249. `"N",`\ 1250. `"N",`\ 1251. `"N",`\ 1252. `"N",`\ 1253. `"N",`\ 1254. `"N",`\ 1255. `"N",`\ 1256. `"N",`\ 1257. `"N",`\ 1258. `"N",`\ 1259. `"N",`\ 1260. `"N",`\ 1261. `"N",`\ 1262. `"N",`\ 1263. `"N",`\ 1264. `"NSM",`\ 1265. `"NSM",`\ 1266. `"NSM",`\ 1267. `"NSM",`\ 1268. `"NSM",`\ 1269. `"NSM",`\ 1270. `"NSM",`\ 1271. `"NSM",`\ 1272. `"NSM",`\ 1273. `"NSM",`\ 1274. `"NSM",`\ 1275. `"NSM",`\ 1276. `"NSM",`\ 1277. `"NSM",`\ 1278. `"NSM",`\ 1279. `"NSM",`\ 1280. `"NSM",`\ 1281. `"NSM",`\ 1282. `"NSM",`\ 1283. `"NSM",`\ 1284. `"NSM",`\ 1285. `"NSM",`\ 1286. `"NSM",`\ 1287. `"NSM",`\ 1288. `"NSM",`\ 1289. `"NSM",`\ 1290. `"NSM",`\ 1291. `"NSM",`\ 1292. `"NSM",`\ 1293. `"NSM",`\ 1294. `"NSM",`\ 1295. `"NSM",`\ 1296. `"NSM",`\ 1297. `"N",`\ 1298. `"N",`\ 1299. `"N",`\ 1300. `"N",`\ 1301. `"N",`\ 1302. `"N",`\ 1303. `"N",`\ 1304. `"N",`\ 1305. `"N",`\ 1306. `"N",`\ 1307. `"N",`\ 1308. `"N",`\ 1309. `"N",`\ 1310. `"N",`\ 1311. `"N",`\ 1312. `"L",`\ 1313. `"L",`\ 1314. `"L",`\ 1315. `"L",`\ 1316. `"L",`\ 1317. `"L",`\ 1318. `"L",`\ 1319. `"N",`\ 1320. `"N",`\ 1321. `"N",`\ 1322. `"N",`\ 1323. `"N",`\ 1324. `"N",`\ 1325. `"N",`\ 1326. `"N",`\ 1327. `"N",`\ 1328. `"N",`\ 1329. `"N",`\ 1330. `"N",`\ 1331. `"L",`\ 1332. `"L",`\ 1333. `"L",`\ 1334. `"L",`\ 1335. `"L",`\ 1336. `"N",`\ 1337. `"N",`\ 1338. `"N",`\ 1339. `"N",`\ 1340. `"N",`\ 1341. `"R",`\ 1342. `"NSM",`\ 1343. `"R",`\ 1344. `"R",`\ 1345. `"R",`\ 1346. `"R",`\ 1347. `"R",`\ 1348. `"R",`\ 1349. `"R",`\ 1350. `"R",`\ 1351. `"R",`\ 1352. `"R",`\ 1353. `"ES",`\ 1354. `"R",`\ 1355. `"R",`\ 1356. `"R",`\ 1357. `"R",`\ 1358. `"R",`\ 1359. `"R",`\ 1360. `"R",`\ 1361. `"R",`\ 1362. `"R",`\ 1363. `"R",`\ 1364. `"R",`\ 1365. `"R",`\ 1366. `"R",`\ 1367. `"N",`\ 1368. `"R",`\ 1369. `"R",`\ 1370. `"R",`\ 1371. `"R",`\ 1372. `"R",`\ 1373. `"N",`\ 1374. `"R",`\ 1375. `"N",`\ 1376. `"R",`\ 1377. `"R",`\ 1378. `"N",`\ 1379. `"R",`\ 1380. `"R",`\ 1381. `"N",`\ 1382. `"R",`\ 1383. `"R",`\ 1384. `"R",`\ 1385. `"R",`\ 1386. `"R",`\ 1387. `"R",`\ 1388. `"R",`\ 1389. `"R",`\ 1390. `"R",`\ 1391. `"R",`\ 1392. `"AL",`\ 1393. `"AL",`\ 1394. `"AL",`\ 1395. `"AL",`\ 1396. `"AL",`\ 1397. `"AL",`\ 1398. `"AL",`\ 1399. `"AL",`\ 1400. `"AL",`\ 1401. `"AL",`\ 1402. `"AL",`\ 1403. `"AL",`\ 1404. `"AL",`\ 1405. `"AL",`\ 1406. `"AL",`\ 1407. `"AL",`\ 1408. `"AL",`\ 1409. `"AL",`\ 1410. `"AL",`\ 1411. `"AL",`\ 1412. `"AL",`\ 1413. `"AL",`\ 1414. `"AL",`\ 1415. `"AL",`\ 1416. `"AL",`\ 1417. `"AL",`\ 1418. `"AL",`\ 1419. `"AL",`\ 1420. `"AL",`\ 1421. `"AL",`\ 1422. `"AL",`\ 1423. `"AL",`\ 1424. `"AL",`\ 1425. `"AL",`\ 1426. `"AL",`\ 1427. `"AL",`\ 1428. `"AL",`\ 1429. `"AL",`\ 1430. `"AL",`\ 1431. `"AL",`\ 1432. `"AL",`\ 1433. `"AL",`\ 1434. `"AL",`\ 1435. `"AL",`\ 1436. `"AL",`\ 1437. `"AL",`\ 1438. `"AL",`\ 1439. `"AL",`\ 1440. `"AL",`\ 1441. `"AL",`\ 1442. `"AL",`\ 1443. `"AL",`\ 1444. `"AL",`\ 1445. `"AL",`\ 1446. `"AL",`\ 1447. `"AL",`\ 1448. `"AL",`\ 1449. `"AL",`\ 1450. `"AL",`\ 1451. `"AL",`\ 1452. `"AL",`\ 1453. `"AL",`\ 1454. `"AL",`\ 1455. `"AL",`\ 1456. `"AL",`\ 1457. `"AL",`\ 1458. `"AL",`\ 1459. `"AL",`\ 1460. `"AL",`\ 1461. `"AL",`\ 1462. `"AL",`\ 1463. `"AL",`\ 1464. `"AL",`\ 1465. `"AL",`\ 1466. `"AL",`\ 1467. `"AL",`\ 1468. `"AL",`\ 1469. `"AL",`\ 1470. `"AL",`\ 1471. `"AL",`\ 1472. `"AL",`\ 1473. `"AL",`\ 1474. `"AL",`\ 1475. `"AL",`\ 1476. `"AL",`\ 1477. `"AL",`\ 1478. `"AL",`\ 1479. `"AL",`\ 1480. `"AL",`\ 1481. `"AL",`\ 1482. `"AL",`\ 1483. `"AL",`\ 1484. `"AL",`\ 1485. `"AL",`\ 1486. `"AL",`\ 1487. `"AL",`\ 1488. `"AL",`\ 1489. `"AL",`\ 1490. `"AL",`\ 1491. `"AL",`\ 1492. `"AL",`\ 1493. `"AL",`\ 1494. `"AL",`\ 1495. `"AL",`\ 1496. `"AL",`\ 1497. `"AL",`\ 1498. `"AL",`\ 1499. `"AL",`\ 1500. `"AL",`\ 1501. `"AL",`\ 1502. `"AL",`\ 1503. `"AL",`\ 1504. `"AL",`\ 1505. `"AL",`\ 1506. `"N",`\ 1507. `"N",`\ 1508. `"N",`\ 1509. `"N",`\ 1510. `"N",`\ 1511. `"N",`\ 1512. `"N",`\ 1513. `"N",`\ 1514. `"N",`\ 1515. `"N",`\ 1516. `"N",`\ 1517. `"N",`\ 1518. `"N",`\ 1519. `"N",`\ 1520. `"N",`\ 1521. `"N",`\ 1522. `"N",`\ 1523. `"AL",`\ 1524. `"AL",`\ 1525. `"AL",`\ 1526. `"AL",`\ 1527. `"AL",`\ 1528. `"AL",`\ 1529. `"AL",`\ 1530. `"AL",`\ 1531. `"AL",`\ 1532. `"AL",`\ 1533. `"AL",`\ 1534. `"AL",`\ 1535. `"AL",`\ 1536. `"AL",`\ 1537. `"AL",`\ 1538. `"AL",`\ 1539. `"AL",`\ 1540. `"AL",`\ 1541. `"AL",`\ 1542. `"AL",`\ 1543. `"AL",`\ 1544. `"AL",`\ 1545. `"AL",`\ 1546. `"AL",`\ 1547. `"AL",`\ 1548. `"AL",`\ 1549. `"AL",`\ 1550. `"AL",`\ 1551. `"AL",`\ 1552. `"AL",`\ 1553. `"AL",`\ 1554. `"AL",`\ 1555. `"AL",`\ 1556. `"AL",`\ 1557. `"AL",`\ 1558. `"AL",`\ 1559. `"AL",`\ 1560. `"AL",`\ 1561. `"AL",`\ 1562. `"AL",`\ 1563. `"AL",`\ 1564. `"AL",`\ 1565. `"AL",`\ 1566. `"AL",`\ 1567. `"AL",`\ 1568. `"NSM",`\ 1569. `"NSM",`\ 1570. `"NSM",`\ 1571. `"NSM",`\ 1572. `"NSM",`\ 1573. `"NSM",`\ 1574. `"NSM",`\ 1575. `"NSM",`\ 1576. `"NSM",`\ 1577. `"NSM",`\ 1578. `"NSM",`\ 1579. `"NSM",`\ 1580. `"NSM",`\ 1581. `"NSM",`\ 1582. `"NSM",`\ 1583. `"NSM",`\ 1584. `"N",`\ 1585. `"N",`\ 1586. `"N",`\ 1587. `"N",`\ 1588. `"N",`\ 1589. `"N",`\ 1590. `"N",`\ 1591. `"N",`\ 1592. `"N",`\ 1593. `"N",`\ 1594. `"N",`\ 1595. `"N",`\ 1596. `"N",`\ 1597. `"N",`\ 1598. `"N",`\ 1599. `"N",`\ 1600. `"NSM",`\ 1601. `"NSM",`\ 1602. `"NSM",`\ 1603. `"NSM",`\ 1604. `"NSM",`\ 1605. `"NSM",`\ 1606. `"NSM",`\ 1607. `"NSM",`\ 1608. `"NSM",`\ 1609. `"NSM",`\ 1610. `"NSM",`\ 1611. `"NSM",`\ 1612. `"NSM",`\ 1613. `"NSM",`\ 1614. `"NSM",`\ 1615. `"NSM",`\ 1616. `"N",`\ 1617. `"N",`\ 1618. `"N",`\ 1619. `"N",`\ 1620. `"N",`\ 1621. `"N",`\ 1622. `"N",`\ 1623. `"N",`\ 1624. `"N",`\ 1625. `"N",`\ 1626. `"N",`\ 1627. `"N",`\ 1628. `"N",`\ 1629. `"N",`\ 1630. `"N",`\ 1631. `"N",`\ 1632. `"N",`\ 1633. `"N",`\ 1634. `"N",`\ 1635. `"N",`\ 1636. `"N",`\ 1637. `"N",`\ 1638. `"N",`\ 1639. `"N",`\ 1640. `"N",`\ 1641. `"N",`\ 1642. `"N",`\ 1643. `"N",`\ 1644. `"N",`\ 1645. `"N",`\ 1646. `"N",`\ 1647. `"N",`\ 1648. `"CS",`\ 1649. `"N",`\ 1650. `"CS",`\ 1651. `"N",`\ 1652. `"N",`\ 1653. `"CS",`\ 1654. `"N",`\ 1655. `"N",`\ 1656. `"N",`\ 1657. `"N",`\ 1658. `"N",`\ 1659. `"N",`\ 1660. `"N",`\ 1661. `"N",`\ 1662. `"N",`\ 1663. `"ET",`\ 1664. `"N",`\ 1665. `"N",`\ 1666. `"ES",`\ 1667. `"ES",`\ 1668. `"N",`\ 1669. `"N",`\ 1670. `"N",`\ 1671. `"N",`\ 1672. `"N",`\ 1673. `"ET",`\ 1674. `"ET",`\ 1675. `"N",`\ 1676. `"N",`\ 1677. `"N",`\ 1678. `"N",`\ 1679. `"N",`\ 1680. `"AL",`\ 1681. `"AL",`\ 1682. `"AL",`\ 1683. `"AL",`\ 1684. `"AL",`\ 1685. `"N",`\ 1686. `"AL",`\ 1687. `"AL",`\ 1688. `"AL",`\ 1689. `"AL",`\ 1690. `"AL",`\ 1691. `"AL",`\ 1692. `"AL",`\ 1693. `"AL",`\ 1694. `"AL",`\ 1695. `"AL",`\ 1696. `"AL",`\ 1697. `"AL",`\ 1698. `"AL",`\ 1699. `"AL",`\ 1700. `"AL",`\ 1701. `"AL",`\ 1702. `"AL",`\ 1703. `"AL",`\ 1704. `"AL",`\ 1705. `"AL",`\ 1706. `"AL",`\ 1707. `"AL",`\ 1708. `"AL",`\ 1709. `"AL",`\ 1710. `"AL",`\ 1711. `"AL",`\ 1712. `"AL",`\ 1713. `"AL",`\ 1714. `"AL",`\ 1715. `"AL",`\ 1716. `"AL",`\ 1717. `"AL",`\ 1718. `"AL",`\ 1719. `"AL",`\ 1720. `"AL",`\ 1721. `"AL",`\ 1722. `"AL",`\ 1723. `"AL",`\ 1724. `"AL",`\ 1725. `"AL",`\ 1726. `"AL",`\ 1727. `"AL",`\ 1728. `"AL",`\ 1729. `"AL",`\ 1730. `"AL",`\ 1731. `"AL",`\ 1732. `"AL",`\ 1733. `"AL",`\ 1734. `"AL",`\ 1735. `"AL",`\ 1736. `"AL",`\ 1737. `"AL",`\ 1738. `"AL",`\ 1739. `"AL",`\ 1740. `"AL",`\ 1741. `"AL",`\ 1742. `"AL",`\ 1743. `"AL",`\ 1744. `"AL",`\ 1745. `"AL",`\ 1746. `"AL",`\ 1747. `"AL",`\ 1748. `"AL",`\ 1749. `"AL",`\ 1750. `"AL",`\ 1751. `"AL",`\ 1752. `"AL",`\ 1753. `"AL",`\ 1754. `"AL",`\ 1755. `"AL",`\ 1756. `"AL",`\ 1757. `"AL",`\ 1758. `"AL",`\ 1759. `"AL",`\ 1760. `"AL",`\ 1761. `"AL",`\ 1762. `"AL",`\ 1763. `"AL",`\ 1764. `"AL",`\ 1765. `"AL",`\ 1766. `"AL",`\ 1767. `"AL",`\ 1768. `"AL",`\ 1769. `"AL",`\ 1770. `"AL",`\ 1771. `"AL",`\ 1772. `"AL",`\ 1773. `"AL",`\ 1774. `"AL",`\ 1775. `"AL",`\ 1776. `"AL",`\ 1777. `"AL",`\ 1778. `"AL",`\ 1779. `"AL",`\ 1780. `"AL",`\ 1781. `"AL",`\ 1782. `"AL",`\ 1783. `"AL",`\ 1784. `"AL",`\ 1785. `"AL",`\ 1786. `"AL",`\ 1787. `"AL",`\ 1788. `"AL",`\ 1789. `"AL",`\ 1790. `"AL",`\ 1791. `"AL",`\ 1792. `"AL",`\ 1793. `"AL",`\ 1794. `"AL",`\ 1795. `"AL",`\ 1796. `"AL",`\ 1797. `"AL",`\ 1798. `"AL",`\ 1799. `"AL",`\ 1800. `"AL",`\ 1801. `"AL",`\ 1802. `"AL",`\ 1803. `"AL",`\ 1804. `"AL",`\ 1805. `"AL",`\ 1806. `"AL",`\ 1807. `"AL",`\ 1808. `"AL",`\ 1809. `"AL",`\ 1810. `"AL",`\ 1811. `"AL",`\ 1812. `"AL",`\ 1813. `"AL",`\ 1814. `"AL",`\ 1815. `"AL",`\ 1816. `"AL",`\ 1817. `"AL",`\ 1818. `"AL",`\ 1819. `"AL",`\ 1820. `"AL",`\ 1821. `"N",`\ 1822. `"N",`\ 1823. `"BN",`\ 1824. `"N",`\ 1825. `"N",`\ 1826. `"N",`\ 1827. `"ET",`\ 1828. `"ET",`\ 1829. `"ET",`\ 1830. `"N",`\ 1831. `"N",`\ 1832. `"N",`\ 1833. `"N",`\ 1834. `"N",`\ 1835. `"ES",`\ 1836. `"CS",`\ 1837. `"ES",`\ 1838. `"CS",`\ 1839. `"CS",`\ 1840. `"EN",`\ 1841. `"EN",`\ 1842. `"EN",`\ 1843. `"EN",`\ 1844. `"EN",`\ 1845. `"EN",`\ 1846. `"EN",`\ 1847. `"EN",`\ 1848. `"EN",`\ 1849. `"EN",`\ 1850. `"CS",`\ 1851. `"N",`\ 1852. `"N",`\ 1853. `"N",`\ 1854. `"N",`\ 1855. `"N",`\ 1856. `"N",`\ 1857. `"L",`\ 1858. `"L",`\ 1859. `"L",`\ 1860. `"L",`\ 1861. `"L",`\ 1862. `"L",`\ 1863. `"L",`\ 1864. `"L",`\ 1865. `"L",`\ 1866. `"L",`\ 1867. `"L",`\ 1868. `"L",`\ 1869. `"L",`\ 1870. `"L",`\ 1871. `"L",`\ 1872. `"L",`\ 1873. `"L",`\ 1874. `"L",`\ 1875. `"L",`\ 1876. `"L",`\ 1877. `"L",`\ 1878. `"L",`\ 1879. `"L",`\ 1880. `"L",`\ 1881. `"L",`\ 1882. `"L",`\ 1883. `"N",`\ 1884. `"N",`\ 1885. `"N",`\ 1886. `"N",`\ 1887. `"N",`\ 1888. `"N",`\ 1889. `"L",`\ 1890. `"L",`\ 1891. `"L",`\ 1892. `"L",`\ 1893. `"L",`\ 1894. `"L",`\ 1895. `"L",`\ 1896. `"L",`\ 1897. `"L",`\ 1898. `"L",`\ 1899. `"L",`\ 1900. `"L",`\ 1901. `"L",`\ 1902. `"L",`\ 1903. `"L",`\ 1904. `"L",`\ 1905. `"L",`\ 1906. `"L",`\ 1907. `"L",`\ 1908. `"L",`\ 1909. `"L",`\ 1910. `"L",`\ 1911. `"L",`\ 1912. `"L",`\ 1913. `"L",`\ 1914. `"L",`\ 1915. `"N",`\ 1916. `"N",`\ 1917. `"N",`\ 1918. `"N",`\ 1919. `"N",`\ 1920. `"N",`\ 1921. `"N",`\ 1922. `"N",`\ 1923. `"N",`\ 1924. `"N",`\ 1925. `"N",`\ 1926. `"L",`\ 1927. `"L",`\ 1928. `"L",`\ 1929. `"L",`\ 1930. `"L",`\ 1931. `"L",`\ 1932. `"L",`\ 1933. `"L",`\ 1934. `"L",`\ 1935. `"L",`\ 1936. `"L",`\ 1937. `"L",`\ 1938. `"L",`\ 1939. `"L",`\ 1940. `"L",`\ 1941. `"L",`\ 1942. `"L",`\ 1943. `"L",`\ 1944. `"L",`\ 1945. `"L",`\ 1946. `"L",`\ 1947. `"L",`\ 1948. `"L",`\ 1949. `"L",`\ 1950. `"L",`\ 1951. `"L",`\ 1952. `"L",`\ 1953. `"L",`\ 1954. `"L",`\ 1955. `"L",`\ 1956. `"L",`\ 1957. `"L",`\ 1958. `"L",`\ 1959. `"L",`\ 1960. `"L",`\ 1961. `"L",`\ 1962. `"L",`\ 1963. `"L",`\ 1964. `"L",`\ 1965. `"L",`\ 1966. `"L",`\ 1967. `"L",`\ 1968. `"L",`\ 1969. `"L",`\ 1970. `"L",`\ 1971. `"L",`\ 1972. `"L",`\ 1973. `"L",`\ 1974. `"L",`\ 1975. `"L",`\ 1976. `"L",`\ 1977. `"L",`\ 1978. `"L",`\ 1979. `"L",`\ 1980. `"L",`\ 1981. `"L",`\ 1982. `"L",`\ 1983. `"L",`\ 1984. `"L",`\ 1985. `"L",`\ 1986. `"L",`\ 1987. `"L",`\ 1988. `"L",`\ 1989. `"L",`\ 1990. `"L",`\ 1991. `"L",`\ 1992. `"L",`\ 1993. `"L",`\ 1994. `"L",`\ 1995. `"L",`\ 1996. `"L",`\ 1997. `"L",`\ 1998. `"L",`\ 1999. `"L",`\ 2000. `"L",`\ 2001. `"L",`\ 2002. `"L",`\ 2003. `"L",`\ 2004. `"L",`\ 2005. `"L",`\ 2006. `"L",`\ 2007. `"L",`\ 2008. `"L",`\ 2009. `"L",`\ 2010. `"L",`\ 2011. `"L",`\ 2012. `"L",`\ 2013. `"L",`\ 2014. `"L",`\ 2015. `"N",`\ 2016. `"N",`\ 2017. `"N",`\ 2018. `"L",`\ 2019. `"L",`\ 2020. `"L",`\ 2021. `"L",`\ 2022. `"L",`\ 2023. `"L",`\ 2024. `"N",`\ 2025. `"N",`\ 2026. `"L",`\ 2027. `"L",`\ 2028. `"L",`\ 2029. `"L",`\ 2030. `"L",`\ 2031. `"L",`\ 2032. `"N",`\ 2033. `"N",`\ 2034. `"L",`\ 2035. `"L",`\ 2036. `"L",`\ 2037. `"L",`\ 2038. `"L",`\ 2039. `"L",`\ 2040. `"N",`\ 2041. `"N",`\ 2042. `"L",`\ 2043. `"L",`\ 2044. `"L",`\ 2045. `"N",`\ 2046. `"N",`\ 2047. `"N",`\ 2048. `"ET",`\ 2049. `"ET",`\ 2050. `"N",`\ 2051. `"N",`\ 2052. `"N",`\ 2053. `"ET",`\ 2054. `"ET",`\ 2055. `"N",`\ 2056. `"N",`\ 2057. `"N",`\ 2058. `"N",`\ 2059. `"N",`\ 2060. `"N",`\ 2061. `"N",`\ 2062. `"N",`\ 2063. `"N",`\ 2064. `"N",`\ 2065. `"N",`\ 2066. `"N",`\ 2067. `"N",`\ 2068. `"N",`\ 2069. `"N",`\ 2070. `"N",`\ 2071. `"N",`\ 2072. `"N",`\ 2073. `"N",`\ 2074. `"N",`\ 2075. `"N",`\ 2076. `"N",`\ 2077. `"N",`\ 2078. `"N",`\ 2079. `"N"`\ 2080. `];` 2082. `/**` 2083. `* Unicode Bidi algorithm compliant Bidi engine.` 2084. `* For reference see http://unicode.org/reports/tr9/` 2085. `*/` 2087. `/**` 2088. `* constructor ( options )` 2089. `*` 2090. `* Initializes Bidi engine` 2091. `*` 2092. `* @param {Object} See 'setOptions' below for detailed description.` 2093. `* options are cashed between invocation of 'doBidiReorder' method` 2094. `*` 2095. `* sample usage pattern of BidiEngine:` 2096. `* var opt = {` 2097. `* isInputVisual: true,` 2098. `* isInputRtl: false,` 2099. `* isOutputVisual: false,` 2100. `* isOutputRtl: false,` 2101. `* isSymmetricSwapping: true` 2102. `* }` 2103. `* var sourceToTarget = [], levels = [];` 2104. `* var bidiEng = Globalize.bidiEngine(opt);` 2105. `* var src = "text string to be reordered";` 2106. `* var ret = bidiEng.doBidiReorder(src, sourceToTarget, levels);` 2107. `*/` 2109. `jsPDF.__bidiEngine__ = jsPDF.prototype.__bidiEngine__ = function(options) {` 2110. `var _UNICODE_TYPES = _bidiUnicodeTypes;` 2112. `var _STATE_TABLE_LTR = [`\ 2113. `[0, 3, 0, 1, 0, 0, 0],`\ 2114. `[0, 3, 0, 1, 2, 2, 0],`\ 2115. `[0, 3, 0, 0x11, 2, 0, 1],`\ 2116. `[0, 3, 5, 5, 4, 1, 0],`\ 2117. `[0, 3, 0x15, 0x15, 4, 0, 1],`\ 2118. `[0, 3, 5, 5, 4, 2, 0]`\ 2119. `];` 2121. `var _STATE_TABLE_RTL = [`\ 2122. `[2, 0, 1, 1, 0, 1, 0],`\ 2123. `[2, 0, 1, 1, 0, 2, 0],`\ 2124. `[2, 0, 2, 1, 3, 2, 0],`\ 2125. `[2, 0, 2, 0x21, 3, 1, 1]`\ 2126. `];` 2128. `var _TYPE_NAMES_MAP = { L: 0, R: 1, EN: 2, AN: 3, N: 4, B: 5, S: 6 };` 2130. `var _UNICODE_RANGES_MAP = {` 2131. `0: 0,` 2132. `5: 1,` 2133. `6: 2,` 2134. `7: 3,` 2135. `0x20: 4,` 2136. `0xfb: 5,` 2137. `0xfe: 6,` 2138. `0xff: 7` 2139. `};` 2141. `var _SWAP_TABLE = [`\ 2142. `"\u0028",`\ 2143. `"\u0029",`\ 2144. `"\u0028",`\ 2145. `"\u003C",`\ 2146. `"\u003E",`\ 2147. `"\u003C",`\ 2148. `"\u005B",`\ 2149. `"\u005D",`\ 2150. `"\u005B",`\ 2151. `"\u007B",`\ 2152. `"\u007D",`\ 2153. `"\u007B",`\ 2154. `"\u00AB",`\ 2155. `"\u00BB",`\ 2156. `"\u00AB",`\ 2157. `"\u2039",`\ 2158. `"\u203A",`\ 2159. `"\u2039",`\ 2160. `"\u2045",`\ 2161. `"\u2046",`\ 2162. `"\u2045",`\ 2163. `"\u207D",`\ 2164. `"\u207E",`\ 2165. `"\u207D",`\ 2166. `"\u208D",`\ 2167. `"\u208E",`\ 2168. `"\u208D",`\ 2169. `"\u2264",`\ 2170. `"\u2265",`\ 2171. `"\u2264",`\ 2172. `"\u2329",`\ 2173. `"\u232A",`\ 2174. `"\u2329",`\ 2175. `"\uFE59",`\ 2176. `"\uFE5A",`\ 2177. `"\uFE59",`\ 2178. `"\uFE5B",`\ 2179. `"\uFE5C",`\ 2180. `"\uFE5B",`\ 2181. `"\uFE5D",`\ 2182. `"\uFE5E",`\ 2183. `"\uFE5D",`\ 2184. `"\uFE64",`\ 2185. `"\uFE65",`\ 2186. `"\uFE64"`\ 2187. `];` 2189. `var _LTR_RANGES_REG_EXPR = new RegExp(` 2190. `/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/` 2191. `);` 2193. `var _lastArabic = false,` 2194. `_hasUbatAl,` 2195. `_hasUbatB,` 2196. `_hasUbatS,` 2197. `DIR_LTR = 0,` 2198. `DIR_RTL = 1,` 2199. `_isInVisual,` 2200. `_isInRtl,` 2201. `_isOutVisual,` 2202. `_isOutRtl,` 2203. `_isSymmetricSwapping,` 2204. `_dir = DIR_LTR;` 2206. `this.__bidiEngine__ = {};` 2208. `var _init = function(text, sourceToTargetMap) {` 2209. `if (sourceToTargetMap) {` 2210. `for (var i = 0; i < text.length; i++) {` 2211. `sourceToTargetMap[i] = i;` 2212. `}` 2213. `}` 2214. `if (_isInRtl === undefined) {` 2215. `_isInRtl = _isContextualDirRtl(text);` 2216. `}` 2217. `if (_isOutRtl === undefined) {` 2218. `_isOutRtl = _isContextualDirRtl(text);` 2219. `}` 2220. `};` 2222. `// for reference see 3.2 in http://unicode.org/reports/tr9/` 2223. `//` 2224. `var _getCharType = function(ch) {` 2225. `var charCode = ch.charCodeAt(),` 2226. `range = charCode >> 8,` 2227. `rangeIdx = _UNICODE_RANGES_MAP[range];` 2229. `if (rangeIdx !== undefined) {` 2230. `return _UNICODE_TYPES[rangeIdx * 256 + (charCode & 0xff)];` 2231. `} else if (range === 0xfc || range === 0xfd) {` 2232. `return "AL";` 2233. `} else if (_LTR_RANGES_REG_EXPR.test(range)) {` 2234. `//unlikely case` 2235. `return "L";` 2236. `} else if (range === 8) {` 2237. `// even less likely` 2238. `return "R";` 2239. `}` 2240. `return "N"; //undefined type, mark as neutral` 2241. `};` 2243. `var _isContextualDirRtl = function(text) {` 2244. `for (var i = 0, charType; i < text.length; i++) {` 2245. `charType = _getCharType(text.charAt(i));` 2246. `if (charType === "L") {` 2247. `return false;` 2248. `} else if (charType === "R") {` 2249. `return true;` 2250. `}` 2251. `}` 2252. `return false;` 2253. `};` 2255. `// for reference see 3.3.4 & 3.3.5 in http://unicode.org/reports/tr9/` 2256. `//` 2257. `var _resolveCharType = function(chars, types, resolvedTypes, index) {` 2258. `var cType = types[index],` 2259. `wType,` 2260. `nType,` 2261. `i,` 2262. `len;` 2263. `switch (cType) {` 2264. `case "L":` 2265. `case "R":` 2266. `_lastArabic = false;` 2267. `break;` 2268. `case "N":` 2269. `case "AN":` 2270. `break;` 2272. `case "EN":` 2273. `if (_lastArabic) {` 2274. `cType = "AN";` 2275. `}` 2276. `break;` 2278. `case "AL":` 2279. `_lastArabic = true;` 2280. `_hasUbatAl = true;` 2281. `cType = "R";` 2282. `break;` 2284. `case "WS":` 2285. `cType = "N";` 2286. `break;` 2288. `case "CS":` 2289. `if (` 2290. `index < 1 ||` 2291. `index + 1 >= types.length ||` 2292. `((wType = resolvedTypes[index - 1]) !== "EN" && wType !== "AN") ||` 2293. `((nType = types[index + 1]) !== "EN" && nType !== "AN")` 2294. `) {` 2295. `cType = "N";` 2296. `} else if (_lastArabic) {` 2297. `nType = "AN";` 2298. `}` 2299. `cType = nType === wType ? nType : "N";` 2300. `break;` 2302. `case "ES":` 2303. `wType = index > 0 ? resolvedTypes[index - 1] : "B";` 2304. `cType =` 2305. `wType === "EN" &&` 2306. `index + 1 < types.length &&` 2307. `types[index + 1] === "EN"` 2308. `? "EN"` 2309. `: "N";` 2310. `break;` 2312. `case "ET":` 2313. `if (index > 0 && resolvedTypes[index - 1] === "EN") {` 2314. `cType = "EN";` 2315. `break;` 2316. `} else if (_lastArabic) {` 2317. `cType = "N";` 2318. `break;` 2319. `}` 2320. `i = index + 1;` 2321. `len = types.length;` 2322. `while (i < len && types[i] === "ET") {` 2323. `i++;` 2324. `}` 2325. `if (i < len && types[i] === "EN") {` 2326. `cType = "EN";` 2327. `} else {` 2328. `cType = "N";` 2329. `}` 2330. `break;` 2332. `case "NSM":` 2333. `if (_isInVisual && !_isInRtl) {` 2334. `//V->L` 2335. `len = types.length;` 2336. `i = index + 1;` 2337. `while (i < len && types[i] === "NSM") {` 2338. `i++;` 2339. `}` 2340. `if (i < len) {` 2341. `var c = chars[index];` 2342. `var rtlCandidate = (c >= 0x0591 && c <= 0x08ff) || c === 0xfb1e;` 2343. `wType = types[i];` 2344. `if (rtlCandidate && (wType === "R" || wType === "AL")) {` 2345. `cType = "R";` 2346. `break;` 2347. `}` 2348. `}` 2349. `}` 2350. `if (index < 1 || (wType = types[index - 1]) === "B") {` 2351. `cType = "N";` 2352. `} else {` 2353. `cType = resolvedTypes[index - 1];` 2354. `}` 2355. `break;` 2357. `case "B":` 2358. `_lastArabic = false;` 2359. `_hasUbatB = true;` 2360. `cType = _dir;` 2361. `break;` 2363. `case "S":` 2364. `_hasUbatS = true;` 2365. `cType = "N";` 2366. `break;` 2368. `case "LRE":` 2369. `case "RLE":` 2370. `case "LRO":` 2371. `case "RLO":` 2372. `case "PDF":` 2373. `_lastArabic = false;` 2374. `break;` 2375. `case "BN":` 2376. `cType = "N";` 2377. `break;` 2378. `}` 2379. `return cType;` 2380. `};` 2382. `var _handleUbatS = function(types, levels, length) {` 2383. `for (var i = 0; i < length; i++) {` 2384. `if (types[i] === "S") {` 2385. `levels[i] = _dir;` 2386. `for (var j = i - 1; j >= 0; j--) {` 2387. `if (types[j] === "WS") {` 2388. `levels[j] = _dir;` 2389. `} else {` 2390. `break;` 2391. `}` 2392. `}` 2393. `}` 2394. `}` 2395. `};` 2397. `var _invertString = function(text, sourceToTargetMap, levels) {` 2398. `var charArray = text.split("");` 2399. `if (levels) {` 2400. `_computeLevels(charArray, levels, { hiLevel: _dir });` 2401. `}` 2402. `charArray.reverse();` 2403. `sourceToTargetMap && sourceToTargetMap.reverse();` 2404. `return charArray.join("");` 2405. `};` 2407. `// For reference see 3.3 in http://unicode.org/reports/tr9/` 2408. `//` 2409. `var _computeLevels = function(chars, levels, params) {` 2410. `var action,` 2411. `condition,` 2412. `i,` 2413. `index,` 2414. `newLevel,` 2415. `prevState,` 2416. `condPos = -1,` 2417. `len = chars.length,` 2418. `newState = 0,` 2419. `resolvedTypes = [],` 2420. `stateTable = _dir ? _STATE_TABLE_RTL : _STATE_TABLE_LTR,` 2421. `types = [];` 2423. `_lastArabic = false;` 2424. `_hasUbatAl = false;` 2425. `_hasUbatB = false;` 2426. `_hasUbatS = false;` 2427. `for (i = 0; i < len; i++) {` 2428. `types[i] = _getCharType(chars[i]);` 2429. `}` 2430. `for (index = 0; index < len; index++) {` 2431. `prevState = newState;` 2432. `resolvedTypes[index] = _resolveCharType(` 2433. `chars,` 2434. `types,` 2435. `resolvedTypes,` 2436. `index` 2437. `);` 2438. `newState = stateTable[prevState][_TYPE_NAMES_MAP[resolvedTypes[index]]];` 2439. `action = newState & 0xf0;` 2440. `newState &= 0x0f;` 2441. `levels[index] = newLevel = stateTable[newState][5];` 2442. `if (action > 0) {` 2443. `if (action === 0x10) {` 2444. `for (i = condPos; i < index; i++) {` 2445. `levels[i] = 1;` 2446. `}` 2447. `condPos = -1;` 2448. `} else {` 2449. `condPos = -1;` 2450. `}` 2451. `}` 2452. `condition = stateTable[newState][6];` 2453. `if (condition) {` 2454. `if (condPos === -1) {` 2455. `condPos = index;` 2456. `}` 2457. `} else {` 2458. `if (condPos > -1) {` 2459. `for (i = condPos; i < index; i++) {` 2460. `levels[i] = newLevel;` 2461. `}` 2462. `condPos = -1;` 2463. `}` 2464. `}` 2465. `if (types[index] === "B") {` 2466. `levels[index] = 0;` 2467. `}` 2468. `params.hiLevel |= newLevel;` 2469. `}` 2470. `if (_hasUbatS) {` 2471. `_handleUbatS(types, levels, len);` 2472. `}` 2473. `};` 2475. `// for reference see 3.4 in http://unicode.org/reports/tr9/` 2476. `//` 2477. `var _invertByLevel = function(` 2478. `level,` 2479. `charArray,` 2480. `sourceToTargetMap,` 2481. `levels,` 2482. `params` 2483. `) {` 2484. `if (params.hiLevel < level) {` 2485. `return;` 2486. `}` 2487. `if (level === 1 && _dir === DIR_RTL && !_hasUbatB) {` 2488. `charArray.reverse();` 2489. `sourceToTargetMap && sourceToTargetMap.reverse();` 2490. `return;` 2491. `}` 2492. `var ch,` 2493. `high,` 2494. `end,` 2495. `low,` 2496. `len = charArray.length,` 2497. `start = 0;` 2499. `while (start < len) {` 2500. `if (levels[start] >= level) {` 2501. `end = start + 1;` 2502. `while (end < len && levels[end] >= level) {` 2503. `end++;` 2504. `}` 2505. `for (low = start, high = end - 1; low < high; low++, high--) {` 2506. `ch = charArray[low];` 2507. `charArray[low] = charArray[high];` 2508. `charArray[high] = ch;` 2509. `if (sourceToTargetMap) {` 2510. `ch = sourceToTargetMap[low];` 2511. `sourceToTargetMap[low] = sourceToTargetMap[high];` 2512. `sourceToTargetMap[high] = ch;` 2513. `}` 2514. `}` 2515. `start = end;` 2516. `}` 2517. `start++;` 2518. `}` 2519. `};` 2521. `// for reference see 7 & BD16 in http://unicode.org/reports/tr9/` 2522. `//` 2523. `var _symmetricSwap = function(charArray, levels, params) {` 2524. `if (params.hiLevel !== 0 && _isSymmetricSwapping) {` 2525. `for (var i = 0, index; i < charArray.length; i++) {` 2526. `if (levels[i] === 1) {` 2527. `index = _SWAP_TABLE.indexOf(charArray[i]);` 2528. `if (index >= 0) {` 2529. `charArray[i] = _SWAP_TABLE[index + 1];` 2530. `}` 2531. `}` 2532. `}` 2533. `}` 2534. `};` 2536. `var _reorder = function(text, sourceToTargetMap, levels) {` 2537. `var charArray = text.split(""),` 2538. `params = { hiLevel: _dir };` 2540. `if (!levels) {` 2541. `levels = [];` 2542. `}` 2543. `_computeLevels(charArray, levels, params);` 2544. `_symmetricSwap(charArray, levels, params);` 2545. `_invertByLevel(DIR_RTL + 1, charArray, sourceToTargetMap, levels, params);` 2546. `_invertByLevel(DIR_RTL, charArray, sourceToTargetMap, levels, params);` 2547. `return charArray.join("");` 2548. `};` 2550. `// doBidiReorder( text, sourceToTargetMap, levels )` 2551. `// Performs Bidi reordering by implementing Unicode Bidi algorithm.` 2552. `// Returns reordered string` 2553. `// @text [String]:` 2554. `// - input string to be reordered, this is input parameter` 2555. `// $sourceToTargetMap [Array] (optional)` 2556. `// - resultant mapping between input and output strings, this is output parameter` 2557. `// $levels [Array] (optional)` 2558. `// - array of calculated Bidi levels, , this is output parameter` 2559. `this.__bidiEngine__.doBidiReorder = function(` 2560. `text,` 2561. `sourceToTargetMap,` 2562. `levels` 2563. `) {` 2564. `_init(text, sourceToTargetMap);` 2565. `if (!_isInVisual && _isOutVisual && !_isOutRtl) {` 2566. `// LLTR->VLTR, LRTL->VLTR` 2567. `_dir = _isInRtl ? DIR_RTL : DIR_LTR;` 2568. `text = _reorder(text, sourceToTargetMap, levels);` 2569. `} else if (_isInVisual && _isOutVisual && _isInRtl ^ _isOutRtl) {` 2570. `// VRTL->VLTR, VLTR->VRTL` 2571. `_dir = _isInRtl ? DIR_RTL : DIR_LTR;` 2572. `text = _invertString(text, sourceToTargetMap, levels);` 2573. `} else if (!_isInVisual && _isOutVisual && _isOutRtl) {` 2574. `// LLTR->VRTL, LRTL->VRTL` 2575. `_dir = _isInRtl ? DIR_RTL : DIR_LTR;` 2576. `text = _reorder(text, sourceToTargetMap, levels);` 2577. `text = _invertString(text, sourceToTargetMap);` 2578. `} else if (_isInVisual && !_isInRtl && !_isOutVisual && !_isOutRtl) {` 2579. `// VLTR->LLTR` 2580. `_dir = DIR_LTR;` 2581. `text = _reorder(text, sourceToTargetMap, levels);` 2582. `} else if (_isInVisual && !_isOutVisual && _isInRtl ^ _isOutRtl) {` 2583. `// VLTR->LRTL, VRTL->LLTR` 2584. `text = _invertString(text, sourceToTargetMap);` 2585. `if (_isInRtl) {` 2586. `//LLTR -> VLTR` 2587. `_dir = DIR_LTR;` 2588. `text = _reorder(text, sourceToTargetMap, levels);` 2589. `} else {` 2590. `//LRTL -> VRTL` 2591. `_dir = DIR_RTL;` 2592. `text = _reorder(text, sourceToTargetMap, levels);` 2593. `text = _invertString(text, sourceToTargetMap);` 2594. `}` 2595. `} else if (_isInVisual && _isInRtl && !_isOutVisual && _isOutRtl) {` 2596. `// VRTL->LRTL` 2597. `_dir = DIR_RTL;` 2598. `text = _reorder(text, sourceToTargetMap, levels);` 2599. `text = _invertString(text, sourceToTargetMap);` 2600. `} else if (!_isInVisual && !_isOutVisual && _isInRtl ^ _isOutRtl) {` 2601. `// LRTL->LLTR, LLTR->LRTL` 2602. `var isSymmetricSwappingOrig = _isSymmetricSwapping;` 2603. `if (_isInRtl) {` 2604. `//LRTL->LLTR` 2605. `_dir = DIR_RTL;` 2606. `text = _reorder(text, sourceToTargetMap, levels);` 2607. `_dir = DIR_LTR;` 2608. `_isSymmetricSwapping = false;` 2609. `text = _reorder(text, sourceToTargetMap, levels);` 2610. `_isSymmetricSwapping = isSymmetricSwappingOrig;` 2611. `} else {` 2612. `//LLTR->LRTL` 2613. `_dir = DIR_LTR;` 2614. `text = _reorder(text, sourceToTargetMap, levels);` 2615. `text = _invertString(text, sourceToTargetMap);` 2616. `_dir = DIR_RTL;` 2617. `_isSymmetricSwapping = false;` 2618. `text = _reorder(text, sourceToTargetMap, levels);` 2619. `_isSymmetricSwapping = isSymmetricSwappingOrig;` 2620. `text = _invertString(text, sourceToTargetMap);` 2621. `}` 2622. `}` 2623. `return text;` 2624. `};` 2626. `/**` 2627. `* @name setOptions( options )` 2628. `* @function` 2629. `* Sets options for Bidi conversion` 2630. `* @param {Object}:` 2631. `* - isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode)` 2632. `* - 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)` 2633. `* - isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode)` 2634. `* - 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)` 2635. `* - isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping),` 2636. `*/` 2637. `this.__bidiEngine__.setOptions = function(options) {` 2638. `if (options) {` 2639. `_isInVisual = options.isInputVisual;` 2640. `_isOutVisual = options.isOutputVisual;` 2641. `_isInRtl = options.isInputRtl;` 2642. `_isOutRtl = options.isOutputRtl;` 2643. `_isSymmetricSwapping = options.isSymmetricSwapping;` 2644. `}` 2645. `};` 2647. `this.__bidiEngine__.setOptions(options);` 2648. `return this.__bidiEngine__;` 2649. `};` 2651. `var _bidiUnicodeTypes = bidiUnicodeTypes;` 2653. `var bidiEngine = new jsPDF.__bidiEngine__({ isInputVisual: true });` 2655. `var bidiEngineFunction = function(args) {` 2656. `var text = args.text;` 2657. `var x = args.x;` 2658. `var y = args.y;` 2659. `var options = args.options || {};` 2660. `var mutex = args.mutex || {};` 2661. `var lang = options.lang;` 2662. `var tmpText = [];` 2664. `options.isInputVisual =` 2665. `typeof options.isInputVisual === "boolean" ? options.isInputVisual : true;` 2666. `bidiEngine.setOptions(options);` 2668. `if (Object.prototype.toString.call(text) === "[object Array]") {` 2669. `var i = 0;` 2670. `tmpText = [];` 2671. `for (i = 0; i < text.length; i += 1) {` 2672. `if (Object.prototype.toString.call(text[i]) === "[object Array]") {` 2673. `tmpText.push([`\ 2674. `bidiEngine.doBidiReorder(text[i][0]),`\ 2675. `text[i][1],`\ 2676. `text[i][2]`\ 2677. `]);` 2678. `} else {` 2679. `tmpText.push([bidiEngine.doBidiReorder(text[i])]);` 2680. `}` 2681. `}` 2682. `args.text = tmpText;` 2683. `} else {` 2684. `args.text = bidiEngine.doBidiReorder(text);` 2685. `}` 2686. `bidiEngine.setOptions({ isInputVisual: true });` 2687. `};` 2689. `jsPDF.API.events.push(["postProcessText", bidiEngineFunction]);` 2690. `})(jsPDF);` --- # modules/autoprint.js - Documentation modules/autoprint.js ==================== 1. `/** @license` 2. `* jsPDF Autoprint Plugin` 3. `*` 4. `* Licensed under the MIT License.` 5. `* http://opensource.org/licenses/mit-license` 6. `*/` 8. `import { jsPDF } from "../jspdf.js";` 10. `/**` 11. `* @name autoprint` 12. `* @module` 13. `*/` 14. `(function(jsPDFAPI) {` 15. `"use strict";` 17. `/**` 18. `* Makes the PDF automatically open the print-Dialog when opened in a PDF-viewer.` 19. `*` 20. `* @name autoPrint` 21. `* @function` 22. `* @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 .` 23. `* @returns {jsPDF}` 24. `* @example` 25. `* var doc = new jsPDF();` 26. `* doc.text(10, 10, 'This is a test');` 27. `* doc.autoPrint({variant: 'non-conform'});` 28. `* doc.save('autoprint.pdf');` 29. `*/` 30. `jsPDFAPI.autoPrint = function(options) {` 31. `"use strict";` 32. `var refAutoPrintTag;` 33. `options = options || {};` 34. `options.variant = options.variant || "non-conform";` 36. `switch (options.variant) {` 37. `case "javascript":` 38. `//https://github.com/Rob--W/pdf.js/commit/c676ecb5a0f54677b9f3340c3ef2cf42225453bb` 39. `this.addJS("print({});");` 40. `break;` 41. `case "non-conform":` 42. `default:` 43. `this.internal.events.subscribe("postPutResources", function() {` 44. `refAutoPrintTag = this.internal.newObject();` 45. `this.internal.out("<<");` 46. `this.internal.out("/S /Named");` 47. `this.internal.out("/Type /Action");` 48. `this.internal.out("/N /Print");` 49. `this.internal.out(">>");` 50. `this.internal.out("endobj");` 51. `});` 53. `this.internal.events.subscribe("putCatalog", function() {` 54. `this.internal.out("/OpenAction " + refAutoPrintTag + " 0 R");` 55. `});` 56. `break;` 57. `}` 58. `return this;` 59. `};` 60. `})(jsPDF.API);` --- # modules/addimage.js - Documentation modules/addimage.js =================== 1. `/** @license` 2. `* jsPDF addImage plugin` 3. `* Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/` 4. `* 2013 Chris Dowling, https://github.com/gingerchris` 5. `* 2013 Trinh Ho, https://github.com/ineedfat` 6. `* 2013 Edwin Alejandro Perez, https://github.com/eaparango` 7. `* 2013 Norah Smith, https://github.com/burnburnrocket` 8. `* 2014 Diego Casorran, https://github.com/diegocr` 9. `* 2014 James Robb, https://github.com/jamesbrobb` 10. `*` 11. `* Permission is hereby granted, free of charge, to any person obtaining` 12. `* a copy of this software and associated documentation files (the` 13. `* "Software"), to deal in the Software without restriction, including` 14. `* without limitation the rights to use, copy, modify, merge, publish,` 15. `* distribute, sublicense, and/or sell copies of the Software, and to` 16. `* permit persons to whom the Software is furnished to do so, subject to` 17. `* the following conditions:` 18. `*` 19. `* The above copyright notice and this permission notice shall be` 20. `* included in all copies or substantial portions of the Software.` 21. `*` 22. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 23. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 24. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 25. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 26. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 27. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 28. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 29. `*/` 30. `/**` 31. `* @name addImage` 32. `* @module` 33. `*/` 35. `import { jsPDF } from "../jspdf.js";` 36. `import { atob, btoa } from "../libs/AtobBtoa.js";` 38. `(function(jsPDFAPI) {` 39. `"use strict";` 41. `var namespace = "addImage_";` 42. `jsPDFAPI.__addimage__ = {};` 44. `var UNKNOWN = "UNKNOWN";` 46. `// Heuristic selection of a good batch for large array .apply. Not limiting make the call overflow.` 47. `// With too small batch iteration will be slow as more calls are made,` 48. `// higher values cause larger and slower garbage collection.` 49. `var ARRAY_APPLY_BATCH = 8192;` 51. `var imageFileTypeHeaders = {` 52. `PNG: [[0x89, 0x50, 0x4e, 0x47]],` 53. `TIFF: [`\ 54. `[0x4d, 0x4d, 0x00, 0x2a], //Motorola`\ 55. `[0x49, 0x49, 0x2a, 0x00] //Intel`\ 56. `],` 57. `JPEG: [`\ 58. `[`\ 59. `0xff,`\ 60. `0xd8,`\ 61. `0xff,`\ 62. `0xe0,`\ 63. `undefined,`\ 64. `undefined,`\ 65. `0x4a,`\ 66. `0x46,`\ 67. `0x49,`\ 68. `0x46,`\ 69. `0x00`\ 70. `], //JFIF`\ 71. `[`\ 72. `0xff,`\ 73. `0xd8,`\ 74. `0xff,`\ 75. `0xe1,`\ 76. `undefined,`\ 77. `undefined,`\ 78. `0x45,`\ 79. `0x78,`\ 80. `0x69,`\ 81. `0x66,`\ 82. `0x00,`\ 83. `0x00`\ 84. `], //Exif`\ 85. `[0xff, 0xd8, 0xff, 0xdb], //JPEG RAW`\ 86. `[0xff, 0xd8, 0xff, 0xee] //EXIF RAW`\ 87. `],` 88. `JPEG2000: [[0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20]],` 89. `GIF87a: [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61]],` 90. `GIF89a: [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61]],` 91. `WEBP: [`\ 92. `[`\ 93. `0x52,`\ 94. `0x49,`\ 95. `0x46,`\ 96. `0x46,`\ 97. `undefined,`\ 98. `undefined,`\ 99. `undefined,`\ 100. `undefined,`\ 101. `0x57,`\ 102. `0x45,`\ 103. `0x42,`\ 104. `0x50`\ 105. `]`\ 106. `],` 107. `BMP: [`\ 108. `[0x42, 0x4d], //BM - Windows 3.1x, 95, NT, ... etc.`\ 109. `[0x42, 0x41], //BA - OS/2 struct bitmap array`\ 110. `[0x43, 0x49], //CI - OS/2 struct color icon`\ 111. `[0x43, 0x50], //CP - OS/2 const color pointer`\ 112. `[0x49, 0x43], //IC - OS/2 struct icon`\ 113. `[0x50, 0x54] //PT - OS/2 pointer`\ 114. `]` 115. `};` 117. `/**` 118. `* Recognize filetype of Image by magic-bytes` 119. `*` 120. `* https://en.wikipedia.org/wiki/List_of_file_signatures` 121. `*` 122. `* @name getImageFileTypeByImageData` 123. `* @public` 124. `* @function` 125. `* @param {string|arraybuffer} imageData imageData as binary String or arraybuffer` 126. `* @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG'` 127. `*` 128. `* @returns {string} filetype of Image` 129. `*/` 130. `var getImageFileTypeByImageData = (jsPDFAPI.__addimage__.getImageFileTypeByImageData = function(` 131. `imageData,` 132. `fallbackFormat` 133. `) {` 134. `fallbackFormat = fallbackFormat || UNKNOWN;` 135. `var i;` 136. `var j;` 137. `var result = UNKNOWN;` 138. `var headerSchemata;` 139. `var compareResult;` 140. `var fileType;` 142. `if (` 143. `fallbackFormat === "RGBA" ||` 144. `(imageData.data !== undefined &&` 145. `imageData.data instanceof Uint8ClampedArray &&` 146. `"height" in imageData &&` 147. `"width" in imageData)` 148. `) {` 149. `return "RGBA";` 150. `}` 152. `if (isArrayBufferView(imageData)) {` 153. `for (fileType in imageFileTypeHeaders) {` 154. `headerSchemata = imageFileTypeHeaders[fileType];` 155. `for (i = 0; i < headerSchemata.length; i += 1) {` 156. `compareResult = true;` 157. `for (j = 0; j < headerSchemata[i].length; j += 1) {` 158. `if (headerSchemata[i][j] === undefined) {` 159. `continue;` 160. `}` 161. `if (headerSchemata[i][j] !== imageData[j]) {` 162. `compareResult = false;` 163. `break;` 164. `}` 165. `}` 166. `if (compareResult === true) {` 167. `result = fileType;` 168. `break;` 169. `}` 170. `}` 171. `}` 172. `} else {` 173. `for (fileType in imageFileTypeHeaders) {` 174. `headerSchemata = imageFileTypeHeaders[fileType];` 175. `for (i = 0; i < headerSchemata.length; i += 1) {` 176. `compareResult = true;` 177. `for (j = 0; j < headerSchemata[i].length; j += 1) {` 178. `if (headerSchemata[i][j] === undefined) {` 179. `continue;` 180. `}` 181. `if (headerSchemata[i][j] !== imageData.charCodeAt(j)) {` 182. `compareResult = false;` 183. `break;` 184. `}` 185. `}` 186. `if (compareResult === true) {` 187. `result = fileType;` 188. `break;` 189. `}` 190. `}` 191. `}` 192. `}` 194. `if (result === UNKNOWN && fallbackFormat !== UNKNOWN) {` 195. `result = fallbackFormat;` 196. `}` 197. `return result;` 198. `});` 200. `// Image functionality ported from pdf.js` 201. `var putImage = function(image) {` 202. `var out = this.internal.write;` 203. `var putStream = this.internal.putStream;` 204. `var getFilters = this.internal.getFilters;` 206. `var filter = getFilters();` 207. `while (filter.indexOf("FlateEncode") !== -1) {` 208. `filter.splice(filter.indexOf("FlateEncode"), 1);` 209. `}` 211. `image.objectId = this.internal.newObject();` 213. `var additionalKeyValues = [];` 214. `additionalKeyValues.push({ key: "Type", value: "/XObject" });` 215. `additionalKeyValues.push({ key: "Subtype", value: "/Image" });` 216. `additionalKeyValues.push({ key: "Width", value: image.width });` 217. `additionalKeyValues.push({ key: "Height", value: image.height });` 219. `if (image.colorSpace === color_spaces.INDEXED) {` 220. `additionalKeyValues.push({` 221. `key: "ColorSpace",` 222. `value:` 223. `"[/Indexed /DeviceRGB " +`\ 224. `// if an indexed png defines more than one colour with transparency, we've created a sMask`\ 225. `(image.palette.length / 3 - 1) +`\ 226. `" " +`\ 227. `("sMask" in image && typeof image.sMask !== "undefined"`\ 228. `? image.objectId + 2`\ 229. `: image.objectId + 1) +`\ 230. `" 0 R]"` 231. `});` 232. `} else {` 233. `additionalKeyValues.push({` 234. `key: "ColorSpace",` 235. `value: "/" + image.colorSpace` 236. `});` 237. `if (image.colorSpace === color_spaces.DEVICE_CMYK) {` 238. `additionalKeyValues.push({ key: "Decode", value: "[1 0 1 0 1 0 1 0]" });` 239. `}` 240. `}` 241. `additionalKeyValues.push({` 242. `key: "BitsPerComponent",` 243. `value: image.bitsPerComponent` 244. `});` 245. `if (` 246. `"decodeParameters" in image &&` 247. `typeof image.decodeParameters !== "undefined"` 248. `) {` 249. `additionalKeyValues.push({` 250. `key: "DecodeParms",` 251. `value: "<<" + image.decodeParameters + ">>"` 252. `});` 253. `}` 254. `if ("transparency" in image && Array.isArray(image.transparency)) {` 255. `var transparency = "",` 256. `i = 0,` 257. `len = image.transparency.length;` 258. `for (; i < len; i++)` 259. `transparency +=` 260. `image.transparency[i] + " " + image.transparency[i] + " ";` 262. `additionalKeyValues.push({` 263. `key: "Mask",` 264. `value: "[" + transparency + "]"` 265. `});` 266. `}` 267. `if (typeof image.sMask !== "undefined") {` 268. `additionalKeyValues.push({` 269. `key: "SMask",` 270. `value: image.objectId + 1 + " 0 R"` 271. `});` 272. `}` 274. `var alreadyAppliedFilters =` 275. `typeof image.filter !== "undefined" ? ["/" + image.filter] : undefined;` 277. `putStream({` 278. `data: image.data,` 279. `additionalKeyValues: additionalKeyValues,` 280. `alreadyAppliedFilters: alreadyAppliedFilters,` 281. `objectId: image.objectId` 282. `});` 284. `out("endobj");` 286. `// Soft mask` 287. `if ("sMask" in image && typeof image.sMask !== "undefined") {` 288. `var decodeParameters =` 289. `"/Predictor " +` 290. `image.predictor +` 291. `" /Colors 1 /BitsPerComponent " +` 292. `image.bitsPerComponent +` 293. `" /Columns " +` 294. `image.width;` 295. `var sMask = {` 296. `width: image.width,` 297. `height: image.height,` 298. `colorSpace: "DeviceGray",` 299. `bitsPerComponent: image.bitsPerComponent,` 300. `decodeParameters: decodeParameters,` 301. `data: image.sMask` 302. `};` 303. `if ("filter" in image) {` 304. `sMask.filter = image.filter;` 305. `}` 306. `putImage.call(this, sMask);` 307. `}` 309. `//Palette` 310. `if (image.colorSpace === color_spaces.INDEXED) {` 311. `var objId = this.internal.newObject();` 312. `//out('<< /Filter / ' + img['f'] +' /Length ' + img['pal'].length + '>>');` 313. `//putStream(zlib.compress(img['pal']));` 314. `putStream({` 315. `data: arrayBufferToBinaryString(new Uint8Array(image.palette)),` 316. `objectId: objId` 317. `});` 318. `out("endobj");` 319. `}` 320. `};` 321. `var putResourcesCallback = function() {` 322. `var images = this.internal.collections[namespace + "images"];` 323. `for (var i in images) {` 324. `putImage.call(this, images[i]);` 325. `}` 326. `};` 327. `var putXObjectsDictCallback = function() {` 328. `var images = this.internal.collections[namespace + "images"],` 329. `out = this.internal.write,` 330. `image;` 331. `for (var i in images) {` 332. `image = images[i];` 333. `out("/I" + image.index, image.objectId, "0", "R");` 334. `}` 335. `};` 337. `var checkCompressValue = function(value) {` 338. `if (value && typeof value === "string") value = value.toUpperCase();` 339. `return value in jsPDFAPI.image_compression ? value : image_compression.NONE;` 340. `};` 342. `var initialize = function() {` 343. `if (!this.internal.collections[namespace + "images"]) {` 344. `this.internal.collections[namespace + "images"] = {};` 345. `this.internal.events.subscribe("putResources", putResourcesCallback);` 346. `this.internal.events.subscribe("putXobjectDict", putXObjectsDictCallback);` 347. `}` 348. `};` 350. `var getImages = function() {` 351. `var images = this.internal.collections[namespace + "images"];` 352. `initialize.call(this);` 353. `return images;` 354. `};` 355. `var getImageIndex = function() {` 356. `return Object.keys(this.internal.collections[namespace + "images"]).length;` 357. `};` 358. `var notDefined = function(value) {` 359. `return typeof value === "undefined" || value === null || value.length === 0;` 360. `};` 361. `var generateAliasFromImageData = function(imageData) {` 362. `if (typeof imageData === "string" || isArrayBufferView(imageData)) {` 363. `return sHashCode(imageData);` 364. `} else if (isArrayBufferView(imageData.data)) {` 365. `return sHashCode(imageData.data);` 366. `}` 368. `return null;` 369. `};` 371. `var isImageTypeSupported = function(type) {` 372. `return typeof jsPDFAPI["process" + type.toUpperCase()] === "function";` 373. `};` 375. `var isDOMElement = function(object) {` 376. `return typeof object === "object" && object.nodeType === 1;` 377. `};` 379. `var getImageDataFromElement = function(element, format) {` 380. `//if element is an image which uses data url definition, just return the dataurl` 381. `if (element.nodeName === "IMG" && element.hasAttribute("src")) {` 382. `var src = "" + element.getAttribute("src");` 384. `//is base64 encoded dataUrl, directly process it` 385. `if (src.indexOf("data:image/") === 0) {` 386. `return atob(` 387. `unescape(src)` 388. `.split("base64,")` 389. `.pop()` 390. `);` 391. `}` 393. `//it is probably an url, try to load it` 394. `var tmpImageData = jsPDFAPI.loadFile(src, true);` 395. `if (tmpImageData !== undefined) {` 396. `return tmpImageData;` 397. `}` 398. `}` 400. `if (element.nodeName === "CANVAS") {` 401. `if (element.width === 0 || element.height === 0) {` 402. `throw new Error(` 403. `"Given canvas must have data. Canvas width: " +` 404. `element.width +` 405. `", height: " +` 406. `element.height` 407. `);` 408. `}` 409. `var mimeType;` 410. `switch (format) {` 411. `case "PNG":` 412. `mimeType = "image/png";` 413. `break;` 414. `case "WEBP":` 415. `mimeType = "image/webp";` 416. `break;` 417. `case "JPEG":` 418. `case "JPG":` 419. `default:` 420. `mimeType = "image/jpeg";` 421. `break;` 422. `}` 423. `return atob(` 424. `element` 425. `.toDataURL(mimeType, 1.0)` 426. `.split("base64,")` 427. `.pop()` 428. `);` 429. `}` 430. `};` 432. `var checkImagesForAlias = function(alias) {` 433. `var images = this.internal.collections[namespace + "images"];` 434. `if (images) {` 435. `for (var e in images) {` 436. `if (alias === images[e].alias) {` 437. `return images[e];` 438. `}` 439. `}` 440. `}` 441. `};` 443. `var determineWidthAndHeight = function(width, height, image) {` 444. `if (!width && !height) {` 445. `width = -96;` 446. `height = -96;` 447. `}` 448. `if (width < 0) {` 449. `width = (-1 * image.width * 72) / width / this.internal.scaleFactor;` 450. `}` 451. `if (height < 0) {` 452. `height = (-1 * image.height * 72) / height / this.internal.scaleFactor;` 453. `}` 454. `if (width === 0) {` 455. `width = (height * image.width) / image.height;` 456. `}` 457. `if (height === 0) {` 458. `height = (width * image.height) / image.width;` 459. `}` 461. `return [width, height];` 462. `};` 464. `var writeImageToPDF = function(x, y, width, height, image, rotation) {` 465. `var dims = determineWidthAndHeight.call(this, width, height, image),` 466. `coord = this.internal.getCoordinateString,` 467. `vcoord = this.internal.getVerticalCoordinateString;` 469. `var images = getImages.call(this);` 471. `width = dims[0];` 472. `height = dims[1];` 473. `images[image.index] = image;` 475. `if (rotation) {` 476. `rotation *= Math.PI / 180;` 477. `var c = Math.cos(rotation);` 478. `var s = Math.sin(rotation);` 479. `//like in pdf Reference do it 4 digits instead of 2` 480. `var f4 = function(number) {` 481. `return number.toFixed(4);` 482. `};` 483. `var rotationTransformationMatrix = [`\ 484. `f4(c),`\ 485. `f4(s),`\ 486. `f4(s * -1),`\ 487. `f4(c),`\ 488. `0,`\ 489. `0,`\ 490. `"cm"`\ 491. `];` 492. `}` 493. `this.internal.write("q"); //Save graphics state` 494. `if (rotation) {` 495. `this.internal.write(` 496. `[1, "0", "0", 1, coord(x), vcoord(y + height), "cm"].join(" ")` 497. `); //Translate` 498. `this.internal.write(rotationTransformationMatrix.join(" ")); //Rotate` 499. `this.internal.write(` 500. `[coord(width), "0", "0", coord(height), "0", "0", "cm"].join(" ")` 501. `); //Scale` 502. `} else {` 503. `this.internal.write(` 504. `[`\ 505. `coord(width),`\ 506. `"0",`\ 507. `"0",`\ 508. `coord(height),`\ 509. `coord(x),`\ 510. `vcoord(y + height),`\ 511. `"cm"`\ 512. `].join(" ")` 513. `); //Translate and Scale` 514. `}` 516. `if (this.isAdvancedAPI()) {` 517. `// draw image bottom up when in "advanced" API mode` 518. `this.internal.write([1, 0, 0, -1, 0, 0, "cm"].join(" "));` 519. `}` 521. `this.internal.write("/I" + image.index + " Do"); //Paint Image` 522. `this.internal.write("Q"); //Restore graphics state` 523. `};` 525. `/**` 526. `* COLOR SPACES` 527. `*/` 528. `var color_spaces = (jsPDFAPI.color_spaces = {` 529. `DEVICE_RGB: "DeviceRGB",` 530. `DEVICE_GRAY: "DeviceGray",` 531. `DEVICE_CMYK: "DeviceCMYK",` 532. `CAL_GREY: "CalGray",` 533. `CAL_RGB: "CalRGB",` 534. `LAB: "Lab",` 535. `ICC_BASED: "ICCBased",` 536. `INDEXED: "Indexed",` 537. `PATTERN: "Pattern",` 538. `SEPARATION: "Separation",` 539. `DEVICE_N: "DeviceN"` 540. `});` 542. `/**` 543. `* DECODE METHODS` 544. `*/` 545. `jsPDFAPI.decode = {` 546. `DCT_DECODE: "DCTDecode",` 547. `FLATE_DECODE: "FlateDecode",` 548. `LZW_DECODE: "LZWDecode",` 549. `JPX_DECODE: "JPXDecode",` 550. `JBIG2_DECODE: "JBIG2Decode",` 551. `ASCII85_DECODE: "ASCII85Decode",` 552. `ASCII_HEX_DECODE: "ASCIIHexDecode",` 553. `RUN_LENGTH_DECODE: "RunLengthDecode",` 554. `CCITT_FAX_DECODE: "CCITTFaxDecode"` 555. `};` 557. `/**` 558. `* IMAGE COMPRESSION TYPES` 559. `*/` 560. `var image_compression = (jsPDFAPI.image_compression = {` 561. `NONE: "NONE",` 562. `FAST: "FAST",` 563. `MEDIUM: "MEDIUM",` 564. `SLOW: "SLOW"` 565. `});` 567. `/**` 568. `* @name sHashCode` 569. `* @function` 570. `* @param {string} data` 571. `* @returns {string}` 572. `*/` 573. `var sHashCode = (jsPDFAPI.__addimage__.sHashCode = function(data) {` 574. `var hash = 0,` 575. `i,` 576. `len;` 578. `if (typeof data === "string") {` 579. `len = data.length;` 580. `for (i = 0; i < len; i++) {` 581. `hash = (hash << 5) - hash + data.charCodeAt(i);` 582. `hash |= 0; // Convert to 32bit integer` 583. `}` 584. `} else if (isArrayBufferView(data)) {` 585. `len = data.byteLength / 2;` 586. `for (i = 0; i < len; i++) {` 587. `hash = (hash << 5) - hash + data[i];` 588. `hash |= 0; // Convert to 32bit integer` 589. `}` 590. `}` 591. `return hash;` 592. `});` 594. `/**` 595. `* Validates if given String is a valid Base64-String` 596. `*` 597. `* @name validateStringAsBase64` 598. `* @public` 599. `* @function` 600. `* @param {String} possible Base64-String` 601. `*` 602. `* @returns {boolean}` 603. `*/` 604. `var validateStringAsBase64 = (jsPDFAPI.__addimage__.validateStringAsBase64 = function(` 605. `possibleBase64String` 606. `) {` 607. `possibleBase64String = possibleBase64String || "";` 608. `possibleBase64String.toString().trim();` 610. `var result = true;` 612. `if (possibleBase64String.length === 0) {` 613. `result = false;` 614. `}` 616. `if (possibleBase64String.length % 4 !== 0) {` 617. `result = false;` 618. `}` 620. `if (` 621. `/^[A-Za-z0-9+/]+$/.test(` 622. `possibleBase64String.substr(0, possibleBase64String.length - 2)` 623. `) === false` 624. `) {` 625. `result = false;` 626. `}` 628. `if (` 629. `/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(` 630. `possibleBase64String.substr(-2)` 631. `) === false` 632. `) {` 633. `result = false;` 634. `}` 635. `return result;` 636. `});` 638. `/**` 639. `* Strips out and returns info from a valid base64 data URI` 640. `*` 641. `* @name extractImageFromDataUrl` 642. `* @function` 643. `* @param {string} dataUrl a valid data URI of format 'data:[][;base64],'` 644. `* @returns {string} The raw Base64-encoded data.` 645. `*/` 646. `var extractImageFromDataUrl = (jsPDFAPI.__addimage__.extractImageFromDataUrl = function(` 647. `dataUrl` 648. `) {` 649. `if (dataUrl == null) {` 650. `return null;` 651. `}` 653. `// avoid using a regexp for parsing because it might be vulnerable against ReDoS attacks` 655. `dataUrl = dataUrl.trim();` 657. `if (!dataUrl.startsWith("data:")) {` 658. `return null;` 659. `}` 661. `const commaIndex = dataUrl.indexOf(",");` 662. `if (commaIndex < 0) {` 663. `return null;` 664. `}` 666. `const dataScheme = dataUrl.substring(0, commaIndex).trim();` 667. `if (!dataScheme.endsWith("base64")) {` 668. `return null;` 669. `}` 671. `return dataUrl.substring(commaIndex + 1);` 672. `});` 674. `/**` 675. `* Check to see if ArrayBuffer is supported` 676. `*` 677. `* @name supportsArrayBuffer` 678. `* @function` 679. `* @returns {boolean}` 680. `*/` 681. `var supportsArrayBuffer = (jsPDFAPI.__addimage__.supportsArrayBuffer = function() {` 682. `return (` 683. `typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined"` 684. `);` 685. `});` 687. `/**` 688. `* Tests supplied object to determine if ArrayBuffer` 689. `*` 690. `* @name isArrayBuffer` 691. `* @function` 692. `* @param {Object} object an Object` 693. `*` 694. `* @returns {boolean}` 695. `*/` 696. `jsPDFAPI.__addimage__.isArrayBuffer = function(object) {` 697. `return supportsArrayBuffer() && object instanceof ArrayBuffer;` 698. `};` 700. `/**` 701. `* Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface` 702. `*` 703. `* @name isArrayBufferView` 704. `* @function` 705. `* @param {Object} object an Object` 706. `* @returns {boolean}` 707. `*/` 708. `var isArrayBufferView = (jsPDFAPI.__addimage__.isArrayBufferView = function(` 709. `object` 710. `) {` 711. `return (` 712. `supportsArrayBuffer() &&` 713. `typeof Uint32Array !== "undefined" &&` 714. `(object instanceof Int8Array ||` 715. `object instanceof Uint8Array ||` 716. `(typeof Uint8ClampedArray !== "undefined" &&` 717. `object instanceof Uint8ClampedArray) ||` 718. `object instanceof Int16Array ||` 719. `object instanceof Uint16Array ||` 720. `object instanceof Int32Array ||` 721. `object instanceof Uint32Array ||` 722. `object instanceof Float32Array ||` 723. `object instanceof Float64Array)` 724. `);` 725. `});` 727. `/**` 728. `* Convert Binary String to ArrayBuffer` 729. `*` 730. `* @name binaryStringToUint8Array` 731. `* @public` 732. `* @function` 733. `* @param {string} BinaryString with ImageData` 734. `* @returns {Uint8Array}` 735. `*/` 736. `var binaryStringToUint8Array = (jsPDFAPI.__addimage__.binaryStringToUint8Array = function(` 737. `binary_string` 738. `) {` 739. `var len = binary_string.length;` 740. `var bytes = new Uint8Array(len);` 741. `for (var i = 0; i < len; i++) {` 742. `bytes[i] = binary_string.charCodeAt(i);` 743. `}` 744. `return bytes;` 745. `});` 747. `/**` 748. `* Convert the Buffer to a Binary String` 749. `*` 750. `* @name arrayBufferToBinaryString` 751. `* @public` 752. `* @function` 753. `* @param {ArrayBuffer|ArrayBufferView} ArrayBuffer buffer or bufferView with ImageData` 754. `*` 755. `* @returns {String}` 756. `*/` 757. `var arrayBufferToBinaryString = (jsPDFAPI.__addimage__.arrayBufferToBinaryString = function(` 758. `buffer` 759. `) {` 760. `var out = "";` 761. `// There are calls with both ArrayBuffer and already converted Uint8Array or other BufferView.` 762. `// Do not copy the array if input is already an array.` 763. `var buf = isArrayBufferView(buffer) ? buffer : new Uint8Array(buffer);` 764. `for (var i = 0; i < buf.length; i += ARRAY_APPLY_BATCH) {` 765. `// Limit the amount of characters being parsed to prevent overflow.` 766. `// Note that while TextDecoder would be faster, it does not have the same` 767. `// functionality as fromCharCode with any provided encodings as of 3/2021.` 768. `out += String.fromCharCode.apply(` 769. `null,` 770. `buf.subarray(i, i + ARRAY_APPLY_BATCH)` 771. `);` 772. `}` 773. `return out;` 774. `});` 776. `/**` 777. `* Possible parameter for addImage, an RGBA buffer with size.` 778. `*` 779. `* @typedef {Object} RGBAData` 780. `* @property {Uint8ClampedArray} data - Single dimensional array of RGBA values. For example from canvas getImageData.` 781. `* @property {number} width - Image width as the data does not carry this information in itself.` 782. `* @property {number} height - Image height as the data does not carry this information in itself.` 783. `*/` 785. `/**` 786. `* Adds an Image to the PDF.` 787. `*` 788. `* @name addImage` 789. `* @public` 790. `* @function` 791. `* @param {string|HTMLImageElement|HTMLCanvasElement|Uint8Array|RGBAData} imageData imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement or object containing RGBA array (like output from canvas.getImageData).` 792. `* @param {string} format format of file if filetype-recognition fails or in case of a Canvas-Element needs to be specified (default for Canvas is JPEG), e.g. 'JPEG', 'PNG', 'WEBP'` 793. `* @param {number} x x Coordinate (in units declared at inception of PDF document) against left edge of the page` 794. `* @param {number} y y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 795. `* @param {number} width width of the image (in units declared at inception of PDF document)` 796. `* @param {number} height height of the Image (in units declared at inception of PDF document)` 797. `* @param {string} alias alias of the image (if used multiple times)` 798. `* @param {string} compression compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'` 799. `* @param {number} rotation rotation of the image in degrees (0-359)` 800. `*` 801. `* @returns jsPDF` 802. `*/` 803. `jsPDFAPI.addImage = function() {` 804. `var imageData, format, x, y, w, h, alias, compression, rotation;` 806. `imageData = arguments[0];` 807. `if (typeof arguments[1] === "number") {` 808. `format = UNKNOWN;` 809. `x = arguments[1];` 810. `y = arguments[2];` 811. `w = arguments[3];` 812. `h = arguments[4];` 813. `alias = arguments[5];` 814. `compression = arguments[6];` 815. `rotation = arguments[7];` 816. `} else {` 817. `format = arguments[1];` 818. `x = arguments[2];` 819. `y = arguments[3];` 820. `w = arguments[4];` 821. `h = arguments[5];` 822. `alias = arguments[6];` 823. `compression = arguments[7];` 824. `rotation = arguments[8];` 825. `}` 827. `if (` 828. `typeof imageData === "object" &&` 829. `!isDOMElement(imageData) &&` 830. `"imageData" in imageData` 831. `) {` 832. `var options = imageData;` 834. `imageData = options.imageData;` 835. `format = options.format || format || UNKNOWN;` 836. `x = options.x || x || 0;` 837. `y = options.y || y || 0;` 838. `w = options.w || options.width || w;` 839. `h = options.h || options.height || h;` 840. `alias = options.alias || alias;` 841. `compression = options.compression || compression;` 842. `rotation = options.rotation || options.angle || rotation;` 843. `}` 845. `//If compression is not explicitly set, determine if we should use compression` 846. `var filter = this.internal.getFilters();` 847. `if (compression === undefined && filter.indexOf("FlateEncode") !== -1) {` 848. `compression = "SLOW";` 849. `}` 851. `if (isNaN(x) || isNaN(y)) {` 852. `throw new Error("Invalid coordinates passed to jsPDF.addImage");` 853. `}` 855. `initialize.call(this);` 857. `var image = processImageData.call(` 858. `this,` 859. `imageData,` 860. `format,` 861. `alias,` 862. `compression` 863. `);` 865. `writeImageToPDF.call(this, x, y, w, h, image, rotation);` 867. `return this;` 868. `};` 870. `var processImageData = function(imageData, format, alias, compression) {` 871. `var result, dataAsBinaryString;` 873. `if (` 874. `typeof imageData === "string" &&` 875. `getImageFileTypeByImageData(imageData) === UNKNOWN` 876. `) {` 877. `imageData = unescape(imageData);` 878. `var tmpImageData = convertBase64ToBinaryString(imageData, false);` 880. `if (tmpImageData !== "") {` 881. `imageData = tmpImageData;` 882. `} else {` 883. `tmpImageData = jsPDFAPI.loadFile(imageData, true);` 884. `if (tmpImageData !== undefined) {` 885. `imageData = tmpImageData;` 886. `}` 887. `}` 888. `}` 890. `if (isDOMElement(imageData)) {` 891. `imageData = getImageDataFromElement(imageData, format);` 892. `}` 894. `format = getImageFileTypeByImageData(imageData, format);` 895. `if (!isImageTypeSupported(format)) {` 896. `throw new Error(` 897. `"addImage does not support files of type '" +` 898. `format +` 899. `"', please ensure that a plugin for '" +` 900. `format +` 901. `"' support is added."` 902. `);` 903. `}` 905. `// now do the heavy lifting` 907. `if (notDefined(alias)) {` 908. `alias = generateAliasFromImageData(imageData);` 909. `}` 910. `result = checkImagesForAlias.call(this, alias);` 912. `if (!result) {` 913. `if (supportsArrayBuffer()) {` 914. `// no need to convert if imageData is already uint8array` 915. `if (!(imageData instanceof Uint8Array) && format !== "RGBA") {` 916. `dataAsBinaryString = imageData;` 917. `imageData = binaryStringToUint8Array(imageData);` 918. `}` 919. `}` 921. `result = this["process" + format.toUpperCase()](` 922. `imageData,` 923. `getImageIndex.call(this),` 924. `alias,` 925. `checkCompressValue(compression),` 926. `dataAsBinaryString` 927. `);` 928. `}` 930. `if (!result) {` 931. `throw new Error("An unknown error occurred whilst processing the image.");` 932. `}` 933. `return result;` 934. `};` 936. `/**` 937. `* @name convertBase64ToBinaryString` 938. `* @function` 939. `* @param {string} stringData` 940. `* @returns {string} binary string` 941. `*/` 942. `var convertBase64ToBinaryString = (jsPDFAPI.__addimage__.convertBase64ToBinaryString = function(` 943. `stringData,` 944. `throwError` 945. `) {` 946. `throwError = typeof throwError === "boolean" ? throwError : true;` 947. `var imageData = "";` 948. `var rawData;` 950. `if (typeof stringData === "string") {` 951. `rawData = extractImageFromDataUrl(stringData) ?? stringData;` 953. `try {` 954. `imageData = atob(rawData);` 955. `} catch (e) {` 956. `if (throwError) {` 957. `if (!validateStringAsBase64(rawData)) {` 958. `throw new Error(` 959. `"Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString "` 960. `);` 961. `} else {` 962. `throw new Error(` 963. `"atob-Error in jsPDF.convertBase64ToBinaryString " + e.message` 964. `);` 965. `}` 966. `}` 967. `}` 968. `}` 969. `return imageData;` 970. `});` 972. `/**` 973. `* @name getImageProperties` 974. `* @function` 975. `* @param {Object} imageData` 976. `* @returns {Object}` 977. `*/` 978. `jsPDFAPI.getImageProperties = function(imageData) {` 979. `var image;` 980. `var tmpImageData = "";` 981. `var format;` 983. `if (isDOMElement(imageData)) {` 984. `imageData = getImageDataFromElement(imageData);` 985. `}` 987. `if (` 988. `typeof imageData === "string" &&` 989. `getImageFileTypeByImageData(imageData) === UNKNOWN` 990. `) {` 991. `tmpImageData = convertBase64ToBinaryString(imageData, false);` 993. `if (tmpImageData === "") {` 994. `tmpImageData = jsPDFAPI.loadFile(imageData) || "";` 995. `}` 996. `imageData = tmpImageData;` 997. `}` 999. `format = getImageFileTypeByImageData(imageData);` 1000. `if (!isImageTypeSupported(format)) {` 1001. `throw new Error(` 1002. `"addImage does not support files of type '" +` 1003. `format +` 1004. `"', please ensure that a plugin for '" +` 1005. `format +` 1006. `"' support is added."` 1007. `);` 1008. `}` 1010. `if (supportsArrayBuffer() && !(imageData instanceof Uint8Array)) {` 1011. `imageData = binaryStringToUint8Array(imageData);` 1012. `}` 1014. `image = this["process" + format.toUpperCase()](imageData);` 1016. `if (!image) {` 1017. `throw new Error("An unknown error occurred whilst processing the image");` 1018. `}` 1020. `image.fileType = format;` 1022. `return image;` 1023. `};` 1024. `})(jsPDF.API);` --- # modules/arabic.js - Documentation modules/arabic.js ================= 1. `/**` 2. `* @license` 3. `* Copyright (c) 2017 Aras Abbasi` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 11. `/**` 12. `* jsPDF arabic parser PlugIn` 13. `*` 14. `* @name arabic` 15. `* @module` 16. `*/` 17. `(function(jsPDFAPI) {` 18. `"use strict";` 20. `/**` 21. `* Arabic shape substitutions: char code => (isolated, final, initial, medial).` 22. `* Arabic Substition A` 23. `*/` 24. `var arabicSubstitionA = {` 25. `0x0621: [0xfe80], // ARABIC LETTER HAMZA` 26. `0x0622: [0xfe81, 0xfe82], // ARABIC LETTER ALEF WITH MADDA ABOVE` 27. `0x0623: [0xfe83, 0xfe84], // ARABIC LETTER ALEF WITH HAMZA ABOVE` 28. `0x0624: [0xfe85, 0xfe86], // ARABIC LETTER WAW WITH HAMZA ABOVE` 29. `0x0625: [0xfe87, 0xfe88], // ARABIC LETTER ALEF WITH HAMZA BELOW` 30. `0x0626: [0xfe89, 0xfe8a, 0xfe8b, 0xfe8c], // ARABIC LETTER YEH WITH HAMZA ABOVE` 31. `0x0627: [0xfe8d, 0xfe8e], // ARABIC LETTER ALEF` 32. `0x0628: [0xfe8f, 0xfe90, 0xfe91, 0xfe92], // ARABIC LETTER BEH` 33. `0x0629: [0xfe93, 0xfe94], // ARABIC LETTER TEH MARBUTA` 34. `0x062a: [0xfe95, 0xfe96, 0xfe97, 0xfe98], // ARABIC LETTER TEH` 35. `0x062b: [0xfe99, 0xfe9a, 0xfe9b, 0xfe9c], // ARABIC LETTER THEH` 36. `0x062c: [0xfe9d, 0xfe9e, 0xfe9f, 0xfea0], // ARABIC LETTER JEEM` 37. `0x062d: [0xfea1, 0xfea2, 0xfea3, 0xfea4], // ARABIC LETTER HAH` 38. `0x062e: [0xfea5, 0xfea6, 0xfea7, 0xfea8], // ARABIC LETTER KHAH` 39. `0x062f: [0xfea9, 0xfeaa], // ARABIC LETTER DAL` 40. `0x0630: [0xfeab, 0xfeac], // ARABIC LETTER THAL` 41. `0x0631: [0xfead, 0xfeae], // ARABIC LETTER REH` 42. `0x0632: [0xfeaf, 0xfeb0], // ARABIC LETTER ZAIN` 43. `0x0633: [0xfeb1, 0xfeb2, 0xfeb3, 0xfeb4], // ARABIC LETTER SEEN` 44. `0x0634: [0xfeb5, 0xfeb6, 0xfeb7, 0xfeb8], // ARABIC LETTER SHEEN` 45. `0x0635: [0xfeb9, 0xfeba, 0xfebb, 0xfebc], // ARABIC LETTER SAD` 46. `0x0636: [0xfebd, 0xfebe, 0xfebf, 0xfec0], // ARABIC LETTER DAD` 47. `0x0637: [0xfec1, 0xfec2, 0xfec3, 0xfec4], // ARABIC LETTER TAH` 48. `0x0638: [0xfec5, 0xfec6, 0xfec7, 0xfec8], // ARABIC LETTER ZAH` 49. `0x0639: [0xfec9, 0xfeca, 0xfecb, 0xfecc], // ARABIC LETTER AIN` 50. `0x063a: [0xfecd, 0xfece, 0xfecf, 0xfed0], // ARABIC LETTER GHAIN` 51. `0x0641: [0xfed1, 0xfed2, 0xfed3, 0xfed4], // ARABIC LETTER FEH` 52. `0x0642: [0xfed5, 0xfed6, 0xfed7, 0xfed8], // ARABIC LETTER QAF` 53. `0x0643: [0xfed9, 0xfeda, 0xfedb, 0xfedc], // ARABIC LETTER KAF` 54. `0x0644: [0xfedd, 0xfede, 0xfedf, 0xfee0], // ARABIC LETTER LAM` 55. `0x0645: [0xfee1, 0xfee2, 0xfee3, 0xfee4], // ARABIC LETTER MEEM` 56. `0x0646: [0xfee5, 0xfee6, 0xfee7, 0xfee8], // ARABIC LETTER NOON` 57. `0x0647: [0xfee9, 0xfeea, 0xfeeb, 0xfeec], // ARABIC LETTER HEH` 58. `0x0648: [0xfeed, 0xfeee], // ARABIC LETTER WAW` 59. `0x0649: [0xfeef, 0xfef0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA` 60. `0x064a: [0xfef1, 0xfef2, 0xfef3, 0xfef4], // ARABIC LETTER YEH` 61. `0x0671: [0xfb50, 0xfb51], // ARABIC LETTER ALEF WASLA` 62. `0x0677: [0xfbdd], // ARABIC LETTER U WITH HAMZA ABOVE` 63. `0x0679: [0xfb66, 0xfb67, 0xfb68, 0xfb69], // ARABIC LETTER TTEH` 64. `0x067a: [0xfb5e, 0xfb5f, 0xfb60, 0xfb61], // ARABIC LETTER TTEHEH` 65. `0x067b: [0xfb52, 0xfb53, 0xfb54, 0xfb55], // ARABIC LETTER BEEH` 66. `0x067e: [0xfb56, 0xfb57, 0xfb58, 0xfb59], // ARABIC LETTER PEH` 67. `0x067f: [0xfb62, 0xfb63, 0xfb64, 0xfb65], // ARABIC LETTER TEHEH` 68. `0x0680: [0xfb5a, 0xfb5b, 0xfb5c, 0xfb5d], // ARABIC LETTER BEHEH` 69. `0x0683: [0xfb76, 0xfb77, 0xfb78, 0xfb79], // ARABIC LETTER NYEH` 70. `0x0684: [0xfb72, 0xfb73, 0xfb74, 0xfb75], // ARABIC LETTER DYEH` 71. `0x0686: [0xfb7a, 0xfb7b, 0xfb7c, 0xfb7d], // ARABIC LETTER TCHEH` 72. `0x0687: [0xfb7e, 0xfb7f, 0xfb80, 0xfb81], // ARABIC LETTER TCHEHEH` 73. `0x0688: [0xfb88, 0xfb89], // ARABIC LETTER DDAL` 74. `0x068c: [0xfb84, 0xfb85], // ARABIC LETTER DAHAL` 75. `0x068d: [0xfb82, 0xfb83], // ARABIC LETTER DDAHAL` 76. `0x068e: [0xfb86, 0xfb87], // ARABIC LETTER DUL` 77. `0x0691: [0xfb8c, 0xfb8d], // ARABIC LETTER RREH` 78. `0x0698: [0xfb8a, 0xfb8b], // ARABIC LETTER JEH` 79. `0x06a4: [0xfb6a, 0xfb6b, 0xfb6c, 0xfb6d], // ARABIC LETTER VEH` 80. `0x06a6: [0xfb6e, 0xfb6f, 0xfb70, 0xfb71], // ARABIC LETTER PEHEH` 81. `0x06a9: [0xfb8e, 0xfb8f, 0xfb90, 0xfb91], // ARABIC LETTER KEHEH` 82. `0x06ad: [0xfbd3, 0xfbd4, 0xfbd5, 0xfbd6], // ARABIC LETTER NG` 83. `0x06af: [0xfb92, 0xfb93, 0xfb94, 0xfb95], // ARABIC LETTER GAF` 84. `0x06b1: [0xfb9a, 0xfb9b, 0xfb9c, 0xfb9d], // ARABIC LETTER NGOEH` 85. `0x06b3: [0xfb96, 0xfb97, 0xfb98, 0xfb99], // ARABIC LETTER GUEH` 86. `0x06ba: [0xfb9e, 0xfb9f], // ARABIC LETTER NOON GHUNNA` 87. `0x06bb: [0xfba0, 0xfba1, 0xfba2, 0xfba3], // ARABIC LETTER RNOON` 88. `0x06be: [0xfbaa, 0xfbab, 0xfbac, 0xfbad], // ARABIC LETTER HEH DOACHASHMEE` 89. `0x06c0: [0xfba4, 0xfba5], // ARABIC LETTER HEH WITH YEH ABOVE` 90. `0x06c1: [0xfba6, 0xfba7, 0xfba8, 0xfba9], // ARABIC LETTER HEH GOAL` 91. `0x06c5: [0xfbe0, 0xfbe1], // ARABIC LETTER KIRGHIZ OE` 92. `0x06c6: [0xfbd9, 0xfbda], // ARABIC LETTER OE` 93. `0x06c7: [0xfbd7, 0xfbd8], // ARABIC LETTER U` 94. `0x06c8: [0xfbdb, 0xfbdc], // ARABIC LETTER YU` 95. `0x06c9: [0xfbe2, 0xfbe3], // ARABIC LETTER KIRGHIZ YU` 96. `0x06cb: [0xfbde, 0xfbdf], // ARABIC LETTER VE` 97. `0x06cc: [0xfbfc, 0xfbfd, 0xfbfe, 0xfbff], // ARABIC LETTER FARSI YEH` 98. `0x06d0: [0xfbe4, 0xfbe5, 0xfbe6, 0xfbe7], //ARABIC LETTER E` 99. `0x06d2: [0xfbae, 0xfbaf], // ARABIC LETTER YEH BARREE` 100. `0x06d3: [0xfbb0, 0xfbb1] // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE` 101. `};` 103. `/*` 104. `var ligaturesSubstitutionA = {` 105. `0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM` 106. `};` 107. `*/` 109. `var ligatures = {` 110. `0xfedf: {` 111. `0xfe82: 0xfef5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM` 112. `0xfe84: 0xfef7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM` 113. `0xfe88: 0xfef9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM` 114. `0xfe8e: 0xfefb // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM` 115. `},` 116. `0xfee0: {` 117. `0xfe82: 0xfef6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM` 118. `0xfe84: 0xfef8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM` 119. `0xfe88: 0xfefa, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM` 120. `0xfe8e: 0xfefc // ARABIC LIGATURE LAM WITH ALEF FINAL FORM` 121. `},` 122. `0xfe8d: { 0xfedf: { 0xfee0: { 0xfeea: 0xfdf2 } } }, // ALLAH` 123. `0x0651: {` 124. `0x064c: 0xfc5e, // Shadda + Dammatan` 125. `0x064d: 0xfc5f, // Shadda + Kasratan` 126. `0x064e: 0xfc60, // Shadda + Fatha` 127. `0x064f: 0xfc61, // Shadda + Damma` 128. `0x0650: 0xfc62 // Shadda + Kasra` 129. `}` 130. `};` 132. `var arabic_diacritics = {` 133. `1612: 64606, // Shadda + Dammatan` 134. `1613: 64607, // Shadda + Kasratan` 135. `1614: 64608, // Shadda + Fatha` 136. `1615: 64609, // Shadda + Damma` 137. `1616: 64610 // Shadda + Kasra` 138. `};` 140. `var alfletter = [1570, 1571, 1573, 1575];` 142. `var noChangeInForm = -1;` 143. `var isolatedForm = 0;` 144. `var finalForm = 1;` 145. `var initialForm = 2;` 146. `var medialForm = 3;` 148. `jsPDFAPI.__arabicParser__ = {};` 150. `//private` 151. `var isInArabicSubstitutionA = (jsPDFAPI.__arabicParser__.isInArabicSubstitutionA = function(` 152. `letter` 153. `) {` 154. `return typeof arabicSubstitionA[letter.charCodeAt(0)] !== "undefined";` 155. `});` 157. `var isArabicLetter = (jsPDFAPI.__arabicParser__.isArabicLetter = function(` 158. `letter` 159. `) {` 160. `return (` 161. `typeof letter === "string" &&` 162. `/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(` 163. `letter` 164. `)` 165. `);` 166. `});` 168. `var isArabicEndLetter = (jsPDFAPI.__arabicParser__.isArabicEndLetter = function(` 169. `letter` 170. `) {` 171. `return (` 172. `isArabicLetter(letter) &&` 173. `isInArabicSubstitutionA(letter) &&` 174. `arabicSubstitionA[letter.charCodeAt(0)].length <= 2` 175. `);` 176. `});` 178. `var isArabicAlfLetter = (jsPDFAPI.__arabicParser__.isArabicAlfLetter = function(` 179. `letter` 180. `) {` 181. `return (` 182. `isArabicLetter(letter) && alfletter.indexOf(letter.charCodeAt(0)) >= 0` 183. `);` 184. `});` 186. `jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm = function(letter) {` 187. `return (` 188. `isArabicLetter(letter) &&` 189. `isInArabicSubstitutionA(letter) &&` 190. `arabicSubstitionA[letter.charCodeAt(0)].length >= 1` 191. `);` 192. `};` 194. `var arabicLetterHasFinalForm = (jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm = function(` 195. `letter` 196. `) {` 197. `return (` 198. `isArabicLetter(letter) &&` 199. `isInArabicSubstitutionA(letter) &&` 200. `arabicSubstitionA[letter.charCodeAt(0)].length >= 2` 201. `);` 202. `});` 204. `jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm = function(letter) {` 205. `return (` 206. `isArabicLetter(letter) &&` 207. `isInArabicSubstitutionA(letter) &&` 208. `arabicSubstitionA[letter.charCodeAt(0)].length >= 3` 209. `);` 210. `};` 212. `var arabicLetterHasMedialForm = (jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm = function(` 213. `letter` 214. `) {` 215. `return (` 216. `isArabicLetter(letter) &&` 217. `isInArabicSubstitutionA(letter) &&` 218. `arabicSubstitionA[letter.charCodeAt(0)].length == 4` 219. `);` 220. `});` 222. `var resolveLigatures = (jsPDFAPI.__arabicParser__.resolveLigatures = function(` 223. `letters` 224. `) {` 225. `var i = 0;` 226. `var tmpLigatures = ligatures;` 227. `var result = "";` 228. `var effectedLetters = 0;` 230. `for (i = 0; i < letters.length; i += 1) {` 231. `if (typeof tmpLigatures[letters.charCodeAt(i)] !== "undefined") {` 232. `effectedLetters++;` 233. `tmpLigatures = tmpLigatures[letters.charCodeAt(i)];` 235. `if (typeof tmpLigatures === "number") {` 236. `result += String.fromCharCode(tmpLigatures);` 237. `tmpLigatures = ligatures;` 238. `effectedLetters = 0;` 239. `}` 240. `if (i === letters.length - 1) {` 241. `tmpLigatures = ligatures;` 242. `result += letters.charAt(i - (effectedLetters - 1));` 243. `i = i - (effectedLetters - 1);` 244. `effectedLetters = 0;` 245. `}` 246. `} else {` 247. `tmpLigatures = ligatures;` 248. `result += letters.charAt(i - effectedLetters);` 249. `i = i - effectedLetters;` 250. `effectedLetters = 0;` 251. `}` 252. `}` 254. `return result;` 255. `});` 257. `jsPDFAPI.__arabicParser__.isArabicDiacritic = function(letter) {` 258. `return (` 259. `letter !== undefined &&` 260. `arabic_diacritics[letter.charCodeAt(0)] !== undefined` 261. `);` 262. `};` 264. `var getCorrectForm = (jsPDFAPI.__arabicParser__.getCorrectForm = function(` 265. `currentChar,` 266. `beforeChar,` 267. `nextChar` 268. `) {` 269. `if (!isArabicLetter(currentChar)) {` 270. `return -1;` 271. `}` 273. `if (isInArabicSubstitutionA(currentChar) === false) {` 274. `return noChangeInForm;` 275. `}` 276. `if (` 277. `!arabicLetterHasFinalForm(currentChar) ||` 278. `(!isArabicLetter(beforeChar) && !isArabicLetter(nextChar)) ||` 279. `(!isArabicLetter(nextChar) && isArabicEndLetter(beforeChar)) ||` 280. `(isArabicEndLetter(currentChar) && !isArabicLetter(beforeChar)) ||` 281. `(isArabicEndLetter(currentChar) && isArabicAlfLetter(beforeChar)) ||` 282. `(isArabicEndLetter(currentChar) && isArabicEndLetter(beforeChar))` 283. `) {` 284. `return isolatedForm;` 285. `}` 287. `if (` 288. `arabicLetterHasMedialForm(currentChar) &&` 289. `isArabicLetter(beforeChar) &&` 290. `!isArabicEndLetter(beforeChar) &&` 291. `isArabicLetter(nextChar) &&` 292. `arabicLetterHasFinalForm(nextChar)` 293. `) {` 294. `return medialForm;` 295. `}` 297. `if (isArabicEndLetter(currentChar) || !isArabicLetter(nextChar)) {` 298. `return finalForm;` 299. `}` 300. `return initialForm;` 301. `});` 303. `/**` 304. `* @name processArabic` 305. `* @function` 306. `* @param {string} text` 307. `* @returns {string}` 308. `*/` 309. `var parseArabic = function(text) {` 310. `text = text || "";` 312. `var result = "";` 313. `var i = 0;` 314. `var j = 0;` 315. `var position = 0;` 316. `var currentLetter = "";` 317. `var prevLetter = "";` 318. `var nextLetter = "";` 320. `var words = text.split("\\s+");` 321. `var newWords = [];` 322. `for (i = 0; i < words.length; i += 1) {` 323. `newWords.push("");` 324. `for (j = 0; j < words[i].length; j += 1) {` 325. `currentLetter = words[i][j];` 326. `prevLetter = words[i][j - 1];` 327. `nextLetter = words[i][j + 1];` 328. `if (isArabicLetter(currentLetter)) {` 329. `position = getCorrectForm(currentLetter, prevLetter, nextLetter);` 330. `if (position !== -1) {` 331. `newWords[i] += String.fromCharCode(` 332. `arabicSubstitionA[currentLetter.charCodeAt(0)][position]` 333. `);` 334. `} else {` 335. `newWords[i] += currentLetter;` 336. `}` 337. `} else {` 338. `newWords[i] += currentLetter;` 339. `}` 340. `}` 342. `newWords[i] = resolveLigatures(newWords[i]);` 343. `}` 344. `result = newWords.join(" ");` 346. `return result;` 347. `};` 349. `var processArabic = (jsPDFAPI.__arabicParser__.processArabic = jsPDFAPI.processArabic = function() {` 350. `var text =` 351. `typeof arguments[0] === "string" ? arguments[0] : arguments[0].text;` 352. `var tmpText = [];` 353. `var result;` 355. `if (Array.isArray(text)) {` 356. `var i = 0;` 357. `tmpText = [];` 358. `for (i = 0; i < text.length; i += 1) {` 359. `if (Array.isArray(text[i])) {` 360. `tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]);` 361. `} else {` 362. `tmpText.push([parseArabic(text[i])]);` 363. `}` 364. `}` 365. `result = tmpText;` 366. `} else {` 367. `result = parseArabic(text);` 368. `}` 369. `if (typeof arguments[0] === "string") {` 370. `return result;` 371. `} else {` 372. `arguments[0].text = result;` 373. `return arguments[0];` 374. `}` 375. `});` 377. `jsPDFAPI.events.push(["preProcessText", processArabic]);` 378. `})(jsPDF.API);` --- # modules/fileloading.js - Documentation modules/fileloading.js ====================== 1. `/**` 2. `* @license` 3. `* jsPDF fileloading PlugIn` 4. `* Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com)` 5. `*` 6. `* Licensed under the MIT License.` 7. `* http://opensource.org/licenses/mit-license` 8. `*/` 10. `import { jsPDF } from "../jspdf.js";` 12. `/**` 13. `* @name fileloading` 14. `* @module` 15. `*/` 16. `(function(jsPDFAPI) {` 17. `"use strict";` 19. `/**` 20. `* @name loadFile` 21. `* @function` 22. `* @param {string} url` 23. `* @param {boolean} sync` 24. `* @param {function} callback` 25. `* @returns {string|undefined} result` 26. `*/` 27. `jsPDFAPI.loadFile = function(url, sync, callback) {` 28. `// @if MODULE_FORMAT!='cjs'` 29. `return browserRequest(url, sync, callback);` 30. `// @endif` 32. `// @if MODULE_FORMAT='cjs'` 33. `// eslint-disable-next-line no-unreachable` 34. `return nodeReadFile(url, sync, callback);` 35. `// @endif` 36. `};` 38. `/**` 39. `* @name loadImageFile` 40. `* @function` 41. `* @param {string} path` 42. `* @param {boolean} sync` 43. `* @param {function} callback` 44. `*/` 45. `jsPDFAPI.loadImageFile = jsPDFAPI.loadFile;` 47. `function browserRequest(url, sync, callback) {` 48. `sync = sync === false ? false : true;` 49. `callback = typeof callback === "function" ? callback : function() {};` 50. `var result = undefined;` 52. `var xhr = function(url, sync, callback) {` 53. `var request = new XMLHttpRequest();` 54. `var i = 0;` 56. `var sanitizeUnicode = function(data) {` 57. `var dataLength = data.length;` 58. `var charArray = [];` 59. `var StringFromCharCode = String.fromCharCode;` 61. `//Transform Unicode to ASCII` 62. `for (i = 0; i < dataLength; i += 1) {` 63. `charArray.push(StringFromCharCode(data.charCodeAt(i) & 0xff));` 64. `}` 65. `return charArray.join("");` 66. `};` 68. `request.open("GET", url, !sync);` 69. `// XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]` 70. `request.overrideMimeType("text/plain; charset=x-user-defined");` 72. `if (sync === false) {` 73. `request.onload = function() {` 74. `if (request.status === 200) {` 75. `callback(sanitizeUnicode(this.responseText));` 76. `} else {` 77. `callback(undefined);` 78. `}` 79. `};` 80. `}` 81. `request.send(null);` 83. `if (sync && request.status === 200) {` 84. `return sanitizeUnicode(request.responseText);` 85. `}` 86. `};` 87. `try {` 88. `result = xhr(url, sync, callback);` 89. `// eslint-disable-next-line no-empty` 90. `} catch (e) {}` 91. `return result;` 92. `}` 94. `function nodeReadFile(url, sync, callback) {` 95. `sync = sync === false ? false : true;` 96. `var result = undefined;` 98. `var fs = require("fs");` 99. `var path = require("path");` 101. `url = path.resolve(url);` 102. `if (sync) {` 103. `try {` 104. `result = fs.readFileSync(url, { encoding: "latin1" });` 105. `} catch (e) {` 106. `return undefined;` 107. `}` 108. `} else {` 109. `fs.readFile(url, { encoding: "latin1" }, function(err, data) {` 110. `if (!callback) {` 111. `return;` 112. `}` 113. `if (err) {` 114. `callback(undefined);` 115. `}` 116. `callback(data);` 117. `});` 118. `}` 120. `return result;` 121. `}` 122. `})(jsPDF.API);` --- # modules/annotations.js - Documentation modules/annotations.js ====================== 1. `/**` 2. `* @license` 3. `* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `/**` 10. `* jsPDF Annotations PlugIn` 11. `*` 12. `* There are many types of annotations in a PDF document. Annotations are placed` 13. `* on a page at a particular location. They are not 'attached' to an object.` 14. `*
` 15. `* This plugin current supports
` 16. `*
  • Goto Page (set pageNumber and top in options)` 17. `*
  • Goto Name (set name and top in options)` 18. `*
  • Goto URL (set url in options)` 19. `*

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

    ` 23. `*

    ` 24. `* Links, Text, Popup, and FreeText are supported.` 25. `*

    ` 26. `*

    ` 27. `* Options In PDF spec Not Implemented Yet` 28. `*

  • link border` 29. `*
  • named target` 30. `*
  • page coordinates` 31. `*
  • destination page scaling and layout` 32. `*
  • actions other than URL and GotoPage` 33. `*
  • background / hover actions` 34. `*

    ` 35. `* @name annotations` 36. `* @module` 37. `*/` 39. `/*` 40. `Destination Magnification Factors` 41. `See PDF 1.3 Page 386 for meanings and options` 43. `[supported]` 44. `XYZ (options; left top zoom)` 45. `Fit (no options)` 46. `FitH (options: top)` 47. `FitV (options: left)` 49. `[not supported]` 50. `FitR` 51. `FitB` 52. `FitBH` 53. `FitBV` 54. `*/` 56. `import { jsPDF } from "../jspdf.js";` 58. `(function(jsPDFAPI) {` 59. `"use strict";` 61. `var notEmpty = function(obj) {` 62. `if (typeof obj != "undefined") {` 63. `if (obj != "") {` 64. `return true;` 65. `}` 66. `}` 67. `};` 69. `jsPDF.API.events.push([`\ 70. `"addPage",`\ 71. `function(addPageData) {`\ 72. `var pageInfo = this.internal.getPageInfo(addPageData.pageNumber);`\ 73. `pageInfo.pageContext.annotations = [];`\ 74. `}`\ 75. `]);` 77. `jsPDFAPI.events.push([`\ 78. `"putPage",`\ 79. `function(putPageData) {`\ 80. `var getHorizontalCoordinateString = this.internal.getCoordinateString;`\ 81. `var getVerticalCoordinateString = this.internal`\ 82. `.getVerticalCoordinateString;`\ 83. `var pageInfo = this.internal.getPageInfoByObjId(putPageData.objId);`\ 84. `var pageAnnos = putPageData.pageContext.annotations;`\ \ 86. `var anno, rect, line;`\ 87. `var found = false;`\ 88. `for (var a = 0; a < pageAnnos.length && !found; a++) {`\ 89. `anno = pageAnnos[a];`\ 90. `switch (anno.type) {`\ 91. `case "link":`\ 92. `if (`\ 93. `notEmpty(anno.options.url) ||`\ 94. `notEmpty(anno.options.pageNumber)`\ 95. `) {`\ 96. `found = true;`\ 97. `}`\ 98. `break;`\ 99. `case "reference":`\ 100. `case "text":`\ 101. `case "freetext":`\ 102. `found = true;`\ 103. `break;`\ 104. `}`\ 105. `}`\ 106. `if (found == false) {`\ 107. `return;`\ 108. `}`\ \ 110. `this.internal.write("/Annots [");`\ 111. `for (var i = 0; i < pageAnnos.length; i++) {`\ 112. `anno = pageAnnos[i];`\ 113. `var escape = this.internal.pdfEscape;`\ 114. `var encryptor = this.internal.getEncryptor(putPageData.objId);`\ \ 116. `switch (anno.type) {`\ 117. `case "reference":`\ 118. `// References to Widget Annotations (for AcroForm Fields)`\ 119. `this.internal.write(" " + anno.object.objId + " 0 R ");`\ 120. `break;`\ 121. `case "text":`\ 122. `// Create a an object for both the text and the popup`\ 123. `var objText = this.internal.newAdditionalObject();`\ 124. `var objPopup = this.internal.newAdditionalObject();`\ 125. `var encryptorText = this.internal.getEncryptor(objText.objId);`\ \ 127. `var title = anno.title || "Note";`\ 128. `rect =`\ 129. `"/Rect [" +`\ 130. `getHorizontalCoordinateString(anno.bounds.x) +`\ 131. `" " +`\ 132. `getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +`\ 133. `" " +`\ 134. `getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w) +`\ 135. `" " +`\ 136. `getVerticalCoordinateString(anno.bounds.y) +`\ 137. `"] ";`\ \ 139. `line =`\ 140. `"<>";`\ 150. `objText.content = line;`\ \ 152. `var parent = objText.objId + " 0 R";`\ 153. `var popoff = 30;`\ 154. `rect =`\ 155. `"/Rect [" +`\ 156. `getHorizontalCoordinateString(anno.bounds.x + popoff) +`\ 157. `" " +`\ 158. `getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +`\ 159. `" " +`\ 160. `getHorizontalCoordinateString(`\ 161. `anno.bounds.x + anno.bounds.w + popoff`\ 162. `) +`\ 163. `" " +`\ 164. `getVerticalCoordinateString(anno.bounds.y) +`\ 165. `"] ";`\ 166. `line =`\ 167. `"<>";`\ 240. `} else if (anno.options.pageNumber) {`\ 241. `// first page is 0`\ 242. `var info = this.internal.getPageInfo(anno.options.pageNumber);`\ 243. `line =`\ 244. `"< pageNumber or url [required]` 321. `*

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

    ` 322. `* @name link` 323. `* @function` 324. `* @param {number} x` 325. `* @param {number} y` 326. `* @param {number} w` 327. `* @param {number} h` 328. `* @param {Object} options` 329. `*/` 330. `jsPDFAPI.link = function(x, y, w, h, options) {` 331. `var pageInfo = this.internal.getCurrentPageInfo();` 332. `var getHorizontalCoordinateString = this.internal.getCoordinateString;` 333. `var getVerticalCoordinateString = this.internal.getVerticalCoordinateString;` 335. `pageInfo.pageContext.annotations.push({` 336. `finalBounds: {` 337. `x: getHorizontalCoordinateString(x),` 338. `y: getVerticalCoordinateString(y),` 339. `w: getHorizontalCoordinateString(x + w),` 340. `h: getVerticalCoordinateString(y + h)` 341. `},` 342. `options: options,` 343. `type: "link"` 344. `});` 345. `};` 347. `/**` 348. `* Currently only supports single line text.` 349. `* Returns the width of the text/link` 350. `*` 351. `* @name textWithLink` 352. `* @function` 353. `* @param {string} text` 354. `* @param {number} x` 355. `* @param {number} y` 356. `* @param {Object} options` 357. `* @returns {number} width the width of the text/link` 358. `*/` 359. `jsPDFAPI.textWithLink = function(text, x, y, options) {` 360. `var totalLineWidth = this.getTextWidth(text);` 361. `var lineHeight = this.internal.getLineHeight() / this.internal.scaleFactor;` 362. `var linkHeight, linkWidth;` 364. `// Checking if maxWidth option is passed to determine lineWidth and number of lines for each line` 365. `if (options.maxWidth !== undefined) {` 366. `var { maxWidth } = options;` 367. `linkWidth = maxWidth;` 368. `var numOfLines = this.splitTextToSize(text, linkWidth).length;` 369. `linkHeight = Math.ceil(lineHeight * numOfLines);` 370. `} else {` 371. `linkWidth = totalLineWidth;` 372. `linkHeight = lineHeight;` 373. `}` 375. `this.text(text, x, y, options);` 377. `//TODO We really need the text baseline height to do this correctly.` 378. `// Or ability to draw text on top, bottom, center, or baseline.` 379. `y += lineHeight * 0.2;` 380. `//handle x position based on the align option` 381. `if (options.align === "center") {` 382. `x = x - totalLineWidth / 2; //since starting from center move the x position by half of text width` 383. `}` 384. `if (options.align === "right") {` 385. `x = x - totalLineWidth;` 386. `}` 387. `this.link(x, y - lineHeight, linkWidth, linkHeight, options);` 388. `return totalLineWidth;` 389. `};` 391. `//TODO move into external library` 392. `/**` 393. `* @name getTextWidth` 394. `* @function` 395. `* @param {string} text` 396. `* @returns {number} txtWidth` 397. `*/` 398. `jsPDFAPI.getTextWidth = function(text) {` 399. `var fontSize = this.internal.getFontSize();` 400. `var txtWidth =` 401. `(this.getStringUnitWidth(text) * fontSize) / this.internal.scaleFactor;` 402. `return txtWidth;` 403. `};` 405. `return this;` 406. `})(jsPDF.API);` --- # modules/gif_support.js - Documentation modules/gif\_support.js ======================= 1. `/**` 2. `* @license` 3. `* Copyright (c) 2017 Aras Abbasi` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 10. `import { GifReader } from "../libs/omggif.js";` 11. `import { JPEGEncoder } from "../libs/JPEGEncoder.js";` 13. `/**` 14. `* jsPDF Gif Support PlugIn` 15. `*` 16. `* @name gif_support` 17. `* @module` 18. `*/` 19. `(function(jsPDFAPI) {` 20. `"use strict";` 22. `jsPDFAPI.processGIF89A = function(imageData, index, alias, compression) {` 23. `var reader = new GifReader(imageData);` 24. `var width = reader.width,` 25. `height = reader.height;` 26. `var qu = 100;` 27. `var pixels = [];` 29. `reader.decodeAndBlitFrameRGBA(0, pixels);` 30. `var rawImageData = {` 31. `data: pixels,` 32. `width: width,` 33. `height: height` 34. `};` 36. `var encoder = new JPEGEncoder(qu);` 37. `var data = encoder.encode(rawImageData, qu);` 38. `return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);` 39. `};` 41. `jsPDFAPI.processGIF87A = jsPDFAPI.processGIF89A;` 42. `})(jsPDF.API);` --- # modules/javascript.js - Documentation modules/javascript.js ===================== 1. `/**` 2. `* @license` 3. `* ====================================================================` 4. `* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 29. `/**` 30. `* jsPDF JavaScript plugin` 31. `*` 32. `* @name javascript` 33. `* @module` 34. `*/` 35. `(function(jsPDFAPI) {` 36. `"use strict";` 37. `var jsNamesObj, jsJsObj, text;` 38. `/**` 39. `* @name addJS` 40. `* @function` 41. `* @param {string} javascript The javascript to be embedded into the PDF-file.` 42. `* @returns {jsPDF}` 43. `*/` 44. `jsPDFAPI.addJS = function(javascript) {` 45. `text = javascript;` 46. `this.internal.events.subscribe("postPutResources", function() {` 47. `jsNamesObj = this.internal.newObject();` 48. `this.internal.out("<<");` 49. `this.internal.out("/Names [(EmbeddedJS) " + (jsNamesObj + 1) + " 0 R]");` 50. `this.internal.out(">>");` 51. `this.internal.out("endobj");` 53. `jsJsObj = this.internal.newObject();` 54. `this.internal.out("<<");` 55. `this.internal.out("/S /JavaScript");` 56. `this.internal.out("/JS (" + text + ")");` 57. `this.internal.out(">>");` 58. `this.internal.out("endobj");` 59. `});` 60. `this.internal.events.subscribe("putCatalog", function() {` 61. `if (jsNamesObj !== undefined && jsJsObj !== undefined) {` 62. `this.internal.out("/Names <>");` 63. `}` 64. `});` 65. `return this;` 66. `};` 67. `})(jsPDF.API);` --- # modules/jpeg_support.js - Documentation modules/jpeg\_support.js ======================== 1. `/**` 2. `* @license` 3. `*` 4. `* Licensed under the MIT License.` 5. `* http://opensource.org/licenses/mit-license` 6. `*/` 8. `import { jsPDF } from "../jspdf.js";` 10. `/**` 11. `* jsPDF jpeg Support PlugIn` 12. `*` 13. `* @name jpeg_support` 14. `* @module` 15. `*/` 16. `(function(jsPDFAPI) {` 17. `"use strict";` 19. `/**` 20. `* 0xc0 (SOF) Huffman - Baseline DCT` 21. `* 0xc1 (SOF) Huffman - Extended sequential DCT` 22. `* 0xc2 Progressive DCT (SOF2)` 23. `* 0xc3 Spatial (sequential) lossless (SOF3)` 24. `* 0xc4 Differential sequential DCT (SOF5)` 25. `* 0xc5 Differential progressive DCT (SOF6)` 26. `* 0xc6 Differential spatial (SOF7)` 27. `* 0xc7` 28. `*/` 29. `var markers = [0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7];` 31. `//takes a string imgData containing the raw bytes of` 32. `//a jpeg image and returns [width, height]` 33. `//Algorithm from: http://www.64lines.com/jpeg-width-height` 34. `var getJpegInfo = function(imgData) {` 35. `var width, height, numcomponents;` 36. `var blockLength = imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5);` 37. `var len = imgData.length;` 38. `var result = { width: 0, height: 0, numcomponents: 1 };` 39. `for (var i = 4; i < len; i += 2) {` 40. `i += blockLength;` 41. `if (markers.indexOf(imgData.charCodeAt(i + 1)) !== -1) {` 42. `height = imgData.charCodeAt(i + 5) * 256 + imgData.charCodeAt(i + 6);` 43. `width = imgData.charCodeAt(i + 7) * 256 + imgData.charCodeAt(i + 8);` 44. `numcomponents = imgData.charCodeAt(i + 9);` 45. `result = { width: width, height: height, numcomponents: numcomponents };` 46. `break;` 47. `} else {` 48. `blockLength =` 49. `imgData.charCodeAt(i + 2) * 256 + imgData.charCodeAt(i + 3);` 50. `}` 51. `}` 52. `return result;` 53. `};` 55. `/**` 56. `* @ignore` 57. `*/` 58. `jsPDFAPI.processJPEG = function(` 59. `data,` 60. `index,` 61. `alias,` 62. `compression,` 63. `dataAsBinaryString,` 64. `colorSpace` 65. `) {` 66. `var filter = this.decode.DCT_DECODE,` 67. `bpc = 8,` 68. `dims,` 69. `result = null;` 71. `if (` 72. `typeof data === "string" ||` 73. `this.__addimage__.isArrayBuffer(data) ||` 74. `this.__addimage__.isArrayBufferView(data)` 75. `) {` 76. `// if we already have a stored binary string rep use that` 77. `data = dataAsBinaryString || data;` 78. `data = this.__addimage__.isArrayBuffer(data)` 79. `? new Uint8Array(data)` 80. `: data;` 81. `data = this.__addimage__.isArrayBufferView(data)` 82. `? this.__addimage__.arrayBufferToBinaryString(data)` 83. `: data;` 85. `dims = getJpegInfo(data);` 86. `switch (dims.numcomponents) {` 87. `case 1:` 88. `colorSpace = this.color_spaces.DEVICE_GRAY;` 89. `break;` 90. `case 4:` 91. `colorSpace = this.color_spaces.DEVICE_CMYK;` 92. `break;` 93. `case 3:` 94. `colorSpace = this.color_spaces.DEVICE_RGB;` 95. `break;` 96. `}` 98. `result = {` 99. `data: data,` 100. `width: dims.width,` 101. `height: dims.height,` 102. `colorSpace: colorSpace,` 103. `bitsPerComponent: bpc,` 104. `filter: filter,` 105. `index: index,` 106. `alias: alias` 107. `};` 108. `}` 109. `return result;` 110. `};` 111. `})(jsPDF.API);` --- # modules/acroform.js - Documentation modules/acroform.js =================== 1. `/* global jsPDF */` 2. `/**` 3. `* @license` 4. `* Copyright (c) 2016 Alexander Weidt,` 5. `* https://github.com/BiggA94` 6. `*` 7. `* Licensed under the MIT License. http://opensource.org/licenses/mit-license` 8. `*/` 10. `/**` 11. `* jsPDF AcroForm Plugin` 12. `* @module AcroForm` 13. `*/` 15. `import { jsPDF } from "../jspdf.js";` 17. `var jsPDFAPI = jsPDF.API;` 18. `var scaleFactor = 1;` 20. `var pdfEscape = function(value) {` 21. `return value` 22. `.replace(/\\/g, "\\\\")` 23. `.replace(/\(/g, "\\(")` 24. `.replace(/\)/g, "\\)");` 25. `};` 26. `var pdfUnescape = function(value) {` 27. `return value` 28. `.replace(/\\\\/g, "\\")` 29. `.replace(/\\\(/g, "(")` 30. `.replace(/\\\)/g, ")");` 31. `};` 33. `var f2 = function(number) {` 34. `return number.toFixed(2); // Ie, %.2f` 35. `};` 37. `var f5 = function(number) {` 38. `return number.toFixed(5); // Ie, %.2f` 39. `};` 41. `jsPDFAPI.__acroform__ = {};` 42. `var inherit = function(child, parent) {` 43. `child.prototype = Object.create(parent.prototype);` 44. `child.prototype.constructor = child;` 45. `};` 47. `var scale = function(x) {` 48. `return x * scaleFactor;` 49. `};` 51. `var createFormXObject = function(formObject) {` 52. `var xobj = new AcroFormXObject();` 53. `var height = AcroFormAppearance.internal.getHeight(formObject) || 0;` 54. `var width = AcroFormAppearance.internal.getWidth(formObject) || 0;` 55. `xobj.BBox = [0, 0, Number(f2(width)), Number(f2(height))];` 56. `return xobj;` 57. `};` 59. `/**` 60. `* Bit-Operations` 61. `*/` 62. `var setBit = (jsPDFAPI.__acroform__.setBit = function(number, bitPosition) {` 63. `number = number || 0;` 64. `bitPosition = bitPosition || 0;` 66. `if (isNaN(number) || isNaN(bitPosition)) {` 67. `throw new Error(` 68. `"Invalid arguments passed to jsPDF.API.__acroform__.setBit"` 69. `);` 70. `}` 71. `var bitMask = 1 << bitPosition;` 73. `number |= bitMask;` 75. `return number;` 76. `});` 78. `var clearBit = (jsPDFAPI.__acroform__.clearBit = function(number, bitPosition) {` 79. `number = number || 0;` 80. `bitPosition = bitPosition || 0;` 82. `if (isNaN(number) || isNaN(bitPosition)) {` 83. `throw new Error(` 84. `"Invalid arguments passed to jsPDF.API.__acroform__.clearBit"` 85. `);` 86. `}` 87. `var bitMask = 1 << bitPosition;` 89. `number &= ~bitMask;` 91. `return number;` 92. `});` 94. `var getBit = (jsPDFAPI.__acroform__.getBit = function(number, bitPosition) {` 95. `if (isNaN(number) || isNaN(bitPosition)) {` 96. `throw new Error(` 97. `"Invalid arguments passed to jsPDF.API.__acroform__.getBit"` 98. `);` 99. `}` 100. `return (number & (1 << bitPosition)) === 0 ? 0 : 1;` 101. `});` 103. `/*` 104. `* Ff starts counting the bit position at 1 and not like javascript at 0` 105. `*/` 106. `var getBitForPdf = (jsPDFAPI.__acroform__.getBitForPdf = function(` 107. `number,` 108. `bitPosition` 109. `) {` 110. `if (isNaN(number) || isNaN(bitPosition)) {` 111. `throw new Error(` 112. `"Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf"` 113. `);` 114. `}` 115. `return getBit(number, bitPosition - 1);` 116. `});` 118. `var setBitForPdf = (jsPDFAPI.__acroform__.setBitForPdf = function(` 119. `number,` 120. `bitPosition` 121. `) {` 122. `if (isNaN(number) || isNaN(bitPosition)) {` 123. `throw new Error(` 124. `"Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf"` 125. `);` 126. `}` 127. `return setBit(number, bitPosition - 1);` 128. `});` 130. `var clearBitForPdf = (jsPDFAPI.__acroform__.clearBitForPdf = function(` 131. `number,` 132. `bitPosition` 133. `) {` 134. `if (isNaN(number) || isNaN(bitPosition)) {` 135. `throw new Error(` 136. `"Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf"` 137. `);` 138. `}` 139. `return clearBit(number, bitPosition - 1);` 140. `});` 142. `var calculateCoordinates = (jsPDFAPI.__acroform__.calculateCoordinates = function(` 143. `args,` 144. `scope` 145. `) {` 146. `var getHorizontalCoordinate = scope.internal.getHorizontalCoordinate;` 147. `var getVerticalCoordinate = scope.internal.getVerticalCoordinate;` 148. `var x = args[0];` 149. `var y = args[1];` 150. `var w = args[2];` 151. `var h = args[3];` 153. `var coordinates = {};` 155. `coordinates.lowerLeft_X = getHorizontalCoordinate(x) || 0;` 156. `coordinates.lowerLeft_Y = getVerticalCoordinate(y + h) || 0;` 157. `coordinates.upperRight_X = getHorizontalCoordinate(x + w) || 0;` 158. `coordinates.upperRight_Y = getVerticalCoordinate(y) || 0;` 160. `return [`\ 161. `Number(f2(coordinates.lowerLeft_X)),`\ 162. `Number(f2(coordinates.lowerLeft_Y)),`\ 163. `Number(f2(coordinates.upperRight_X)),`\ 164. `Number(f2(coordinates.upperRight_Y))`\ 165. `];` 166. `});` 168. `var calculateAppearanceStream = function(formObject) {` 169. `if (formObject.appearanceStreamContent) {` 170. `return formObject.appearanceStreamContent;` 171. `}` 173. `if (!formObject.V && !formObject.DV) {` 174. `return;` 175. `}` 177. `// else calculate it` 179. `var stream = [];` 180. `var text = formObject._V || formObject.DV;` 181. `var calcRes = calculateX(formObject, text);` 182. `var fontKey = formObject.scope.internal.getFont(` 183. `formObject.fontName,` 184. `formObject.fontStyle` 185. `).id;` 187. `//PDF 32000-1:2008, page 444` 188. `stream.push("/Tx BMC");` 189. `stream.push("q");` 190. `stream.push("BT"); // Begin Text` 191. `stream.push(formObject.scope.__private__.encodeColorString(formObject.color));` 192. `stream.push("/" + fontKey + " " + f2(calcRes.fontSize) + " Tf");` 193. `stream.push("1 0 0 1 0 0 Tm"); // Transformation Matrix` 194. `stream.push(calcRes.text);` 195. `stream.push("ET"); // End Text` 196. `stream.push("Q");` 197. `stream.push("EMC");` 199. `var appearanceStreamContent = createFormXObject(formObject);` 200. `appearanceStreamContent.scope = formObject.scope;` 201. `appearanceStreamContent.stream = stream.join("\n");` 202. `return appearanceStreamContent;` 203. `};` 205. `var calculateX = function(formObject, text) {` 206. `var maxFontSize =` 207. `formObject.fontSize === 0 ? formObject.maxFontSize : formObject.fontSize;` 208. `var returnValue = {` 209. `text: "",` 210. `fontSize: ""` 211. `};` 212. `// Remove Brackets` 213. `text = text.substr(0, 1) == "(" ? text.substr(1) : text;` 214. `text =` 215. `text.substr(text.length - 1) == ")"` 216. `? text.substr(0, text.length - 1)` 217. `: text;` 218. `// split into array of words` 219. `var textSplit = text.split(" ");` 220. `if (formObject.multiline) {` 221. `textSplit = textSplit.map(word => word.split("\n"));` 222. `} else {` 223. `textSplit = textSplit.map(word => [word]);` 224. `}` 226. `var fontSize = maxFontSize; // The Starting fontSize (The Maximum)` 227. `var lineSpacing = 2;` 228. `var borderPadding = 2;` 230. `var height = AcroFormAppearance.internal.getHeight(formObject) || 0;` 231. `height = height < 0 ? -height : height;` 232. `var width = AcroFormAppearance.internal.getWidth(formObject) || 0;` 233. `width = width < 0 ? -width : width;` 235. `var isSmallerThanWidth = function(i, lastLine, fontSize) {` 236. `if (i + 1 < textSplit.length) {` 237. `var tmp = lastLine + " " + textSplit[i + 1][0];` 238. `var TextWidth = calculateFontSpace(tmp, formObject, fontSize).width;` 239. `var FieldWidth = width - 2 * borderPadding;` 240. `return TextWidth <= FieldWidth;` 241. `} else {` 242. `return false;` 243. `}` 244. `};` 246. `fontSize++;` 247. `FontSize: while (fontSize > 0) {` 248. `text = "";` 249. `fontSize--;` 250. `var textHeight = calculateFontSpace("3", formObject, fontSize).height;` 251. `var startY = formObject.multiline` 252. `? height - fontSize` 253. `: (height - textHeight) / 2;` 254. `startY += lineSpacing;` 255. `var startX;` 257. `var lastY = startY;` 258. `var firstWordInLine = 0,` 259. `lastWordInLine = 0;` 260. `var lastLength;` 261. `var currWord = 0;` 263. `if (fontSize <= 0) {` 264. `// In case, the Text doesn't fit at all` 265. `fontSize = 12;` 266. `text = "(...) Tj\n";` 267. `text +=` 268. `"% Width of Text: " +` 269. `calculateFontSpace(text, formObject, fontSize).width +` 270. `", FieldWidth:" +` 271. `width +` 272. `"\n";` 273. `break;` 274. `}` 276. `var lastLine = "";` 277. `var lineCount = 0;` 278. `Line: for (var i = 0; i < textSplit.length; i++) {` 279. `if (textSplit.hasOwnProperty(i)) {` 280. `let isWithNewLine = false;` 281. `if (textSplit[i].length !== 1 && currWord !== textSplit[i].length - 1) {` 282. `if (` 283. `(textHeight + lineSpacing) * (lineCount + 2) + lineSpacing >` 284. `height` 285. `) {` 286. `continue FontSize;` 287. `}` 289. `lastLine += textSplit[i][currWord];` 290. `isWithNewLine = true;` 291. `lastWordInLine = i;` 292. `i--;` 293. `} else {` 294. `lastLine += textSplit[i][currWord] + " ";` 295. `lastLine =` 296. `lastLine.substr(lastLine.length - 1) == " "` 297. `? lastLine.substr(0, lastLine.length - 1)` 298. `: lastLine;` 299. `var key = parseInt(i);` 300. `var nextLineIsSmaller = isSmallerThanWidth(key, lastLine, fontSize);` 301. `var isLastWord = i >= textSplit.length - 1;` 303. `if (nextLineIsSmaller && !isLastWord) {` 304. `lastLine += " ";` 305. `currWord = 0;` 306. `continue; // Line` 307. `} else if (!nextLineIsSmaller && !isLastWord) {` 308. `if (!formObject.multiline) {` 309. `continue FontSize;` 310. `} else {` 311. `if (` 312. `(textHeight + lineSpacing) * (lineCount + 2) + lineSpacing >` 313. `height` 314. `) {` 315. `// If the Text is higher than the` 316. `// FieldObject` 317. `continue FontSize;` 318. `}` 319. `lastWordInLine = key;` 320. `// go on` 321. `}` 322. `} else if (isLastWord) {` 323. `lastWordInLine = key;` 324. `} else {` 325. `if (` 326. `formObject.multiline &&` 327. `(textHeight + lineSpacing) * (lineCount + 2) + lineSpacing >` 328. `height` 329. `) {` 330. `// If the Text is higher than the FieldObject` 331. `continue FontSize;` 332. `}` 333. `}` 334. `}` 335. `// Remove last blank` 337. `var line = "";` 339. `for (var x = firstWordInLine; x <= lastWordInLine; x++) {` 340. `var currLine = textSplit[x];` 341. `if (formObject.multiline) {` 342. `if (x === lastWordInLine) {` 343. `line += currLine[currWord] + " ";` 344. `currWord = (currWord + 1) % currLine.length;` 345. `continue;` 346. `}` 347. `if (x === firstWordInLine) {` 348. `line += currLine[currLine.length - 1] + " ";` 349. `continue;` 350. `}` 351. `}` 352. `line += currLine[0] + " ";` 353. `}` 355. `// Remove last blank` 356. `line =` 357. `line.substr(line.length - 1) == " "` 358. `? line.substr(0, line.length - 1)` 359. `: line;` 360. `// lastLength -= blankSpace.width;` 361. `lastLength = calculateFontSpace(line, formObject, fontSize).width;` 363. `// Calculate startX` 364. `switch (formObject.textAlign) {` 365. `case "right":` 366. `startX = width - lastLength - borderPadding;` 367. `break;` 368. `case "center":` 369. `startX = (width - lastLength) / 2;` 370. `break;` 371. `case "left":` 372. `default:` 373. `startX = borderPadding;` 374. `break;` 375. `}` 376. `text += f2(startX) + " " + f2(lastY) + " Td\n";` 377. `text += "(" + pdfEscape(line) + ") Tj\n";` 378. `// reset X in PDF` 379. `text += -f2(startX) + " 0 Td\n";` 381. `// After a Line, adjust y position` 382. `lastY = -(fontSize + lineSpacing);` 384. `// Reset for next iteration step` 385. `lastLength = 0;` 386. `firstWordInLine = isWithNewLine ? lastWordInLine : lastWordInLine + 1;` 387. `lineCount++;` 389. `lastLine = "";` 390. `continue Line;` 391. `}` 392. `}` 393. `break;` 394. `}` 396. `returnValue.text = text;` 397. `returnValue.fontSize = fontSize;` 399. `return returnValue;` 400. `};` 402. `/**` 403. `* Small workaround for calculating the TextMetric approximately.` 404. `*` 405. `* @param text` 406. `* @param fontsize` 407. `* @returns {TextMetrics} (Has Height and Width)` 408. `*/` 409. `var calculateFontSpace = function(text, formObject, fontSize) {` 410. `var font = formObject.scope.internal.getFont(` 411. `formObject.fontName,` 412. `formObject.fontStyle` 413. `);` 414. `var width =` 415. `formObject.scope.getStringUnitWidth(text, {` 416. `font: font,` 417. `fontSize: parseFloat(fontSize),` 418. `charSpace: 0` 419. `}) * parseFloat(fontSize);` 420. `var height =` 421. `formObject.scope.getStringUnitWidth("3", {` 422. `font: font,` 423. `fontSize: parseFloat(fontSize),` 424. `charSpace: 0` 425. `}) *` 426. `parseFloat(fontSize) *` 427. `1.5;` 428. `return { height: height, width: width };` 429. `};` 431. `var acroformPluginTemplate = {` 432. `fields: [],` 433. `xForms: [],` 434. `/**` 435. `* acroFormDictionaryRoot contains information about the AcroForm` 436. `* Dictionary 0: The Event-Token, the AcroFormDictionaryCallback has` 437. `* 1: The Object ID of the Root` 438. `*/` 439. `acroFormDictionaryRoot: null,` 440. `/**` 441. `* After the PDF gets evaluated, the reference to the root has to be` 442. `* reset, this indicates, whether the root has already been printed` 443. `* out` 444. `*/` 445. `printedOut: false,` 446. `internal: null,` 447. `isInitialized: false` 448. `};` 450. `var annotReferenceCallback = function(scope) {` 451. `//set objId to undefined and force it to get a new objId on buildDocument` 452. `scope.internal.acroformPlugin.acroFormDictionaryRoot.objId = undefined;` 453. `var fields = scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields;` 454. `for (var i in fields) {` 455. `if (fields.hasOwnProperty(i)) {` 456. `var formObject = fields[i];` 457. `//set objId to undefined and force it to get a new objId on buildDocument` 458. `formObject.objId = undefined;` 459. `// add Annot Reference!` 460. `if (formObject.hasAnnotation) {` 461. `// If theres an Annotation Widget in the Form Object, put the` 462. `// Reference in the /Annot array` 463. `createAnnotationReference(formObject, scope);` 464. `}` 465. `}` 466. `}` 467. `};` 469. `var putForm = function(formObject) {` 470. `if (formObject.scope.internal.acroformPlugin.printedOut) {` 471. `formObject.scope.internal.acroformPlugin.printedOut = false;` 472. `formObject.scope.internal.acroformPlugin.acroFormDictionaryRoot = null;` 473. `}` 474. `formObject.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(` 475. `formObject` 476. `);` 477. `};` 478. `/**` 479. `* Create the Reference to the widgetAnnotation, so that it gets referenced` 480. `* in the Annot[] int the+ (Requires the Annotation Plugin)` 481. `*/` 482. `var createAnnotationReference = function(object, scope) {` 483. `var options = {` 484. `type: "reference",` 485. `object: object` 486. `};` 487. `var findEntry = function(entry) {` 488. `return entry.type === options.type && entry.object === options.object;` 489. `};` 490. `if (` 491. `scope.internal` 492. `.getPageInfo(object.page)` 493. `.pageContext.annotations.find(findEntry) === undefined` 494. `) {` 495. `scope.internal` 496. `.getPageInfo(object.page)` 497. `.pageContext.annotations.push(options);` 498. `}` 499. `};` 501. `// Callbacks` 503. `var putCatalogCallback = function(scope) {` 504. `// Put reference to AcroForm to DocumentCatalog` 505. `if (` 506. `typeof scope.internal.acroformPlugin.acroFormDictionaryRoot !== "undefined"` 507. `) {` 508. `// for safety, shouldn't normally be the case` 509. `scope.internal.write(` 510. `"/AcroForm " +` 511. `scope.internal.acroformPlugin.acroFormDictionaryRoot.objId +` 512. `" " +` 513. `0 +` 514. `" R"` 515. `);` 516. `} else {` 517. `throw new Error("putCatalogCallback: Root missing.");` 518. `}` 519. `};` 521. `/**` 522. `* Adds /Acroform X 0 R to Document Catalog, and creates the AcroForm` 523. `* Dictionary` 524. `*/` 525. `var AcroFormDictionaryCallback = function(scope) {` 526. `// Remove event` 527. `scope.internal.events.unsubscribe(` 528. `scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID` 529. `);` 530. `delete scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID;` 531. `scope.internal.acroformPlugin.printedOut = true;` 532. `};` 534. `/**` 535. `* Creates the single Fields and writes them into the Document` 536. `*` 537. `* If fieldArray is set, use the fields that are inside it instead of the` 538. `* fields from the AcroRoot (for the FormXObjects...)` 539. `*/` 540. `var createFieldCallback = function(fieldArray, scope) {` 541. `var standardFields = !fieldArray;` 543. `if (!fieldArray) {` 544. `// in case there is no fieldArray specified, we want to print out` 545. `// the Fields of the AcroForm` 546. `// Print out Root` 547. `scope.internal.newObjectDeferredBegin(` 548. `scope.internal.acroformPlugin.acroFormDictionaryRoot.objId,` 549. `true` 550. `);` 551. `scope.internal.acroformPlugin.acroFormDictionaryRoot.putStream();` 552. `}` 554. `fieldArray =` 555. `fieldArray || scope.internal.acroformPlugin.acroFormDictionaryRoot.Kids;` 557. `for (var i in fieldArray) {` 558. `if (fieldArray.hasOwnProperty(i)) {` 559. `var fieldObject = fieldArray[i];` 560. `var keyValueList = [];` 561. `var oldRect = fieldObject.Rect;` 563. `if (fieldObject.Rect) {` 564. `fieldObject.Rect = calculateCoordinates(fieldObject.Rect, scope);` 565. `}` 567. `// Start Writing the Object` 568. `scope.internal.newObjectDeferredBegin(fieldObject.objId, true);` 570. `fieldObject.DA = AcroFormAppearance.createDefaultAppearanceStream(` 571. `fieldObject` 572. `);` 574. `if (` 575. `typeof fieldObject === "object" &&` 576. `typeof fieldObject.getKeyValueListForStream === "function"` 577. `) {` 578. `keyValueList = fieldObject.getKeyValueListForStream();` 579. `}` 581. `fieldObject.Rect = oldRect;` 583. `if (` 584. `fieldObject.hasAppearanceStream &&` 585. `!fieldObject.appearanceStreamContent` 586. `) {` 587. `// Calculate Appearance` 588. `var appearance = calculateAppearanceStream(fieldObject);` 589. `keyValueList.push({ key: "AP", value: "<>" });` 591. `scope.internal.acroformPlugin.xForms.push(appearance);` 592. `}` 594. `// Assume AppearanceStreamContent is a Array with N,R,D (at least` 595. `// one of them!)` 596. `if (fieldObject.appearanceStreamContent) {` 597. `var appearanceStreamString = "";` 598. `// Iterate over N,R and D` 599. `for (var k in fieldObject.appearanceStreamContent) {` 600. `if (fieldObject.appearanceStreamContent.hasOwnProperty(k)) {` 601. `var value = fieldObject.appearanceStreamContent[k];` 602. `appearanceStreamString += "/" + k + " ";` 603. `appearanceStreamString += "<<";` 604. `if (Object.keys(value).length >= 1 || Array.isArray(value)) {` 605. `// appearanceStream is an Array or Object!` 606. `for (var i in value) {` 607. `if (value.hasOwnProperty(i)) {` 608. `var obj = value[i];` 609. `if (typeof obj === "function") {` 610. `// if Function is referenced, call it in order` 611. `// to get the FormXObject` 612. `obj = obj.call(scope, fieldObject);` 613. `}` 614. `appearanceStreamString += "/" + i + " " + obj + " ";` 616. `// In case the XForm is already used, e.g. OffState` 617. `// of CheckBoxes, don't add it` 618. `if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0))` 619. `scope.internal.acroformPlugin.xForms.push(obj);` 620. `}` 621. `}` 622. `} else {` 623. `obj = value;` 624. `if (typeof obj === "function") {` 625. `// if Function is referenced, call it in order to` 626. `// get the FormXObject` 627. `obj = obj.call(scope, fieldObject);` 628. `}` 629. `appearanceStreamString += "/" + i + " " + obj;` 630. `if (!(scope.internal.acroformPlugin.xForms.indexOf(obj) >= 0))` 631. `scope.internal.acroformPlugin.xForms.push(obj);` 632. `}` 633. `appearanceStreamString += ">>";` 634. `}` 635. `}` 637. `// appearance stream is a normal Object..` 638. `keyValueList.push({` 639. `key: "AP",` 640. `value: "<<\n" + appearanceStreamString + ">>"` 641. `});` 642. `}` 644. `scope.internal.putStream({` 645. `additionalKeyValues: keyValueList,` 646. `objectId: fieldObject.objId` 647. `});` 649. `scope.internal.out("endobj");` 650. `}` 651. `}` 652. `if (standardFields) {` 653. `createXFormObjectCallback(scope.internal.acroformPlugin.xForms, scope);` 654. `}` 655. `};` 657. `var createXFormObjectCallback = function(fieldArray, scope) {` 658. `for (var i in fieldArray) {` 659. `if (fieldArray.hasOwnProperty(i)) {` 660. `var key = i;` 661. `var fieldObject = fieldArray[i];` 662. `// Start Writing the Object` 663. `scope.internal.newObjectDeferredBegin(fieldObject.objId, true);` 665. `if (` 666. `typeof fieldObject === "object" &&` 667. `typeof fieldObject.putStream === "function"` 668. `) {` 669. `fieldObject.putStream();` 670. `}` 671. `delete fieldArray[key];` 672. `}` 673. `}` 674. `};` 676. `var initializeAcroForm = function(scope, formObject) {` 677. `formObject.scope = scope;` 678. `if (` 679. `scope.internal !== undefined &&` 680. `(scope.internal.acroformPlugin === undefined ||` 681. `scope.internal.acroformPlugin.isInitialized === false)` 682. `) {` 683. `AcroFormField.FieldNum = 0;` 684. `scope.internal.acroformPlugin = JSON.parse(` 685. `JSON.stringify(acroformPluginTemplate)` 686. `);` 687. `if (scope.internal.acroformPlugin.acroFormDictionaryRoot) {` 688. `throw new Error("Exception while creating AcroformDictionary");` 689. `}` 690. `scaleFactor = scope.internal.scaleFactor;` 691. `// The Object Number of the AcroForm Dictionary` 692. `scope.internal.acroformPlugin.acroFormDictionaryRoot = new AcroFormDictionary();` 693. `scope.internal.acroformPlugin.acroFormDictionaryRoot.scope = scope;` 695. `// add Callback for creating the AcroForm Dictionary` 696. `scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID = scope.internal.events.subscribe(` 697. `"postPutResources",` 698. `function() {` 699. `AcroFormDictionaryCallback(scope);` 700. `}` 701. `);` 703. `scope.internal.events.subscribe("buildDocument", function() {` 704. `annotReferenceCallback(scope);` 705. `}); // buildDocument` 707. `// Register event, that is triggered when the DocumentCatalog is` 708. `// written, in order to add /AcroForm` 710. `scope.internal.events.subscribe("putCatalog", function() {` 711. `putCatalogCallback(scope);` 712. `});` 714. `// Register event, that creates all Fields` 715. `scope.internal.events.subscribe("postPutPages", function(fieldArray) {` 716. `createFieldCallback(fieldArray, scope);` 717. `});` 719. `scope.internal.acroformPlugin.isInitialized = true;` 720. `}` 721. `};` 723. `//PDF 32000-1:2008, page 26, 7.3.6` 724. `var arrayToPdfArray = (jsPDFAPI.__acroform__.arrayToPdfArray = function(` 725. `array,` 726. `objId,` 727. `scope` 728. `) {` 729. `var encryptor = function(data) {` 730. `return data;` 731. `};` 732. `if (Array.isArray(array)) {` 733. `var content = "[";`\ 734. `for (var i = 0; i < array.length; i++) {`\ 735. `if (i !== 0) {`\ 736. `content += " ";`\ 737. `}`\ 738. `switch (typeof array[i]) {`\ 739. `case "boolean":`\ 740. `case "number":`\ 741. `case "object":`\ 742. `content += array[i].toString();`\ 743. `break;`\ 744. `case "string":`\ 745. `if (array[i].substr(0, 1) !== "/") {`\ 746. `if (typeof objId !== "undefined" && scope)`\ 747. `encryptor = scope.internal.getEncryptor(objId);`\ 748. `content += "(" + pdfEscape(encryptor(array[i].toString())) + ")";`\ 749. `} else {`\ 750. `content += array[i].toString();`\ 751. `}`\ 752. `break;`\ 753. `}`\ 754. `}`\ 755. `content += "]";` 756. `return content;` 757. `}` 758. `throw new Error(` 759. `"Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray"` 760. `);` 761. `});` 762. `function getMatches(string, regex, index) {` 763. `index || (index = 1); // default to the first capturing group` 764. `var matches = [];` 765. `var match;` 766. `while ((match = regex.exec(string))) {` 767. `matches.push(match[index]);` 768. `}` 769. `return matches;` 770. `}` 771. `var pdfArrayToStringArray = function(array) {` 772. `var result = [];` 773. `if (typeof array === "string") {` 774. `result = getMatches(array, /\((.*?)\)/g);` 775. `}` 776. `return result;` 777. `};` 779. `var toPdfString = function(string, objId, scope) {` 780. `var encryptor = function(data) {` 781. `return data;` 782. `};` 783. `if (typeof objId !== "undefined" && scope)` 784. `encryptor = scope.internal.getEncryptor(objId);` 785. `string = string || "";` 786. `string.toString();` 787. `string = "(" + pdfEscape(encryptor(string)) + ")";` 788. `return string;` 789. `};` 791. `// ##########################` 792. `// Classes` 793. `// ##########################` 795. `/**` 796. `* @class AcroFormPDFObject` 797. `* @classdesc A AcroFormPDFObject` 798. `*/` 799. `var AcroFormPDFObject = function() {` 800. `this._objId = undefined;` 801. `this._scope = undefined;` 803. `/**` 804. `* @name AcroFormPDFObject#objId` 805. `* @type {any}` 806. `*/` 807. `Object.defineProperty(this, "objId", {` 808. `get: function() {` 809. `if (typeof this._objId === "undefined") {` 810. `if (typeof this.scope === "undefined") {` 811. `return undefined;` 812. `}` 813. `this._objId = this.scope.internal.newObjectDeferred();` 814. `}` 815. `return this._objId;` 816. `},` 817. `set: function(value) {` 818. `this._objId = value;` 819. `}` 820. `});` 821. `Object.defineProperty(this, "scope", {` 822. `value: this._scope,` 823. `writable: true` 824. `});` 825. `};` 827. `/**` 828. `* @function AcroFormPDFObject.toString` 829. `*/` 830. `AcroFormPDFObject.prototype.toString = function() {` 831. `return this.objId + " 0 R";` 832. `};` 834. `AcroFormPDFObject.prototype.putStream = function() {` 835. `var keyValueList = this.getKeyValueListForStream();` 836. `this.scope.internal.putStream({` 837. `data: this.stream,` 838. `additionalKeyValues: keyValueList,` 839. `objectId: this.objId` 840. `});` 841. `this.scope.internal.out("endobj");` 842. `};` 844. `/**` 845. `* Returns an key-value-List of all non-configurable Variables from the Object` 846. `*` 847. `* @name getKeyValueListForStream` 848. `* @returns {string}` 849. `*/` 850. `AcroFormPDFObject.prototype.getKeyValueListForStream = function() {` 851. `var keyValueList = [];` 852. `var keys = Object.getOwnPropertyNames(this).filter(function(key) {` 853. `return (` 854. `key != "content" &&` 855. `key != "appearanceStreamContent" &&` 856. `key != "scope" &&` 857. `key != "objId" &&` 858. `key.substring(0, 1) != "_"` 859. `);` 860. `});` 862. `for (var i in keys) {` 863. `if (Object.getOwnPropertyDescriptor(this, keys[i]).configurable === false) {` 864. `var key = keys[i];` 865. `var value = this[key];` 867. `if (value) {` 868. `if (Array.isArray(value)) {` 869. `keyValueList.push({` 870. `key: key,` 871. `value: arrayToPdfArray(value, this.objId, this.scope)` 872. `});` 873. `} else if (value instanceof AcroFormPDFObject) {` 874. `// In case it is a reference to another PDFObject,` 875. `// take the reference number` 876. `value.scope = this.scope;` 877. `keyValueList.push({ key: key, value: value.objId + " 0 R" });` 878. `} else if (typeof value !== "function") {` 879. `keyValueList.push({ key: key, value: value });` 880. `}` 881. `}` 882. `}` 883. `}` 884. `return keyValueList;` 885. `};` 887. `var AcroFormXObject = function() {` 888. `AcroFormPDFObject.call(this);` 890. `Object.defineProperty(this, "Type", {` 891. `value: "/XObject",` 892. `configurable: false,` 893. `writable: true` 894. `});` 896. `Object.defineProperty(this, "Subtype", {` 897. `value: "/Form",` 898. `configurable: false,` 899. `writable: true` 900. `});` 902. `Object.defineProperty(this, "FormType", {` 903. `value: 1,` 904. `configurable: false,` 905. `writable: true` 906. `});` 908. `var _BBox = [];` 909. `Object.defineProperty(this, "BBox", {` 910. `configurable: false,` 911. `get: function() {` 912. `return _BBox;` 913. `},` 914. `set: function(value) {` 915. `_BBox = value;` 916. `}` 917. `});` 919. `Object.defineProperty(this, "Resources", {` 920. `value: "2 0 R",` 921. `configurable: false,` 922. `writable: true` 923. `});` 925. `var _stream;` 926. `Object.defineProperty(this, "stream", {` 927. `enumerable: false,` 928. `configurable: true,` 929. `set: function(value) {` 930. `_stream = value.trim();` 931. `},` 932. `get: function() {` 933. `if (_stream) {` 934. `return _stream;` 935. `} else {` 936. `return null;` 937. `}` 938. `}` 939. `});` 940. `};` 942. `inherit(AcroFormXObject, AcroFormPDFObject);` 944. `var AcroFormDictionary = function() {` 945. `AcroFormPDFObject.call(this);` 947. `var _Kids = [];` 949. `Object.defineProperty(this, "Kids", {` 950. `enumerable: false,` 951. `configurable: true,` 952. `get: function() {` 953. `if (_Kids.length > 0) {` 954. `return _Kids;` 955. `} else {` 956. `return undefined;` 957. `}` 958. `}` 959. `});` 960. `Object.defineProperty(this, "Fields", {` 961. `enumerable: false,` 962. `configurable: false,` 963. `get: function() {` 964. `return _Kids;` 965. `}` 966. `});` 968. `// Default Appearance` 969. `var _DA;` 970. `Object.defineProperty(this, "DA", {` 971. `enumerable: false,` 972. `configurable: false,` 973. `get: function() {` 974. `if (!_DA) {` 975. `return undefined;` 976. `}` 977. `var encryptor = function(data) {` 978. `return data;` 979. `};` 980. `if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId);` 981. `return "(" + pdfEscape(encryptor(_DA)) + ")";` 982. `},` 983. `set: function(value) {` 984. `_DA = value;` 985. `}` 986. `});` 987. `};` 989. `inherit(AcroFormDictionary, AcroFormPDFObject);` 991. `/**` 992. `* The Field Object contains the Variables, that every Field needs` 993. `*` 994. `* @class AcroFormField` 995. `* @classdesc An AcroForm FieldObject` 996. `*/` 997. `var AcroFormField = function() {` 998. `AcroFormPDFObject.call(this);` 1000. `//Annotation-Flag See Table 165` 1001. `var _F = 4;` 1002. `Object.defineProperty(this, "F", {` 1003. `enumerable: false,` 1004. `configurable: false,` 1005. `get: function() {` 1006. `return _F;` 1007. `},` 1008. `set: function(value) {` 1009. `if (!isNaN(value)) {` 1010. `_F = value;` 1011. `} else {` 1012. `throw new Error(` 1013. `'Invalid value "' + value + '" for attribute F supplied.'` 1014. `);` 1015. `}` 1016. `}` 1017. `});` 1019. `/**` 1020. `* (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.` 1021. `* NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page.` 1022. `*` 1023. `* @name AcroFormField#showWhenPrinted` 1024. `* @default true` 1025. `* @type {boolean}` 1026. `*/` 1027. `Object.defineProperty(this, "showWhenPrinted", {` 1028. `enumerable: true,` 1029. `configurable: true,` 1030. `get: function() {` 1031. `return Boolean(getBitForPdf(_F, 3));` 1032. `},` 1033. `set: function(value) {` 1034. `if (Boolean(value) === true) {` 1035. `this.F = setBitForPdf(_F, 3);` 1036. `} else {` 1037. `this.F = clearBitForPdf(_F, 3);` 1038. `}` 1039. `}` 1040. `});` 1042. `var _Ff = 0;` 1043. `Object.defineProperty(this, "Ff", {` 1044. `enumerable: false,` 1045. `configurable: false,` 1046. `get: function() {` 1047. `return _Ff;` 1048. `},` 1049. `set: function(value) {` 1050. `if (!isNaN(value)) {` 1051. `_Ff = value;` 1052. `} else {` 1053. `throw new Error(` 1054. `'Invalid value "' + value + '" for attribute Ff supplied.'` 1055. `);` 1056. `}` 1057. `}` 1058. `});` 1060. `var _Rect = [];` 1061. `Object.defineProperty(this, "Rect", {` 1062. `enumerable: false,` 1063. `configurable: false,` 1064. `get: function() {` 1065. `if (_Rect.length === 0) {` 1066. `return undefined;` 1067. `}` 1068. `return _Rect;` 1069. `},` 1070. `set: function(value) {` 1071. `if (typeof value !== "undefined") {` 1072. `_Rect = value;` 1073. `} else {` 1074. `_Rect = [];` 1075. `}` 1076. `}` 1077. `});` 1079. `/**` 1080. `* The x-position of the field.` 1081. `*` 1082. `* @name AcroFormField#x` 1083. `* @default null` 1084. `* @type {number}` 1085. `*/` 1086. `Object.defineProperty(this, "x", {` 1087. `enumerable: true,` 1088. `configurable: true,` 1089. `get: function() {` 1090. `if (!_Rect || isNaN(_Rect[0])) {` 1091. `return 0;` 1092. `}` 1093. `return _Rect[0];` 1094. `},` 1095. `set: function(value) {` 1096. `_Rect[0] = value;` 1097. `}` 1098. `});` 1100. `/**` 1101. `* The y-position of the field.` 1102. `*` 1103. `* @name AcroFormField#y` 1104. `* @default null` 1105. `* @type {number}` 1106. `*/` 1107. `Object.defineProperty(this, "y", {` 1108. `enumerable: true,` 1109. `configurable: true,` 1110. `get: function() {` 1111. `if (!_Rect || isNaN(_Rect[1])) {` 1112. `return 0;` 1113. `}` 1114. `return _Rect[1];` 1115. `},` 1116. `set: function(value) {` 1117. `_Rect[1] = value;` 1118. `}` 1119. `});` 1121. `/**` 1122. `* The width of the field.` 1123. `*` 1124. `* @name AcroFormField#width` 1125. `* @default null` 1126. `* @type {number}` 1127. `*/` 1128. `Object.defineProperty(this, "width", {` 1129. `enumerable: true,` 1130. `configurable: true,` 1131. `get: function() {` 1132. `if (!_Rect || isNaN(_Rect[2])) {` 1133. `return 0;` 1134. `}` 1135. `return _Rect[2];` 1136. `},` 1137. `set: function(value) {` 1138. `_Rect[2] = value;` 1139. `}` 1140. `});` 1142. `/**` 1143. `* The height of the field.` 1144. `*` 1145. `* @name AcroFormField#height` 1146. `* @default null` 1147. `* @type {number}` 1148. `*/` 1149. `Object.defineProperty(this, "height", {` 1150. `enumerable: true,` 1151. `configurable: true,` 1152. `get: function() {` 1153. `if (!_Rect || isNaN(_Rect[3])) {` 1154. `return 0;` 1155. `}` 1156. `return _Rect[3];` 1157. `},` 1158. `set: function(value) {` 1159. `_Rect[3] = value;` 1160. `}` 1161. `});` 1163. `var _FT = "";` 1164. `Object.defineProperty(this, "FT", {` 1165. `enumerable: true,` 1166. `configurable: false,` 1167. `get: function() {` 1168. `return _FT;` 1169. `},` 1170. `set: function(value) {` 1171. `switch (value) {` 1172. `case "/Btn":` 1173. `case "/Tx":` 1174. `case "/Ch":` 1175. `case "/Sig":` 1176. `_FT = value;` 1177. `break;` 1178. `default:` 1179. `throw new Error(` 1180. `'Invalid value "' + value + '" for attribute FT supplied.'` 1181. `);` 1182. `}` 1183. `}` 1184. `});` 1186. `var _T = null;` 1188. `Object.defineProperty(this, "T", {` 1189. `enumerable: true,` 1190. `configurable: false,` 1191. `get: function() {` 1192. `if (!_T || _T.length < 1) {` 1193. `// In case of a Child from a Radio´Group, you don't need a FieldName` 1194. `if (this instanceof AcroFormChildClass) {` 1195. `return undefined;` 1196. `}` 1197. `_T = "FieldObject" + AcroFormField.FieldNum++;` 1198. `}` 1199. `var encryptor = function(data) {` 1200. `return data;` 1201. `};` 1202. `if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId);` 1203. `return "(" + pdfEscape(encryptor(_T)) + ")";` 1204. `},` 1205. `set: function(value) {` 1206. `_T = value.toString();` 1207. `}` 1208. `});` 1210. `/**` 1211. `* (Optional) The partial field name (see 12.7.3.2, “Field Names”).` 1212. `*` 1213. `* @name AcroFormField#fieldName` 1214. `* @default null` 1215. `* @type {string}` 1216. `*/` 1217. `Object.defineProperty(this, "fieldName", {` 1218. `configurable: true,` 1219. `enumerable: true,` 1220. `get: function() {` 1221. `return _T;` 1222. `},` 1223. `set: function(value) {` 1224. `_T = value;` 1225. `}` 1226. `});` 1228. `var _fontName = "helvetica";` 1229. `/**` 1230. `* The fontName of the font to be used.` 1231. `*` 1232. `* @name AcroFormField#fontName` 1233. `* @default 'helvetica'` 1234. `* @type {string}` 1235. `*/` 1236. `Object.defineProperty(this, "fontName", {` 1237. `enumerable: true,` 1238. `configurable: true,` 1239. `get: function() {` 1240. `return _fontName;` 1241. `},` 1242. `set: function(value) {` 1243. `_fontName = value;` 1244. `}` 1245. `});` 1247. `var _fontStyle = "normal";` 1248. `/**` 1249. `* The fontStyle of the font to be used.` 1250. `*` 1251. `* @name AcroFormField#fontStyle` 1252. `* @default 'normal'` 1253. `* @type {string}` 1254. `*/` 1255. `Object.defineProperty(this, "fontStyle", {` 1256. `enumerable: true,` 1257. `configurable: true,` 1258. `get: function() {` 1259. `return _fontStyle;` 1260. `},` 1261. `set: function(value) {` 1262. `_fontStyle = value;` 1263. `}` 1264. `});` 1266. `var _fontSize = 0;` 1267. `/**` 1268. `* The fontSize of the font to be used.` 1269. `*` 1270. `* @name AcroFormField#fontSize` 1271. `* @default 0 (for auto)` 1272. `* @type {number}` 1273. `*/` 1274. `Object.defineProperty(this, "fontSize", {` 1275. `enumerable: true,` 1276. `configurable: true,` 1277. `get: function() {` 1278. `return _fontSize;` 1279. `},` 1280. `set: function(value) {` 1281. `_fontSize = value;` 1282. `}` 1283. `});` 1285. `var _maxFontSize = undefined;` 1286. `/**` 1287. `* The maximum fontSize of the font to be used.` 1288. `*` 1289. `* @name AcroFormField#maxFontSize` 1290. `* @default 0 (for auto)` 1291. `* @type {number}` 1292. `*/` 1293. `Object.defineProperty(this, "maxFontSize", {` 1294. `enumerable: true,` 1295. `configurable: true,` 1296. `get: function() {` 1297. `if (_maxFontSize === undefined) {` 1298. `// use the old default value here - the value is some kind of random as it depends on the scaleFactor (user unit)` 1299. `// ("50" is transformed to the "user space" but then used in "pdf space")` 1300. `return 50 / scaleFactor;` 1301. `} else {` 1302. `return _maxFontSize;` 1303. `}` 1304. `},` 1305. `set: function(value) {` 1306. `_maxFontSize = value;` 1307. `}` 1308. `});` 1310. `var _color = "black";` 1311. `/**` 1312. `* The color of the text` 1313. `*` 1314. `* @name AcroFormField#color` 1315. `* @default 'black'` 1316. `* @type {string|rgba}` 1317. `*/` 1318. `Object.defineProperty(this, "color", {` 1319. `enumerable: true,` 1320. `configurable: true,` 1321. `get: function() {` 1322. `return _color;` 1323. `},` 1324. `set: function(value) {` 1325. `_color = value;` 1326. `}` 1327. `});` 1329. `var _DA = "/F1 0 Tf 0 g";` 1330. `// Defines the default appearance (Needed for variable Text)` 1331. `Object.defineProperty(this, "DA", {` 1332. `enumerable: true,` 1333. `configurable: false,` 1334. `get: function() {` 1335. `if (` 1336. `!_DA ||` 1337. `this instanceof AcroFormChildClass ||` 1338. `this instanceof AcroFormTextField` 1339. `) {` 1340. `return undefined;` 1341. `}` 1342. `return toPdfString(_DA, this.objId, this.scope);` 1343. `},` 1344. `set: function(value) {` 1345. `value = value.toString();` 1346. `_DA = value;` 1347. `}` 1348. `});` 1350. `var _DV = null;` 1351. `Object.defineProperty(this, "DV", {` 1352. `enumerable: false,` 1353. `configurable: false,` 1354. `get: function() {` 1355. `if (!_DV) {` 1356. `return undefined;` 1357. `}` 1358. `if (this instanceof AcroFormButton === false) {` 1359. `return toPdfString(_DV, this.objId, this.scope);` 1360. `}` 1361. `return _DV;` 1362. `},` 1363. `set: function(value) {` 1364. `value = value.toString();` 1365. `if (this instanceof AcroFormButton === false) {` 1366. `if (value.substr(0, 1) === "(") {` 1367. `_DV = pdfUnescape(value.substr(1, value.length - 2));` 1368. `} else {` 1369. `_DV = pdfUnescape(value);` 1370. `}` 1371. `} else {` 1372. `_DV = value;` 1373. `}` 1374. `}` 1375. `});` 1377. `/**` 1378. `* (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.` 1379. `*` 1380. `* @name AcroFormField#defaultValue` 1381. `* @default null` 1382. `* @type {any}` 1383. `*/` 1384. `Object.defineProperty(this, "defaultValue", {` 1385. `enumerable: true,` 1386. `configurable: true,` 1387. `get: function() {` 1388. `if (this instanceof AcroFormButton === true) {` 1389. `return pdfUnescape(_DV.substr(1, _DV.length - 1));` 1390. `} else {` 1391. `return _DV;` 1392. `}` 1393. `},` 1394. `set: function(value) {` 1395. `value = value.toString();` 1396. `if (this instanceof AcroFormButton === true) {` 1397. `_DV = "/" + value;` 1398. `} else {` 1399. `_DV = value;` 1400. `}` 1401. `}` 1402. `});` 1404. `var _V = null;` 1405. `Object.defineProperty(this, "_V", {` 1406. `enumerable: false,` 1407. `configurable: false,` 1408. `get: function() {` 1409. `if (!_V) {` 1410. `return undefined;` 1411. `}` 1412. `return _V;` 1413. `},` 1414. `set: function(value) {` 1415. `this.V = value;` 1416. `}` 1417. `});` 1418. `Object.defineProperty(this, "V", {` 1419. `enumerable: false,` 1420. `configurable: false,` 1421. `get: function() {` 1422. `if (!_V) {` 1423. `return undefined;` 1424. `}` 1425. `if (this instanceof AcroFormButton === false) {` 1426. `return toPdfString(_V, this.objId, this.scope);` 1427. `}` 1428. `return _V;` 1429. `},` 1430. `set: function(value) {` 1431. `value = value.toString();` 1432. `if (this instanceof AcroFormButton === false) {` 1433. `if (value.substr(0, 1) === "(") {` 1434. `_V = pdfUnescape(value.substr(1, value.length - 2));` 1435. `} else {` 1436. `_V = pdfUnescape(value);` 1437. `}` 1438. `} else {` 1439. `_V = value;` 1440. `}` 1441. `}` 1442. `});` 1444. `/**` 1445. `* (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information.` 1446. `*` 1447. `* @name AcroFormField#value` 1448. `* @default null` 1449. `* @type {any}` 1450. `*/` 1451. `Object.defineProperty(this, "value", {` 1452. `enumerable: true,` 1453. `configurable: true,` 1454. `get: function() {` 1455. `if (this instanceof AcroFormButton === true) {` 1456. `return pdfUnescape(_V.substr(1, _V.length - 1));` 1457. `} else {` 1458. `return _V;` 1459. `}` 1460. `},` 1461. `set: function(value) {` 1462. `value = value.toString();` 1463. `if (this instanceof AcroFormButton === true) {` 1464. `_V = "/" + value;` 1465. `} else {` 1466. `_V = value;` 1467. `}` 1468. `}` 1469. `});` 1471. `/**` 1472. `* Check if field has annotations` 1473. `*` 1474. `* @name AcroFormField#hasAnnotation` 1475. `* @readonly` 1476. `* @type {boolean}` 1477. `*/` 1478. `Object.defineProperty(this, "hasAnnotation", {` 1479. `enumerable: true,` 1480. `configurable: true,` 1481. `get: function() {` 1482. `return this.Rect;` 1483. `}` 1484. `});` 1486. `Object.defineProperty(this, "Type", {` 1487. `enumerable: true,` 1488. `configurable: false,` 1489. `get: function() {` 1490. `return this.hasAnnotation ? "/Annot" : null;` 1491. `}` 1492. `});` 1494. `Object.defineProperty(this, "Subtype", {` 1495. `enumerable: true,` 1496. `configurable: false,` 1497. `get: function() {` 1498. `return this.hasAnnotation ? "/Widget" : null;` 1499. `}` 1500. `});` 1502. `var _hasAppearanceStream = false;` 1503. `/**` 1504. `* true if field has an appearanceStream` 1505. `*` 1506. `* @name AcroFormField#hasAppearanceStream` 1507. `* @readonly` 1508. `* @type {boolean}` 1509. `*/` 1510. `Object.defineProperty(this, "hasAppearanceStream", {` 1511. `enumerable: true,` 1512. `configurable: true,` 1513. `get: function() {` 1514. `return _hasAppearanceStream;` 1515. `},` 1516. `set: function(value) {` 1517. `value = Boolean(value);` 1518. `_hasAppearanceStream = value;` 1519. `}` 1520. `});` 1522. `/**` 1523. `* The page on which the AcroFormField is placed` 1524. `*` 1525. `* @name AcroFormField#page` 1526. `* @type {number}` 1527. `*/` 1528. `var _page;` 1529. `Object.defineProperty(this, "page", {` 1530. `enumerable: true,` 1531. `configurable: true,` 1532. `get: function() {` 1533. `if (!_page) {` 1534. `return undefined;` 1535. `}` 1536. `return _page;` 1537. `},` 1538. `set: function(value) {` 1539. `_page = value;` 1540. `}` 1541. `});` 1543. `/**` 1544. `* 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.` 1545. `*` 1546. `* @name AcroFormField#readOnly` 1547. `* @default false` 1548. `* @type {boolean}` 1549. `*/` 1550. `Object.defineProperty(this, "readOnly", {` 1551. `enumerable: true,` 1552. `configurable: true,` 1553. `get: function() {` 1554. `return Boolean(getBitForPdf(this.Ff, 1));` 1555. `},` 1556. `set: function(value) {` 1557. `if (Boolean(value) === true) {` 1558. `this.Ff = setBitForPdf(this.Ff, 1);` 1559. `} else {` 1560. `this.Ff = clearBitForPdf(this.Ff, 1);` 1561. `}` 1562. `}` 1563. `});` 1565. `/**` 1566. `* 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”).` 1567. `*` 1568. `* @name AcroFormField#required` 1569. `* @default false` 1570. `* @type {boolean}` 1571. `*/` 1572. `Object.defineProperty(this, "required", {` 1573. `enumerable: true,` 1574. `configurable: true,` 1575. `get: function() {` 1576. `return Boolean(getBitForPdf(this.Ff, 2));` 1577. `},` 1578. `set: function(value) {` 1579. `if (Boolean(value) === true) {` 1580. `this.Ff = setBitForPdf(this.Ff, 2);` 1581. `} else {` 1582. `this.Ff = clearBitForPdf(this.Ff, 2);` 1583. `}` 1584. `}` 1585. `});` 1587. `/**` 1588. `* If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”)` 1589. `*` 1590. `* @name AcroFormField#noExport` 1591. `* @default false` 1592. `* @type {boolean}` 1593. `*/` 1594. `Object.defineProperty(this, "noExport", {` 1595. `enumerable: true,` 1596. `configurable: true,` 1597. `get: function() {` 1598. `return Boolean(getBitForPdf(this.Ff, 3));` 1599. `},` 1600. `set: function(value) {` 1601. `if (Boolean(value) === true) {` 1602. `this.Ff = setBitForPdf(this.Ff, 3);` 1603. `} else {` 1604. `this.Ff = clearBitForPdf(this.Ff, 3);` 1605. `}` 1606. `}` 1607. `});` 1609. `var _Q = null;` 1610. `Object.defineProperty(this, "Q", {` 1611. `enumerable: true,` 1612. `configurable: false,` 1613. `get: function() {` 1614. `if (_Q === null) {` 1615. `return undefined;` 1616. `}` 1617. `return _Q;` 1618. `},` 1619. `set: function(value) {` 1620. `if ([0, 1, 2].indexOf(value) !== -1) {` 1621. `_Q = value;` 1622. `} else {` 1623. `throw new Error(` 1624. `'Invalid value "' + value + '" for attribute Q supplied.'` 1625. `);` 1626. `}` 1627. `}` 1628. `});` 1630. `/**` 1631. `* (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text:` 1632. `* 'left', 'center', 'right'` 1633. `*` 1634. `* @name AcroFormField#textAlign` 1635. `* @default 'left'` 1636. `* @type {string}` 1637. `*/` 1638. `Object.defineProperty(this, "textAlign", {` 1639. `get: function() {` 1640. `var result;` 1641. `switch (_Q) {` 1642. `case 0:` 1643. `default:` 1644. `result = "left";` 1645. `break;` 1646. `case 1:` 1647. `result = "center";` 1648. `break;` 1649. `case 2:` 1650. `result = "right";` 1651. `break;` 1652. `}` 1653. `return result;` 1654. `},` 1655. `configurable: true,` 1656. `enumerable: true,` 1657. `set: function(value) {` 1658. `switch (value) {` 1659. `case "right":` 1660. `case 2:` 1661. `_Q = 2;` 1662. `break;` 1663. `case "center":` 1664. `case 1:` 1665. `_Q = 1;` 1666. `break;` 1667. `case "left":` 1668. `case 0:` 1669. `default:` 1670. `_Q = 0;` 1671. `}` 1672. `}` 1673. `});` 1674. `};` 1676. `inherit(AcroFormField, AcroFormPDFObject);` 1678. `/**` 1679. `* @class AcroFormChoiceField` 1680. `* @extends AcroFormField` 1681. `*/` 1682. `var AcroFormChoiceField = function() {` 1683. `AcroFormField.call(this);` 1684. `// Field Type = Choice Field` 1685. `this.FT = "/Ch";` 1686. `// options` 1687. `this.V = "()";` 1689. `this.fontName = "zapfdingbats";` 1690. `// Top Index` 1691. `var _TI = 0;` 1693. `Object.defineProperty(this, "TI", {` 1694. `enumerable: true,` 1695. `configurable: false,` 1696. `get: function() {` 1697. `return _TI;` 1698. `},` 1699. `set: function(value) {` 1700. `_TI = value;` 1701. `}` 1702. `});` 1704. `/**` 1705. `* (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.` 1706. `*` 1707. `* @name AcroFormChoiceField#topIndex` 1708. `* @default 0` 1709. `* @type {number}` 1710. `*/` 1711. `Object.defineProperty(this, "topIndex", {` 1712. `enumerable: true,` 1713. `configurable: true,` 1714. `get: function() {` 1715. `return _TI;` 1716. `},` 1717. `set: function(value) {` 1718. `_TI = value;` 1719. `}` 1720. `});` 1722. `var _Opt = [];` 1723. `Object.defineProperty(this, "Opt", {` 1724. `enumerable: true,` 1725. `configurable: false,` 1726. `get: function() {` 1727. `return arrayToPdfArray(_Opt, this.objId, this.scope);` 1728. `},` 1729. `set: function(value) {` 1730. `_Opt = pdfArrayToStringArray(value);` 1731. `}` 1732. `});` 1734. `/**` 1735. `* @memberof AcroFormChoiceField` 1736. `* @name getOptions` 1737. `* @function` 1738. `* @instance` 1739. `* @returns {array} array of Options` 1740. `*/` 1741. `this.getOptions = function() {` 1742. `return _Opt;` 1743. `};` 1745. `/**` 1746. `* @memberof AcroFormChoiceField` 1747. `* @name setOptions` 1748. `* @function` 1749. `* @instance` 1750. `* @param {array} value` 1751. `*/` 1752. `this.setOptions = function(value) {` 1753. `_Opt = value;` 1754. `if (this.sort) {` 1755. `_Opt.sort();` 1756. `}` 1757. `};` 1759. `/**` 1760. `* @memberof AcroFormChoiceField` 1761. `* @name addOption` 1762. `* @function` 1763. `* @instance` 1764. `* @param {string} value` 1765. `*/` 1766. `this.addOption = function(value) {` 1767. `value = value || "";` 1768. `value = value.toString();` 1769. `_Opt.push(value);` 1770. `if (this.sort) {` 1771. `_Opt.sort();` 1772. `}` 1773. `};` 1775. `/**` 1776. `* @memberof AcroFormChoiceField` 1777. `* @name removeOption` 1778. `* @function` 1779. `* @instance` 1780. `* @param {string} value` 1781. `* @param {boolean} allEntries (default: false)` 1782. `*/` 1783. `this.removeOption = function(value, allEntries) {` 1784. `allEntries = allEntries || false;` 1785. `value = value || "";` 1786. `value = value.toString();` 1788. `while (_Opt.indexOf(value) !== -1) {` 1789. `_Opt.splice(_Opt.indexOf(value), 1);` 1790. `if (allEntries === false) {` 1791. `break;` 1792. `}` 1793. `}` 1794. `};` 1796. `/**` 1797. `* If set, the field is a combo box; if clear, the field is a list box.` 1798. `*` 1799. `* @name AcroFormChoiceField#combo` 1800. `* @default false` 1801. `* @type {boolean}` 1802. `*/` 1803. `Object.defineProperty(this, "combo", {` 1804. `enumerable: true,` 1805. `configurable: true,` 1806. `get: function() {` 1807. `return Boolean(getBitForPdf(this.Ff, 18));` 1808. `},` 1809. `set: function(value) {` 1810. `if (Boolean(value) === true) {` 1811. `this.Ff = setBitForPdf(this.Ff, 18);` 1812. `} else {` 1813. `this.Ff = clearBitForPdf(this.Ff, 18);` 1814. `}` 1815. `}` 1816. `});` 1818. `/**` 1819. `* 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.` 1820. `*` 1821. `* @name AcroFormChoiceField#edit` 1822. `* @default false` 1823. `* @type {boolean}` 1824. `*/` 1825. `Object.defineProperty(this, "edit", {` 1826. `enumerable: true,` 1827. `configurable: true,` 1828. `get: function() {` 1829. `return Boolean(getBitForPdf(this.Ff, 19));` 1830. `},` 1831. `set: function(value) {` 1832. `//PDF 32000-1:2008, page 444` 1833. `if (this.combo === true) {` 1834. `if (Boolean(value) === true) {` 1835. `this.Ff = setBitForPdf(this.Ff, 19);` 1836. `} else {` 1837. `this.Ff = clearBitForPdf(this.Ff, 19);` 1838. `}` 1839. `}` 1840. `}` 1841. `});` 1843. `/**` 1844. `* 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).` 1845. `*` 1846. `* @name AcroFormChoiceField#sort` 1847. `* @default false` 1848. `* @type {boolean}` 1849. `*/` 1850. `Object.defineProperty(this, "sort", {` 1851. `enumerable: true,` 1852. `configurable: true,` 1853. `get: function() {` 1854. `return Boolean(getBitForPdf(this.Ff, 20));` 1855. `},` 1856. `set: function(value) {` 1857. `if (Boolean(value) === true) {` 1858. `this.Ff = setBitForPdf(this.Ff, 20);` 1859. `_Opt.sort();` 1860. `} else {` 1861. `this.Ff = clearBitForPdf(this.Ff, 20);` 1862. `}` 1863. `}` 1864. `});` 1866. `/**` 1867. `* (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` 1868. `*` 1869. `* @name AcroFormChoiceField#multiSelect` 1870. `* @default false` 1871. `* @type {boolean}` 1872. `*/` 1873. `Object.defineProperty(this, "multiSelect", {` 1874. `enumerable: true,` 1875. `configurable: true,` 1876. `get: function() {` 1877. `return Boolean(getBitForPdf(this.Ff, 22));` 1878. `},` 1879. `set: function(value) {` 1880. `if (Boolean(value) === true) {` 1881. `this.Ff = setBitForPdf(this.Ff, 22);` 1882. `} else {` 1883. `this.Ff = clearBitForPdf(this.Ff, 22);` 1884. `}` 1885. `}` 1886. `});` 1888. `/**` 1889. `* (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.` 1890. `*` 1891. `* @name AcroFormChoiceField#doNotSpellCheck` 1892. `* @default false` 1893. `* @type {boolean}` 1894. `*/` 1895. `Object.defineProperty(this, "doNotSpellCheck", {` 1896. `enumerable: true,` 1897. `configurable: true,` 1898. `get: function() {` 1899. `return Boolean(getBitForPdf(this.Ff, 23));` 1900. `},` 1901. `set: function(value) {` 1902. `if (Boolean(value) === true) {` 1903. `this.Ff = setBitForPdf(this.Ff, 23);` 1904. `} else {` 1905. `this.Ff = clearBitForPdf(this.Ff, 23);` 1906. `}` 1907. `}` 1908. `});` 1910. `/**` 1911. `* (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.` 1912. `* 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.` 1913. `*` 1914. `* @name AcroFormChoiceField#commitOnSelChange` 1915. `* @default false` 1916. `* @type {boolean}` 1917. `*/` 1918. `Object.defineProperty(this, "commitOnSelChange", {` 1919. `enumerable: true,` 1920. `configurable: true,` 1921. `get: function() {` 1922. `return Boolean(getBitForPdf(this.Ff, 27));` 1923. `},` 1924. `set: function(value) {` 1925. `if (Boolean(value) === true) {` 1926. `this.Ff = setBitForPdf(this.Ff, 27);` 1927. `} else {` 1928. `this.Ff = clearBitForPdf(this.Ff, 27);` 1929. `}` 1930. `}` 1931. `});` 1933. `this.hasAppearanceStream = false;` 1934. `};` 1935. `inherit(AcroFormChoiceField, AcroFormField);` 1937. `/**` 1938. `* @class AcroFormListBox` 1939. `* @extends AcroFormChoiceField` 1940. `* @extends AcroFormField` 1941. `*/` 1942. `var AcroFormListBox = function() {` 1943. `AcroFormChoiceField.call(this);` 1944. `this.fontName = "helvetica";` 1946. `//PDF 32000-1:2008, page 444` 1947. `this.combo = false;` 1948. `};` 1949. `inherit(AcroFormListBox, AcroFormChoiceField);` 1951. `/**` 1952. `* @class AcroFormComboBox` 1953. `* @extends AcroFormListBox` 1954. `* @extends AcroFormChoiceField` 1955. `* @extends AcroFormField` 1956. `*/` 1957. `var AcroFormComboBox = function() {` 1958. `AcroFormListBox.call(this);` 1959. `this.combo = true;` 1960. `};` 1961. `inherit(AcroFormComboBox, AcroFormListBox);` 1963. `/**` 1964. `* @class AcroFormEditBox` 1965. `* @extends AcroFormComboBox` 1966. `* @extends AcroFormListBox` 1967. `* @extends AcroFormChoiceField` 1968. `* @extends AcroFormField` 1969. `*/` 1970. `var AcroFormEditBox = function() {` 1971. `AcroFormComboBox.call(this);` 1972. `this.edit = true;` 1973. `};` 1974. `inherit(AcroFormEditBox, AcroFormComboBox);` 1976. `/**` 1977. `* @class AcroFormButton` 1978. `* @extends AcroFormField` 1979. `*/` 1980. `var AcroFormButton = function() {` 1981. `AcroFormField.call(this);` 1982. `this.FT = "/Btn";` 1984. `/**` 1985. `* (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.` 1986. `*` 1987. `* @name AcroFormButton#noToggleToOff` 1988. `* @type {boolean}` 1989. `*/` 1990. `Object.defineProperty(this, "noToggleToOff", {` 1991. `enumerable: true,` 1992. `configurable: true,` 1993. `get: function() {` 1994. `return Boolean(getBitForPdf(this.Ff, 15));` 1995. `},` 1996. `set: function(value) {` 1997. `if (Boolean(value) === true) {` 1998. `this.Ff = setBitForPdf(this.Ff, 15);` 1999. `} else {` 2000. `this.Ff = clearBitForPdf(this.Ff, 15);` 2001. `}` 2002. `}` 2003. `});` 2005. `/**` 2006. `* 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.` 2007. `*` 2008. `* @name AcroFormButton#radio` 2009. `* @type {boolean}` 2010. `*/` 2011. `Object.defineProperty(this, "radio", {` 2012. `enumerable: true,` 2013. `configurable: true,` 2014. `get: function() {` 2015. `return Boolean(getBitForPdf(this.Ff, 16));` 2016. `},` 2017. `set: function(value) {` 2018. `if (Boolean(value) === true) {` 2019. `this.Ff = setBitForPdf(this.Ff, 16);` 2020. `} else {` 2021. `this.Ff = clearBitForPdf(this.Ff, 16);` 2022. `}` 2023. `}` 2024. `});` 2026. `/**` 2027. `* If set, the field is a pushbutton that does not retain a permanent value.` 2028. `*` 2029. `* @name AcroFormButton#pushButton` 2030. `* @type {boolean}` 2031. `*/` 2032. `Object.defineProperty(this, "pushButton", {` 2033. `enumerable: true,` 2034. `configurable: true,` 2035. `get: function() {` 2036. `return Boolean(getBitForPdf(this.Ff, 17));` 2037. `},` 2038. `set: function(value) {` 2039. `if (Boolean(value) === true) {` 2040. `this.Ff = setBitForPdf(this.Ff, 17);` 2041. `} else {` 2042. `this.Ff = clearBitForPdf(this.Ff, 17);` 2043. `}` 2044. `}` 2045. `});` 2047. `/**` 2048. `* (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).` 2049. `*` 2050. `* @name AcroFormButton#radioIsUnison` 2051. `* @type {boolean}` 2052. `*/` 2053. `Object.defineProperty(this, "radioIsUnison", {` 2054. `enumerable: true,` 2055. `configurable: true,` 2056. `get: function() {` 2057. `return Boolean(getBitForPdf(this.Ff, 26));` 2058. `},` 2059. `set: function(value) {` 2060. `if (Boolean(value) === true) {` 2061. `this.Ff = setBitForPdf(this.Ff, 26);` 2062. `} else {` 2063. `this.Ff = clearBitForPdf(this.Ff, 26);` 2064. `}` 2065. `}` 2066. `});` 2068. `var _MK = {};` 2069. `Object.defineProperty(this, "MK", {` 2070. `enumerable: false,` 2071. `configurable: false,` 2072. `get: function() {` 2073. `var encryptor = function(data) {` 2074. `return data;` 2075. `};` 2076. `if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId);` 2077. `if (Object.keys(_MK).length !== 0) {` 2078. `var result = [];` 2079. `result.push("<<");` 2080. `var key;` 2081. `for (key in _MK) {` 2082. `result.push("/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")");` 2083. `}` 2084. `result.push(">>");` 2085. `return result.join("\n");` 2086. `}` 2087. `return undefined;` 2088. `},` 2089. `set: function(value) {` 2090. `if (typeof value === "object") {` 2091. `_MK = value;` 2092. `}` 2093. `}` 2094. `});` 2096. `/**` 2097. `* From the PDF reference:` 2098. `* (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user.` 2099. `* 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").` 2100. `*` 2101. `* - '8' = Cross,` 2102. `* - 'l' = Circle,` 2103. `* - '' = nothing` 2104. `* @name AcroFormButton#caption` 2105. `* @type {string}` 2106. `*/` 2107. `Object.defineProperty(this, "caption", {` 2108. `enumerable: true,` 2109. `configurable: true,` 2110. `get: function() {` 2111. `return _MK.CA || "";` 2112. `},` 2113. `set: function(value) {` 2114. `if (typeof value === "string") {` 2115. `_MK.CA = value;` 2116. `}` 2117. `}` 2118. `});` 2120. `var _AS;` 2121. `Object.defineProperty(this, "AS", {` 2122. `enumerable: false,` 2123. `configurable: false,` 2124. `get: function() {` 2125. `return _AS;` 2126. `},` 2127. `set: function(value) {` 2128. `_AS = value;` 2129. `}` 2130. `});` 2132. `/**` 2133. `* (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")` 2134. `*` 2135. `* @name AcroFormButton#appearanceState` 2136. `* @type {any}` 2137. `*/` 2138. `Object.defineProperty(this, "appearanceState", {` 2139. `enumerable: true,` 2140. `configurable: true,` 2141. `get: function() {` 2142. `return _AS.substr(1, _AS.length - 1);` 2143. `},` 2144. `set: function(value) {` 2145. `_AS = "/" + value;` 2146. `}` 2147. `});` 2148. `};` 2149. `inherit(AcroFormButton, AcroFormField);` 2151. `/**` 2152. `* @class AcroFormPushButton` 2153. `* @extends AcroFormButton` 2154. `* @extends AcroFormField` 2155. `*/` 2156. `var AcroFormPushButton = function() {` 2157. `AcroFormButton.call(this);` 2158. `this.pushButton = true;` 2159. `};` 2160. `inherit(AcroFormPushButton, AcroFormButton);` 2162. `/**` 2163. `* @class AcroFormRadioButton` 2164. `* @extends AcroFormButton` 2165. `* @extends AcroFormField` 2166. `*/` 2167. `var AcroFormRadioButton = function() {` 2168. `AcroFormButton.call(this);` 2169. `this.radio = true;` 2170. `this.pushButton = false;` 2172. `var _Kids = [];` 2173. `Object.defineProperty(this, "Kids", {` 2174. `enumerable: true,` 2175. `configurable: false,` 2176. `get: function() {` 2177. `return _Kids;` 2178. `},` 2179. `set: function(value) {` 2180. `if (typeof value !== "undefined") {` 2181. `_Kids = value;` 2182. `} else {` 2183. `_Kids = [];` 2184. `}` 2185. `}` 2186. `});` 2187. `};` 2188. `inherit(AcroFormRadioButton, AcroFormButton);` 2190. `/**` 2191. `* The Child class of a RadioButton (the radioGroup) -> The single Buttons` 2192. `*` 2193. `* @class AcroFormChildClass` 2194. `* @extends AcroFormField` 2195. `* @ignore` 2196. `*/` 2197. `var AcroFormChildClass = function() {` 2198. `AcroFormField.call(this);` 2200. `var _parent;` 2201. `Object.defineProperty(this, "Parent", {` 2202. `enumerable: false,` 2203. `configurable: false,` 2204. `get: function() {` 2205. `return _parent;` 2206. `},` 2207. `set: function(value) {` 2208. `_parent = value;` 2209. `}` 2210. `});` 2212. `var _optionName;` 2213. `Object.defineProperty(this, "optionName", {` 2214. `enumerable: false,` 2215. `configurable: true,` 2216. `get: function() {` 2217. `return _optionName;` 2218. `},` 2219. `set: function(value) {` 2220. `_optionName = value;` 2221. `}` 2222. `});` 2224. `var _MK = {};` 2225. `Object.defineProperty(this, "MK", {` 2226. `enumerable: false,` 2227. `configurable: false,` 2228. `get: function() {` 2229. `var encryptor = function(data) {` 2230. `return data;` 2231. `};` 2232. `if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId);` 2233. `var result = [];` 2234. `result.push("<<");` 2235. `var key;` 2236. `for (key in _MK) {` 2237. `result.push("/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")");` 2238. `}` 2239. `result.push(">>");` 2240. `return result.join("\n");` 2241. `},` 2242. `set: function(value) {` 2243. `if (typeof value === "object") {` 2244. `_MK = value;` 2245. `}` 2246. `}` 2247. `});` 2249. `/**` 2250. `* From the PDF reference:` 2251. `* (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user.` 2252. `* 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").` 2253. `*` 2254. `* - '8' = Cross,` 2255. `* - 'l' = Circle,` 2256. `* - '' = nothing` 2257. `* @name AcroFormButton#caption` 2258. `* @type {string}` 2259. `*/` 2260. `Object.defineProperty(this, "caption", {` 2261. `enumerable: true,` 2262. `configurable: true,` 2263. `get: function() {` 2264. `return _MK.CA || "";` 2265. `},` 2266. `set: function(value) {` 2267. `if (typeof value === "string") {` 2268. `_MK.CA = value;` 2269. `}` 2270. `}` 2271. `});` 2273. `var _AS;` 2274. `Object.defineProperty(this, "AS", {` 2275. `enumerable: false,` 2276. `configurable: false,` 2277. `get: function() {` 2278. `return _AS;` 2279. `},` 2280. `set: function(value) {` 2281. `_AS = value;` 2282. `}` 2283. `});` 2285. `/**` 2286. `* (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")` 2287. `*` 2288. `* @name AcroFormButton#appearanceState` 2289. `* @type {any}` 2290. `*/` 2291. `Object.defineProperty(this, "appearanceState", {` 2292. `enumerable: true,` 2293. `configurable: true,` 2294. `get: function() {` 2295. `return _AS.substr(1, _AS.length - 1);` 2296. `},` 2297. `set: function(value) {` 2298. `_AS = "/" + value;` 2299. `}` 2300. `});` 2301. `this.caption = "l";` 2302. `this.appearanceState = "Off";` 2303. `// todo: set AppearanceType as variable that can be set from the` 2304. `// outside...` 2305. `this._AppearanceType = AcroFormAppearance.RadioButton.Circle;` 2306. `// The Default appearanceType is the Circle` 2307. `this.appearanceStreamContent = this._AppearanceType.createAppearanceStream(` 2308. `this.optionName` 2309. `);` 2310. `};` 2311. `inherit(AcroFormChildClass, AcroFormField);` 2313. `AcroFormRadioButton.prototype.setAppearance = function(appearance) {` 2314. `if (!("createAppearanceStream" in appearance && "getCA" in appearance)) {` 2315. `throw new Error(` 2316. `"Couldn't assign Appearance to RadioButton. Appearance was Invalid!"` 2317. `);` 2318. `}` 2319. `for (var objId in this.Kids) {` 2320. `if (this.Kids.hasOwnProperty(objId)) {` 2321. `var child = this.Kids[objId];` 2322. `child.appearanceStreamContent = appearance.createAppearanceStream(` 2323. `child.optionName` 2324. `);` 2325. `child.caption = appearance.getCA();` 2326. `}` 2327. `}` 2328. `};` 2330. `AcroFormRadioButton.prototype.createOption = function(name) {` 2331. `// Create new Child for RadioGroup` 2332. `var child = new AcroFormChildClass();` 2333. `child.Parent = this;` 2334. `child.optionName = name;` 2335. `// Add to Parent` 2336. `this.Kids.push(child);` 2338. `addField.call(this.scope, child);` 2340. `return child;` 2341. `};` 2343. `/**` 2344. `* @class AcroFormCheckBox` 2345. `* @extends AcroFormButton` 2346. `* @extends AcroFormField` 2347. `*/` 2348. `var AcroFormCheckBox = function() {` 2349. `AcroFormButton.call(this);` 2351. `this.fontName = "zapfdingbats";` 2352. `this.caption = "3";` 2353. `this.appearanceState = "On";` 2354. `this.value = "On";` 2355. `this.textAlign = "center";` 2356. `this.appearanceStreamContent = AcroFormAppearance.CheckBox.createAppearanceStream();` 2357. `};` 2358. `inherit(AcroFormCheckBox, AcroFormButton);` 2360. `/**` 2361. `* @class AcroFormTextField` 2362. `* @extends AcroFormField` 2363. `*/` 2364. `var AcroFormTextField = function() {` 2365. `AcroFormField.call(this);` 2366. `this.FT = "/Tx";` 2368. `/**` 2369. `* If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line.` 2370. `*` 2371. `* @name AcroFormTextField#multiline` 2372. `* @type {boolean}` 2373. `*/` 2374. `Object.defineProperty(this, "multiline", {` 2375. `enumerable: true,` 2376. `configurable: true,` 2377. `get: function() {` 2378. `return Boolean(getBitForPdf(this.Ff, 13));` 2379. `},` 2380. `set: function(value) {` 2381. `if (Boolean(value) === true) {` 2382. `this.Ff = setBitForPdf(this.Ff, 13);` 2383. `} else {` 2384. `this.Ff = clearBitForPdf(this.Ff, 13);` 2385. `}` 2386. `}` 2387. `});` 2389. `/**` 2390. `* (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.` 2391. `*` 2392. `* @name AcroFormTextField#fileSelect` 2393. `* @type {boolean}` 2394. `*/` 2395. `Object.defineProperty(this, "fileSelect", {` 2396. `enumerable: true,` 2397. `configurable: true,` 2398. `get: function() {` 2399. `return Boolean(getBitForPdf(this.Ff, 21));` 2400. `},` 2401. `set: function(value) {` 2402. `if (Boolean(value) === true) {` 2403. `this.Ff = setBitForPdf(this.Ff, 21);` 2404. `} else {` 2405. `this.Ff = clearBitForPdf(this.Ff, 21);` 2406. `}` 2407. `}` 2408. `});` 2410. `/**` 2411. `* (PDF 1.4) If set, text entered in the field shall not be spell-checked.` 2412. `*` 2413. `* @name AcroFormTextField#doNotSpellCheck` 2414. `* @type {boolean}` 2415. `*/` 2416. `Object.defineProperty(this, "doNotSpellCheck", {` 2417. `enumerable: true,` 2418. `configurable: true,` 2419. `get: function() {` 2420. `return Boolean(getBitForPdf(this.Ff, 23));` 2421. `},` 2422. `set: function(value) {` 2423. `if (Boolean(value) === true) {` 2424. `this.Ff = setBitForPdf(this.Ff, 23);` 2425. `} else {` 2426. `this.Ff = clearBitForPdf(this.Ff, 23);` 2427. `}` 2428. `}` 2429. `});` 2431. `/**` 2432. `* (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.` 2433. `*` 2434. `* @name AcroFormTextField#doNotScroll` 2435. `* @type {boolean}` 2436. `*/` 2437. `Object.defineProperty(this, "doNotScroll", {` 2438. `enumerable: true,` 2439. `configurable: true,` 2440. `get: function() {` 2441. `return Boolean(getBitForPdf(this.Ff, 24));` 2442. `},` 2443. `set: function(value) {` 2444. `if (Boolean(value) === true) {` 2445. `this.Ff = setBitForPdf(this.Ff, 24);` 2446. `} else {` 2447. `this.Ff = clearBitForPdf(this.Ff, 24);` 2448. `}` 2449. `}` 2450. `});` 2452. `/**` 2453. `* (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.` 2454. `*` 2455. `* @name AcroFormTextField#comb` 2456. `* @type {boolean}` 2457. `*/` 2458. `Object.defineProperty(this, "comb", {` 2459. `enumerable: true,` 2460. `configurable: true,` 2461. `get: function() {` 2462. `return Boolean(getBitForPdf(this.Ff, 25));` 2463. `},` 2464. `set: function(value) {` 2465. `if (Boolean(value) === true) {` 2466. `this.Ff = setBitForPdf(this.Ff, 25);` 2467. `} else {` 2468. `this.Ff = clearBitForPdf(this.Ff, 25);` 2469. `}` 2470. `}` 2471. `});` 2473. `/**` 2474. `* (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.` 2475. `*` 2476. `* @name AcroFormTextField#richText` 2477. `* @type {boolean}` 2478. `*/` 2479. `Object.defineProperty(this, "richText", {` 2480. `enumerable: true,` 2481. `configurable: true,` 2482. `get: function() {` 2483. `return Boolean(getBitForPdf(this.Ff, 26));` 2484. `},` 2485. `set: function(value) {` 2486. `if (Boolean(value) === true) {` 2487. `this.Ff = setBitForPdf(this.Ff, 26);` 2488. `} else {` 2489. `this.Ff = clearBitForPdf(this.Ff, 26);` 2490. `}` 2491. `}` 2492. `});` 2494. `var _MaxLen = null;` 2495. `Object.defineProperty(this, "MaxLen", {` 2496. `enumerable: true,` 2497. `configurable: false,` 2498. `get: function() {` 2499. `return _MaxLen;` 2500. `},` 2501. `set: function(value) {` 2502. `_MaxLen = value;` 2503. `}` 2504. `});` 2506. `/**` 2507. `* (Optional; inheritable) The maximum length of the field’s text, in characters.` 2508. `*` 2509. `* @name AcroFormTextField#maxLength` 2510. `* @type {number}` 2511. `*/` 2512. `Object.defineProperty(this, "maxLength", {` 2513. `enumerable: true,` 2514. `configurable: true,` 2515. `get: function() {` 2516. `return _MaxLen;` 2517. `},` 2518. `set: function(value) {` 2519. `if (Number.isInteger(value)) {` 2520. `_MaxLen = value;` 2521. `}` 2522. `}` 2523. `});` 2525. `Object.defineProperty(this, "hasAppearanceStream", {` 2526. `enumerable: true,` 2527. `configurable: true,` 2528. `get: function() {` 2529. `return this.V || this.DV;` 2530. `}` 2531. `});` 2532. `};` 2533. `inherit(AcroFormTextField, AcroFormField);` 2535. `/**` 2536. `* @class AcroFormPasswordField` 2537. `* @extends AcroFormTextField` 2538. `* @extends AcroFormField` 2539. `*/` 2540. `var AcroFormPasswordField = function() {` 2541. `AcroFormTextField.call(this);` 2543. `/**` 2544. `* 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.` 2545. `* NOTE To protect password confidentiality, readers should never store the value of the text field in the PDF file if this flag is set.` 2546. `*` 2547. `* @name AcroFormTextField#password` 2548. `* @type {boolean}` 2549. `*/` 2550. `Object.defineProperty(this, "password", {` 2551. `enumerable: true,` 2552. `configurable: true,` 2553. `get: function() {` 2554. `return Boolean(getBitForPdf(this.Ff, 14));` 2555. `},` 2556. `set: function(value) {` 2557. `if (Boolean(value) === true) {` 2558. `this.Ff = setBitForPdf(this.Ff, 14);` 2559. `} else {` 2560. `this.Ff = clearBitForPdf(this.Ff, 14);` 2561. `}` 2562. `}` 2563. `});` 2564. `this.password = true;` 2565. `};` 2566. `inherit(AcroFormPasswordField, AcroFormTextField);` 2568. `// Contains Methods for creating standard appearances` 2569. `var AcroFormAppearance = {` 2570. `CheckBox: {` 2571. `createAppearanceStream: function() {` 2572. `var appearance = {` 2573. `N: {` 2574. `On: AcroFormAppearance.CheckBox.YesNormal` 2575. `},` 2576. `D: {` 2577. `On: AcroFormAppearance.CheckBox.YesPushDown,` 2578. `Off: AcroFormAppearance.CheckBox.OffPushDown` 2579. `}` 2580. `};` 2582. `return appearance;` 2583. `},` 2584. `/**` 2585. `* Returns the standard On Appearance for a CheckBox` 2586. `*` 2587. `* @returns {AcroFormXObject}` 2588. `*/` 2589. `YesPushDown: function(formObject) {` 2590. `var xobj = createFormXObject(formObject);` 2591. `xobj.scope = formObject.scope;` 2592. `var stream = [];` 2593. `var fontKey = formObject.scope.internal.getFont(` 2594. `formObject.fontName,` 2595. `formObject.fontStyle` 2596. `).id;` 2597. `var encodedColor = formObject.scope.__private__.encodeColorString(` 2598. `formObject.color` 2599. `);` 2600. `var calcRes = calculateX(formObject, formObject.caption);` 2601. `stream.push("0.749023 g");` 2602. `stream.push(` 2603. `"0 0 " +` 2604. `f2(AcroFormAppearance.internal.getWidth(formObject)) +` 2605. `" " +` 2606. `f2(AcroFormAppearance.internal.getHeight(formObject)) +` 2607. `" re"` 2608. `);` 2609. `stream.push("f");` 2610. `stream.push("BMC");` 2611. `stream.push("q");` 2612. `stream.push("0 0 1 rg");` 2613. `stream.push(` 2614. `"/" + fontKey + " " + f2(calcRes.fontSize) + " Tf " + encodedColor` 2615. `);` 2616. `stream.push("BT");` 2617. `stream.push(calcRes.text);` 2618. `stream.push("ET");` 2619. `stream.push("Q");` 2620. `stream.push("EMC");` 2621. `xobj.stream = stream.join("\n");` 2622. `return xobj;` 2623. `},` 2625. `YesNormal: function(formObject) {` 2626. `var xobj = createFormXObject(formObject);` 2627. `xobj.scope = formObject.scope;` 2628. `var fontKey = formObject.scope.internal.getFont(` 2629. `formObject.fontName,` 2630. `formObject.fontStyle` 2631. `).id;` 2632. `var encodedColor = formObject.scope.__private__.encodeColorString(` 2633. `formObject.color` 2634. `);` 2635. `var stream = [];` 2636. `var height = AcroFormAppearance.internal.getHeight(formObject);` 2637. `var width = AcroFormAppearance.internal.getWidth(formObject);` 2638. `var calcRes = calculateX(formObject, formObject.caption);` 2639. `stream.push("1 g");` 2640. `stream.push("0 0 " + f2(width) + " " + f2(height) + " re");` 2641. `stream.push("f");` 2642. `stream.push("q");` 2643. `stream.push("0 0 1 rg");` 2644. `stream.push("0 0 " + f2(width - 1) + " " + f2(height - 1) + " re");` 2645. `stream.push("W");` 2646. `stream.push("n");` 2647. `stream.push("0 g");` 2648. `stream.push("BT");` 2649. `stream.push(` 2650. `"/" + fontKey + " " + f2(calcRes.fontSize) + " Tf " + encodedColor` 2651. `);` 2652. `stream.push(calcRes.text);` 2653. `stream.push("ET");` 2654. `stream.push("Q");` 2655. `xobj.stream = stream.join("\n");` 2656. `return xobj;` 2657. `},` 2659. `/**` 2660. `* Returns the standard Off Appearance for a CheckBox` 2661. `*` 2662. `* @returns {AcroFormXObject}` 2663. `*/` 2664. `OffPushDown: function(formObject) {` 2665. `var xobj = createFormXObject(formObject);` 2666. `xobj.scope = formObject.scope;` 2667. `var stream = [];` 2668. `stream.push("0.749023 g");` 2669. `stream.push(` 2670. `"0 0 " +` 2671. `f2(AcroFormAppearance.internal.getWidth(formObject)) +` 2672. `" " +` 2673. `f2(AcroFormAppearance.internal.getHeight(formObject)) +` 2674. `" re"` 2675. `);` 2676. `stream.push("f");` 2677. `xobj.stream = stream.join("\n");` 2678. `return xobj;` 2679. `}` 2680. `},` 2682. `RadioButton: {` 2683. `Circle: {` 2684. `createAppearanceStream: function(name) {` 2685. `var appearanceStreamContent = {` 2686. `D: {` 2687. `Off: AcroFormAppearance.RadioButton.Circle.OffPushDown` 2688. `},` 2689. `N: {}` 2690. `};` 2691. `appearanceStreamContent.N[name] =` 2692. `AcroFormAppearance.RadioButton.Circle.YesNormal;` 2693. `appearanceStreamContent.D[name] =` 2694. `AcroFormAppearance.RadioButton.Circle.YesPushDown;` 2695. `return appearanceStreamContent;` 2696. `},` 2697. `getCA: function() {` 2698. `return "l";` 2699. `},` 2701. `YesNormal: function(formObject) {` 2702. `var xobj = createFormXObject(formObject);` 2703. `xobj.scope = formObject.scope;` 2704. `var stream = [];` 2705. `// Make the Radius of the Circle relative to min(height, width) of formObject` 2706. `var DotRadius =` 2707. `AcroFormAppearance.internal.getWidth(formObject) <=` 2708. `AcroFormAppearance.internal.getHeight(formObject)` 2709. `? AcroFormAppearance.internal.getWidth(formObject) / 4` 2710. `: AcroFormAppearance.internal.getHeight(formObject) / 4;` 2711. `// The Borderpadding...` 2712. `DotRadius = Number((DotRadius * 0.9).toFixed(5));` 2713. `var c = AcroFormAppearance.internal.Bezier_C;` 2714. `var DotRadiusBezier = Number((DotRadius * c).toFixed(5));` 2715. `/*` 2716. `* The Following is a Circle created with Bezier-Curves.` 2717. `*/` 2718. `stream.push("q");` 2719. `stream.push(` 2720. `"1 0 0 1 " +` 2721. `f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +` 2722. `" " +` 2723. `f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +` 2724. `" cm"` 2725. `);` 2726. `stream.push(DotRadius + " 0 m");` 2727. `stream.push(` 2728. `DotRadius +` 2729. `" " +` 2730. `DotRadiusBezier +` 2731. `" " +` 2732. `DotRadiusBezier +` 2733. `" " +` 2734. `DotRadius +` 2735. `" 0 " +` 2736. `DotRadius +` 2737. `" c"` 2738. `);` 2739. `stream.push(` 2740. `"-" +` 2741. `DotRadiusBezier +` 2742. `" " +` 2743. `DotRadius +` 2744. `" -" +` 2745. `DotRadius +` 2746. `" " +` 2747. `DotRadiusBezier +` 2748. `" -" +` 2749. `DotRadius +` 2750. `" 0 c"` 2751. `);` 2752. `stream.push(` 2753. `"-" +` 2754. `DotRadius +` 2755. `" -" +` 2756. `DotRadiusBezier +` 2757. `" -" +` 2758. `DotRadiusBezier +` 2759. `" -" +` 2760. `DotRadius +` 2761. `" 0 -" +` 2762. `DotRadius +` 2763. `" c"` 2764. `);` 2765. `stream.push(` 2766. `DotRadiusBezier +` 2767. `" -" +` 2768. `DotRadius +` 2769. `" " +` 2770. `DotRadius +` 2771. `" -" +` 2772. `DotRadiusBezier +` 2773. `" " +` 2774. `DotRadius +` 2775. `" 0 c"` 2776. `);` 2777. `stream.push("f");` 2778. `stream.push("Q");` 2779. `xobj.stream = stream.join("\n");` 2780. `return xobj;` 2781. `},` 2782. `YesPushDown: function(formObject) {` 2783. `var xobj = createFormXObject(formObject);` 2784. `xobj.scope = formObject.scope;` 2785. `var stream = [];` 2786. `var DotRadius =` 2787. `AcroFormAppearance.internal.getWidth(formObject) <=` 2788. `AcroFormAppearance.internal.getHeight(formObject)` 2789. `? AcroFormAppearance.internal.getWidth(formObject) / 4` 2790. `: AcroFormAppearance.internal.getHeight(formObject) / 4;` 2791. `// The Borderpadding...` 2792. `DotRadius = Number((DotRadius * 0.9).toFixed(5));` 2793. `// Save results for later use; no need to waste` 2794. `// processor ticks on doing math` 2795. `var k = Number((DotRadius * 2).toFixed(5));` 2796. `var kc = Number((k * AcroFormAppearance.internal.Bezier_C).toFixed(5));` 2797. `var dc = Number(` 2798. `(DotRadius * AcroFormAppearance.internal.Bezier_C).toFixed(5)` 2799. `);` 2801. `stream.push("0.749023 g");` 2802. `stream.push("q");` 2803. `stream.push(` 2804. `"1 0 0 1 " +` 2805. `f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +` 2806. `" " +` 2807. `f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +` 2808. `" cm"` 2809. `);` 2810. `stream.push(k + " 0 m");` 2811. `stream.push(k + " " + kc + " " + kc + " " + k + " 0 " + k + " c");` 2812. `stream.push(` 2813. `"-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c"` 2814. `);` 2815. `stream.push(` 2816. `"-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c"` 2817. `);` 2818. `stream.push(kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c");` 2819. `stream.push("f");` 2820. `stream.push("Q");` 2821. `stream.push("0 g");` 2822. `stream.push("q");` 2823. `stream.push(` 2824. `"1 0 0 1 " +` 2825. `f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +` 2826. `" " +` 2827. `f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +` 2828. `" cm"` 2829. `);` 2830. `stream.push(DotRadius + " 0 m");` 2831. `stream.push(` 2832. `"" +` 2833. `DotRadius +` 2834. `" " +` 2835. `dc +` 2836. `" " +` 2837. `dc +` 2838. `" " +` 2839. `DotRadius +` 2840. `" 0 " +` 2841. `DotRadius +` 2842. `" c"` 2843. `);` 2844. `stream.push(` 2845. `"-" +` 2846. `dc +` 2847. `" " +` 2848. `DotRadius +` 2849. `" -" +` 2850. `DotRadius +` 2851. `" " +` 2852. `dc +` 2853. `" -" +` 2854. `DotRadius +` 2855. `" 0 c"` 2856. `);` 2857. `stream.push(` 2858. `"-" +` 2859. `DotRadius +` 2860. `" -" +` 2861. `dc +` 2862. `" -" +` 2863. `dc +` 2864. `" -" +` 2865. `DotRadius +` 2866. `" 0 -" +` 2867. `DotRadius +` 2868. `" c"` 2869. `);` 2870. `stream.push(` 2871. `dc +` 2872. `" -" +` 2873. `DotRadius +` 2874. `" " +` 2875. `DotRadius +` 2876. `" -" +` 2877. `dc +` 2878. `" " +` 2879. `DotRadius +` 2880. `" 0 c"` 2881. `);` 2882. `stream.push("f");` 2883. `stream.push("Q");` 2884. `xobj.stream = stream.join("\n");` 2885. `return xobj;` 2886. `},` 2887. `OffPushDown: function(formObject) {` 2888. `var xobj = createFormXObject(formObject);` 2889. `xobj.scope = formObject.scope;` 2890. `var stream = [];` 2891. `var DotRadius =` 2892. `AcroFormAppearance.internal.getWidth(formObject) <=` 2893. `AcroFormAppearance.internal.getHeight(formObject)` 2894. `? AcroFormAppearance.internal.getWidth(formObject) / 4` 2895. `: AcroFormAppearance.internal.getHeight(formObject) / 4;` 2896. `// The Borderpadding...` 2897. `DotRadius = Number((DotRadius * 0.9).toFixed(5));` 2898. `// Save results for later use; no need to waste` 2899. `// processor ticks on doing math` 2900. `var k = Number((DotRadius * 2).toFixed(5));` 2901. `var kc = Number((k * AcroFormAppearance.internal.Bezier_C).toFixed(5));` 2903. `stream.push("0.749023 g");` 2904. `stream.push("q");` 2905. `stream.push(` 2906. `"1 0 0 1 " +` 2907. `f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +` 2908. `" " +` 2909. `f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +` 2910. `" cm"` 2911. `);` 2912. `stream.push(k + " 0 m");` 2913. `stream.push(k + " " + kc + " " + kc + " " + k + " 0 " + k + " c");` 2914. `stream.push(` 2915. `"-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c"` 2916. `);` 2917. `stream.push(` 2918. `"-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c"` 2919. `);` 2920. `stream.push(kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c");` 2921. `stream.push("f");` 2922. `stream.push("Q");` 2923. `xobj.stream = stream.join("\n");` 2924. `return xobj;` 2925. `}` 2926. `},` 2928. `Cross: {` 2929. `/**` 2930. `* Creates the Actual AppearanceDictionary-References` 2931. `*` 2932. `* @param {string} name` 2933. `* @returns {Object}` 2934. `* @ignore` 2935. `*/` 2936. `createAppearanceStream: function(name) {` 2937. `var appearanceStreamContent = {` 2938. `D: {` 2939. `Off: AcroFormAppearance.RadioButton.Cross.OffPushDown` 2940. `},` 2941. `N: {}` 2942. `};` 2943. `appearanceStreamContent.N[name] =` 2944. `AcroFormAppearance.RadioButton.Cross.YesNormal;` 2945. `appearanceStreamContent.D[name] =` 2946. `AcroFormAppearance.RadioButton.Cross.YesPushDown;` 2947. `return appearanceStreamContent;` 2948. `},` 2949. `getCA: function() {` 2950. `return "8";` 2951. `},` 2953. `YesNormal: function(formObject) {` 2954. `var xobj = createFormXObject(formObject);` 2955. `xobj.scope = formObject.scope;` 2956. `var stream = [];` 2957. `var cross = AcroFormAppearance.internal.calculateCross(formObject);` 2958. `stream.push("q");` 2959. `stream.push(` 2960. `"1 1 " +` 2961. `f2(AcroFormAppearance.internal.getWidth(formObject) - 2) +` 2962. `" " +` 2963. `f2(AcroFormAppearance.internal.getHeight(formObject) - 2) +` 2964. `" re"` 2965. `);` 2966. `stream.push("W");` 2967. `stream.push("n");` 2968. `stream.push(f2(cross.x1.x) + " " + f2(cross.x1.y) + " m");` 2969. `stream.push(f2(cross.x2.x) + " " + f2(cross.x2.y) + " l");` 2970. `stream.push(f2(cross.x4.x) + " " + f2(cross.x4.y) + " m");` 2971. `stream.push(f2(cross.x3.x) + " " + f2(cross.x3.y) + " l");` 2972. `stream.push("s");` 2973. `stream.push("Q");` 2974. `xobj.stream = stream.join("\n");` 2975. `return xobj;` 2976. `},` 2977. `YesPushDown: function(formObject) {` 2978. `var xobj = createFormXObject(formObject);` 2979. `xobj.scope = formObject.scope;` 2980. `var cross = AcroFormAppearance.internal.calculateCross(formObject);` 2981. `var stream = [];` 2982. `stream.push("0.749023 g");` 2983. `stream.push(` 2984. `"0 0 " +` 2985. `f2(AcroFormAppearance.internal.getWidth(formObject)) +` 2986. `" " +` 2987. `f2(AcroFormAppearance.internal.getHeight(formObject)) +` 2988. `" re"` 2989. `);` 2990. `stream.push("f");` 2991. `stream.push("q");` 2992. `stream.push(` 2993. `"1 1 " +` 2994. `f2(AcroFormAppearance.internal.getWidth(formObject) - 2) +` 2995. `" " +` 2996. `f2(AcroFormAppearance.internal.getHeight(formObject) - 2) +` 2997. `" re"` 2998. `);` 2999. `stream.push("W");` 3000. `stream.push("n");` 3001. `stream.push(f2(cross.x1.x) + " " + f2(cross.x1.y) + " m");` 3002. `stream.push(f2(cross.x2.x) + " " + f2(cross.x2.y) + " l");` 3003. `stream.push(f2(cross.x4.x) + " " + f2(cross.x4.y) + " m");` 3004. `stream.push(f2(cross.x3.x) + " " + f2(cross.x3.y) + " l");` 3005. `stream.push("s");` 3006. `stream.push("Q");` 3007. `xobj.stream = stream.join("\n");` 3008. `return xobj;` 3009. `},` 3010. `OffPushDown: function(formObject) {` 3011. `var xobj = createFormXObject(formObject);` 3012. `xobj.scope = formObject.scope;` 3013. `var stream = [];` 3014. `stream.push("0.749023 g");` 3015. `stream.push(` 3016. `"0 0 " +` 3017. `f2(AcroFormAppearance.internal.getWidth(formObject)) +` 3018. `" " +` 3019. `f2(AcroFormAppearance.internal.getHeight(formObject)) +` 3020. `" re"` 3021. `);` 3022. `stream.push("f");` 3023. `xobj.stream = stream.join("\n");` 3024. `return xobj;` 3025. `}` 3026. `}` 3027. `},` 3029. `/**` 3030. `* Returns the standard Appearance` 3031. `*` 3032. `* @returns {AcroFormXObject}` 3033. `*/` 3034. `createDefaultAppearanceStream: function(formObject) {` 3035. `// Set Helvetica to Standard Font (size: auto)` 3036. `// Color: Black` 3037. `var fontKey = formObject.scope.internal.getFont(` 3038. `formObject.fontName,` 3039. `formObject.fontStyle` 3040. `).id;` 3041. `var encodedColor = formObject.scope.__private__.encodeColorString(` 3042. `formObject.color` 3043. `);` 3044. `var fontSize = formObject.fontSize;` 3045. `var result = "/" + fontKey + " " + fontSize + " Tf " + encodedColor;` 3046. `return result;` 3047. `}` 3048. `};` 3050. `AcroFormAppearance.internal = {` 3051. `Bezier_C: 0.551915024494,` 3053. `calculateCross: function(formObject) {` 3054. `var width = AcroFormAppearance.internal.getWidth(formObject);` 3055. `var height = AcroFormAppearance.internal.getHeight(formObject);` 3056. `var a = Math.min(width, height);` 3058. `var cross = {` 3059. `x1: {` 3060. `// upperLeft` 3061. `x: (width - a) / 2,` 3062. `y: (height - a) / 2 + a // height - borderPadding` 3063. `},` 3064. `x2: {` 3065. `// lowerRight` 3066. `x: (width - a) / 2 + a,` 3067. `y: (height - a) / 2 // borderPadding` 3068. `},` 3069. `x3: {` 3070. `// lowerLeft` 3071. `x: (width - a) / 2,` 3072. `y: (height - a) / 2 // borderPadding` 3073. `},` 3074. `x4: {` 3075. `// upperRight` 3076. `x: (width - a) / 2 + a,` 3077. `y: (height - a) / 2 + a // height - borderPadding` 3078. `}` 3079. `};` 3081. `return cross;` 3082. `}` 3083. `};` 3084. `AcroFormAppearance.internal.getWidth = function(formObject) {` 3085. `var result = 0;` 3086. `if (typeof formObject === "object") {` 3087. `result = scale(formObject.Rect[2]);` 3088. `}` 3089. `return result;` 3090. `};` 3091. `AcroFormAppearance.internal.getHeight = function(formObject) {` 3092. `var result = 0;` 3093. `if (typeof formObject === "object") {` 3094. `result = scale(formObject.Rect[3]);` 3095. `}` 3096. `return result;` 3097. `};` 3099. `// Public:` 3101. `/**` 3102. `* Add an AcroForm-Field to the jsPDF-instance` 3103. `*` 3104. `* @name addField` 3105. `* @function` 3106. `* @instance` 3107. `* @param {Object} fieldObject` 3108. `* @returns {jsPDF}` 3109. `*/` 3110. `var addField = (jsPDFAPI.addField = function(fieldObject) {` 3111. `initializeAcroForm(this, fieldObject);` 3113. `if (fieldObject instanceof AcroFormField) {` 3114. `putForm(fieldObject);` 3115. `} else {` 3116. `throw new Error("Invalid argument passed to jsPDF.addField.");` 3117. `}` 3118. `fieldObject.page = fieldObject.scope.internal.getCurrentPageInfo().pageNumber;` 3119. `return this;` 3120. `});` 3122. `jsPDFAPI.AcroFormChoiceField = AcroFormChoiceField;` 3123. `jsPDFAPI.AcroFormListBox = AcroFormListBox;` 3124. `jsPDFAPI.AcroFormComboBox = AcroFormComboBox;` 3125. `jsPDFAPI.AcroFormEditBox = AcroFormEditBox;` 3126. `jsPDFAPI.AcroFormButton = AcroFormButton;` 3127. `jsPDFAPI.AcroFormPushButton = AcroFormPushButton;` 3128. `jsPDFAPI.AcroFormRadioButton = AcroFormRadioButton;` 3129. `jsPDFAPI.AcroFormCheckBox = AcroFormCheckBox;` 3130. `jsPDFAPI.AcroFormTextField = AcroFormTextField;` 3131. `jsPDFAPI.AcroFormPasswordField = AcroFormPasswordField;` 3132. `jsPDFAPI.AcroFormAppearance = AcroFormAppearance;` 3134. `jsPDFAPI.AcroForm = {` 3135. `ChoiceField: AcroFormChoiceField,` 3136. `ListBox: AcroFormListBox,` 3137. `ComboBox: AcroFormComboBox,` 3138. `EditBox: AcroFormEditBox,` 3139. `Button: AcroFormButton,` 3140. `PushButton: AcroFormPushButton,` 3141. `RadioButton: AcroFormRadioButton,` 3142. `CheckBox: AcroFormCheckBox,` 3143. `TextField: AcroFormTextField,` 3144. `PasswordField: AcroFormPasswordField,` 3145. `Appearance: AcroFormAppearance` 3146. `};` 3148. `jsPDF.AcroForm = {` 3149. `ChoiceField: AcroFormChoiceField,` 3150. `ListBox: AcroFormListBox,` 3151. `ComboBox: AcroFormComboBox,` 3152. `EditBox: AcroFormEditBox,` 3153. `Button: AcroFormButton,` 3154. `PushButton: AcroFormPushButton,` 3155. `RadioButton: AcroFormRadioButton,` 3156. `CheckBox: AcroFormCheckBox,` 3157. `TextField: AcroFormTextField,` 3158. `PasswordField: AcroFormPasswordField,` 3159. `Appearance: AcroFormAppearance` 3160. `};` 3162. `var AcroForm = jsPDF.AcroForm;` 3164. `export {` 3165. `AcroForm,` 3166. `AcroFormChoiceField,` 3167. `AcroFormListBox,` 3168. `AcroFormComboBox,` 3169. `AcroFormEditBox,` 3170. `AcroFormButton,` 3171. `AcroFormPushButton,` 3172. `AcroFormRadioButton,` 3173. `AcroFormCheckBox,` 3174. `AcroFormTextField,` 3175. `AcroFormPasswordField,` 3176. `AcroFormAppearance` 3177. `};` --- # modules/html.js - Documentation modules/html.js =============== 1. `/**` 2. `* @license` 3. `* Copyright (c) 2018 Erik Koopmans` 4. `* Released under the MIT License.` 5. `*` 6. `* Licensed under the MIT License.` 7. `* http://opensource.org/licenses/mit-license` 8. `*/` 10. `import { jsPDF } from "../jspdf.js";` 11. `import { normalizeFontFace } from "../libs/fontFace.js";` 12. `import { globalObject } from "../libs/globalObject.js";` 14. `/**` 15. `* jsPDF html PlugIn` 16. `*` 17. `* @name html` 18. `* @module` 19. `*/` 20. `(function(jsPDFAPI) {` 21. `"use strict";` 23. `function loadHtml2Canvas() {` 24. `return (function() {` 25. `if (globalObject["html2canvas"]) {` 26. `return Promise.resolve(globalObject["html2canvas"]);` 27. `}` 29. `// @if MODULE_FORMAT='es'` 30. `return import("html2canvas");` 31. `// @endif` 33. `// @if MODULE_FORMAT!='es'` 34. `if (typeof exports === "object" && typeof module !== "undefined") {` 35. `return new Promise(function(resolve, reject) {` 36. `try {` 37. `resolve(require("html2canvas"));` 38. `} catch (e) {` 39. `reject(e);` 40. `}` 41. `});` 42. `}` 43. `if (typeof define === "function" && define.amd) {` 44. `return new Promise(function(resolve, reject) {` 45. `try {` 46. `require(["html2canvas"], resolve);` 47. `} catch (e) {` 48. `reject(e);` 49. `}` 50. `});` 51. `}` 52. `return Promise.reject(new Error("Could not load html2canvas"));` 53. `// @endif` 54. `})()` 55. `.catch(function(e) {` 56. `return Promise.reject(new Error("Could not load html2canvas: " + e));` 57. `})` 58. `.then(function(html2canvas) {` 59. `return html2canvas.default ? html2canvas.default : html2canvas;` 60. `});` 61. `}` 63. `function loadDomPurify() {` 64. `return (function() {` 65. `if (globalObject["DOMPurify"]) {` 66. `return Promise.resolve(globalObject["DOMPurify"]);` 67. `}` 69. `// @if MODULE_FORMAT='es'` 70. `return import("dompurify");` 71. `// @endif` 73. `// @if MODULE_FORMAT!='es'` 74. `if (typeof exports === "object" && typeof module !== "undefined") {` 75. `return new Promise(function(resolve, reject) {` 76. `try {` 77. `resolve(require("dompurify"));` 78. `} catch (e) {` 79. `reject(e);` 80. `}` 81. `});` 82. `}` 83. `if (typeof define === "function" && define.amd) {` 84. `return new Promise(function(resolve, reject) {` 85. `try {` 86. `require(["dompurify"], resolve);` 87. `} catch (e) {` 88. `reject(e);` 89. `}` 90. `});` 91. `}` 92. `return Promise.reject(new Error("Could not load dompurify"));` 93. `// @endif` 94. `})()` 95. `.catch(function(e) {` 96. `return Promise.reject(new Error("Could not load dompurify: " + e));` 97. `})` 98. `.then(function(dompurify) {` 99. `return dompurify.default ? dompurify.default : dompurify;` 100. `});` 101. `}` 103. `/**` 104. `* Determine the type of a variable/object.` 105. `*` 106. `* @private` 107. `* @ignore` 108. `*/` 109. `var objType = function(obj) {` 110. `var type = typeof obj;` 111. `if (type === "undefined") return "undefined";` 112. `else if (type === "string" || obj instanceof String) return "string";` 113. `else if (type === "number" || obj instanceof Number) return "number";` 114. `else if (type === "function" || obj instanceof Function) return "function";` 115. `else if (!!obj && obj.constructor === Array) return "array";` 116. `else if (obj && obj.nodeType === 1) return "element";` 117. `else if (type === "object") return "object";` 118. `else return "unknown";` 119. `};` 121. `/**` 122. `* Create an HTML element with optional className, innerHTML, and style.` 123. `*` 124. `* @private` 125. `* @ignore` 126. `*/` 127. `var createElement = function(tagName, opt) {` 128. `var el = document.createElement(tagName);` 129. `if (opt.className) el.className = opt.className;` 130. `if (opt.innerHTML && opt.dompurify) {` 131. `el.innerHTML = opt.dompurify.sanitize(opt.innerHTML);` 132. `}` 133. `for (var key in opt.style) {` 134. `el.style[key] = opt.style[key];` 135. `}` 136. `return el;` 137. `};` 139. `/**` 140. `* Deep-clone a node and preserve contents/properties.` 141. `*` 142. `* @private` 143. `* @ignore` 144. `*/` 145. `var cloneNode = function(node, javascriptEnabled) {` 146. `// Recursively clone the node.` 147. `var clone =` 148. `node.nodeType === 3` 149. `? document.createTextNode(node.nodeValue)` 150. `: node.cloneNode(false);` 151. `for (var child = node.firstChild; child; child = child.nextSibling) {` 152. `if (` 153. `javascriptEnabled === true ||` 154. `child.nodeType !== 1 ||` 155. `child.nodeName !== "SCRIPT"` 156. `) {` 157. `clone.appendChild(cloneNode(child, javascriptEnabled));` 158. `}` 159. `}` 161. `if (node.nodeType === 1) {` 162. `// Preserve contents/properties of special nodes.` 163. `if (node.nodeName === "CANVAS") {` 164. `clone.width = node.width;` 165. `clone.height = node.height;` 166. `clone.getContext("2d").drawImage(node, 0, 0);` 167. `} else if (node.nodeName === "TEXTAREA" || node.nodeName === "SELECT") {` 168. `clone.value = node.value;` 169. `}` 171. `// Preserve the node's scroll position when it loads.` 172. `clone.addEventListener(` 173. `"load",` 174. `function() {` 175. `clone.scrollTop = node.scrollTop;` 176. `clone.scrollLeft = node.scrollLeft;` 177. `},` 178. `true` 179. `);` 180. `}` 182. `// Return the cloned node.` 183. `return clone;` 184. `};` 186. `/* ----- CONSTRUCTOR ----- */` 188. `var Worker = function Worker(opt) {` 189. `// Create the root parent for the proto chain, and the starting Worker.` 190. `var root = Object.assign(` 191. `Worker.convert(Promise.resolve()),` 192. `JSON.parse(JSON.stringify(Worker.template))` 193. `);` 194. `var self = Worker.convert(Promise.resolve(), root);` 196. `// Set progress, optional settings, and return.` 197. `self = self.setProgress(1, Worker, 1, [Worker]);` 198. `self = self.set(opt);` 199. `return self;` 200. `};` 202. `// Boilerplate for subclassing Promise.` 203. `Worker.prototype = Object.create(Promise.prototype);` 204. `Worker.prototype.constructor = Worker;` 206. `// Converts/casts promises into Workers.` 207. `Worker.convert = function convert(promise, inherit) {` 208. `// Uses prototypal inheritance to receive changes made to ancestors' properties.` 209. `promise.__proto__ = inherit || Worker.prototype;` 210. `return promise;` 211. `};` 213. `Worker.template = {` 214. `prop: {` 215. `src: null,` 216. `container: null,` 217. `overlay: null,` 218. `canvas: null,` 219. `img: null,` 220. `pdf: null,` 221. `pageSize: null,` 222. `callback: function() {}` 223. `},` 224. `progress: {` 225. `val: 0,` 226. `state: null,` 227. `n: 0,` 228. `stack: []` 229. `},` 230. `opt: {` 231. `filename: "file.pdf",` 232. `margin: [0, 0, 0, 0],` 233. `enableLinks: true,` 234. `x: 0,` 235. `y: 0,` 236. `html2canvas: {},` 237. `jsPDF: {},` 238. `backgroundColor: "transparent"` 239. `}` 240. `};` 242. `/* ----- FROM / TO ----- */` 244. `Worker.prototype.from = function from(src, type) {` 245. `function getType(src) {` 246. `switch (objType(src)) {` 247. `case "string":` 248. `return "string";` 249. `case "element":` 250. `return src.nodeName.toLowerCase() === "canvas" ? "canvas" : "element";` 251. `default:` 252. `return "unknown";` 253. `}` 254. `}` 256. `return this.then(function from_main() {` 257. `type = type || getType(src);` 258. `switch (type) {` 259. `case "string":` 260. `return this.then(loadDomPurify).then(function(dompurify) {` 261. `return this.set({` 262. `src: createElement("div", {` 263. `innerHTML: src,` 264. `dompurify: dompurify` 265. `})` 266. `});` 267. `});` 268. `case "element":` 269. `return this.set({ src: src });` 270. `case "canvas":` 271. `return this.set({ canvas: src });` 272. `case "img":` 273. `return this.set({ img: src });` 274. `default:` 275. `return this.error("Unknown source type.");` 276. `}` 277. `});` 278. `};` 280. `Worker.prototype.to = function to(target) {` 281. `// Route the 'to' request to the appropriate method.` 282. `switch (target) {` 283. `case "container":` 284. `return this.toContainer();` 285. `case "canvas":` 286. `return this.toCanvas();` 287. `case "img":` 288. `return this.toImg();` 289. `case "pdf":` 290. `return this.toPdf();` 291. `default:` 292. `return this.error("Invalid target.");` 293. `}` 294. `};` 296. `Worker.prototype.toContainer = function toContainer() {` 297. `// Set up function prerequisites.` 298. `var prereqs = [`\ 299. `function checkSrc() {`\ 300. `return (`\ 301. `this.prop.src || this.error("Cannot duplicate - no source HTML.")`\ 302. `);`\ 303. `},`\ 304. `function checkPageSize() {`\ 305. `return this.prop.pageSize || this.setPageSize();`\ 306. `}`\ 307. `];` 308. `return this.thenList(prereqs).then(function toContainer_main() {` 309. `// Define the CSS styles for the container and its overlay parent.` 310. `var overlayCSS = {` 311. `position: "fixed",` 312. `overflow: "hidden",` 313. `zIndex: 1000,` 314. `left: "-100000px",` 315. `right: 0,` 316. `bottom: 0,` 317. `top: 0` 318. `};` 319. `var containerCSS = {` 320. `position: "relative",` 321. `display: "inline-block",` 322. `width:` 323. `(typeof this.opt.width === "number" &&` 324. `!isNaN(this.opt.width) &&` 325. `typeof this.opt.windowWidth === "number" &&` 326. `!isNaN(this.opt.windowWidth)` 327. `? this.opt.windowWidth` 328. `: Math.max(` 329. `this.prop.src.clientWidth,` 330. `this.prop.src.scrollWidth,` 331. `this.prop.src.offsetWidth` 332. `)) + "px",` 333. `left: 0,` 334. `right: 0,` 335. `top: 0,` 336. `margin: "auto",` 337. `backgroundColor: this.opt.backgroundColor` 338. `}; // Set the overlay to hidden (could be changed in the future to provide a print preview).` 340. `var source = cloneNode(` 341. `this.prop.src,` 342. `this.opt.html2canvas.javascriptEnabled` 343. `);` 345. `if (source.tagName === "BODY") {` 346. `containerCSS.height =` 347. `Math.max(` 348. `document.body.scrollHeight,` 349. `document.body.offsetHeight,` 350. `document.documentElement.clientHeight,` 351. `document.documentElement.scrollHeight,` 352. `document.documentElement.offsetHeight` 353. `) + "px";` 354. `}` 356. `this.prop.overlay = createElement("div", {` 357. `className: "html2pdf__overlay",` 358. `style: overlayCSS` 359. `});` 360. `this.prop.container = createElement("div", {` 361. `className: "html2pdf__container",` 362. `style: containerCSS` 363. `});` 364. `this.prop.container.appendChild(source);` 365. `this.prop.container.firstChild.appendChild(` 366. `createElement("div", {` 367. `style: {` 368. `clear: "both",` 369. `border: "0 none transparent",` 370. `margin: 0,` 371. `padding: 0,` 372. `height: 0` 373. `}` 374. `})` 375. `);` 376. `this.prop.container.style.float = "none";` 377. `this.prop.overlay.appendChild(this.prop.container);` 378. `document.body.appendChild(this.prop.overlay);` 379. `this.prop.container.firstChild.style.position = "relative";` 380. `this.prop.container.height =` 381. `Math.max(` 382. `this.prop.container.firstChild.clientHeight,` 383. `this.prop.container.firstChild.scrollHeight,` 384. `this.prop.container.firstChild.offsetHeight` 385. `) + "px";` 386. `});` 387. `};` 389. `Worker.prototype.toCanvas = function toCanvas() {` 390. `// Set up function prerequisites.` 391. `var prereqs = [`\ 392. `function checkContainer() {`\ 393. `return (`\ 394. `document.body.contains(this.prop.container) || this.toContainer()`\ 395. `);`\ 396. `}`\ 397. `];` 399. `// Fulfill prereqs then create the canvas.` 400. `return this.thenList(prereqs)` 401. `.then(loadHtml2Canvas)` 402. `.then(function toCanvas_main(html2canvas) {` 403. `// Handle old-fashioned 'onrendered' argument.` 404. `var options = Object.assign({}, this.opt.html2canvas);` 405. `delete options.onrendered;` 407. `return html2canvas(this.prop.container, options);` 408. `})` 409. `.then(function toCanvas_post(canvas) {` 410. `// Handle old-fashioned 'onrendered' argument.` 411. `var onRendered = this.opt.html2canvas.onrendered || function() {};` 412. `onRendered(canvas);` 414. `this.prop.canvas = canvas;` 415. `document.body.removeChild(this.prop.overlay);` 416. `});` 417. `};` 419. `Worker.prototype.toContext2d = function toContext2d() {` 420. `// Set up function prerequisites.` 421. `var prereqs = [`\ 422. `function checkContainer() {`\ 423. `return (`\ 424. `document.body.contains(this.prop.container) || this.toContainer()`\ 425. `);`\ 426. `}`\ 427. `];` 429. `// Fulfill prereqs then create the canvas.` 430. `return this.thenList(prereqs)` 431. `.then(loadHtml2Canvas)` 432. `.then(function toContext2d_main(html2canvas) {` 433. `// Handle old-fashioned 'onrendered' argument.` 435. `var pdf = this.opt.jsPDF;` 436. `var fontFaces = this.opt.fontFaces;` 438. `var scale =` 439. `typeof this.opt.width === "number" &&` 440. `!isNaN(this.opt.width) &&` 441. `typeof this.opt.windowWidth === "number" &&` 442. `!isNaN(this.opt.windowWidth)` 443. `? this.opt.width / this.opt.windowWidth` 444. `: 1;` 446. `var options = Object.assign(` 447. `{` 448. `async: true,` 449. `allowTaint: true,` 450. `scale: scale,` 451. `scrollX: this.opt.scrollX || 0,` 452. `scrollY: this.opt.scrollY || 0,` 453. `backgroundColor: "#ffffff",` 454. `imageTimeout: 15000,` 455. `logging: true,` 456. `proxy: null,` 457. `removeContainer: true,` 458. `foreignObjectRendering: false,` 459. `useCORS: false` 460. `},` 461. `this.opt.html2canvas` 462. `);` 463. `delete options.onrendered;` 465. `pdf.context2d.autoPaging =` 466. `typeof this.opt.autoPaging === "undefined"` 467. `? true` 468. `: this.opt.autoPaging;` 469. `pdf.context2d.posX = this.opt.x;` 470. `pdf.context2d.posY = this.opt.y;` 471. `pdf.context2d.margin = this.opt.margin;` 472. `pdf.context2d.fontFaces = fontFaces;` 474. `if (fontFaces) {` 475. `for (var i = 0; i < fontFaces.length; ++i) {` 476. `var font = fontFaces[i];` 477. `var src = font.src.find(function(src) {` 478. `return src.format === "truetype";` 479. `});` 481. `if (src) {` 482. `pdf.addFont(src.url, font.ref.name, font.ref.style);` 483. `}` 484. `}` 485. `}` 487. `options.windowHeight = options.windowHeight || 0;` 488. `options.windowHeight =` 489. `options.windowHeight == 0` 490. `? Math.max(` 491. `this.prop.container.clientHeight,` 492. `this.prop.container.scrollHeight,` 493. `this.prop.container.offsetHeight` 494. `)` 495. `: options.windowHeight;` 497. `pdf.context2d.save(true);` 498. `return html2canvas(this.prop.container, options);` 499. `})` 500. `.then(function toContext2d_post(canvas) {` 501. `this.opt.jsPDF.context2d.restore(true);` 503. `// Handle old-fashioned 'onrendered' argument.` 504. `var onRendered = this.opt.html2canvas.onrendered || function() {};` 505. `onRendered(canvas);` 507. `this.prop.canvas = canvas;` 508. `document.body.removeChild(this.prop.overlay);` 509. `});` 510. `};` 512. `Worker.prototype.toImg = function toImg() {` 513. `// Set up function prerequisites.` 514. `var prereqs = [`\ 515. `function checkCanvas() {`\ 516. `return this.prop.canvas || this.toCanvas();`\ 517. `}`\ 518. `];` 520. `// Fulfill prereqs then create the image.` 521. `return this.thenList(prereqs).then(function toImg_main() {` 522. `var imgData = this.prop.canvas.toDataURL(` 523. `"image/" + this.opt.image.type,` 524. `this.opt.image.quality` 525. `);` 526. `this.prop.img = document.createElement("img");` 527. `this.prop.img.src = imgData;` 528. `});` 529. `};` 531. `Worker.prototype.toPdf = function toPdf() {` 532. `// Set up function prerequisites.` 533. `var prereqs = [`\ 534. `function checkContext2d() {`\ 535. `return this.toContext2d();`\ 536. `}`\ 537. `//function checkCanvas() { return this.prop.canvas || this.toCanvas(); }`\ 538. `];` 540. `// Fulfill prereqs then create the image.` 541. `return this.thenList(prereqs).then(function toPdf_main() {` 542. `// Create local copies of frequently used properties.` 543. `this.prop.pdf = this.prop.pdf || this.opt.jsPDF;` 544. `});` 545. `};` 547. `/* ----- OUTPUT / SAVE ----- */` 549. `Worker.prototype.output = function output(type, options, src) {` 550. `// Redirect requests to the correct function (outputPdf / outputImg).` 551. `src = src || "pdf";` 552. `if (src.toLowerCase() === "img" || src.toLowerCase() === "image") {` 553. `return this.outputImg(type, options);` 554. `} else {` 555. `return this.outputPdf(type, options);` 556. `}` 557. `};` 559. `Worker.prototype.outputPdf = function outputPdf(type, options) {` 560. `// Set up function prerequisites.` 561. `var prereqs = [`\ 562. `function checkPdf() {`\ 563. `return this.prop.pdf || this.toPdf();`\ 564. `}`\ 565. `];` 567. `// Fulfill prereqs then perform the appropriate output.` 568. `return this.thenList(prereqs).then(function outputPdf_main() {` 569. `/* Currently implemented output types:` 570. `* https://rawgit.com/MrRio/jsPDF/master/docs/jspdf.js.html#line992` 571. `* save(options), arraybuffer, blob, bloburi/bloburl,` 572. `* datauristring/dataurlstring, dataurlnewwindow, datauri/dataurl` 573. `*/` 574. `return this.prop.pdf.output(type, options);` 575. `});` 576. `};` 578. `Worker.prototype.outputImg = function outputImg(type) {` 579. `// Set up function prerequisites.` 580. `var prereqs = [`\ 581. `function checkImg() {`\ 582. `return this.prop.img || this.toImg();`\ 583. `}`\ 584. `];` 586. `// Fulfill prereqs then perform the appropriate output.` 587. `return this.thenList(prereqs).then(function outputImg_main() {` 588. `switch (type) {` 589. `case undefined:` 590. `case "img":` 591. `return this.prop.img;` 592. `case "datauristring":` 593. `case "dataurlstring":` 594. `return this.prop.img.src;` 595. `case "datauri":` 596. `case "dataurl":` 597. `return (document.location.href = this.prop.img.src);` 598. `default:` 599. `throw 'Image output type "' + type + '" is not supported.';` 600. `}` 601. `});` 602. `};` 604. `Worker.prototype.save = function save(filename) {` 605. `// Set up function prerequisites.` 606. `var prereqs = [`\ 607. `function checkPdf() {`\ 608. `return this.prop.pdf || this.toPdf();`\ 609. `}`\ 610. `];` 612. `// Fulfill prereqs, update the filename (if provided), and save the PDF.` 613. `return this.thenList(prereqs)` 614. `.set(filename ? { filename: filename } : null)` 615. `.then(function save_main() {` 616. `this.prop.pdf.save(this.opt.filename);` 617. `});` 618. `};` 620. `Worker.prototype.doCallback = function doCallback() {` 621. `// Set up function prerequisites.` 622. `var prereqs = [`\ 623. `function checkPdf() {`\ 624. `return this.prop.pdf || this.toPdf();`\ 625. `}`\ 626. `];` 628. `// Fulfill prereqs, update the filename (if provided), and save the PDF.` 629. `return this.thenList(prereqs).then(function doCallback_main() {` 630. `this.prop.callback(this.prop.pdf);` 631. `});` 632. `};` 634. `/* ----- SET / GET ----- */` 636. `Worker.prototype.set = function set(opt) {` 637. `// TODO: Implement ordered pairs?` 639. `// Silently ignore invalid or empty input.` 640. `if (objType(opt) !== "object") {` 641. `return this;` 642. `}` 644. `// Build an array of setter functions to queue.` 645. `var fns = Object.keys(opt || {}).map(function(key) {` 646. `if (key in Worker.template.prop) {` 647. `// Set pre-defined properties.` 648. `return function set_prop() {` 649. `this.prop[key] = opt[key];` 650. `};` 651. `} else {` 652. `switch (key) {` 653. `case "margin":` 654. `return this.setMargin.bind(this, opt.margin);` 655. `case "jsPDF":` 656. `return function set_jsPDF() {` 657. `this.opt.jsPDF = opt.jsPDF;` 658. `return this.setPageSize();` 659. `};` 660. `case "pageSize":` 661. `return this.setPageSize.bind(this, opt.pageSize);` 662. `default:` 663. `// Set any other properties in opt.` 664. `return function set_opt() {` 665. `this.opt[key] = opt[key];` 666. `};` 667. `}` 668. `}` 669. `}, this);` 671. `// Set properties within the promise chain.` 672. `return this.then(function set_main() {` 673. `return this.thenList(fns);` 674. `});` 675. `};` 677. `Worker.prototype.get = function get(key, cbk) {` 678. `return this.then(function get_main() {` 679. `// Fetch the requested property, either as a predefined prop or in opt.` 680. `var val = key in Worker.template.prop ? this.prop[key] : this.opt[key];` 681. `return cbk ? cbk(val) : val;` 682. `});` 683. `};` 685. `Worker.prototype.setMargin = function setMargin(margin) {` 686. `return this.then(function setMargin_main() {` 687. `// Parse the margin property.` 688. `switch (objType(margin)) {` 689. `case "number":` 690. `margin = [margin, margin, margin, margin];` 691. `// eslint-disable-next-line no-fallthrough` 692. `case "array":` 693. `if (margin.length === 2) {` 694. `margin = [margin[0], margin[1], margin[0], margin[1]];` 695. `}` 696. `if (margin.length === 4) {` 697. `break;` 698. `}` 699. `// eslint-disable-next-line no-fallthrough` 700. `default:` 701. `return this.error("Invalid margin array.");` 702. `}` 704. `// Set the margin property, then update pageSize.` 705. `this.opt.margin = margin;` 706. `}).then(this.setPageSize);` 707. `};` 709. `Worker.prototype.setPageSize = function setPageSize(pageSize) {` 710. `function toPx(val, k) {` 711. `return Math.floor(((val * k) / 72) * 96);` 712. `}` 714. `return this.then(function setPageSize_main() {` 715. `// Retrieve page-size based on jsPDF settings, if not explicitly provided.` 716. `pageSize = pageSize || jsPDF.getPageSize(this.opt.jsPDF);` 718. `// Add 'inner' field if not present.` 719. `if (!pageSize.hasOwnProperty("inner")) {` 720. `pageSize.inner = {` 721. `width: pageSize.width - this.opt.margin[1] - this.opt.margin[3],` 722. `height: pageSize.height - this.opt.margin[0] - this.opt.margin[2]` 723. `};` 724. `pageSize.inner.px = {` 725. `width: toPx(pageSize.inner.width, pageSize.k),` 726. `height: toPx(pageSize.inner.height, pageSize.k)` 727. `};` 728. `pageSize.inner.ratio = pageSize.inner.height / pageSize.inner.width;` 729. `}` 731. `// Attach pageSize to this.` 732. `this.prop.pageSize = pageSize;` 733. `});` 734. `};` 736. `Worker.prototype.setProgress = function setProgress(val, state, n, stack) {` 737. `// Immediately update all progress values.` 738. `if (val != null) this.progress.val = val;` 739. `if (state != null) this.progress.state = state;` 740. `if (n != null) this.progress.n = n;` 741. `if (stack != null) this.progress.stack = stack;` 742. `this.progress.ratio = this.progress.val / this.progress.state;` 744. `// Return this for command chaining.` 745. `return this;` 746. `};` 748. `Worker.prototype.updateProgress = function updateProgress(` 749. `val,` 750. `state,` 751. `n,` 752. `stack` 753. `) {` 754. `// Immediately update all progress values, using setProgress.` 755. `return this.setProgress(` 756. `val ? this.progress.val + val : null,` 757. `state ? state : null,` 758. `n ? this.progress.n + n : null,` 759. `stack ? this.progress.stack.concat(stack) : null` 760. `);` 761. `};` 763. `/* ----- PROMISE MAPPING ----- */` 765. `Worker.prototype.then = function then(onFulfilled, onRejected) {` 766. ``// Wrap `this` for encapsulation.`` 767. `var self = this;` 769. `return this.thenCore(onFulfilled, onRejected, function then_main(` 770. `onFulfilled,` 771. `onRejected` 772. `) {` 773. ``// Update progress while queuing, calling, and resolving `then`.`` 774. `self.updateProgress(null, null, 1, [onFulfilled]);` 775. `return Promise.prototype.then` 776. `.call(this, function then_pre(val) {` 777. `self.updateProgress(null, onFulfilled);` 778. `return val;` 779. `})` 780. `.then(onFulfilled, onRejected)` 781. `.then(function then_post(val) {` 782. `self.updateProgress(1);` 783. `return val;` 784. `});` 785. `});` 786. `};` 788. `Worker.prototype.thenCore = function thenCore(` 789. `onFulfilled,` 790. `onRejected,` 791. `thenBase` 792. `) {` 793. `// Handle optional thenBase parameter.` 794. `thenBase = thenBase || Promise.prototype.then;` 796. ``// Wrap `this` for encapsulation and bind it to the promise handlers.`` 797. `var self = this;` 798. `if (onFulfilled) {` 799. `onFulfilled = onFulfilled.bind(self);` 800. `}` 801. `if (onRejected) {` 802. `onRejected = onRejected.bind(self);` 803. `}` 805. ``// Cast self into a Promise to avoid polyfills recursively defining `then`.`` 806. `var isNative =` 807. `Promise.toString().indexOf("[native code]") !== -1 &&` 808. `Promise.name === "Promise";` 809. `var selfPromise = isNative` 810. `? self` 811. `: Worker.convert(Object.assign({}, self), Promise.prototype);` 813. `// Return the promise, after casting it into a Worker and preserving props.` 814. `var returnVal = thenBase.call(selfPromise, onFulfilled, onRejected);` 815. `return Worker.convert(returnVal, self.__proto__);` 816. `};` 818. `Worker.prototype.thenExternal = function thenExternal(` 819. `onFulfilled,` 820. `onRejected` 821. `) {` 822. ``// Call `then` and return a standard promise (exits the Worker chain).`` 823. `return Promise.prototype.then.call(this, onFulfilled, onRejected);` 824. `};` 826. `Worker.prototype.thenList = function thenList(fns) {` 827. `// Queue a series of promise 'factories' into the promise chain.` 828. `var self = this;` 829. `fns.forEach(function thenList_forEach(fn) {` 830. `self = self.thenCore(fn);` 831. `});` 832. `return self;` 833. `};` 835. `Worker.prototype["catch"] = function(onRejected) {` 836. ``// Bind `this` to the promise handler, call `catch`, and return a Worker.`` 837. `if (onRejected) {` 838. `onRejected = onRejected.bind(this);` 839. `}` 840. `var returnVal = Promise.prototype["catch"].call(this, onRejected);` 841. `return Worker.convert(returnVal, this);` 842. `};` 844. `Worker.prototype.catchExternal = function catchExternal(onRejected) {` 845. ``// Call `catch` and return a standard promise (exits the Worker chain).`` 846. `return Promise.prototype["catch"].call(this, onRejected);` 847. `};` 849. `Worker.prototype.error = function error(msg) {` 850. `// Throw the error in the Promise chain.` 851. `return this.then(function error_main() {` 852. `throw new Error(msg);` 853. `});` 854. `};` 856. `/* ----- ALIASES ----- */` 858. `Worker.prototype.using = Worker.prototype.set;` 859. `Worker.prototype.saveAs = Worker.prototype.save;` 860. `Worker.prototype.export = Worker.prototype.output;` 861. `Worker.prototype.run = Worker.prototype.then;` 863. `// Get dimensions of a PDF page, as determined by jsPDF.` 864. `jsPDF.getPageSize = function(orientation, unit, format) {` 865. `// Decode options object` 866. `if (typeof orientation === "object") {` 867. `var options = orientation;` 868. `orientation = options.orientation;` 869. `unit = options.unit || unit;` 870. `format = options.format || format;` 871. `}` 873. `// Default options` 874. `unit = unit || "mm";` 875. `format = format || "a4";` 876. `orientation = ("" + (orientation || "P")).toLowerCase();` 877. `var format_as_string = ("" + format).toLowerCase();` 879. `// Size in pt of various paper formats` 880. `var pageFormats = {` 881. `a0: [2383.94, 3370.39],` 882. `a1: [1683.78, 2383.94],` 883. `a2: [1190.55, 1683.78],` 884. `a3: [841.89, 1190.55],` 885. `a4: [595.28, 841.89],` 886. `a5: [419.53, 595.28],` 887. `a6: [297.64, 419.53],` 888. `a7: [209.76, 297.64],` 889. `a8: [147.4, 209.76],` 890. `a9: [104.88, 147.4],` 891. `a10: [73.7, 104.88],` 892. `b0: [2834.65, 4008.19],` 893. `b1: [2004.09, 2834.65],` 894. `b2: [1417.32, 2004.09],` 895. `b3: [1000.63, 1417.32],` 896. `b4: [708.66, 1000.63],` 897. `b5: [498.9, 708.66],` 898. `b6: [354.33, 498.9],` 899. `b7: [249.45, 354.33],` 900. `b8: [175.75, 249.45],` 901. `b9: [124.72, 175.75],` 902. `b10: [87.87, 124.72],` 903. `c0: [2599.37, 3676.54],` 904. `c1: [1836.85, 2599.37],` 905. `c2: [1298.27, 1836.85],` 906. `c3: [918.43, 1298.27],` 907. `c4: [649.13, 918.43],` 908. `c5: [459.21, 649.13],` 909. `c6: [323.15, 459.21],` 910. `c7: [229.61, 323.15],` 911. `c8: [161.57, 229.61],` 912. `c9: [113.39, 161.57],` 913. `c10: [79.37, 113.39],` 914. `dl: [311.81, 623.62],` 915. `letter: [612, 792],` 916. `"government-letter": [576, 756],` 917. `legal: [612, 1008],` 918. `"junior-legal": [576, 360],` 919. `ledger: [1224, 792],` 920. `tabloid: [792, 1224],` 921. `"credit-card": [153, 243]` 922. `};` 924. `var k;` 925. `// Unit conversion` 926. `switch (unit) {` 927. `case "pt":` 928. `k = 1;` 929. `break;` 930. `case "mm":` 931. `k = 72 / 25.4;` 932. `break;` 933. `case "cm":` 934. `k = 72 / 2.54;` 935. `break;` 936. `case "in":` 937. `k = 72;` 938. `break;` 939. `case "px":` 940. `k = 72 / 96;` 941. `break;` 942. `case "pc":` 943. `k = 12;` 944. `break;` 945. `case "em":` 946. `k = 12;` 947. `break;` 948. `case "ex":` 949. `k = 6;` 950. `break;` 951. `default:` 952. `throw "Invalid unit: " + unit;` 953. `}` 954. `var pageHeight = 0;` 955. `var pageWidth = 0;` 957. `// Dimensions are stored as user units and converted to points on output` 958. `if (pageFormats.hasOwnProperty(format_as_string)) {` 959. `pageHeight = pageFormats[format_as_string][1] / k;` 960. `pageWidth = pageFormats[format_as_string][0] / k;` 961. `} else {` 962. `try {` 963. `pageHeight = format[1];` 964. `pageWidth = format[0];` 965. `} catch (err) {` 966. `throw new Error("Invalid format: " + format);` 967. `}` 968. `}` 970. `var tmp;` 971. `// Handle page orientation` 972. `if (orientation === "p" || orientation === "portrait") {` 973. `orientation = "p";` 974. `if (pageWidth > pageHeight) {` 975. `tmp = pageWidth;` 976. `pageWidth = pageHeight;` 977. `pageHeight = tmp;` 978. `}` 979. `} else if (orientation === "l" || orientation === "landscape") {` 980. `orientation = "l";` 981. `if (pageHeight > pageWidth) {` 982. `tmp = pageWidth;` 983. `pageWidth = pageHeight;` 984. `pageHeight = tmp;` 985. `}` 986. `} else {` 987. `throw "Invalid orientation: " + orientation;` 988. `}` 990. `// Return information (k is the unit conversion ratio from pts)` 991. `var info = {` 992. `width: pageWidth,` 993. `height: pageHeight,` 994. `unit: unit,` 995. `k: k,` 996. `orientation: orientation` 997. `};` 998. `return info;` 999. `};` 1001. `/**` 1002. `* @typedef FontFace` 1003. `*` 1004. `* The font-face type implements an interface similar to that of the font-face CSS rule,` 1005. `* and is used by jsPDF to match fonts when the font property of CanvasRenderingContext2D` 1006. `* is updated.` 1007. `*` 1008. `* All properties expect values similar to those in the font-face CSS rule. A difference` 1009. `* is the font-family, which do not need to be enclosed in double-quotes when containing` 1010. `* spaces like in CSS.` 1011. `*` 1012. `* @property {string} family The name of the font-family.` 1013. `* @property {string|undefined} style The style that this font-face defines, e.g. 'italic'.` 1014. `* @property {string|number|undefined} weight The weight of the font, either as a string or a number (400, 500, 600, e.g.)` 1015. `* @property {string|undefined} stretch The stretch of the font, e.g. condensed, normal, expanded.` 1016. `* @property {Object[]} src A list of URLs from where fonts of various formats can be fetched.` 1017. `* @property {string} [src] url A URL to a font of a specific format.` 1018. `* @property {string} [src] format Format of the font referenced by the URL.` 1019. `*/` 1021. `/**` 1022. `* Generate a PDF from an HTML element or string using.` 1023. `*` 1024. `* @name html` 1025. `* @function` 1026. `* @param {HTMLElement|string} source The source HTMLElement or a string containing HTML.` 1027. `* @param {Object} [options] Collection of settings` 1028. `* @param {function} [options.callback] The mandatory callback-function gets as first parameter the current jsPDF instance` 1029. `* @param {(number|number[])=} [options.margin] Page margins [top, right, bottom, left]. Default is 0.` 1030. `* @param {(boolean|'slice'|'text')=} [options.autoPaging] The auto paging mode.` 1031. `*
      ` 1032. `*
    • ` 1033. `* false: Auto paging is disabled.` 1034. `*
    • ` 1035. `*
    • ` 1036. `* true or 'slice': Will cut shapes or text chunks across page breaks. Will possibly` 1037. `* slice text in half, making it difficult to read.` 1038. `*
    • ` 1039. `*
    • ` 1040. `* 'text': Trys not to cut text in half across page breaks. Works best for documents consisting` 1041. `* mostly of a single column of text.` 1042. `*
    • ` 1043. `*
    ` 1044. `* Default is true.` 1045. `* @param {string} [options.filename] name of the file` 1046. `* @param {HTMLOptionImage} [options.image] image settings when converting HTML to image` 1047. `* @param {Html2CanvasOptions} [options.html2canvas] html2canvas options` 1048. `* @param {FontFace[]} [options.fontFaces] A list of font-faces to match when resolving fonts. Fonts will be added to the PDF based on the specified URL. If omitted, the font match algorithm falls back to old algorithm.` 1049. `* @param {jsPDF} [options.jsPDF] jsPDF instance` 1050. `* @param {number=} [options.x] x position on the PDF document in jsPDF units.` 1051. `* @param {number=} [options.y] y position on the PDF document in jsPDF units.` 1052. `* @param {number=} [options.width] The target width in the PDF document in jsPDF units. The rendered element will be` 1053. `* scaled such that it fits into the specified width. Has no effect if either the html2canvas.scale is` 1054. `* specified or the windowWidth option is NOT specified.` 1055. `* @param {number=} [options.windowWidth] The window width in CSS pixels. In contrast to the` 1056. `* html2canvas.windowWidth option, this option affects the actual container size while rendering and` 1057. `* does NOT affect CSS media queries. This option only has an effect, if the width option is also specified.` 1058. `*` 1059. `* @example` 1060. `* var doc = new jsPDF();` 1061. `*` 1062. `* doc.html(document.body, {` 1063. `* callback: function (doc) {` 1064. `* doc.save();` 1065. `* },` 1066. `* x: 10,` 1067. `* y: 10` 1068. `* });` 1069. `*/` 1070. `jsPDFAPI.html = function(src, options) {` 1071. `"use strict";` 1073. `options = options || {};` 1074. `options.callback = options.callback || function() {};` 1075. `options.html2canvas = options.html2canvas || {};` 1076. `options.html2canvas.canvas = options.html2canvas.canvas || this.canvas;` 1077. `options.jsPDF = options.jsPDF || this;` 1078. `options.fontFaces = options.fontFaces` 1079. `? options.fontFaces.map(normalizeFontFace)` 1080. `: null;` 1082. `// Create a new worker with the given options.` 1083. `var worker = new Worker(options);` 1085. `if (!options.worker) {` 1086. `// If worker is not set to true, perform the traditional 'simple' operation.` 1087. `return worker.from(src).doCallback();` 1088. `} else {` 1089. `// Otherwise, return the worker for new Promise-based operation.` 1090. `return worker;` 1091. `}` 1092. `};` 1093. `})(jsPDF.API);` --- # modules/outline.js - Documentation modules/outline.js ================== 1. `/**` 2. `* @license` 3. `* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 11. `/**` 12. `* jsPDF Outline PlugIn` 13. `*` 14. `* Generates a PDF Outline` 15. `* @name outline` 16. `* @module` 17. `*/` 18. `(function(jsPDFAPI) {` 19. `"use strict";` 21. `var namesOid;` 22. `//var destsGoto = [];` 24. `jsPDFAPI.events.push([`\ 25. `"postPutResources",`\ 26. `function() {`\ 27. `var pdf = this;`\ 28. `var rx = /^(\d+) 0 obj$/;`\ \ 30. `// Write action goto objects for each page`\ 31. `// this.outline.destsGoto = [];`\ 32. `// for (var i = 0; i < totalPages; i++) {`\ 33. `// var id = pdf.internal.newObject();`\ 34. `// this.outline.destsGoto.push(id);`\ 35. `// pdf.internal.write("<> endobj");`\ 37. `// }`\ 38. `//`\ 39. `// for (var i = 0; i < dests.length; i++) {`\ 40. `// pdf.internal.write("(page_" + (i + 1) + ")" + dests[i] + " 0`\ 41. `// R");`\ 42. `// }`\ 43. `//`\ 44. `if (this.outline.root.children.length > 0) {`\ 45. `var lines = pdf.outline.render().split(/\r\n/);`\ 46. `for (var i = 0; i < lines.length; i++) {`\ 47. `var line = lines[i];`\ 48. `var m = rx.exec(line);`\ 49. `if (m != null) {`\ 50. `var oid = m[1];`\ 51. `pdf.internal.newObjectDeferredBegin(oid, false);`\ 52. `}`\ 53. `pdf.internal.write(line);`\ 54. `}`\ 55. `}`\ \ 57. `// This code will write named destination for each page reference`\ 58. `// (page_1, etc)`\ 59. `if (this.outline.createNamedDestinations) {`\ 60. `var totalPages = this.internal.pages.length;`\ 61. `// WARNING: this assumes jsPDF starts on page 3 and pageIDs`\ 62. `// follow 5, 7, 9, etc`\ 63. `// Write destination objects for each page`\ 64. `var dests = [];`\ 65. `for (var i = 0; i < totalPages; i++) {`\ 66. `var id = pdf.internal.newObject();`\ 67. `dests.push(id);`\ 68. `var info = pdf.internal.getPageInfo(i + 1);`\ 69. `pdf.internal.write(`\ 70. `"<< /D[" + info.objId + " 0 R /XYZ null null null]>> endobj"`\ 71. `);`\ 72. `}`\ \ 74. `// assign a name for each destination`\ 75. `var names2Oid = pdf.internal.newObject();`\ 76. `pdf.internal.write("<< /Names [ ");`\ 77. `for (var i = 0; i < dests.length; i++) {`\ 78. `pdf.internal.write("(page_" + (i + 1) + ")" + dests[i] + " 0 R");`\ 79. `}`\ 80. `pdf.internal.write(" ] >>", "endobj");`\ \ 82. `// var kids = pdf.internal.newObject();`\ 83. `// pdf.internal.write('<< /Kids [ ' + names2Oid + ' 0 R');`\ 84. `// pdf.internal.write(' ] >>', 'endobj');`\ \ 86. `namesOid = pdf.internal.newObject();`\ 87. `pdf.internal.write("<< /Dests " + names2Oid + " 0 R");`\ 88. `pdf.internal.write(">>", "endobj");`\ 89. `}`\ 90. `}`\ 91. `]);` 93. `jsPDFAPI.events.push([`\ 94. `"putCatalog",`\ 95. `function() {`\ 96. `var pdf = this;`\ 97. `if (pdf.outline.root.children.length > 0) {`\ 98. `pdf.internal.write(`\ 99. `"/Outlines",`\ 100. `this.outline.makeRef(this.outline.root)`\ 101. `);`\ 102. `if (this.outline.createNamedDestinations) {`\ 103. `pdf.internal.write("/Names " + namesOid + " 0 R");`\ 104. `}`\ 105. `// Open with Bookmarks showing`\ 106. `// pdf.internal.write("/PageMode /UseOutlines");`\ 107. `}`\ 108. `}`\ 109. `]);` 111. `jsPDFAPI.events.push([`\ 112. `"initialized",`\ 113. `function() {`\ 114. `var pdf = this;`\ \ 116. `pdf.outline = {`\ 117. `createNamedDestinations: false,`\ 118. `root: {`\ 119. `children: []`\ 120. `}`\ 121. `};`\ \ 123. `/**`\ 124. `* Options: pageNumber`\ 125. `*/`\ 126. `pdf.outline.add = function(parent, title, options) {`\ 127. `var item = {`\ 128. `title: title,`\ 129. `options: options,`\ 130. `children: []`\ 131. `};`\ 132. `if (parent == null) {`\ 133. `parent = this.root;`\ 134. `}`\ 135. `parent.children.push(item);`\ 136. `return item;`\ 137. `};`\ \ 139. `pdf.outline.render = function() {`\ 140. `this.ctx = {};`\ 141. `this.ctx.val = "";`\ 142. `this.ctx.pdf = pdf;`\ \ 144. `this.genIds_r(this.root);`\ 145. `this.renderRoot(this.root);`\ 146. `this.renderItems(this.root);`\ \ 148. `return this.ctx.val;`\ 149. `};`\ \ 151. `pdf.outline.genIds_r = function(node) {`\ 152. `node.id = pdf.internal.newObjectDeferred();`\ 153. `for (var i = 0; i < node.children.length; i++) {`\ 154. `this.genIds_r(node.children[i]);`\ 155. `}`\ 156. `};`\ \ 158. `pdf.outline.renderRoot = function(node) {`\ 159. `this.objStart(node);`\ 160. `this.line("/Type /Outlines");`\ 161. `if (node.children.length > 0) {`\ 162. `this.line("/First " + this.makeRef(node.children[0]));`\ 163. `this.line(`\ 164. `"/Last " + this.makeRef(node.children[node.children.length - 1])`\ 165. `);`\ 166. `}`\ 167. `this.line(`\ 168. `"/Count " +`\ 169. `this.count_r(`\ 170. `{`\ 171. `count: 0`\ 172. `},`\ 173. `node`\ 174. `)`\ 175. `);`\ 176. `this.objEnd();`\ 177. `};`\ \ 179. `pdf.outline.renderItems = function(node) {`\ 180. `var getVerticalCoordinateString = this.ctx.pdf.internal`\ 181. `.getVerticalCoordinateString;`\ 182. `for (var i = 0; i < node.children.length; i++) {`\ 183. `var item = node.children[i];`\ 184. `this.objStart(item);`\ \ 186. `this.line("/Title " + this.makeString(item.title));`\ \ 188. `this.line("/Parent " + this.makeRef(node));`\ 189. `if (i > 0) {`\ 190. `this.line("/Prev " + this.makeRef(node.children[i - 1]));`\ 191. `}`\ 192. `if (i < node.children.length - 1) {`\ 193. `this.line("/Next " + this.makeRef(node.children[i + 1]));`\ 194. `}`\ 195. `if (item.children.length > 0) {`\ 196. `this.line("/First " + this.makeRef(item.children[0]));`\ 197. `this.line(`\ 198. `"/Last " + this.makeRef(item.children[item.children.length - 1])`\ 199. `);`\ 200. `}`\ \ 202. `var count = (this.count = this.count_r(`\ 203. `{`\ 204. `count: 0`\ 205. `},`\ 206. `item`\ 207. `));`\ 208. `if (count > 0) {`\ 209. `this.line("/Count " + count);`\ 210. `}`\ \ 212. `if (item.options) {`\ 213. `if (item.options.pageNumber) {`\ 214. `// Explicit Destination`\ 215. `//WARNING this assumes page ids are 3,5,7, etc.`\ 216. `var info = pdf.internal.getPageInfo(item.options.pageNumber);`\ 217. `this.line(`\ 218. `"/Dest " +`\ 219. `"[" +`\ 220. `info.objId +`\ 221. `" 0 R /XYZ 0 " +`\ 222. `getVerticalCoordinateString(0) +`\ 223. `" 0]"`\ 224. `);`\ 225. `// this line does not work on all clients (pageNumber instead of page ref)`\ 226. `//this.line('/Dest ' + '[' + (item.options.pageNumber - 1) + ' /XYZ 0 ' + this.ctx.pdf.internal.pageSize.getHeight() + ' 0]');`\ \ 228. `// Named Destination`\ 229. `// this.line('/Dest (page_' + (item.options.pageNumber) + ')');`\ \ 231. `// Action Destination`\ 232. `// var id = pdf.internal.newObject();`\ 233. `// pdf.internal.write('<> endobj');`\ 234. `// this.line('/A ' + id + ' 0 R' );`\ 235. `}`\ 236. `}`\ 237. `this.objEnd();`\ 238. `}`\ 239. `for (var z = 0; z < node.children.length; z++) {`\ 240. `this.renderItems(node.children[z]);`\ 241. `}`\ 242. `};`\ \ 244. `pdf.outline.line = function(text) {`\ 245. `this.ctx.val += text + "\r\n";`\ 246. `};`\ \ 248. `pdf.outline.makeRef = function(node) {`\ 249. `return node.id + " 0 R";`\ 250. `};`\ \ 252. `pdf.outline.makeString = function(val) {`\ 253. `return "(" + pdf.internal.pdfEscape(val) + ")";`\ 254. `};`\ \ 256. `pdf.outline.objStart = function(node) {`\ 257. `this.ctx.val += "\r\n" + node.id + " 0 obj" + "\r\n<<\r\n";`\ 258. `};`\ \ 260. `pdf.outline.objEnd = function() {`\ 261. `this.ctx.val += ">> \r\n" + "endobj" + "\r\n";`\ 262. `};`\ \ 264. `pdf.outline.count_r = function(ctx, node) {`\ 265. `for (var i = 0; i < node.children.length; i++) {`\ 266. `ctx.count++;`\ 267. `this.count_r(ctx, node.children[i]);`\ 268. `}`\ 269. `return ctx.count;`\ 270. `};`\ 271. `}`\ 272. `]);` 274. `return this;` 275. `})(jsPDF.API);` --- # modules/rgba_support.js - Documentation modules/rgba\_support.js ======================== 1. `/**` 2. `* @license` 3. `*` 4. `* Copyright (c) 2021 Antti Palola, https://github.com/Pantura` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 29. `/**` 30. `* jsPDF RGBA array PlugIn` 31. `* @name rgba_support` 32. `* @module` 33. `*/` 34. `(function(jsPDFAPI) {` 35. `"use strict";` 37. `/**` 38. `* @name processRGBA` 39. `* @function` 40. `*` 41. `* Process RGBA Array. This is a one-dimension array with pixel data [red, green, blue, alpha, red, green, ...].` 42. `* RGBA array data can be obtained from DOM canvas getImageData.` 43. `* @ignore` 44. `*/` 45. `jsPDFAPI.processRGBA = function(imageData, index, alias) {` 46. `"use strict";` 48. `var imagePixels = imageData.data;` 49. `var length = imagePixels.length;` 50. `// jsPDF takes alpha data separately so extract that.` 51. `var rgbOut = new Uint8Array((length / 4) * 3);` 52. `var alphaOut = new Uint8Array(length / 4);` 53. `var outIndex = 0;` 54. `var alphaIndex = 0;` 56. `for (var i = 0; i < length; i += 4) {` 57. `var r = imagePixels[i];` 58. `var g = imagePixels[i + 1];` 59. `var b = imagePixels[i + 2];` 60. `var alpha = imagePixels[i + 3];` 61. `rgbOut[outIndex++] = r;` 62. `rgbOut[outIndex++] = g;` 63. `rgbOut[outIndex++] = b;` 64. `alphaOut[alphaIndex++] = alpha;` 65. `}` 67. `var rgbData = this.__addimage__.arrayBufferToBinaryString(rgbOut);` 68. `var alphaData = this.__addimage__.arrayBufferToBinaryString(alphaOut);` 70. `return {` 71. `alpha: alphaData,` 72. `data: rgbData,` 73. `index: index,` 74. `alias: alias,` 75. `colorSpace: "DeviceRGB",` 76. `bitsPerComponent: 8,` 77. `width: imageData.width,` 78. `height: imageData.height` 79. `};` 80. `};` 81. `})(jsPDF.API);` --- # modules/setlanguage.js - Documentation modules/setlanguage.js ====================== 1. `/**` 2. `* @license` 3. `* Licensed under the MIT License.` 4. `* http://opensource.org/licenses/mit-license` 5. `*/` 7. `import { jsPDF } from "../jspdf.js";` 9. `/**` 10. `* jsPDF setLanguage Plugin` 11. `*` 12. `* @name setLanguage` 13. `* @module` 14. `*/` 15. `(function(jsPDFAPI) {` 16. `"use strict";` 18. `/**` 19. `* Add Language Tag to the generated PDF` 20. `*` 21. `* @name setLanguage` 22. `* @function` 23. `* @param {string} langCode The Language code as ISO-639-1 (e.g. 'en') or as country language code (e.g. 'en-GB').` 24. `* @returns {jsPDF}` 25. `* @example` 26. `* var doc = new jsPDF()` 27. `* doc.text(10, 10, 'This is a test')` 28. `* doc.setLanguage("en-US")` 29. `* doc.save('english.pdf')` 30. `*/` 31. `jsPDFAPI.setLanguage = function(langCode) {` 32. `"use strict";` 34. `var langCodes = {` 35. `af: "Afrikaans",` 36. `sq: "Albanian",` 37. `ar: "Arabic (Standard)",` 38. `"ar-DZ": "Arabic (Algeria)",` 39. `"ar-BH": "Arabic (Bahrain)",` 40. `"ar-EG": "Arabic (Egypt)",` 41. `"ar-IQ": "Arabic (Iraq)",` 42. `"ar-JO": "Arabic (Jordan)",` 43. `"ar-KW": "Arabic (Kuwait)",` 44. `"ar-LB": "Arabic (Lebanon)",` 45. `"ar-LY": "Arabic (Libya)",` 46. `"ar-MA": "Arabic (Morocco)",` 47. `"ar-OM": "Arabic (Oman)",` 48. `"ar-QA": "Arabic (Qatar)",` 49. `"ar-SA": "Arabic (Saudi Arabia)",` 50. `"ar-SY": "Arabic (Syria)",` 51. `"ar-TN": "Arabic (Tunisia)",` 52. `"ar-AE": "Arabic (U.A.E.)",` 53. `"ar-YE": "Arabic (Yemen)",` 54. `an: "Aragonese",` 55. `hy: "Armenian",` 56. `as: "Assamese",` 57. `ast: "Asturian",` 58. `az: "Azerbaijani",` 59. `eu: "Basque",` 60. `be: "Belarusian",` 61. `bn: "Bengali",` 62. `bs: "Bosnian",` 63. `br: "Breton",` 64. `bg: "Bulgarian",` 65. `my: "Burmese",` 66. `ca: "Catalan",` 67. `ch: "Chamorro",` 68. `ce: "Chechen",` 69. `zh: "Chinese",` 70. `"zh-HK": "Chinese (Hong Kong)",` 71. `"zh-CN": "Chinese (PRC)",` 72. `"zh-SG": "Chinese (Singapore)",` 73. `"zh-TW": "Chinese (Taiwan)",` 74. `cv: "Chuvash",` 75. `co: "Corsican",` 76. `cr: "Cree",` 77. `hr: "Croatian",` 78. `cs: "Czech",` 79. `da: "Danish",` 80. `nl: "Dutch (Standard)",` 81. `"nl-BE": "Dutch (Belgian)",` 82. `en: "English",` 83. `"en-AU": "English (Australia)",` 84. `"en-BZ": "English (Belize)",` 85. `"en-CA": "English (Canada)",` 86. `"en-IE": "English (Ireland)",` 87. `"en-JM": "English (Jamaica)",` 88. `"en-NZ": "English (New Zealand)",` 89. `"en-PH": "English (Philippines)",` 90. `"en-ZA": "English (South Africa)",` 91. `"en-TT": "English (Trinidad & Tobago)",` 92. `"en-GB": "English (United Kingdom)",` 93. `"en-US": "English (United States)",` 94. `"en-ZW": "English (Zimbabwe)",` 95. `eo: "Esperanto",` 96. `et: "Estonian",` 97. `fo: "Faeroese",` 98. `fj: "Fijian",` 99. `fi: "Finnish",` 100. `fr: "French (Standard)",` 101. `"fr-BE": "French (Belgium)",` 102. `"fr-CA": "French (Canada)",` 103. `"fr-FR": "French (France)",` 104. `"fr-LU": "French (Luxembourg)",` 105. `"fr-MC": "French (Monaco)",` 106. `"fr-CH": "French (Switzerland)",` 107. `fy: "Frisian",` 108. `fur: "Friulian",` 109. `gd: "Gaelic (Scots)",` 110. `"gd-IE": "Gaelic (Irish)",` 111. `gl: "Galacian",` 112. `ka: "Georgian",` 113. `de: "German (Standard)",` 114. `"de-AT": "German (Austria)",` 115. `"de-DE": "German (Germany)",` 116. `"de-LI": "German (Liechtenstein)",` 117. `"de-LU": "German (Luxembourg)",` 118. `"de-CH": "German (Switzerland)",` 119. `el: "Greek",` 120. `gu: "Gujurati",` 121. `ht: "Haitian",` 122. `he: "Hebrew",` 123. `hi: "Hindi",` 124. `hu: "Hungarian",` 125. `is: "Icelandic",` 126. `id: "Indonesian",` 127. `iu: "Inuktitut",` 128. `ga: "Irish",` 129. `it: "Italian (Standard)",` 130. `"it-CH": "Italian (Switzerland)",` 131. `ja: "Japanese",` 132. `kn: "Kannada",` 133. `ks: "Kashmiri",` 134. `kk: "Kazakh",` 135. `km: "Khmer",` 136. `ky: "Kirghiz",` 137. `tlh: "Klingon",` 138. `ko: "Korean",` 139. `"ko-KP": "Korean (North Korea)",` 140. `"ko-KR": "Korean (South Korea)",` 141. `la: "Latin",` 142. `lv: "Latvian",` 143. `lt: "Lithuanian",` 144. `lb: "Luxembourgish",` 145. `mk: "North Macedonia",` 146. `ms: "Malay",` 147. `ml: "Malayalam",` 148. `mt: "Maltese",` 149. `mi: "Maori",` 150. `mr: "Marathi",` 151. `mo: "Moldavian",` 152. `nv: "Navajo",` 153. `ng: "Ndonga",` 154. `ne: "Nepali",` 155. `no: "Norwegian",` 156. `nb: "Norwegian (Bokmal)",` 157. `nn: "Norwegian (Nynorsk)",` 158. `oc: "Occitan",` 159. `or: "Oriya",` 160. `om: "Oromo",` 161. `fa: "Persian",` 162. `"fa-IR": "Persian/Iran",` 163. `pl: "Polish",` 164. `pt: "Portuguese",` 165. `"pt-BR": "Portuguese (Brazil)",` 166. `pa: "Punjabi",` 167. `"pa-IN": "Punjabi (India)",` 168. `"pa-PK": "Punjabi (Pakistan)",` 169. `qu: "Quechua",` 170. `rm: "Rhaeto-Romanic",` 171. `ro: "Romanian",` 172. `"ro-MO": "Romanian (Moldavia)",` 173. `ru: "Russian",` 174. `"ru-MO": "Russian (Moldavia)",` 175. `sz: "Sami (Lappish)",` 176. `sg: "Sango",` 177. `sa: "Sanskrit",` 178. `sc: "Sardinian",` 179. `sd: "Sindhi",` 180. `si: "Singhalese",` 181. `sr: "Serbian",` 182. `sk: "Slovak",` 183. `sl: "Slovenian",` 184. `so: "Somani",` 185. `sb: "Sorbian",` 186. `es: "Spanish",` 187. `"es-AR": "Spanish (Argentina)",` 188. `"es-BO": "Spanish (Bolivia)",` 189. `"es-CL": "Spanish (Chile)",` 190. `"es-CO": "Spanish (Colombia)",` 191. `"es-CR": "Spanish (Costa Rica)",` 192. `"es-DO": "Spanish (Dominican Republic)",` 193. `"es-EC": "Spanish (Ecuador)",` 194. `"es-SV": "Spanish (El Salvador)",` 195. `"es-GT": "Spanish (Guatemala)",` 196. `"es-HN": "Spanish (Honduras)",` 197. `"es-MX": "Spanish (Mexico)",` 198. `"es-NI": "Spanish (Nicaragua)",` 199. `"es-PA": "Spanish (Panama)",` 200. `"es-PY": "Spanish (Paraguay)",` 201. `"es-PE": "Spanish (Peru)",` 202. `"es-PR": "Spanish (Puerto Rico)",` 203. `"es-ES": "Spanish (Spain)",` 204. `"es-UY": "Spanish (Uruguay)",` 205. `"es-VE": "Spanish (Venezuela)",` 206. `sx: "Sutu",` 207. `sw: "Swahili",` 208. `sv: "Swedish",` 209. `"sv-FI": "Swedish (Finland)",` 210. `"sv-SV": "Swedish (Sweden)",` 211. `ta: "Tamil",` 212. `tt: "Tatar",` 213. `te: "Teluga",` 214. `th: "Thai",` 215. `tig: "Tigre",` 216. `ts: "Tsonga",` 217. `tn: "Tswana",` 218. `tr: "Turkish",` 219. `tk: "Turkmen",` 220. `uk: "Ukrainian",` 221. `hsb: "Upper Sorbian",` 222. `ur: "Urdu",` 223. `ve: "Venda",` 224. `vi: "Vietnamese",` 225. `vo: "Volapuk",` 226. `wa: "Walloon",` 227. `cy: "Welsh",` 228. `xh: "Xhosa",` 229. `ji: "Yiddish",` 230. `zu: "Zulu"` 231. `};` 233. `if (this.internal.languageSettings === undefined) {` 234. `this.internal.languageSettings = {};` 235. `this.internal.languageSettings.isSubscribed = false;` 236. `}` 238. `if (langCodes[langCode] !== undefined) {` 239. `this.internal.languageSettings.languageCode = langCode;` 240. `if (this.internal.languageSettings.isSubscribed === false) {` 241. `this.internal.events.subscribe("putCatalog", function() {` 242. `this.internal.write(` 243. `"/Lang (" + this.internal.languageSettings.languageCode + ")"` 244. `);` 245. `});` 246. `this.internal.languageSettings.isSubscribed = true;` 247. `}` 248. `}` 249. `return this;` 250. `};` 251. `})(jsPDF.API);` --- # modules/png_support.js - Documentation modules/png\_support.js ======================= 1. `/**` 2. `* @license` 3. `*` 4. `* Copyright (c) 2014 James Robb, https://github.com/jamesbrobb` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 28. `import { zlibSync } from "../libs/fflate.js";` 29. `import { PNG } from "../libs/png.js";` 31. `/**` 32. `* jsPDF PNG PlugIn` 33. `* @name png_support` 34. `* @module` 35. `*/` 36. `(function(jsPDFAPI) {` 37. `"use strict";` 39. `/*` 40. `* @see http://www.w3.org/TR/PNG-Chunks.html` 41. `*` 42. `Color Allowed Interpretation` 43. `Type Bit Depths` 45. `0 1,2,4,8,16 Each pixel is a grayscale sample.` 47. `2 8,16 Each pixel is an R,G,B triple.` 49. `3 1,2,4,8 Each pixel is a palette index;` 50. `a PLTE chunk must appear.` 52. `4 8,16 Each pixel is a grayscale sample,` 53. `followed by an alpha sample.` 55. `6 8,16 Each pixel is an R,G,B triple,` 56. `followed by an alpha sample.` 57. `*/` 59. `/*` 60. `* PNG filter method types` 61. `*` 62. `* @see http://www.w3.org/TR/PNG-Filters.html` 63. `* @see http://www.libpng.org/pub/png/book/chapter09.html` 64. `*` 65. `* This is what the value 'Predictor' in decode params relates to` 66. `*` 67. `* 15 is "optimal prediction", which means the prediction algorithm can change from line to line.` 68. `* 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.` 69. `*` 70. `0 None` 71. `1 Sub` 72. `2 Up` 73. `3 Average` 74. `4 Paeth` 75. `*/` 77. `var canCompress = function(value) {` 78. `return value !== jsPDFAPI.image_compression.NONE && hasCompressionJS();` 79. `};` 81. `var hasCompressionJS = function() {` 82. `return typeof zlibSync === "function";` 83. `};` 84. `var compressBytes = function(bytes, lineLength, colorsPerPixel, compression) {` 85. `var level = 4;` 86. `var filter_method = filterUp;` 88. `switch (compression) {` 89. `case jsPDFAPI.image_compression.FAST:` 90. `level = 1;` 91. `filter_method = filterSub;` 92. `break;` 94. `case jsPDFAPI.image_compression.MEDIUM:` 95. `level = 6;` 96. `filter_method = filterAverage;` 97. `break;` 99. `case jsPDFAPI.image_compression.SLOW:` 100. `level = 9;` 101. `filter_method = filterPaeth;` 102. `break;` 103. `}` 105. `bytes = applyPngFilterMethod(` 106. `bytes,` 107. `lineLength,` 108. `colorsPerPixel,` 109. `filter_method` 110. `);` 111. `var dat = zlibSync(bytes, { level: level });` 112. `return jsPDFAPI.__addimage__.arrayBufferToBinaryString(dat);` 113. `};` 115. `var applyPngFilterMethod = function(` 116. `bytes,` 117. `lineLength,` 118. `colorsPerPixel,` 119. `filter_method` 120. `) {` 121. `var lines = bytes.length / lineLength,` 122. `result = new Uint8Array(bytes.length + lines),` 123. `filter_methods = getFilterMethods(),` 124. `line,` 125. `prevLine,` 126. `offset;` 128. `for (var i = 0; i < lines; i += 1) {` 129. `offset = i * lineLength;` 130. `line = bytes.subarray(offset, offset + lineLength);` 132. `if (filter_method) {` 133. `result.set(filter_method(line, colorsPerPixel, prevLine), offset + i);` 134. `} else {` 135. `var len = filter_methods.length,` 136. `results = [];` 138. `for (var j; j < len; j += 1) {` 139. `results[j] = filter_methods[j](line, colorsPerPixel, prevLine);` 140. `}` 142. `var ind = getIndexOfSmallestSum(results.concat());` 144. `result.set(results[ind], offset + i);` 145. `}` 147. `prevLine = line;` 148. `}` 150. `return result;` 151. `};` 153. `var filterNone = function(line) {` 154. `/*var result = new Uint8Array(line.length + 1);` 155. `result[0] = 0;` 156. `result.set(line, 1);*/` 158. `var result = Array.apply([], line);` 159. `result.unshift(0);` 161. `return result;` 162. `};` 164. `var filterSub = function(line, colorsPerPixel) {` 165. `var result = [],` 166. `len = line.length,` 167. `left;` 169. `result[0] = 1;` 171. `for (var i = 0; i < len; i += 1) {` 172. `left = line[i - colorsPerPixel] || 0;` 173. `result[i + 1] = (line[i] - left + 0x0100) & 0xff;` 174. `}` 176. `return result;` 177. `};` 179. `var filterUp = function(line, colorsPerPixel, prevLine) {` 180. `var result = [],` 181. `len = line.length,` 182. `up;` 184. `result[0] = 2;` 186. `for (var i = 0; i < len; i += 1) {` 187. `up = (prevLine && prevLine[i]) || 0;` 188. `result[i + 1] = (line[i] - up + 0x0100) & 0xff;` 189. `}` 191. `return result;` 192. `};` 194. `var filterAverage = function(line, colorsPerPixel, prevLine) {` 195. `var result = [],` 196. `len = line.length,` 197. `left,` 198. `up;` 200. `result[0] = 3;` 202. `for (var i = 0; i < len; i += 1) {` 203. `left = line[i - colorsPerPixel] || 0;` 204. `up = (prevLine && prevLine[i]) || 0;` 205. `result[i + 1] = (line[i] + 0x0100 - ((left + up) >>> 1)) & 0xff;` 206. `}` 208. `return result;` 209. `};` 211. `var filterPaeth = function(line, colorsPerPixel, prevLine) {` 212. `var result = [],` 213. `len = line.length,` 214. `left,` 215. `up,` 216. `upLeft,` 217. `paeth;` 219. `result[0] = 4;` 221. `for (var i = 0; i < len; i += 1) {` 222. `left = line[i - colorsPerPixel] || 0;` 223. `up = (prevLine && prevLine[i]) || 0;` 224. `upLeft = (prevLine && prevLine[i - colorsPerPixel]) || 0;` 225. `paeth = paethPredictor(left, up, upLeft);` 226. `result[i + 1] = (line[i] - paeth + 0x0100) & 0xff;` 227. `}` 229. `return result;` 230. `};` 232. `var paethPredictor = function(left, up, upLeft) {` 233. `if (left === up && up === upLeft) {` 234. `return left;` 235. `}` 236. `var pLeft = Math.abs(up - upLeft),` 237. `pUp = Math.abs(left - upLeft),` 238. `pUpLeft = Math.abs(left + up - upLeft - upLeft);` 239. `return pLeft <= pUp && pLeft <= pUpLeft` 240. `? left` 241. `: pUp <= pUpLeft` 242. `? up` 243. `: upLeft;` 244. `};` 246. `var getFilterMethods = function() {` 247. `return [filterNone, filterSub, filterUp, filterAverage, filterPaeth];` 248. `};` 250. `var getIndexOfSmallestSum = function(arrays) {` 251. `var sum = arrays.map(function(value) {` 252. `return value.reduce(function(pv, cv) {` 253. `return pv + Math.abs(cv);` 254. `}, 0);` 255. `});` 256. `return sum.indexOf(Math.min.apply(null, sum));` 257. `};` 259. `var getPredictorFromCompression = function(compression) {` 260. `var predictor;` 261. `switch (compression) {` 262. `case jsPDFAPI.image_compression.FAST:` 263. `predictor = 11;` 264. `break;` 266. `case jsPDFAPI.image_compression.MEDIUM:` 267. `predictor = 13;` 268. `break;` 270. `case jsPDFAPI.image_compression.SLOW:` 271. `predictor = 14;` 272. `break;` 274. `default:` 275. `predictor = 12;` 276. `break;` 277. `}` 278. `return predictor;` 279. `};` 281. `/**` 282. `* @name processPNG` 283. `* @function` 284. `* @ignore` 285. `*/` 286. `jsPDFAPI.processPNG = function(imageData, index, alias, compression) {` 287. `"use strict";` 289. `var colorSpace,` 290. `filter = this.decode.FLATE_DECODE,` 291. `bitsPerComponent,` 292. `image,` 293. `decodeParameters = "",` 294. `trns,` 295. `colors,` 296. `pal,` 297. `smask,` 298. `pixels,` 299. `len,` 300. `alphaData,` 301. `imgData,` 302. `hasColors,` 303. `pixel,` 304. `i,` 305. `n;` 307. `if (this.__addimage__.isArrayBuffer(imageData))` 308. `imageData = new Uint8Array(imageData);` 310. `if (this.__addimage__.isArrayBufferView(imageData)) {` 311. `image = new PNG(imageData);` 312. `imageData = image.imgData;` 313. `bitsPerComponent = image.bits;` 314. `colorSpace = image.colorSpace;` 315. `colors = image.colors;` 317. `/*` 318. `* colorType 6 - Each pixel is an R,G,B triple, followed by an alpha sample.` 319. `*` 320. `* colorType 4 - Each pixel is a grayscale sample, followed by an alpha sample.` 321. `*` 322. `* Extract alpha to create two separate images, using the alpha as a sMask` 323. `*/` 324. `if ([4, 6].indexOf(image.colorType) !== -1) {` 325. `/*` 326. `* processes 8 bit RGBA and grayscale + alpha images` 327. `*/` 328. `if (image.bits === 8) {` 329. `pixels =` 330. `image.pixelBitlength == 32` 331. `? new Uint32Array(image.decodePixels().buffer)` 332. `: image.pixelBitlength == 16` 333. `? new Uint16Array(image.decodePixels().buffer)` 334. `: new Uint8Array(image.decodePixels().buffer);` 335. `len = pixels.length;` 336. `imgData = new Uint8Array(len * image.colors);` 337. `alphaData = new Uint8Array(len);` 338. `var pDiff = image.pixelBitlength - image.bits;` 339. `i = 0;` 340. `n = 0;` 341. `var pbl;` 343. `for (; i < len; i++) {` 344. `pixel = pixels[i];` 345. `pbl = 0;` 347. `while (pbl < pDiff) {` 348. `imgData[n++] = (pixel >>> pbl) & 0xff;` 349. `pbl = pbl + image.bits;` 350. `}` 352. `alphaData[i] = (pixel >>> pbl) & 0xff;` 353. `}` 354. `}` 356. `/*` 357. `* processes 16 bit RGBA and grayscale + alpha images` 358. `*/` 359. `if (image.bits === 16) {` 360. `pixels = new Uint32Array(image.decodePixels().buffer);` 361. `len = pixels.length;` 362. `imgData = new Uint8Array(` 363. `len * (32 / image.pixelBitlength) * image.colors` 364. `);` 365. `alphaData = new Uint8Array(len * (32 / image.pixelBitlength));` 366. `hasColors = image.colors > 1;` 367. `i = 0;` 368. `n = 0;` 369. `var a = 0;` 371. `while (i < len) {` 372. `pixel = pixels[i++];` 374. `imgData[n++] = (pixel >>> 0) & 0xff;` 376. `if (hasColors) {` 377. `imgData[n++] = (pixel >>> 16) & 0xff;` 379. `pixel = pixels[i++];` 380. `imgData[n++] = (pixel >>> 0) & 0xff;` 381. `}` 383. `alphaData[a++] = (pixel >>> 16) & 0xff;` 384. `}` 385. `bitsPerComponent = 8;` 386. `}` 388. `if (canCompress(compression)) {` 389. `imageData = compressBytes(` 390. `imgData,` 391. `image.width * image.colors,` 392. `image.colors,` 393. `compression` 394. `);` 395. `smask = compressBytes(alphaData, image.width, 1, compression);` 396. `} else {` 397. `imageData = imgData;` 398. `smask = alphaData;` 399. `filter = undefined;` 400. `}` 401. `}` 403. `/*` 404. `* Indexed png. Each pixel is a palette index.` 405. `*/` 406. `if (image.colorType === 3) {` 407. `colorSpace = this.color_spaces.INDEXED;` 408. `pal = image.palette;` 410. `if (image.transparency.indexed) {` 411. `var trans = image.transparency.indexed;` 412. `var total = 0;` 413. `i = 0;` 414. `len = trans.length;` 416. `for (; i < len; ++i) {` 417. `total += trans[i];` 418. `}` 420. `total = total / 255;` 422. `/*` 423. `* a single color is specified as 100% transparent (0),` 424. `* so we set trns to use a /Mask with that index` 425. `*/` 426. `if (total === len - 1 && trans.indexOf(0) !== -1) {` 427. `trns = [trans.indexOf(0)];` 429. `/*` 430. `* there's more than one colour within the palette that specifies` 431. `* a transparency value less than 255, so we unroll the pixels to create an image sMask` 432. `*/` 433. `} else if (total !== len) {` 434. `pixels = image.decodePixels();` 435. `alphaData = new Uint8Array(pixels.length);` 436. `i = 0;` 437. `len = pixels.length;` 439. `for (; i < len; i++) {` 440. `alphaData[i] = trans[pixels[i]];` 441. `}` 443. `smask = compressBytes(alphaData, image.width, 1);` 444. `}` 445. `}` 446. `}` 448. `var predictor = getPredictorFromCompression(compression);` 450. `if (filter === this.decode.FLATE_DECODE) {` 451. `decodeParameters = "/Predictor " + predictor + " ";` 452. `}` 453. `decodeParameters +=` 454. `"/Colors " +` 455. `colors +` 456. `" /BitsPerComponent " +` 457. `bitsPerComponent +` 458. `" /Columns " +` 459. `image.width;` 461. `if (` 462. `this.__addimage__.isArrayBuffer(imageData) ||` 463. `this.__addimage__.isArrayBufferView(imageData)` 464. `) {` 465. `imageData = this.__addimage__.arrayBufferToBinaryString(imageData);` 466. `}` 468. `if (` 469. `(smask && this.__addimage__.isArrayBuffer(smask)) ||` 470. `this.__addimage__.isArrayBufferView(smask)` 471. `) {` 472. `smask = this.__addimage__.arrayBufferToBinaryString(smask);` 473. `}` 475. `return {` 476. `alias: alias,` 477. `data: imageData,` 478. `index: index,` 479. `filter: filter,` 480. `decodeParameters: decodeParameters,` 481. `transparency: trns,` 482. `palette: pal,` 483. `sMask: smask,` 484. `predictor: predictor,` 485. `width: image.width,` 486. `height: image.height,` 487. `bitsPerComponent: bitsPerComponent,` 488. `colorSpace: colorSpace` 489. `};` 490. `}` 491. `};` 492. `})(jsPDF.API);` --- # jspdf.js - Documentation jspdf.js ======== 1. `/* eslint-disable no-console */` 3. `// @if MODULE_FORMAT!='cjs'` 4. `import { saveAs } from "./libs/FileSaver.js";` 5. `// @endif` 6. `import { globalObject } from "./libs/globalObject.js";` 7. `import { RGBColor } from "./libs/rgbcolor.js";` 8. `import { btoa } from "./libs/AtobBtoa.js";` 9. `import { console } from "./libs/console.js";` 10. `import { PDFSecurity } from "./libs/pdfsecurity.js";` 11. `import { toPDFName } from "./libs/pdfname.js";` 12. `/**` 13. `* jsPDF's Internal PubSub Implementation.` 14. `* Backward compatible rewritten on 2014 by` 15. `* Diego Casorran, https://github.com/diegocr` 16. `*` 17. `* @class` 18. `* @name PubSub` 19. `* @ignore` 20. `*/` 21. `function PubSub(context) {` 22. `if (typeof context !== "object") {` 23. `throw new Error(` 24. `"Invalid Context passed to initialize PubSub (jsPDF-module)"` 25. `);` 26. `}` 27. `var topics = {};` 29. `this.subscribe = function(topic, callback, once) {` 30. `once = once || false;` 31. `if (` 32. `typeof topic !== "string" ||` 33. `typeof callback !== "function" ||` 34. `typeof once !== "boolean"` 35. `) {` 36. `throw new Error(` 37. `"Invalid arguments passed to PubSub.subscribe (jsPDF-module)"` 38. `);` 39. `}` 41. `if (!topics.hasOwnProperty(topic)) {` 42. `topics[topic] = {};` 43. `}` 45. `var token = Math.random().toString(35);` 46. `topics[topic][token] = [callback, !!once];` 48. `return token;` 49. `};` 51. `this.unsubscribe = function(token) {` 52. `for (var topic in topics) {` 53. `if (topics[topic][token]) {` 54. `delete topics[topic][token];` 55. `if (Object.keys(topics[topic]).length === 0) {` 56. `delete topics[topic];` 57. `}` 58. `return true;` 59. `}` 60. `}` 61. `return false;` 62. `};` 64. `this.publish = function(topic) {` 65. `if (topics.hasOwnProperty(topic)) {` 66. `var args = Array.prototype.slice.call(arguments, 1),` 67. `tokens = [];` 69. `for (var token in topics[topic]) {` 70. `var sub = topics[topic][token];` 71. `try {` 72. `sub[0].apply(context, args);` 73. `} catch (ex) {` 74. `if (globalObject.console) {` 75. `console.error("jsPDF PubSub Error", ex.message, ex);` 76. `}` 77. `}` 78. `if (sub[1]) tokens.push(token);` 79. `}` 80. `if (tokens.length) tokens.forEach(this.unsubscribe);` 81. `}` 82. `};` 84. `this.getTopics = function() {` 85. `return topics;` 86. `};` 87. `}` 89. `function GState(parameters) {` 90. `if (!(this instanceof GState)) {` 91. `return new GState(parameters);` 92. `}` 94. `/**` 95. `* @name GState#opacity` 96. `* @type {any}` 97. `*/` 98. `/**` 99. `* @name GState#stroke-opacity` 100. `* @type {any}` 101. `*/` 102. `var supported = "opacity,stroke-opacity".split(",");` 103. `for (var p in parameters) {` 104. `if (parameters.hasOwnProperty(p) && supported.indexOf(p) >= 0) {` 105. `this[p] = parameters[p];` 106. `}` 107. `}` 108. `/**` 109. `* @name GState#id` 110. `* @type {string}` 111. `*/` 112. `this.id = ""; // set by addGState()` 113. `/**` 114. `* @name GState#objectNumber` 115. `* @type {number}` 116. `*/` 117. `this.objectNumber = -1; // will be set by putGState()` 118. `}` 120. `GState.prototype.equals = function equals(other) {` 121. `var ignore = "id,objectNumber,equals";` 122. `var p;` 123. `if (!other || typeof other !== typeof this) return false;` 124. `var count = 0;` 125. `for (p in this) {` 126. `if (ignore.indexOf(p) >= 0) continue;` 127. `if (this.hasOwnProperty(p) && !other.hasOwnProperty(p)) return false;` 128. `if (this[p] !== other[p]) return false;` 129. `count++;` 130. `}` 131. `for (p in other) {` 132. `if (other.hasOwnProperty(p) && ignore.indexOf(p) < 0) count--;` 133. `}` 134. `return count === 0;` 135. `};` 137. `function Pattern(gState, matrix) {` 138. `this.gState = gState;` 139. `this.matrix = matrix;` 141. `this.id = ""; // set by addPattern()` 142. `this.objectNumber = -1; // will be set by putPattern()` 143. `}` 145. `function ShadingPattern(type, coords, colors, gState, matrix) {` 146. `if (!(this instanceof ShadingPattern)) {` 147. `return new ShadingPattern(type, coords, colors, gState, matrix);` 148. `}` 150. `// see putPattern() for information how they are realized` 151. `this.type = type === "axial" ? 2 : 3;` 152. `this.coords = coords;` 153. `this.colors = colors;` 155. `Pattern.call(this, gState, matrix);` 156. `}` 158. `function TilingPattern(boundingBox, xStep, yStep, gState, matrix) {` 159. `if (!(this instanceof TilingPattern)) {` 160. `return new TilingPattern(boundingBox, xStep, yStep, gState, matrix);` 161. `}` 163. `this.boundingBox = boundingBox;` 164. `this.xStep = xStep;` 165. `this.yStep = yStep;` 167. `this.stream = ""; // set by endTilingPattern();` 169. `this.cloneIndex = 0;` 171. `Pattern.call(this, gState, matrix);` 172. `}` 174. `/**` 175. `* Creates new jsPDF document object instance.` 176. `* @name jsPDF` 177. `* @class` 178. `* @param {Object} [options] - Collection of settings initializing the jsPDF-instance` 179. `* @param {string} [options.orientation=portrait] - Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" or "l").
    ` 180. `* @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.
    ` 181. `* Possible values are "pt" (points), "mm", "cm", "in", "px", "pc", "em" or "ex". Note that in order to get the correct scaling for "px"` 182. `* units, you need to enable the hotfix "px_scaling" by setting options.hotfixes = ["px_scaling"].` 183. `* @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

    ` 184. `* 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]` 185. `* @param {boolean} [options.putOnlyUsedFonts=false] Only put fonts into the PDF, which were used.` 186. `* @param {boolean} [options.compress=false] Compress the generated PDF.` 187. `* @param {number} [options.precision=16] Precision of the element-positions.` 188. `* @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.` 189. `* @param {string[]} [options.hotfixes] An array of strings to enable hotfixes such as correct pixel scaling.` 190. `* @param {Object} [options.encryption]` 191. `* @param {string} [options.encryption.userPassword] Password for the user bound by the given permissions list.` 192. `* @param {string} [options.encryption.ownerPassword] Both userPassword and ownerPassword should be set for proper authentication.` 193. `* @param {string[]} [options.encryption.userPermissions] Array of permissions "print", "modify", "copy", "annot-forms", accessible by the user.` 194. `* @param {number|"smart"} [options.floatPrecision=16]` 195. `* @returns {jsPDF} jsPDF-instance` 196. `* @description` 197. ` * ``` ` 198. `* {` 199. `* orientation: 'p',` 200. `* unit: 'mm',` 201. `* format: 'a4',` 202. `* putOnlyUsedFonts:true,` 203. `* floatPrecision: 16 // or "smart", default is 16` 204. `* }` 205. ` * ``` ` 206. `*` 207. `* @constructor` 208. `*/` 209. `function jsPDF(options) {` 210. `var orientation = typeof arguments[0] === "string" ? arguments[0] : "p";` 211. `var unit = arguments[1];` 212. `var format = arguments[2];` 213. `var compressPdf = arguments[3];` 214. `var filters = [];` 215. `var userUnit = 1.0;` 216. `var precision;` 217. `var floatPrecision = 16;` 218. `var defaultPathOperation = "S";` 219. `var encryptionOptions = null;` 221. `options = options || {};` 223. `if (typeof options === "object") {` 224. `orientation = options.orientation;` 225. `unit = options.unit || unit;` 226. `format = options.format || format;` 227. `compressPdf = options.compress || options.compressPdf || compressPdf;` 228. `encryptionOptions = options.encryption || null;` 229. `if (encryptionOptions !== null) {` 230. `encryptionOptions.userPassword = encryptionOptions.userPassword || "";` 231. `encryptionOptions.ownerPassword = encryptionOptions.ownerPassword || "";` 232. `encryptionOptions.userPermissions =` 233. `encryptionOptions.userPermissions || [];` 234. `}` 235. `userUnit =` 236. `typeof options.userUnit === "number" ? Math.abs(options.userUnit) : 1.0;` 237. `if (typeof options.precision !== "undefined") {` 238. `precision = options.precision;` 239. `}` 240. `if (typeof options.floatPrecision !== "undefined") {` 241. `floatPrecision = options.floatPrecision;` 242. `}` 243. `defaultPathOperation = options.defaultPathOperation || "S";` 244. `}` 246. `filters =` 247. `options.filters || (compressPdf === true ? ["FlateEncode"] : filters);` 249. `unit = unit || "mm";` 250. `orientation = ("" + (orientation || "P")).toLowerCase();` 251. `var putOnlyUsedFonts = options.putOnlyUsedFonts || false;` 252. `var usedFonts = {};` 254. `var API = {` 255. `internal: {},` 256. `__private__: {}` 257. `};` 259. `API.__private__.PubSub = PubSub;` 261. `var pdfVersion = "1.3";` 262. `var getPdfVersion = (API.__private__.getPdfVersion = function() {` 263. `return pdfVersion;` 264. `});` 266. `API.__private__.setPdfVersion = function(value) {` 267. `pdfVersion = value;` 268. `};` 270. `// Size in pt of various paper formats` 271. `var pageFormats = {` 272. `a0: [2383.94, 3370.39],` 273. `a1: [1683.78, 2383.94],` 274. `a2: [1190.55, 1683.78],` 275. `a3: [841.89, 1190.55],` 276. `a4: [595.28, 841.89],` 277. `a5: [419.53, 595.28],` 278. `a6: [297.64, 419.53],` 279. `a7: [209.76, 297.64],` 280. `a8: [147.4, 209.76],` 281. `a9: [104.88, 147.4],` 282. `a10: [73.7, 104.88],` 283. `b0: [2834.65, 4008.19],` 284. `b1: [2004.09, 2834.65],` 285. `b2: [1417.32, 2004.09],` 286. `b3: [1000.63, 1417.32],` 287. `b4: [708.66, 1000.63],` 288. `b5: [498.9, 708.66],` 289. `b6: [354.33, 498.9],` 290. `b7: [249.45, 354.33],` 291. `b8: [175.75, 249.45],` 292. `b9: [124.72, 175.75],` 293. `b10: [87.87, 124.72],` 294. `c0: [2599.37, 3676.54],` 295. `c1: [1836.85, 2599.37],` 296. `c2: [1298.27, 1836.85],` 297. `c3: [918.43, 1298.27],` 298. `c4: [649.13, 918.43],` 299. `c5: [459.21, 649.13],` 300. `c6: [323.15, 459.21],` 301. `c7: [229.61, 323.15],` 302. `c8: [161.57, 229.61],` 303. `c9: [113.39, 161.57],` 304. `c10: [79.37, 113.39],` 305. `dl: [311.81, 623.62],` 306. `letter: [612, 792],` 307. `"government-letter": [576, 756],` 308. `legal: [612, 1008],` 309. `"junior-legal": [576, 360],` 310. `ledger: [1224, 792],` 311. `tabloid: [792, 1224],` 312. `"credit-card": [153, 243]` 313. `};` 315. `API.__private__.getPageFormats = function() {` 316. `return pageFormats;` 317. `};` 319. `var getPageFormat = (API.__private__.getPageFormat = function(value) {` 320. `return pageFormats[value];` 321. `});` 323. `format = format || "a4";` 325. `var ApiMode = {` 326. `COMPAT: "compat",` 327. `ADVANCED: "advanced"` 328. `};` 329. `var apiMode = ApiMode.COMPAT;` 331. `function advancedAPI() {` 332. `// prepend global change of basis matrix` 333. `// (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix` 334. `// that does this job for us (however, texts, images and similar objects must be drawn bottom up))` 335. `this.saveGraphicsState();` 336. `out(` 337. `new Matrix(` 338. `scaleFactor,` 339. `0,` 340. `0,` 341. `-scaleFactor,` 342. `0,` 343. `getPageHeight() * scaleFactor` 344. `).toString() + " cm"` 345. `);` 346. `this.setFontSize(this.getFontSize() / scaleFactor);` 348. `// The default in MrRio's implementation is "S" (stroke), whereas the default in the yWorks implementation` 349. `// was "n" (none). Although this has nothing to do with transforms, we should use the API switch here.` 350. `defaultPathOperation = "n";` 352. `apiMode = ApiMode.ADVANCED;` 353. `}` 355. `function compatAPI() {` 356. `this.restoreGraphicsState();` 357. `defaultPathOperation = "S";` 358. `apiMode = ApiMode.COMPAT;` 359. `}` 361. `/**` 362. `* @function combineFontStyleAndFontWeight` 363. `* @param {string} fontStyle Fontstyle or variant. Example: "italic".` 364. `* @param {number | string} fontWeight Weight of the Font. Example: "normal" | 400` 365. `* @returns {string}` 366. `* @private` 367. `*/` 368. `var combineFontStyleAndFontWeight = (API.__private__.combineFontStyleAndFontWeight = function(` 369. `fontStyle,` 370. `fontWeight` 371. `) {` 372. `if (` 373. `(fontStyle == "bold" && fontWeight == "normal") ||` 374. `(fontStyle == "bold" && fontWeight == 400) ||` 375. `(fontStyle == "normal" && fontWeight == "italic") ||` 376. `(fontStyle == "bold" && fontWeight == "italic")` 377. `) {` 378. `throw new Error("Invalid Combination of fontweight and fontstyle");` 379. `}` 380. `if (fontWeight) {` 381. `fontStyle =` 382. `fontWeight == 400 || fontWeight === "normal"` 383. `? fontStyle === "italic"` 384. `? "italic"` 385. `: "normal"` 386. `: (fontWeight == 700 || fontWeight === "bold") &&` 387. `fontStyle === "normal"` 388. `? "bold"` 389. `: (fontWeight == 700 ? "bold" : fontWeight) + "" + fontStyle;` 390. `}` 391. `return fontStyle;` 392. `});` 394. `/**` 395. `* @callback ApiSwitchBody` 396. `* @param {jsPDF} pdf` 397. `*/` 399. `/**` 400. `* For compatibility reasons jsPDF offers two API modes which differ in the way they convert between the the usual` 401. `* screen coordinates and the PDF coordinate system.` 402. `* - "compat": Offers full compatibility across all plugins but does not allow arbitrary transforms` 403. `* - "advanced": Allows arbitrary transforms and more advanced features like pattern fills. Some plugins might` 404. `* not support this mode, though.` 405. `* Initial mode is "compat".` 406. `*` 407. `* You can either provide a callback to the body argument, which means that jsPDF will automatically switch back to` 408. `* the original API mode afterwards; or you can omit the callback and switch back manually using {@link compatAPI}.` 409. `*` 410. `* Note, that the calls to {@link saveGraphicsState} and {@link restoreGraphicsState} need to be balanced within the` 411. `* callback or between calls of this method and its counterpart {@link compatAPI}. Calls to {@link beginFormObject}` 412. `* or {@link beginTilingPattern} need to be closed by their counterparts before switching back to "compat" API mode.` 413. `*` 414. `* @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.` 415. `* The API mode will be switched back automatically afterwards.` 416. `* @returns {jsPDF}` 417. `* @memberof jsPDF#` 418. `* @name advancedAPI` 419. `*/` 420. `API.advancedAPI = function(body) {` 421. `var doSwitch = apiMode === ApiMode.COMPAT;` 423. `if (doSwitch) {` 424. `advancedAPI.call(this);` 425. `}` 427. `if (typeof body !== "function") {` 428. `return this;` 429. `}` 431. `body(this);` 433. `if (doSwitch) {` 434. `compatAPI.call(this);` 435. `}` 437. `return this;` 438. `};` 440. `/**` 441. `* Switches to "compat" API mode. See {@link advancedAPI} for more details.` 442. `*` 443. `* @param {ApiSwitchBody=} body When provided, this callback will be called after the API mode has been switched.` 444. `* The API mode will be switched back automatically afterwards.` 445. `* @return {jsPDF}` 446. `* @memberof jsPDF#` 447. `* @name compatApi` 448. `*/` 449. `API.compatAPI = function(body) {` 450. `var doSwitch = apiMode === ApiMode.ADVANCED;` 452. `if (doSwitch) {` 453. `compatAPI.call(this);` 454. `}` 456. `if (typeof body !== "function") {` 457. `return this;` 458. `}` 460. `body(this);` 462. `if (doSwitch) {` 463. `advancedAPI.call(this);` 464. `}` 466. `return this;` 467. `};` 469. `/**` 470. `* @return {boolean} True iff the current API mode is "advanced". See {@link advancedAPI}.` 471. `* @memberof jsPDF#` 472. `* @name isAdvancedAPI` 473. `*/` 474. `API.isAdvancedAPI = function() {` 475. `return apiMode === ApiMode.ADVANCED;` 476. `};` 478. `var advancedApiModeTrap = function(methodName) {` 479. `if (apiMode !== ApiMode.ADVANCED) {` 480. `throw new Error(` 481. `methodName +` 482. `" is only available in 'advanced' API mode. " +` 483. `"You need to call advancedAPI() first."` 484. `);` 485. `}` 486. `};` 488. `var roundToPrecision = (API.roundToPrecision = API.__private__.roundToPrecision = function(` 489. `number,` 490. `parmPrecision` 491. `) {` 492. `var tmpPrecision = precision || parmPrecision;` 493. `if (isNaN(number) || isNaN(tmpPrecision)) {` 494. `throw new Error("Invalid argument passed to jsPDF.roundToPrecision");` 495. `}` 496. `return number.toFixed(tmpPrecision).replace(/0+$/, "");` 497. `});` 499. `// high precision float` 500. `var hpf;` 501. `if (typeof floatPrecision === "number") {` 502. `hpf = API.hpf = API.__private__.hpf = function(number) {` 503. `if (isNaN(number)) {` 504. `throw new Error("Invalid argument passed to jsPDF.hpf");` 505. `}` 506. `return roundToPrecision(number, floatPrecision);` 507. `};` 508. `} else if (floatPrecision === "smart") {` 509. `hpf = API.hpf = API.__private__.hpf = function(number) {` 510. `if (isNaN(number)) {` 511. `throw new Error("Invalid argument passed to jsPDF.hpf");` 512. `}` 513. `if (number > -1 && number < 1) {` 514. `return roundToPrecision(number, 16);` 515. `} else {` 516. `return roundToPrecision(number, 5);` 517. `}` 518. `};` 519. `} else {` 520. `hpf = API.hpf = API.__private__.hpf = function(number) {` 521. `if (isNaN(number)) {` 522. `throw new Error("Invalid argument passed to jsPDF.hpf");` 523. `}` 524. `return roundToPrecision(number, 16);` 525. `};` 526. `}` 527. `var f2 = (API.f2 = API.__private__.f2 = function(number) {` 528. `if (isNaN(number)) {` 529. `throw new Error("Invalid argument passed to jsPDF.f2");` 530. `}` 531. `return roundToPrecision(number, 2);` 532. `});` 534. `var f3 = (API.__private__.f3 = function(number) {` 535. `if (isNaN(number)) {` 536. `throw new Error("Invalid argument passed to jsPDF.f3");` 537. `}` 538. `return roundToPrecision(number, 3);` 539. `});` 541. `var scale = (API.scale = API.__private__.scale = function(number) {` 542. `if (isNaN(number)) {` 543. `throw new Error("Invalid argument passed to jsPDF.scale");` 544. `}` 545. `if (apiMode === ApiMode.COMPAT) {` 546. `return number * scaleFactor;` 547. `} else if (apiMode === ApiMode.ADVANCED) {` 548. `return number;` 549. `}` 550. `});` 552. `var transformY = function(y) {` 553. `if (apiMode === ApiMode.COMPAT) {` 554. `return getPageHeight() - y;` 555. `} else if (apiMode === ApiMode.ADVANCED) {` 556. `return y;` 557. `}` 558. `};` 560. `var transformScaleY = function(y) {` 561. `return scale(transformY(y));` 562. `};` 564. `/**` 565. `* @name setPrecision` 566. `* @memberof jsPDF#` 567. `* @function` 568. `* @instance` 569. `* @param {string} precision` 570. `* @returns {jsPDF}` 571. `*/` 572. `API.__private__.setPrecision = API.setPrecision = function(value) {` 573. `if (typeof parseInt(value, 10) === "number") {` 574. `precision = parseInt(value, 10);` 575. `}` 576. `};` 578. `var fileId = "00000000000000000000000000000000";` 580. `var getFileId = (API.__private__.getFileId = function() {` 581. `return fileId;` 582. `});` 584. `var setFileId = (API.__private__.setFileId = function(value) {` 585. `if (typeof value !== "undefined" && /^[a-fA-F0-9]{32}$/.test(value)) {` 586. `fileId = value.toUpperCase();` 587. `} else {` 588. `fileId = fileId` 589. `.split("")` 590. `.map(function() {` 591. `return "ABCDEF0123456789".charAt(Math.floor(Math.random() * 16));` 592. `})` 593. `.join("");` 594. `}` 596. `if (encryptionOptions !== null) {` 597. `encryption = new PDFSecurity(` 598. `encryptionOptions.userPermissions,` 599. `encryptionOptions.userPassword,` 600. `encryptionOptions.ownerPassword,` 601. `fileId` 602. `);` 603. `}` 604. `return fileId;` 605. `});` 607. `/**` 608. `* @name setFileId` 609. `* @memberof jsPDF#` 610. `* @function` 611. `* @instance` 612. `* @param {string} value GUID.` 613. `* @returns {jsPDF}` 614. `*/` 615. `API.setFileId = function(value) {` 616. `setFileId(value);` 617. `return this;` 618. `};` 620. `/**` 621. `* @name getFileId` 622. `* @memberof jsPDF#` 623. `* @function` 624. `* @instance` 625. `*` 626. `* @returns {string} GUID.` 627. `*/` 628. `API.getFileId = function() {` 629. `return getFileId();` 630. `};` 632. `var creationDate;` 634. `var convertDateToPDFDate = (API.__private__.convertDateToPDFDate = function(` 635. `parmDate` 636. `) {` 637. `var result = "";` 638. `var tzoffset = parmDate.getTimezoneOffset(),` 639. `tzsign = tzoffset < 0 ? "+" : "-",` 640. `tzhour = Math.floor(Math.abs(tzoffset / 60)),` 641. `tzmin = Math.abs(tzoffset % 60),` 642. `timeZoneString = [tzsign, padd2(tzhour), "'", padd2(tzmin), "'"].join("");` 644. `result = [`\ 645. `"D:",`\ 646. `parmDate.getFullYear(),`\ 647. `padd2(parmDate.getMonth() + 1),`\ 648. `padd2(parmDate.getDate()),`\ 649. `padd2(parmDate.getHours()),`\ 650. `padd2(parmDate.getMinutes()),`\ 651. `padd2(parmDate.getSeconds()),`\ 652. `timeZoneString`\ 653. `].join("");` 654. `return result;` 655. `});` 657. `var convertPDFDateToDate = (API.__private__.convertPDFDateToDate = function(` 658. `parmPDFDate` 659. `) {` 660. `var year = parseInt(parmPDFDate.substr(2, 4), 10);` 661. `var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;` 662. `var date = parseInt(parmPDFDate.substr(8, 2), 10);` 663. `var hour = parseInt(parmPDFDate.substr(10, 2), 10);` 664. `var minutes = parseInt(parmPDFDate.substr(12, 2), 10);` 665. `var seconds = parseInt(parmPDFDate.substr(14, 2), 10);` 666. `// var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);` 667. `// var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);` 669. `var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);` 670. `return resultingDate;` 671. `});` 673. `var setCreationDate = (API.__private__.setCreationDate = function(date) {` 674. `var tmpCreationDateString;` 675. `var regexPDFCreationDate = /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/;` 676. `if (typeof date === "undefined") {` 677. `date = new Date();` 678. `}` 680. `if (date instanceof Date) {` 681. `tmpCreationDateString = convertDateToPDFDate(date);` 682. `} else if (regexPDFCreationDate.test(date)) {` 683. `tmpCreationDateString = date;` 684. `} else {` 685. `throw new Error("Invalid argument passed to jsPDF.setCreationDate");` 686. `}` 687. `creationDate = tmpCreationDateString;` 688. `return creationDate;` 689. `});` 691. `var getCreationDate = (API.__private__.getCreationDate = function(type) {` 692. `var result = creationDate;` 693. `if (type === "jsDate") {` 694. `result = convertPDFDateToDate(creationDate);` 695. `}` 696. `return result;` 697. `});` 699. `/**` 700. `* @name setCreationDate` 701. `* @memberof jsPDF#` 702. `* @function` 703. `* @instance` 704. `* @param {Object} date` 705. `* @returns {jsPDF}` 706. `*/` 707. `API.setCreationDate = function(date) {` 708. `setCreationDate(date);` 709. `return this;` 710. `};` 712. `/**` 713. `* @name getCreationDate` 714. `* @memberof jsPDF#` 715. `* @function` 716. `* @instance` 717. `* @param {Object} type` 718. `* @returns {Object}` 719. `*/` 720. `API.getCreationDate = function(type) {` 721. `return getCreationDate(type);` 722. `};` 724. `var padd2 = (API.__private__.padd2 = function(number) {` 725. `return ("0" + parseInt(number)).slice(-2);` 726. `});` 728. `var padd2Hex = (API.__private__.padd2Hex = function(hexString) {` 729. `hexString = hexString.toString();` 730. `return ("00" + hexString).substr(hexString.length);` 731. `});` 733. `var objectNumber = 0; // 'n' Current object number` 734. `var offsets = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.` 735. `var content = [];` 736. `var contentLength = 0;` 737. `var additionalObjects = [];` 739. `var pages = [];` 740. `var currentPage;` 741. `var hasCustomDestination = false;` 742. `var outputDestination = content;` 744. `var resetDocument = function() {` 745. `//reset fields relevant for objectNumber generation and xref.` 746. `objectNumber = 0;` 747. `contentLength = 0;` 748. `content = [];` 749. `offsets = [];` 750. `additionalObjects = [];` 752. `rootDictionaryObjId = newObjectDeferred();` 753. `resourceDictionaryObjId = newObjectDeferred();` 754. `};` 756. `API.__private__.setCustomOutputDestination = function(destination) {` 757. `hasCustomDestination = true;` 758. `outputDestination = destination;` 759. `};` 760. `var setOutputDestination = function(destination) {` 761. `if (!hasCustomDestination) {` 762. `outputDestination = destination;` 763. `}` 764. `};` 766. `API.__private__.resetCustomOutputDestination = function() {` 767. `hasCustomDestination = false;` 768. `outputDestination = content;` 769. `};` 771. `var out = (API.__private__.out = function(string) {` 772. `string = string.toString();` 773. `contentLength += string.length + 1;` 774. `outputDestination.push(string);` 776. `return outputDestination;` 777. `});` 779. `var write = (API.__private__.write = function(value) {` 780. `return out(` 781. `arguments.length === 1` 782. `? value.toString()` 783. `: Array.prototype.join.call(arguments, " ")` 784. `);` 785. `});` 787. `var getArrayBuffer = (API.__private__.getArrayBuffer = function(data) {` 788. `var len = data.length,` 789. `ab = new ArrayBuffer(len),` 790. `u8 = new Uint8Array(ab);` 792. `while (len--) u8[len] = data.charCodeAt(len);` 793. `return ab;` 794. `});` 796. `var standardFonts = [`\ 797. `["Helvetica", "helvetica", "normal", "WinAnsiEncoding"],`\ 798. `["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"],`\ 799. `["Helvetica-Oblique", "helvetica", "italic", "WinAnsiEncoding"],`\ 800. `["Helvetica-BoldOblique", "helvetica", "bolditalic", "WinAnsiEncoding"],`\ 801. `["Courier", "courier", "normal", "WinAnsiEncoding"],`\ 802. `["Courier-Bold", "courier", "bold", "WinAnsiEncoding"],`\ 803. `["Courier-Oblique", "courier", "italic", "WinAnsiEncoding"],`\ 804. `["Courier-BoldOblique", "courier", "bolditalic", "WinAnsiEncoding"],`\ 805. `["Times-Roman", "times", "normal", "WinAnsiEncoding"],`\ 806. `["Times-Bold", "times", "bold", "WinAnsiEncoding"],`\ 807. `["Times-Italic", "times", "italic", "WinAnsiEncoding"],`\ 808. `["Times-BoldItalic", "times", "bolditalic", "WinAnsiEncoding"],`\ 809. `["ZapfDingbats", "zapfdingbats", "normal", null],`\ 810. `["Symbol", "symbol", "normal", null]`\ 811. `];` 813. `API.__private__.getStandardFonts = function() {` 814. `return standardFonts;` 815. `};` 817. `var activeFontSize = options.fontSize || 16;` 819. `/**` 820. `* Sets font size for upcoming text elements.` 821. `*` 822. `* @param {number} size Font size in points.` 823. `* @function` 824. `* @instance` 825. `* @returns {jsPDF}` 826. `* @memberof jsPDF#` 827. `* @name setFontSize` 828. `*/` 829. `API.__private__.setFontSize = API.setFontSize = function(size) {` 830. `if (apiMode === ApiMode.ADVANCED) {` 831. `activeFontSize = size / scaleFactor;` 832. `} else {` 833. `activeFontSize = size;` 834. `}` 835. `return this;` 836. `};` 838. `/**` 839. `* Gets the fontsize for upcoming text elements.` 840. `*` 841. `* @function` 842. `* @instance` 843. `* @returns {number}` 844. `* @memberof jsPDF#` 845. `* @name getFontSize` 846. `*/` 847. `var getFontSize = (API.__private__.getFontSize = API.getFontSize = function() {` 848. `if (apiMode === ApiMode.COMPAT) {` 849. `return activeFontSize;` 850. `} else {` 851. `return activeFontSize * scaleFactor;` 852. `}` 853. `});` 855. `var R2L = options.R2L || false;` 857. `/**` 858. `* Set value of R2L functionality.` 859. `*` 860. `* @param {boolean} value` 861. `* @function` 862. `* @instance` 863. `* @returns {jsPDF} jsPDF-instance` 864. `* @memberof jsPDF#` 865. `* @name setR2L` 866. `*/` 867. `API.__private__.setR2L = API.setR2L = function(value) {` 868. `R2L = value;` 869. `return this;` 870. `};` 872. `/**` 873. `* Get value of R2L functionality.` 874. `*` 875. `* @function` 876. `* @instance` 877. `* @returns {boolean} jsPDF-instance` 878. `* @memberof jsPDF#` 879. `* @name getR2L` 880. `*/` 881. `API.__private__.getR2L = API.getR2L = function() {` 882. `return R2L;` 883. `};` 885. `var zoomMode; // default: 1;` 887. `var setZoomMode = (API.__private__.setZoomMode = function(zoom) {` 888. `var validZoomModes = [`\ 889. `undefined,`\ 890. `null,`\ 891. `"fullwidth",`\ 892. `"fullheight",`\ 893. `"fullpage",`\ 894. `"original"`\ 895. `];` 897. `if (/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(zoom)) {` 898. `zoomMode = zoom;` 899. `} else if (!isNaN(zoom)) {` 900. `zoomMode = parseInt(zoom, 10);` 901. `} else if (validZoomModes.indexOf(zoom) !== -1) {` 902. `zoomMode = zoom;` 903. `} else {` 904. `throw new Error(` 905. `'zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "' +` 906. `zoom +` 907. `'" is not recognized.'` 908. `);` 909. `}` 910. `});` 912. `API.__private__.getZoomMode = function() {` 913. `return zoomMode;` 914. `};` 916. `var pageMode; // default: 'UseOutlines';` 917. `var setPageMode = (API.__private__.setPageMode = function(pmode) {` 918. `var validPageModes = [`\ 919. `undefined,`\ 920. `null,`\ 921. `"UseNone",`\ 922. `"UseOutlines",`\ 923. `"UseThumbs",`\ 924. `"FullScreen"`\ 925. `];` 927. `if (validPageModes.indexOf(pmode) == -1) {` 928. `throw new Error(` 929. `'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' +` 930. `pmode +` 931. `'" is not recognized.'` 932. `);` 933. `}` 934. `pageMode = pmode;` 935. `});` 937. `API.__private__.getPageMode = function() {` 938. `return pageMode;` 939. `};` 941. `var layoutMode; // default: 'continuous';` 942. `var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {` 943. `var validLayoutModes = [`\ 944. `undefined,`\ 945. `null,`\ 946. `"continuous",`\ 947. `"single",`\ 948. `"twoleft",`\ 949. `"tworight",`\ 950. `"two"`\ 951. `];` 953. `if (validLayoutModes.indexOf(layout) == -1) {` 954. `throw new Error(` 955. `'Layout mode must be one of continuous, single, twoleft, tworight. "' +` 956. `layout +` 957. `'" is not recognized.'` 958. `);` 959. `}` 960. `layoutMode = layout;` 961. `});` 963. `API.__private__.getLayoutMode = function() {` 964. `return layoutMode;` 965. `};` 967. `/**` 968. `* Set the display mode options of the page like zoom and layout.` 969. `*` 970. `* @name setDisplayMode` 971. `* @memberof jsPDF#` 972. `* @function` 973. `* @instance` 974. `* @param {integer|String} zoom You can pass an integer or percentage as` 975. `* a string. 2 will scale the document up 2x, '200%' will scale up by the` 976. `* same amount. You can also set it to 'fullwidth', 'fullheight',` 977. `* 'fullpage', or 'original'.` 978. `*` 979. `* Only certain PDF readers support this, such as Adobe Acrobat.` 980. `*` 981. `* @param {string} layout Layout mode can be: 'continuous' - this is the` 982. `* default continuous scroll. 'single' - the single page mode only shows one` 983. `* page at a time. 'twoleft' - two column left mode, first page starts on` 984. `* the left, and 'tworight' - pages are laid out in two columns, with the` 985. `* first page on the right. This would be used for books.` 986. `* @param {string} pmode 'UseOutlines' - it shows the` 987. `* outline of the document on the left. 'UseThumbs' - shows thumbnails along` 988. `* the left. 'FullScreen' - prompts the user to enter fullscreen mode.` 989. `*` 990. `* @returns {jsPDF}` 991. `*/` 992. `API.__private__.setDisplayMode = API.setDisplayMode = function(` 993. `zoom,` 994. `layout,` 995. `pmode` 996. `) {` 997. `setZoomMode(zoom);` 998. `setLayoutMode(layout);` 999. `setPageMode(pmode);` 1000. `return this;` 1001. `};` 1003. `var documentProperties = {` 1004. `title: "",` 1005. `subject: "",` 1006. `author: "",` 1007. `keywords: "",` 1008. `creator: ""` 1009. `};` 1011. `API.__private__.getDocumentProperty = function(key) {` 1012. `if (Object.keys(documentProperties).indexOf(key) === -1) {` 1013. `throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");` 1014. `}` 1015. `return documentProperties[key];` 1016. `};` 1018. `API.__private__.getDocumentProperties = function() {` 1019. `return documentProperties;` 1020. `};` 1022. `/**` 1023. `* Adds a properties to the PDF document.` 1024. `*` 1025. `* @param {Object} A property_name-to-property_value object structure.` 1026. `* @function` 1027. `* @instance` 1028. `* @returns {jsPDF}` 1029. `* @memberof jsPDF#` 1030. `* @name setDocumentProperties` 1031. `*/` 1032. `API.__private__.setDocumentProperties = API.setProperties = API.setDocumentProperties = function(` 1033. `properties` 1034. `) {` 1035. `// copying only those properties we can render.` 1036. `for (var property in documentProperties) {` 1037. `if (documentProperties.hasOwnProperty(property) && properties[property]) {` 1038. `documentProperties[property] = properties[property];` 1039. `}` 1040. `}` 1041. `return this;` 1042. `};` 1044. `API.__private__.setDocumentProperty = function(key, value) {` 1045. `if (Object.keys(documentProperties).indexOf(key) === -1) {` 1046. `throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");` 1047. `}` 1048. `return (documentProperties[key] = value);` 1049. `};` 1051. `var fonts = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font.` 1052. `var fontmap = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont()` 1053. `var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle` 1054. `var fontStateStack = []; //` 1055. `var patterns = {}; // collection of pattern objects` 1056. `var patternMap = {}; // see fonts` 1057. `var gStates = {}; // collection of graphic state objects` 1058. `var gStatesMap = {}; // see fonts` 1059. `var activeGState = null;` 1060. `var scaleFactor; // Scale factor` 1061. `var page = 0;` 1062. `var pagesContext = [];` 1063. `var events = new PubSub(API);` 1064. `var hotfixes = options.hotfixes || [];` 1066. `var renderTargets = {};` 1067. `var renderTargetMap = {};` 1068. `var renderTargetStack = [];` 1069. `var pageX;` 1070. `var pageY;` 1071. `var pageMatrix; // only used for FormObjects` 1073. `/**` 1074. `* A matrix object for 2D homogenous transformations:
    ` 1075. `* | a b 0 |
    ` 1076. `* | c d 0 |
    ` 1077. `* | e f 1 |
    ` 1078. `* pdf multiplies matrices righthand: v' = v x m1 x m2 x ...` 1079. `*` 1080. `* @class` 1081. `* @name Matrix` 1082. `* @param {number} sx` 1083. `* @param {number} shy` 1084. `* @param {number} shx` 1085. `* @param {number} sy` 1086. `* @param {number} tx` 1087. `* @param {number} ty` 1088. `* @constructor` 1089. `*/` 1090. `var Matrix = function(sx, shy, shx, sy, tx, ty) {` 1091. `if (!(this instanceof Matrix)) {` 1092. `return new Matrix(sx, shy, shx, sy, tx, ty);` 1093. `}` 1095. `if (isNaN(sx)) sx = 1;` 1096. `if (isNaN(shy)) shy = 0;` 1097. `if (isNaN(shx)) shx = 0;` 1098. `if (isNaN(sy)) sy = 1;` 1099. `if (isNaN(tx)) tx = 0;` 1100. `if (isNaN(ty)) ty = 0;` 1102. `this._matrix = [sx, shy, shx, sy, tx, ty];` 1103. `};` 1105. `/**` 1106. `* @name sx` 1107. `* @memberof Matrix#` 1108. `*/` 1109. `Object.defineProperty(Matrix.prototype, "sx", {` 1110. `get: function() {` 1111. `return this._matrix[0];` 1112. `},` 1113. `set: function(value) {` 1114. `this._matrix[0] = value;` 1115. `}` 1116. `});` 1118. `/**` 1119. `* @name shy` 1120. `* @memberof Matrix#` 1121. `*/` 1122. `Object.defineProperty(Matrix.prototype, "shy", {` 1123. `get: function() {` 1124. `return this._matrix[1];` 1125. `},` 1126. `set: function(value) {` 1127. `this._matrix[1] = value;` 1128. `}` 1129. `});` 1131. `/**` 1132. `* @name shx` 1133. `* @memberof Matrix#` 1134. `*/` 1135. `Object.defineProperty(Matrix.prototype, "shx", {` 1136. `get: function() {` 1137. `return this._matrix[2];` 1138. `},` 1139. `set: function(value) {` 1140. `this._matrix[2] = value;` 1141. `}` 1142. `});` 1144. `/**` 1145. `* @name sy` 1146. `* @memberof Matrix#` 1147. `*/` 1148. `Object.defineProperty(Matrix.prototype, "sy", {` 1149. `get: function() {` 1150. `return this._matrix[3];` 1151. `},` 1152. `set: function(value) {` 1153. `this._matrix[3] = value;` 1154. `}` 1155. `});` 1157. `/**` 1158. `* @name tx` 1159. `* @memberof Matrix#` 1160. `*/` 1161. `Object.defineProperty(Matrix.prototype, "tx", {` 1162. `get: function() {` 1163. `return this._matrix[4];` 1164. `},` 1165. `set: function(value) {` 1166. `this._matrix[4] = value;` 1167. `}` 1168. `});` 1170. `/**` 1171. `* @name ty` 1172. `* @memberof Matrix#` 1173. `*/` 1174. `Object.defineProperty(Matrix.prototype, "ty", {` 1175. `get: function() {` 1176. `return this._matrix[5];` 1177. `},` 1178. `set: function(value) {` 1179. `this._matrix[5] = value;` 1180. `}` 1181. `});` 1183. `Object.defineProperty(Matrix.prototype, "a", {` 1184. `get: function() {` 1185. `return this._matrix[0];` 1186. `},` 1187. `set: function(value) {` 1188. `this._matrix[0] = value;` 1189. `}` 1190. `});` 1192. `Object.defineProperty(Matrix.prototype, "b", {` 1193. `get: function() {` 1194. `return this._matrix[1];` 1195. `},` 1196. `set: function(value) {` 1197. `this._matrix[1] = value;` 1198. `}` 1199. `});` 1201. `Object.defineProperty(Matrix.prototype, "c", {` 1202. `get: function() {` 1203. `return this._matrix[2];` 1204. `},` 1205. `set: function(value) {` 1206. `this._matrix[2] = value;` 1207. `}` 1208. `});` 1210. `Object.defineProperty(Matrix.prototype, "d", {` 1211. `get: function() {` 1212. `return this._matrix[3];` 1213. `},` 1214. `set: function(value) {` 1215. `this._matrix[3] = value;` 1216. `}` 1217. `});` 1219. `Object.defineProperty(Matrix.prototype, "e", {` 1220. `get: function() {` 1221. `return this._matrix[4];` 1222. `},` 1223. `set: function(value) {` 1224. `this._matrix[4] = value;` 1225. `}` 1226. `});` 1228. `Object.defineProperty(Matrix.prototype, "f", {` 1229. `get: function() {` 1230. `return this._matrix[5];` 1231. `},` 1232. `set: function(value) {` 1233. `this._matrix[5] = value;` 1234. `}` 1235. `});` 1237. `/**` 1238. `* @name rotation` 1239. `* @memberof Matrix#` 1240. `*/` 1241. `Object.defineProperty(Matrix.prototype, "rotation", {` 1242. `get: function() {` 1243. `return Math.atan2(this.shx, this.sx);` 1244. `}` 1245. `});` 1247. `/**` 1248. `* @name scaleX` 1249. `* @memberof Matrix#` 1250. `*/` 1251. `Object.defineProperty(Matrix.prototype, "scaleX", {` 1252. `get: function() {` 1253. `return this.decompose().scale.sx;` 1254. `}` 1255. `});` 1257. `/**` 1258. `* @name scaleY` 1259. `* @memberof Matrix#` 1260. `*/` 1261. `Object.defineProperty(Matrix.prototype, "scaleY", {` 1262. `get: function() {` 1263. `return this.decompose().scale.sy;` 1264. `}` 1265. `});` 1267. `/**` 1268. `* @name isIdentity` 1269. `* @memberof Matrix#` 1270. `*/` 1271. `Object.defineProperty(Matrix.prototype, "isIdentity", {` 1272. `get: function() {` 1273. `if (this.sx !== 1) {` 1274. `return false;` 1275. `}` 1276. `if (this.shy !== 0) {` 1277. `return false;` 1278. `}` 1279. `if (this.shx !== 0) {` 1280. `return false;` 1281. `}` 1282. `if (this.sy !== 1) {` 1283. `return false;` 1284. `}` 1285. `if (this.tx !== 0) {` 1286. `return false;` 1287. `}` 1288. `if (this.ty !== 0) {` 1289. `return false;` 1290. `}` 1291. `return true;` 1292. `}` 1293. `});` 1295. `/**` 1296. `* Join the Matrix Values to a String` 1297. `*` 1298. `* @function join` 1299. `* @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.` 1300. `* @returns {string} A string with all array elements joined.` 1301. `* @memberof Matrix#` 1302. `*/` 1303. `Matrix.prototype.join = function(separator) {` 1304. `return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty]` 1305. `.map(hpf)` 1306. `.join(separator);` 1307. `};` 1309. `/**` 1310. `* Multiply the matrix with given Matrix` 1311. `*` 1312. `* @function multiply` 1313. `* @param matrix` 1314. `* @returns {Matrix}` 1315. `* @memberof Matrix#` 1316. `*/` 1317. `Matrix.prototype.multiply = function(matrix) {` 1318. `var sx = matrix.sx * this.sx + matrix.shy * this.shx;` 1319. `var shy = matrix.sx * this.shy + matrix.shy * this.sy;` 1320. `var shx = matrix.shx * this.sx + matrix.sy * this.shx;` 1321. `var sy = matrix.shx * this.shy + matrix.sy * this.sy;` 1322. `var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx;` 1323. `var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty;` 1325. `return new Matrix(sx, shy, shx, sy, tx, ty);` 1326. `};` 1328. `/**` 1329. `* @function decompose` 1330. `* @memberof Matrix#` 1331. `*/` 1332. `Matrix.prototype.decompose = function() {` 1333. `var a = this.sx;` 1334. `var b = this.shy;` 1335. `var c = this.shx;` 1336. `var d = this.sy;` 1337. `var e = this.tx;` 1338. `var f = this.ty;` 1340. `var scaleX = Math.sqrt(a * a + b * b);` 1341. `a /= scaleX;` 1342. `b /= scaleX;` 1344. `var shear = a * c + b * d;` 1345. `c -= a * shear;` 1346. `d -= b * shear;` 1348. `var scaleY = Math.sqrt(c * c + d * d);` 1349. `c /= scaleY;` 1350. `d /= scaleY;` 1351. `shear /= scaleY;` 1353. `if (a * d < b * c) {` 1354. `a = -a;` 1355. `b = -b;` 1356. `shear = -shear;` 1357. `scaleX = -scaleX;` 1358. `}` 1360. `return {` 1361. `scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),` 1362. `translate: new Matrix(1, 0, 0, 1, e, f),` 1363. `rotate: new Matrix(a, b, -b, a, 0, 0),` 1364. `skew: new Matrix(1, 0, shear, 1, 0, 0)` 1365. `};` 1366. `};` 1368. `/**` 1369. `* @function toString` 1370. `* @memberof Matrix#` 1371. `*/` 1372. `Matrix.prototype.toString = function(parmPrecision) {` 1373. `return this.join(" ");` 1374. `};` 1376. `/**` 1377. `* @function inversed` 1378. `* @memberof Matrix#` 1379. `*/` 1380. `Matrix.prototype.inversed = function() {` 1381. `var a = this.sx,` 1382. `b = this.shy,` 1383. `c = this.shx,` 1384. `d = this.sy,` 1385. `e = this.tx,` 1386. `f = this.ty;` 1388. `var quot = 1 / (a * d - b * c);` 1390. `var aInv = d * quot;` 1391. `var bInv = -b * quot;` 1392. `var cInv = -c * quot;` 1393. `var dInv = a * quot;` 1394. `var eInv = -aInv * e - cInv * f;` 1395. `var fInv = -bInv * e - dInv * f;` 1397. `return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);` 1398. `};` 1400. `/**` 1401. `* @function applyToPoint` 1402. `* @memberof Matrix#` 1403. `*/` 1404. `Matrix.prototype.applyToPoint = function(pt) {` 1405. `var x = pt.x * this.sx + pt.y * this.shx + this.tx;` 1406. `var y = pt.x * this.shy + pt.y * this.sy + this.ty;` 1407. `return new Point(x, y);` 1408. `};` 1410. `/**` 1411. `* @function applyToRectangle` 1412. `* @memberof Matrix#` 1413. `*/` 1414. `Matrix.prototype.applyToRectangle = function(rect) {` 1415. `var pt1 = this.applyToPoint(rect);` 1416. `var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));` 1417. `return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);` 1418. `};` 1420. `/**` 1421. `* Clone the Matrix` 1422. `*` 1423. `* @function clone` 1424. `* @memberof Matrix#` 1425. `* @name clone` 1426. `* @instance` 1427. `*/` 1428. `Matrix.prototype.clone = function() {` 1429. `var sx = this.sx;` 1430. `var shy = this.shy;` 1431. `var shx = this.shx;` 1432. `var sy = this.sy;` 1433. `var tx = this.tx;` 1434. `var ty = this.ty;` 1436. `return new Matrix(sx, shy, shx, sy, tx, ty);` 1437. `};` 1439. `API.Matrix = Matrix;` 1441. `/**` 1442. `* Multiplies two matrices. (see {@link Matrix})` 1443. `* @param {Matrix} m1` 1444. `* @param {Matrix} m2` 1445. `* @memberof jsPDF#` 1446. `* @name matrixMult` 1447. `*/` 1448. `var matrixMult = (API.matrixMult = function(m1, m2) {` 1449. `return m2.multiply(m1);` 1450. `});` 1452. `/**` 1453. `* The identity matrix (equivalent to new Matrix(1, 0, 0, 1, 0, 0)).` 1454. `* @type {Matrix}` 1455. `* @memberof! jsPDF#` 1456. `* @name identityMatrix` 1457. `*/` 1458. `var identityMatrix = new Matrix(1, 0, 0, 1, 0, 0);` 1459. `API.unitMatrix = API.identityMatrix = identityMatrix;` 1461. `/**` 1462. `* Adds a new pattern for later use.` 1463. `* @param {String} key The key by it can be referenced later. The keys must be unique!` 1464. `* @param {API.Pattern} pattern The pattern` 1465. `*/` 1466. `var addPattern = function(key, pattern) {` 1467. `// only add it if it is not already present (the keys provided by the user must be unique!)` 1468. `if (patternMap[key]) return;` 1470. `var prefix = pattern instanceof ShadingPattern ? "Sh" : "P";` 1471. `var patternKey = prefix + (Object.keys(patterns).length + 1).toString(10);` 1472. `pattern.id = patternKey;` 1474. `patternMap[key] = patternKey;` 1475. `patterns[patternKey] = pattern;` 1477. `events.publish("addPattern", pattern);` 1478. `};` 1480. `/**` 1481. `* A pattern describing a shading pattern.` 1482. `*` 1483. `* Only available in "advanced" API mode.` 1484. `*` 1485. `* @param {String} type One of "axial" or "radial"` 1486. `* @param {Array} coords Either [x1, y1, x2, y2] for "axial" type describing the two interpolation points` 1487. `* or [x1, y1, r, x2, y2, r2] for "radial" describing inner and the outer circle.` 1488. `* @param {Array} colors An array of objects with the fields "offset" and "color". "offset" describes` 1489. `* the offset in parameter space [0, 1]. "color" is an array of length 3 describing RGB values in [0, 255].` 1490. `* @param {GState=} gState An additional graphics state that gets applied to the pattern (optional).` 1491. `* @param {Matrix=} matrix A matrix that describes the transformation between the pattern coordinate system` 1492. `* and the use coordinate system (optional).` 1493. `* @constructor` 1494. `* @extends API.Pattern` 1495. `*/` 1496. `API.ShadingPattern = ShadingPattern;` 1498. `/**` 1499. `* A PDF Tiling pattern.` 1500. `*` 1501. `* Only available in "advanced" API mode.` 1502. `*` 1503. `* @param {Array.} boundingBox The bounding box at which one pattern cell gets clipped.` 1504. `* @param {Number} xStep Horizontal spacing between pattern cells.` 1505. `* @param {Number} yStep Vertical spacing between pattern cells.` 1506. `* @param {API.GState=} gState An additional graphics state that gets applied to the pattern (optional).` 1507. `* @param {Matrix=} matrix A matrix that describes the transformation between the pattern coordinate system` 1508. `* and the use coordinate system (optional).` 1509. `* @constructor` 1510. `* @extends API.Pattern` 1511. `*/` 1512. `API.TilingPattern = TilingPattern;` 1514. `/**` 1515. `* Adds a new {@link API.ShadingPattern} for later use. Only available in "advanced" API mode.` 1516. `* @param {String} key` 1517. `* @param {Pattern} pattern` 1518. `* @function` 1519. `* @returns {jsPDF}` 1520. `* @memberof jsPDF#` 1521. `* @name addPattern` 1522. `*/` 1523. `API.addShadingPattern = function(key, pattern) {` 1524. `advancedApiModeTrap("addShadingPattern()");` 1526. `addPattern(key, pattern);` 1527. `return this;` 1528. `};` 1530. `/**` 1531. `* Begins a new tiling pattern. All subsequent render calls are drawn to this pattern until {@link API.endTilingPattern}` 1532. `* gets called. Only available in "advanced" API mode.` 1533. `* @param {API.Pattern} pattern` 1534. `* @memberof jsPDF#` 1535. `* @name beginTilingPattern` 1536. `*/` 1537. `API.beginTilingPattern = function(pattern) {` 1538. `advancedApiModeTrap("beginTilingPattern()");` 1540. `beginNewRenderTarget(` 1541. `pattern.boundingBox[0],` 1542. `pattern.boundingBox[1],` 1543. `pattern.boundingBox[2] - pattern.boundingBox[0],` 1544. `pattern.boundingBox[3] - pattern.boundingBox[1],` 1545. `pattern.matrix` 1546. `);` 1547. `};` 1549. `/**` 1550. `* Ends a tiling pattern and sets the render target to the one active before {@link API.beginTilingPattern} has been called.` 1551. `*` 1552. `* Only available in "advanced" API mode.` 1553. `*` 1554. `* @param {string} key A unique key that is used to reference this pattern at later use.` 1555. `* @param {API.Pattern} pattern The pattern to end.` 1556. `* @memberof jsPDF#` 1557. `* @name endTilingPattern` 1558. `*/` 1559. `API.endTilingPattern = function(key, pattern) {` 1560. `advancedApiModeTrap("endTilingPattern()");` 1562. `// retrieve the stream` 1563. `pattern.stream = pages[currentPage].join("\n");` 1565. `addPattern(key, pattern);` 1567. `events.publish("endTilingPattern", pattern);` 1569. `// restore state from stack` 1570. `renderTargetStack.pop().restore();` 1571. `};` 1573. `var newObject = (API.__private__.newObject = function() {` 1574. `var oid = newObjectDeferred();` 1575. `newObjectDeferredBegin(oid, true);` 1576. `return oid;` 1577. `});` 1579. `// Does not output the object. The caller must call newObjectDeferredBegin(oid) before outputing any data` 1580. `var newObjectDeferred = (API.__private__.newObjectDeferred = function() {` 1581. `objectNumber++;` 1582. `offsets[objectNumber] = function() {` 1583. `return contentLength;` 1584. `};` 1585. `return objectNumber;` 1586. `});` 1588. `var newObjectDeferredBegin = function(oid, doOutput) {` 1589. `doOutput = typeof doOutput === "boolean" ? doOutput : false;` 1590. `offsets[oid] = contentLength;` 1591. `if (doOutput) {` 1592. `out(oid + " 0 obj");` 1593. `}` 1594. `return oid;` 1595. `};` 1596. `// Does not output the object until after the pages have been output.` 1597. `// Returns an object containing the objectId and content.` 1598. `// All pages have been added so the object ID can be estimated to start right after.` 1599. `// This does not modify the current objectNumber; It must be updated after the newObjects are output.` 1600. `var newAdditionalObject = (API.__private__.newAdditionalObject = function() {` 1601. `var objId = newObjectDeferred();` 1602. `var obj = {` 1603. `objId: objId,` 1604. `content: ""` 1605. `};` 1606. `additionalObjects.push(obj);` 1607. `return obj;` 1608. `});` 1610. `var rootDictionaryObjId = newObjectDeferred();` 1611. `var resourceDictionaryObjId = newObjectDeferred();` 1613. `/////////////////////` 1614. `// Private functions` 1615. `/////////////////////` 1617. `var decodeColorString = (API.__private__.decodeColorString = function(color) {` 1618. `var colorEncoded = color.split(" ");` 1619. `if (` 1620. `colorEncoded.length === 2 &&` 1621. `(colorEncoded[1] === "g" || colorEncoded[1] === "G")` 1622. `) {` 1623. `// convert grayscale value to rgb so that it can be converted to hex for consistency` 1624. `var floatVal = parseFloat(colorEncoded[0]);` 1625. `colorEncoded = [floatVal, floatVal, floatVal, "r"];` 1626. `} else if (` 1627. `colorEncoded.length === 5 &&` 1628. `(colorEncoded[4] === "k" || colorEncoded[4] === "K")` 1629. `) {` 1630. `// convert CMYK values to rbg so that it can be converted to hex for consistency` 1631. `var red = (1.0 - colorEncoded[0]) * (1.0 - colorEncoded[3]);` 1632. `var green = (1.0 - colorEncoded[1]) * (1.0 - colorEncoded[3]);` 1633. `var blue = (1.0 - colorEncoded[2]) * (1.0 - colorEncoded[3]);` 1635. `colorEncoded = [red, green, blue, "r"];` 1636. `}` 1637. `var colorAsRGB = "#";` 1638. `for (var i = 0; i < 3; i++) {` 1639. `colorAsRGB += (` 1640. `"0" + Math.floor(parseFloat(colorEncoded[i]) * 255).toString(16)` 1641. `).slice(-2);` 1642. `}` 1643. `return colorAsRGB;` 1644. `});` 1646. `var encodeColorString = (API.__private__.encodeColorString = function(` 1647. `options` 1648. `) {` 1649. `var color;` 1651. `if (typeof options === "string") {` 1652. `options = {` 1653. `ch1: options` 1654. `};` 1655. `}` 1656. `var ch1 = options.ch1;` 1657. `var ch2 = options.ch2;` 1658. `var ch3 = options.ch3;` 1659. `var ch4 = options.ch4;` 1660. `var letterArray =` 1661. `options.pdfColorType === "draw" ? ["G", "RG", "K"] : ["g", "rg", "k"];` 1663. `if (typeof ch1 === "string" && ch1.charAt(0) !== "#") {` 1664. `var rgbColor = new RGBColor(ch1);` 1665. `if (rgbColor.ok) {` 1666. `ch1 = rgbColor.toHex();` 1667. `} else if (!/^\d*\.?\d*$/.test(ch1)) {` 1668. `throw new Error(` 1669. `'Invalid color "' + ch1 + '" passed to jsPDF.encodeColorString.'` 1670. `);` 1671. `}` 1672. `}` 1673. `//convert short rgb to long form` 1674. `if (typeof ch1 === "string" && /^#[0-9A-Fa-f]{3}$/.test(ch1)) {` 1675. `ch1 = "#" + ch1[1] + ch1[1] + ch1[2] + ch1[2] + ch1[3] + ch1[3];` 1676. `}` 1678. `if (typeof ch1 === "string" && /^#[0-9A-Fa-f]{6}$/.test(ch1)) {` 1679. `var hex = parseInt(ch1.substr(1), 16);` 1680. `ch1 = (hex >> 16) & 255;` 1681. `ch2 = (hex >> 8) & 255;` 1682. `ch3 = hex & 255;` 1683. `}` 1685. `if (` 1686. `typeof ch2 === "undefined" ||` 1687. `(typeof ch4 === "undefined" && ch1 === ch2 && ch2 === ch3)` 1688. `) {` 1689. `// Gray color space.` 1690. `if (typeof ch1 === "string") {` 1691. `color = ch1 + " " + letterArray[0];` 1692. `} else {` 1693. `switch (options.precision) {` 1694. `case 2:` 1695. `color = f2(ch1 / 255) + " " + letterArray[0];` 1696. `break;` 1697. `case 3:` 1698. `default:` 1699. `color = f3(ch1 / 255) + " " + letterArray[0];` 1700. `}` 1701. `}` 1702. `} else if (typeof ch4 === "undefined" || typeof ch4 === "object") {` 1703. `// assume RGBA` 1704. `if (ch4 && !isNaN(ch4.a)) {` 1705. `//TODO Implement transparency.` 1706. `//WORKAROUND use white for now, if transparent, otherwise handle as rgb` 1707. `if (ch4.a === 0) {` 1708. `color = ["1.", "1.", "1.", letterArray[1]].join(" ");` 1709. `return color;` 1710. `}` 1711. `}` 1712. `// assume RGB` 1713. `if (typeof ch1 === "string") {` 1714. `color = [ch1, ch2, ch3, letterArray[1]].join(" ");` 1715. `} else {` 1716. `switch (options.precision) {` 1717. `case 2:` 1718. `color = [`\ 1719. `f2(ch1 / 255),`\ 1720. `f2(ch2 / 255),`\ 1721. `f2(ch3 / 255),`\ 1722. `letterArray[1]`\ 1723. `].join(" ");` 1724. `break;` 1725. `default:` 1726. `case 3:` 1727. `color = [`\ 1728. `f3(ch1 / 255),`\ 1729. `f3(ch2 / 255),`\ 1730. `f3(ch3 / 255),`\ 1731. `letterArray[1]`\ 1732. `].join(" ");` 1733. `}` 1734. `}` 1735. `} else {` 1736. `// assume CMYK` 1737. `if (typeof ch1 === "string") {` 1738. `color = [ch1, ch2, ch3, ch4, letterArray[2]].join(" ");` 1739. `} else {` 1740. `switch (options.precision) {` 1741. `case 2:` 1742. `color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), letterArray[2]].join(` 1743. `" "` 1744. `);` 1745. `break;` 1746. `case 3:` 1747. `default:` 1748. `color = [f3(ch1), f3(ch2), f3(ch3), f3(ch4), letterArray[2]].join(` 1749. `" "` 1750. `);` 1751. `}` 1752. `}` 1753. `}` 1754. `return color;` 1755. `});` 1757. `var getFilters = (API.__private__.getFilters = function() {` 1758. `return filters;` 1759. `});` 1761. `var putStream = (API.__private__.putStream = function(options) {` 1762. `options = options || {};` 1763. `var data = options.data || "";` 1764. `var filters = options.filters || getFilters();` 1765. `var alreadyAppliedFilters = options.alreadyAppliedFilters || [];` 1766. `var addLength1 = options.addLength1 || false;` 1767. `var valueOfLength1 = data.length;` 1768. `var objectId = options.objectId;` 1769. `var encryptor = function(data) {` 1770. `return data;` 1771. `};` 1772. `if (encryptionOptions !== null && typeof objectId == "undefined") {` 1773. `throw new Error(` 1774. `"ObjectId must be passed to putStream for file encryption"` 1775. `);` 1776. `}` 1777. `if (encryptionOptions !== null) {` 1778. `encryptor = encryption.encryptor(objectId, 0);` 1779. `}` 1781. `var processedData = {};` 1782. `if (filters === true) {` 1783. `filters = ["FlateEncode"];` 1784. `}` 1785. `var keyValues = options.additionalKeyValues || [];` 1786. `if (typeof jsPDF.API.processDataByFilters !== "undefined") {` 1787. `processedData = jsPDF.API.processDataByFilters(data, filters);` 1788. `} else {` 1789. `processedData = { data: data, reverseChain: [] };` 1790. `}` 1791. `var filterAsString =` 1792. `processedData.reverseChain +` 1793. `(Array.isArray(alreadyAppliedFilters)` 1794. `? alreadyAppliedFilters.join(" ")` 1795. `: alreadyAppliedFilters.toString());` 1797. `if (processedData.data.length !== 0) {` 1798. `keyValues.push({` 1799. `key: "Length",` 1800. `value: processedData.data.length` 1801. `});` 1802. `if (addLength1 === true) {` 1803. `keyValues.push({` 1804. `key: "Length1",` 1805. `value: valueOfLength1` 1806. `});` 1807. `}` 1808. `}` 1810. `if (filterAsString.length != 0) {` 1811. `if (filterAsString.split("/").length - 1 === 1) {` 1812. `keyValues.push({` 1813. `key: "Filter",` 1814. `value: filterAsString` 1815. `});` 1816. `} else {` 1817. `keyValues.push({` 1818. `key: "Filter",` 1819. `value: "[" + filterAsString + "]"` 1820. `});` 1822. `for (var j = 0; j < keyValues.length; j += 1) {` 1823. `if (keyValues[j].key === "DecodeParms") {` 1824. `var decodeParmsArray = [];` 1826. `for (` 1827. `var i = 0;` 1828. `i < processedData.reverseChain.split("/").length - 1;` 1829. `i += 1` 1830. `) {` 1831. `decodeParmsArray.push("null");` 1832. `}` 1834. `decodeParmsArray.push(keyValues[j].value);` 1835. `keyValues[j].value = "[" + decodeParmsArray.join(" ") + "]";` 1836. `}` 1837. `}` 1838. `}` 1839. `}` 1841. `out("<<");` 1842. `for (var k = 0; k < keyValues.length; k++) {` 1843. `out("/" + keyValues[k].key + " " + keyValues[k].value);` 1844. `}` 1845. `out(">>");` 1846. `if (processedData.data.length !== 0) {` 1847. `out("stream");` 1848. `out(encryptor(processedData.data));` 1849. `out("endstream");` 1850. `}` 1851. `});` 1853. `var putPage = (API.__private__.putPage = function(page) {` 1854. `var pageNumber = page.number;` 1855. `var data = page.data;` 1856. `var pageObjectNumber = page.objId;` 1857. `var pageContentsObjId = page.contentsObjId;` 1859. `newObjectDeferredBegin(pageObjectNumber, true);` 1860. `out("<>");` 1942. `out("endobj");` 1943. `// Page content` 1944. `var pageContent = data.join("\n");` 1946. `if (apiMode === ApiMode.ADVANCED) {` 1947. `// if the user forgot to switch back to COMPAT mode, we must balance the graphics stack again` 1948. `pageContent += "\nQ";` 1949. `}` 1951. `newObjectDeferredBegin(pageContentsObjId, true);` 1952. `putStream({` 1953. `data: pageContent,` 1954. `filters: getFilters(),` 1955. `objectId: pageContentsObjId` 1956. `});` 1957. `out("endobj");` 1958. `return pageObjectNumber;` 1959. `});` 1961. `var putPages = (API.__private__.putPages = function() {` 1962. `var n,` 1963. `i,` 1964. `pageObjectNumbers = [];` 1966. `for (n = 1; n <= page; n++) {` 1967. `pagesContext[n].objId = newObjectDeferred();` 1968. `pagesContext[n].contentsObjId = newObjectDeferred();` 1969. `}` 1971. `for (n = 1; n <= page; n++) {` 1972. `pageObjectNumbers.push(` 1973. `putPage({` 1974. `number: n,` 1975. `data: pages[n],` 1976. `objId: pagesContext[n].objId,` 1977. `contentsObjId: pagesContext[n].contentsObjId,` 1978. `mediaBox: pagesContext[n].mediaBox,` 1979. `cropBox: pagesContext[n].cropBox,` 1980. `bleedBox: pagesContext[n].bleedBox,` 1981. `trimBox: pagesContext[n].trimBox,` 1982. `artBox: pagesContext[n].artBox,` 1983. `userUnit: pagesContext[n].userUnit,` 1984. `rootDictionaryObjId: rootDictionaryObjId,` 1985. `resourceDictionaryObjId: resourceDictionaryObjId` 1986. `})` 1987. `);` 1988. `}` 1989. `newObjectDeferredBegin(rootDictionaryObjId, true);` 1990. `out("<>");` 1998. `out("endobj");` 1999. `events.publish("postPutPages");` 2000. `});` 2002. `var putFont = function(font) {` 2003. `events.publish("putFont", {` 2004. `font: font,` 2005. `out: out,` 2006. `newObject: newObject,` 2007. `putStream: putStream` 2008. `});` 2010. `if (font.isAlreadyPutted !== true) {` 2011. `font.objectNumber = newObject();` 2012. `out("<<");` 2013. `out("/Type /Font");` 2014. `out("/BaseFont /" + toPDFName(font.postScriptName));` 2015. `out("/Subtype /Type1");` 2016. `if (typeof font.encoding === "string") {` 2017. `out("/Encoding /" + font.encoding);` 2018. `}` 2019. `out("/FirstChar 32");` 2020. `out("/LastChar 255");` 2021. `out(">>");` 2022. `out("endobj");` 2023. `}` 2024. `};` 2026. `var putFonts = function() {` 2027. `for (var fontKey in fonts) {` 2028. `if (fonts.hasOwnProperty(fontKey)) {` 2029. `if (` 2030. `putOnlyUsedFonts === false ||` 2031. `(putOnlyUsedFonts === true && usedFonts.hasOwnProperty(fontKey))` 2032. `) {` 2033. `putFont(fonts[fontKey]);` 2034. `}` 2035. `}` 2036. `}` 2037. `};` 2039. `var putXObject = function(xObject) {` 2040. `xObject.objectNumber = newObject();` 2042. `var options = [];` 2043. `options.push({ key: "Type", value: "/XObject" });` 2044. `options.push({ key: "Subtype", value: "/Form" });` 2045. `options.push({` 2046. `key: "BBox",` 2047. `value:` 2048. `"[" +`\ 2049. `[`\ 2050. `hpf(xObject.x),`\ 2051. `hpf(xObject.y),`\ 2052. `hpf(xObject.x + xObject.width),`\ 2053. `hpf(xObject.y + xObject.height)`\ 2054. `].join(" ") +`\ 2055. `"]"` 2056. `});` 2057. `options.push({` 2058. `key: "Matrix",` 2059. `value: "[" + xObject.matrix.toString() + "]"` 2060. `});` 2061. `// TODO: /Resources` 2063. `var stream = xObject.pages[1].join("\n");` 2064. `putStream({` 2065. `data: stream,` 2066. `additionalKeyValues: options,` 2067. `objectId: xObject.objectNumber` 2068. `});` 2069. `out("endobj");` 2070. `};` 2072. `var putXObjects = function() {` 2073. `for (var xObjectKey in renderTargets) {` 2074. `if (renderTargets.hasOwnProperty(xObjectKey)) {` 2075. `putXObject(renderTargets[xObjectKey]);` 2076. `}` 2077. `}` 2078. `};` 2080. `var interpolateAndEncodeRGBStream = function(colors, numberSamples) {` 2081. `var tValues = [];` 2082. `var t;` 2083. `var dT = 1.0 / (numberSamples - 1);` 2084. `for (t = 0.0; t < 1.0; t += dT) {` 2085. `tValues.push(t);` 2086. `}` 2087. `tValues.push(1.0);` 2088. `// add first and last control point if not present` 2089. `if (colors[0].offset != 0.0) {` 2090. `var c0 = {` 2091. `offset: 0.0,` 2092. `color: colors[0].color` 2093. `};` 2094. `colors.unshift(c0);` 2095. `}` 2096. `if (colors[colors.length - 1].offset != 1.0) {` 2097. `var c1 = {` 2098. `offset: 1.0,` 2099. `color: colors[colors.length - 1].color` 2100. `};` 2101. `colors.push(c1);` 2102. `}` 2103. `var out = "";` 2104. `var index = 0;` 2106. `for (var i = 0; i < tValues.length; i++) {` 2107. `t = tValues[i];` 2108. `while (t > colors[index + 1].offset) index++;` 2109. `var a = colors[index].offset;` 2110. `var b = colors[index + 1].offset;` 2111. `var d = (t - a) / (b - a);` 2113. `var aColor = colors[index].color;` 2114. `var bColor = colors[index + 1].color;` 2116. `out +=` 2117. `padd2Hex(Math.round((1 - d) * aColor[0] + d * bColor[0]).toString(16)) +` 2118. `padd2Hex(Math.round((1 - d) * aColor[1] + d * bColor[1]).toString(16)) +` 2119. `padd2Hex(Math.round((1 - d) * aColor[2] + d * bColor[2]).toString(16));` 2120. `}` 2121. `return out.trim();` 2122. `};` 2124. `var putShadingPattern = function(pattern, numberSamples) {` 2125. `/*` 2126. `Axial patterns shade between the two points specified in coords, radial patterns between the inner` 2127. `and outer circle.` 2128. `The user can specify an array (colors) that maps t-Values in [0, 1] to RGB colors. These are now` 2129. `interpolated to equidistant samples and written to pdf as a sample (type 0) function.` 2130. `*/` 2131. `// The number of color samples that should be used to describe the shading.` 2132. `// The higher, the more accurate the gradient will be.` 2133. `numberSamples || (numberSamples = 21);` 2134. `var funcObjectNumber = newObject();` 2135. `var stream = interpolateAndEncodeRGBStream(pattern.colors, numberSamples);` 2137. `var options = [];` 2138. `options.push({ key: "FunctionType", value: "0" });` 2139. `options.push({ key: "Domain", value: "[0.0 1.0]" });` 2140. `options.push({ key: "Size", value: "[" + numberSamples + "]" });` 2141. `options.push({ key: "BitsPerSample", value: "8" });` 2142. `options.push({ key: "Range", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" });` 2143. `options.push({ key: "Decode", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" });` 2145. `putStream({` 2146. `data: stream,` 2147. `additionalKeyValues: options,` 2148. `alreadyAppliedFilters: ["/ASCIIHexDecode"],` 2149. `objectId: funcObjectNumber` 2150. `});` 2151. `out("endobj");` 2153. `pattern.objectNumber = newObject();` 2154. `out("<< /ShadingType " + pattern.type);` 2155. `out("/ColorSpace /DeviceRGB");` 2156. `var coords =` 2157. `"/Coords [" +`\ 2158. `hpf(parseFloat(pattern.coords[0])) +`\ 2159. `" " + // x1`\ 2160. `hpf(parseFloat(pattern.coords[1])) +`\ 2161. `" "; // y1`\ 2162. `if (pattern.type === 2) {`\ 2163. `// axial`\ 2164. `coords +=`\ 2165. `hpf(parseFloat(pattern.coords[2])) +`\ 2166. `" " + // x2`\ 2167. `hpf(parseFloat(pattern.coords[3])); // y2`\ 2168. `} else {`\ 2169. `// radial`\ 2170. `coords +=`\ 2171. `hpf(parseFloat(pattern.coords[2])) +`\ 2172. `" " + // r1`\ 2173. `hpf(parseFloat(pattern.coords[3])) +`\ 2174. `" " + // x2`\ 2175. `hpf(parseFloat(pattern.coords[4])) +`\ 2176. `" " + // y2`\ 2177. `hpf(parseFloat(pattern.coords[5])); // r2`\ 2178. `}`\ 2179. `coords += "]";` 2180. `out(coords);` 2182. `if (pattern.matrix) {` 2183. `out("/Matrix [" + pattern.matrix.toString() + "]");` 2184. `}` 2185. `out("/Function " + funcObjectNumber + " 0 R");` 2186. `out("/Extend [true true]");` 2187. `out(">>");` 2188. `out("endobj");` 2189. `};` 2191. `var putTilingPattern = function(pattern, deferredResourceDictionaryIds) {` 2192. `var resourcesObjectId = newObjectDeferred();` 2193. `var patternObjectId = newObject();` 2195. `deferredResourceDictionaryIds.push({` 2196. `resourcesOid: resourcesObjectId,` 2197. `objectOid: patternObjectId` 2198. `});` 2200. `pattern.objectNumber = patternObjectId;` 2201. `var options = [];` 2202. `options.push({ key: "Type", value: "/Pattern" });` 2203. `options.push({ key: "PatternType", value: "1" }); // tiling pattern` 2204. `options.push({ key: "PaintType", value: "1" }); // colored tiling pattern` 2205. `options.push({ key: "TilingType", value: "1" }); // constant spacing` 2206. `options.push({` 2207. `key: "BBox",` 2208. `value: "[" + pattern.boundingBox.map(hpf).join(" ") + "]"` 2209. `});` 2210. `options.push({ key: "XStep", value: hpf(pattern.xStep) });` 2211. `options.push({ key: "YStep", value: hpf(pattern.yStep) });` 2212. `options.push({ key: "Resources", value: resourcesObjectId + " 0 R" });` 2213. `if (pattern.matrix) {` 2214. `options.push({` 2215. `key: "Matrix",` 2216. `value: "[" + pattern.matrix.toString() + "]"` 2217. `});` 2218. `}` 2220. `putStream({` 2221. `data: pattern.stream,` 2222. `additionalKeyValues: options,` 2223. `objectId: pattern.objectNumber` 2224. `});` 2225. `out("endobj");` 2226. `};` 2228. `var putPatterns = function(deferredResourceDictionaryIds) {` 2229. `var patternKey;` 2230. `for (patternKey in patterns) {` 2231. `if (patterns.hasOwnProperty(patternKey)) {` 2232. `if (patterns[patternKey] instanceof ShadingPattern) {` 2233. `putShadingPattern(patterns[patternKey]);` 2234. `} else if (patterns[patternKey] instanceof TilingPattern) {` 2235. `putTilingPattern(patterns[patternKey], deferredResourceDictionaryIds);` 2236. `}` 2237. `}` 2238. `}` 2239. `};` 2241. `var putGState = function(gState) {` 2242. `gState.objectNumber = newObject();` 2243. `out("<<");` 2244. `for (var p in gState) {` 2245. `switch (p) {` 2246. `case "opacity":` 2247. `out("/ca " + f2(gState[p]));` 2248. `break;` 2249. `case "stroke-opacity":` 2250. `out("/CA " + f2(gState[p]));` 2251. `break;` 2252. `}` 2253. `}` 2254. `out(">>");` 2255. `out("endobj");` 2256. `};` 2258. `var putGStates = function() {` 2259. `var gStateKey;` 2260. `for (gStateKey in gStates) {` 2261. `if (gStates.hasOwnProperty(gStateKey)) {` 2262. `putGState(gStates[gStateKey]);` 2263. `}` 2264. `}` 2265. `};` 2267. `var putXobjectDict = function() {` 2268. `out("/XObject <<");` 2269. `for (var xObjectKey in renderTargets) {` 2270. `if (` 2271. `renderTargets.hasOwnProperty(xObjectKey) &&` 2272. `renderTargets[xObjectKey].objectNumber >= 0` 2273. `) {` 2274. `out(` 2275. `"/" +` 2276. `xObjectKey +` 2277. `" " +` 2278. `renderTargets[xObjectKey].objectNumber +` 2279. `" 0 R"` 2280. `);` 2281. `}` 2282. `}` 2284. `// Loop through images, or other data objects` 2285. `events.publish("putXobjectDict");` 2286. `out(">>");` 2287. `};` 2289. `var putEncryptionDict = function() {` 2290. `encryption.oid = newObject();` 2291. `out("<<");` 2292. `out("/Filter /Standard");` 2293. `out("/V " + encryption.v);` 2294. `out("/R " + encryption.r);` 2295. `out("/U <" + encryption.toHexString(encryption.U) + ">");` 2296. `out("/O <" + encryption.toHexString(encryption.O) + ">");` 2297. `out("/P " + encryption.P);` 2298. `out(">>");` 2299. `out("endobj");` 2300. `};` 2302. `var putFontDict = function() {` 2303. `out("/Font <<");` 2305. `for (var fontKey in fonts) {` 2306. `if (fonts.hasOwnProperty(fontKey)) {` 2307. `if (` 2308. `putOnlyUsedFonts === false ||` 2309. `(putOnlyUsedFonts === true && usedFonts.hasOwnProperty(fontKey))` 2310. `) {` 2311. `out("/" + fontKey + " " + fonts[fontKey].objectNumber + " 0 R");` 2312. `}` 2313. `}` 2314. `}` 2315. `out(">>");` 2316. `};` 2318. `var putShadingPatternDict = function() {` 2319. `if (Object.keys(patterns).length > 0) {` 2320. `out("/Shading <<");` 2321. `for (var patternKey in patterns) {` 2322. `if (` 2323. `patterns.hasOwnProperty(patternKey) &&` 2324. `patterns[patternKey] instanceof ShadingPattern &&` 2325. `patterns[patternKey].objectNumber >= 0` 2326. `) {` 2327. `out(` 2328. `"/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R"` 2329. `);` 2330. `}` 2331. `}` 2333. `events.publish("putShadingPatternDict");` 2334. `out(">>");` 2335. `}` 2336. `};` 2338. `var putTilingPatternDict = function(objectOid) {` 2339. `if (Object.keys(patterns).length > 0) {` 2340. `out("/Pattern <<");` 2341. `for (var patternKey in patterns) {` 2342. `if (` 2343. `patterns.hasOwnProperty(patternKey) &&` 2344. `patterns[patternKey] instanceof API.TilingPattern &&` 2345. `patterns[patternKey].objectNumber >= 0 &&` 2346. `patterns[patternKey].objectNumber < objectOid // prevent cyclic dependencies` 2347. `) {` 2348. `out(` 2349. `"/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R"` 2350. `);` 2351. `}` 2352. `}` 2353. `events.publish("putTilingPatternDict");` 2354. `out(">>");` 2355. `}` 2356. `};` 2358. `var putGStatesDict = function() {` 2359. `if (Object.keys(gStates).length > 0) {` 2360. `var gStateKey;` 2361. `out("/ExtGState <<");` 2362. `for (gStateKey in gStates) {` 2363. `if (` 2364. `gStates.hasOwnProperty(gStateKey) &&` 2365. `gStates[gStateKey].objectNumber >= 0` 2366. `) {` 2367. `out("/" + gStateKey + " " + gStates[gStateKey].objectNumber + " 0 R");` 2368. `}` 2369. `}` 2371. `events.publish("putGStateDict");` 2372. `out(">>");` 2373. `}` 2374. `};` 2376. `var putResourceDictionary = function(objectIds) {` 2377. `newObjectDeferredBegin(objectIds.resourcesOid, true);` 2378. `out("<<");` 2379. `out("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");` 2380. `putFontDict();` 2381. `putShadingPatternDict();` 2382. `putTilingPatternDict(objectIds.objectOid);` 2383. `putGStatesDict();` 2384. `putXobjectDict();` 2385. `out(">>");` 2386. `out("endobj");` 2387. `};` 2389. `var putResources = function() {` 2390. `// FormObjects, Patterns etc. might use other FormObjects/Patterns/Images` 2391. `// which means their resource dictionaries must contain the already resolved` 2392. `// object ids. For this reason we defer the serialization of the resource` 2393. `// dicts until all objects have been serialized and have object ids.` 2394. `//` 2395. `// In order to prevent cyclic dependencies (which Adobe Reader doesn't like),` 2396. `// we only put all oids that are smaller than the oid of the object the` 2397. `// resource dict belongs to. This is correct behavior, since the streams` 2398. `// may only use other objects that have already been defined and thus appear` 2399. `// earlier in their respective collection.` 2400. `// Currently, this only affects tiling patterns, but a (more) correct` 2401. `// implementation of FormObjects would also define their own resource dicts.` 2402. `var deferredResourceDictionaryIds = [];` 2404. `putFonts();` 2405. `putGStates();` 2406. `putXObjects();` 2407. `putPatterns(deferredResourceDictionaryIds);` 2409. `events.publish("putResources");` 2410. `deferredResourceDictionaryIds.forEach(putResourceDictionary);` 2411. `putResourceDictionary({` 2412. `resourcesOid: resourceDictionaryObjId,` 2413. `objectOid: Number.MAX_SAFE_INTEGER // output all objects` 2414. `});` 2415. `events.publish("postPutResources");` 2416. `};` 2418. `var putAdditionalObjects = function() {` 2419. `events.publish("putAdditionalObjects");` 2420. `for (var i = 0; i < additionalObjects.length; i++) {` 2421. `var obj = additionalObjects[i];` 2422. `newObjectDeferredBegin(obj.objId, true);` 2423. `out(obj.content);` 2424. `out("endobj");` 2425. `}` 2426. `events.publish("postPutAdditionalObjects");` 2427. `};` 2429. `var addFontToFontDictionary = function(font) {` 2430. `fontmap[font.fontName] = fontmap[font.fontName] || {};` 2431. `fontmap[font.fontName][font.fontStyle] = font.id;` 2432. `};` 2434. `var addFont = function(` 2435. `postScriptName,` 2436. `fontName,` 2437. `fontStyle,` 2438. `encoding,` 2439. `isStandardFont` 2440. `) {` 2441. `var font = {` 2442. `id: "F" + (Object.keys(fonts).length + 1).toString(10),` 2443. `postScriptName: postScriptName,` 2444. `fontName: fontName,` 2445. `fontStyle: fontStyle,` 2446. `encoding: encoding,` 2447. `isStandardFont: isStandardFont || false,` 2448. `metadata: {}` 2449. `};` 2451. `events.publish("addFont", {` 2452. `font: font,` 2453. `instance: this` 2454. `});` 2456. `fonts[font.id] = font;` 2457. `addFontToFontDictionary(font);` 2458. `return font.id;` 2459. `};` 2461. `var addFonts = function(arrayOfFonts) {` 2462. `for (var i = 0, l = standardFonts.length; i < l; i++) {` 2463. `var fontKey = addFont.call(` 2464. `this,` 2465. `arrayOfFonts[i][0],` 2466. `arrayOfFonts[i][1],` 2467. `arrayOfFonts[i][2],` 2468. `standardFonts[i][3],` 2469. `true` 2470. `);` 2472. `if (putOnlyUsedFonts === false) {` 2473. `usedFonts[fontKey] = true;` 2474. `}` 2475. `// adding aliases for standard fonts, this time matching the capitalization` 2476. `var parts = arrayOfFonts[i][0].split("-");` 2477. `addFontToFontDictionary({` 2478. `id: fontKey,` 2479. `fontName: parts[0],` 2480. `fontStyle: parts[1] || ""` 2481. `});` 2482. `}` 2483. `events.publish("addFonts", {` 2484. `fonts: fonts,` 2485. `dictionary: fontmap` 2486. `});` 2487. `};` 2489. `var SAFE = function __safeCall(fn) {` 2490. `fn.foo = function __safeCallWrapper() {` 2491. `try {` 2492. `return fn.apply(this, arguments);` 2493. `} catch (e) {` 2494. `var stack = e.stack || "";` 2495. `if (~stack.indexOf(" at ")) stack = stack.split(" at ")[1];` 2496. `var m =` 2497. `"Error in function " +` 2498. `stack.split("\n")[0].split("<")[0] +` 2499. `": " +` 2500. `e.message;` 2501. `if (globalObject.console) {` 2502. `globalObject.console.error(m, e);` 2503. `if (globalObject.alert) alert(m);` 2504. `} else {` 2505. `throw new Error(m);` 2506. `}` 2507. `}` 2508. `};` 2509. `fn.foo.bar = fn;` 2510. `return fn.foo;` 2511. `};` 2513. `var to8bitStream = function(text, flags) {` 2514. `/**` 2515. `* PDF 1.3 spec:` 2516. `* "For text strings encoded in Unicode, the first two bytes must be 254 followed by` 2517. `* 255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts` 2518. `* with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely` 2519. `* to be a meaningful beginning of a word or phrase.) The remainder of the` 2520. `* string consists of Unicode character codes, according to the UTF-16 encoding` 2521. `* specified in the Unicode standard, version 2.0. Commonly used Unicode values` 2522. `* are represented as 2 bytes per character, with the high-order byte appearing first` 2523. `* in the string."` 2524. `*` 2525. `* In other words, if there are chars in a string with char code above 255, we` 2526. `* recode the string to UCS2 BE - string doubles in length and BOM is prepended.` 2527. `*` 2528. `* HOWEVER!` 2529. `* Actual *content* (body) text (as opposed to strings used in document properties etc)` 2530. `* does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)` 2531. `*` 2532. `* Because of Adobe's focus on "you subset your fonts!" you are not supposed to have` 2533. `* a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could` 2534. `* fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode` 2535. `* code page. There, however, all characters in the stream are treated as GIDs,` 2536. `* including BOM, which is the reason we need to skip BOM in content text (i.e. that` 2537. `* that is tied to a font).` 2538. `*` 2539. `* To signal this "special" PDFEscape / to8bitStream handling mode,` 2540. `* API.text() function sets (unless you overwrite it with manual values` 2541. `* given to API.text(.., flags) )` 2542. `* flags.autoencode = true` 2543. `* flags.noBOM = true` 2544. `*` 2545. `* ===================================================================================` 2546. ``* `flags` properties relied upon:`` 2547. `* .sourceEncoding = string with encoding label.` 2548. `* "Unicode" by default. = encoding of the incoming text.` 2549. `* pass some non-existing encoding name` 2550. `* (ex: 'Do not touch my strings! I know what I am doing.')` 2551. `* to make encoding code skip the encoding step.` 2552. `* .outputEncoding = Either valid PDF encoding name` 2553. `* (must be supported by jsPDF font metrics, otherwise no encoding)` 2554. `* or a JS object, where key = sourceCharCode, value = outputCharCode` 2555. `* missing keys will be treated as: sourceCharCode === outputCharCode` 2556. `* .noBOM` 2557. `* See comment higher above for explanation for why this is important` 2558. `* .autoencode` 2559. `* See comment higher above for explanation for why this is important` 2560. `*/` 2562. `var i,` 2563. `l,` 2564. `sourceEncoding,` 2565. `encodingBlock,` 2566. `outputEncoding,` 2567. `newtext,` 2568. `isUnicode,` 2569. `ch,` 2570. `bch;` 2572. `flags = flags || {};` 2573. `sourceEncoding = flags.sourceEncoding || "Unicode";` 2574. `outputEncoding = flags.outputEncoding;` 2576. `// This 'encoding' section relies on font metrics format` 2577. `// attached to font objects by, among others,` 2578. `// "Willow Systems' standard_font_metrics plugin"` 2579. `// see jspdf.plugin.standard_font_metrics.js for format` 2580. `// of the font.metadata.encoding Object.` 2581. `// It should be something like` 2582. `// .encoding = {'codePages':['WinANSI....'], 'WinANSI...':{code:code, ...}}` 2583. `// .widths = {0:width, code:width, ..., 'fof':divisor}` 2584. `// .kerning = {code:{previous_char_code:shift, ..., 'fof':-divisor},...}` 2585. `if (` 2586. `(flags.autoencode || outputEncoding) &&` 2587. `fonts[activeFontKey].metadata &&` 2588. `fonts[activeFontKey].metadata[sourceEncoding] &&` 2589. `fonts[activeFontKey].metadata[sourceEncoding].encoding` 2590. `) {` 2591. `encodingBlock = fonts[activeFontKey].metadata[sourceEncoding].encoding;` 2593. `// each font has default encoding. Some have it clearly defined.` 2594. `if (!outputEncoding && fonts[activeFontKey].encoding) {` 2595. `outputEncoding = fonts[activeFontKey].encoding;` 2596. `}` 2598. `// Hmmm, the above did not work? Let's try again, in different place.` 2599. `if (!outputEncoding && encodingBlock.codePages) {` 2600. `outputEncoding = encodingBlock.codePages[0]; // let's say, first one is the default` 2601. `}` 2603. `if (typeof outputEncoding === "string") {` 2604. `outputEncoding = encodingBlock[outputEncoding];` 2605. `}` 2606. `// we want output encoding to be a JS Object, where` 2607. `// key = sourceEncoding's character code and` 2608. `// value = outputEncoding's character code.` 2609. `if (outputEncoding) {` 2610. `isUnicode = false;` 2611. `newtext = [];` 2612. `for (i = 0, l = text.length; i < l; i++) {` 2613. `ch = outputEncoding[text.charCodeAt(i)];` 2614. `if (ch) {` 2615. `newtext.push(String.fromCharCode(ch));` 2616. `} else {` 2617. `newtext.push(text[i]);` 2618. `}` 2620. `// since we are looping over chars anyway, might as well` 2621. `// check for residual unicodeness` 2622. `if (newtext[i].charCodeAt(0) >> 8) {` 2623. `/* more than 255 */` 2624. `isUnicode = true;` 2625. `}` 2626. `}` 2627. `text = newtext.join("");` 2628. `}` 2629. `}` 2631. `i = text.length;` 2632. `// isUnicode may be set to false above. Hence the triple-equal to undefined` 2633. `while (isUnicode === undefined && i !== 0) {` 2634. `if (text.charCodeAt(i - 1) >> 8) {` 2635. `/* more than 255 */` 2636. `isUnicode = true;` 2637. `}` 2638. `i--;` 2639. `}` 2640. `if (!isUnicode) {` 2641. `return text;` 2642. `}` 2644. `newtext = flags.noBOM ? [] : [254, 255];` 2645. `for (i = 0, l = text.length; i < l; i++) {` 2646. `ch = text.charCodeAt(i);` 2647. `bch = ch >> 8; // divide by 256` 2648. `if (bch >> 8) {` 2649. `/* something left after dividing by 256 second time */` 2650. `throw new Error(` 2651. `"Character at position " +` 2652. `i +` 2653. `" of string '" +` 2654. `text +` 2655. `"' exceeds 16bits. Cannot be encoded into UCS-2 BE"` 2656. `);` 2657. `}` 2658. `newtext.push(bch);` 2659. `newtext.push(ch - (bch << 8));` 2660. `}` 2661. `return String.fromCharCode.apply(undefined, newtext);` 2662. `};` 2664. `var pdfEscape = (API.__private__.pdfEscape = API.pdfEscape = function(` 2665. `text,` 2666. `flags` 2667. `) {` 2668. `/**` 2669. `* Replace '/', '(', and ')' with pdf-safe versions` 2670. `*` 2671. `* Doing to8bitStream does NOT make this PDF display unicode text. For that` 2672. `* we also need to reference a unicode font and embed it - royal pain in the rear.` 2673. `*` 2674. `* There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,` 2675. `* which JavaScript Strings are happy to provide. So, while we still cannot display` 2676. `* 2-byte characters property, at least CONDITIONALLY converting (entire string containing)` 2677. `* 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF` 2678. `* is still parseable.` 2679. `* This will allow immediate support for unicode in document properties strings.` 2680. `*/` 2681. `return to8bitStream(text, flags)` 2682. `.replace(/\\/g, "\\\\")` 2683. `.replace(/\(/g, "\\(")` 2684. `.replace(/\)/g, "\\)");` 2685. `});` 2687. `var beginPage = (API.__private__.beginPage = function(format) {` 2688. `pages[++page] = [];` 2689. `pagesContext[page] = {` 2690. `objId: 0,` 2691. `contentsObjId: 0,` 2692. `userUnit: Number(userUnit),` 2693. `artBox: null,` 2694. `bleedBox: null,` 2695. `cropBox: null,` 2696. `trimBox: null,` 2697. `mediaBox: {` 2698. `bottomLeftX: 0,` 2699. `bottomLeftY: 0,` 2700. `topRightX: Number(format[0]),` 2701. `topRightY: Number(format[1])` 2702. `}` 2703. `};` 2704. `_setPage(page);` 2705. `setOutputDestination(pages[currentPage]);` 2706. `});` 2708. `var _addPage = function(parmFormat, parmOrientation) {` 2709. `var dimensions, width, height;` 2711. `orientation = parmOrientation || orientation;` 2713. `if (typeof parmFormat === "string") {` 2714. `dimensions = getPageFormat(parmFormat.toLowerCase());` 2715. `if (Array.isArray(dimensions)) {` 2716. `width = dimensions[0];` 2717. `height = dimensions[1];` 2718. `}` 2719. `}` 2721. `if (Array.isArray(parmFormat)) {` 2722. `width = parmFormat[0] * scaleFactor;` 2723. `height = parmFormat[1] * scaleFactor;` 2724. `}` 2726. `if (isNaN(width)) {` 2727. `width = format[0];` 2728. `height = format[1];` 2729. `}` 2731. `if (width > 14400 || height > 14400) {` 2732. `console.warn(` 2733. `"A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"` 2734. `);` 2735. `width = Math.min(14400, width);` 2736. `height = Math.min(14400, height);` 2737. `}` 2739. `format = [width, height];` 2741. `switch (orientation.substr(0, 1)) {` 2742. `case "l":` 2743. `if (height > width) {` 2744. `format = [height, width];` 2745. `}` 2746. `break;` 2747. `case "p":` 2748. `if (width > height) {` 2749. `format = [height, width];` 2750. `}` 2751. `break;` 2752. `}` 2754. `beginPage(format);` 2756. `// Set line width` 2757. `setLineWidth(lineWidth);` 2758. `// Set draw color` 2759. `out(strokeColor);` 2760. `// resurrecting non-default line caps, joins` 2761. `if (lineCapID !== 0) {` 2762. `out(lineCapID + " J");` 2763. `}` 2764. `if (lineJoinID !== 0) {` 2765. `out(lineJoinID + " j");` 2766. `}` 2767. `events.publish("addPage", {` 2768. `pageNumber: page` 2769. `});` 2770. `};` 2772. `var _deletePage = function(n) {` 2773. `if (n > 0 && n <= page) {` 2774. `pages.splice(n, 1);` 2775. `pagesContext.splice(n, 1);` 2776. `page--;` 2777. `if (currentPage > page) {` 2778. `currentPage = page;` 2779. `}` 2780. `this.setPage(currentPage);` 2781. `}` 2782. `};` 2784. `var _setPage = function(n) {` 2785. `if (n > 0 && n <= page) {` 2786. `currentPage = n;` 2787. `}` 2788. `};` 2790. `var getNumberOfPages = (API.__private__.getNumberOfPages = API.getNumberOfPages = function() {` 2791. `return pages.length - 1;` 2792. `});` 2794. `/**` 2795. `* Returns a document-specific font key - a label assigned to a` 2796. `* font name + font type combination at the time the font was added` 2797. `* to the font inventory.` 2798. `*` 2799. `* Font key is used as label for the desired font for a block of text` 2800. `* to be added to the PDF document stream.` 2801. `* @private` 2802. `* @function` 2803. `* @param fontName {string} can be undefined on "falthy" to indicate "use current"` 2804. `* @param fontStyle {string} can be undefined on "falthy" to indicate "use current"` 2805. `* @returns {string} Font key.` 2806. `* @ignore` 2807. `*/` 2808. `var getFont = function(fontName, fontStyle, options) {` 2809. `var key = undefined,` 2810. `fontNameLowerCase;` 2811. `options = options || {};` 2813. `fontName =` 2814. `fontName !== undefined ? fontName : fonts[activeFontKey].fontName;` 2815. `fontStyle =` 2816. `fontStyle !== undefined ? fontStyle : fonts[activeFontKey].fontStyle;` 2817. `fontNameLowerCase = fontName.toLowerCase();` 2819. `if (` 2820. `fontmap[fontNameLowerCase] !== undefined &&` 2821. `fontmap[fontNameLowerCase][fontStyle] !== undefined` 2822. `) {` 2823. `key = fontmap[fontNameLowerCase][fontStyle];` 2824. `} else if (` 2825. `fontmap[fontName] !== undefined &&` 2826. `fontmap[fontName][fontStyle] !== undefined` 2827. `) {` 2828. `key = fontmap[fontName][fontStyle];` 2829. `} else {` 2830. `if (options.disableWarning === false) {` 2831. `console.warn(` 2832. `"Unable to look up font label for font '" +` 2833. `fontName +` 2834. `"', '" +` 2835. `fontStyle +` 2836. `"'. Refer to getFontList() for available fonts."` 2837. `);` 2838. `}` 2839. `}` 2841. `if (!key && !options.noFallback) {` 2842. `key = fontmap["times"][fontStyle];` 2843. `if (key == null) {` 2844. `key = fontmap["times"]["normal"];` 2845. `}` 2846. `}` 2847. `return key;` 2848. `};` 2850. `var putInfo = (API.__private__.putInfo = function() {` 2851. `var objectId = newObject();` 2852. `var encryptor = function(data) {` 2853. `return data;` 2854. `};` 2855. `if (encryptionOptions !== null) {` 2856. `encryptor = encryption.encryptor(objectId, 0);` 2857. `}` 2858. `out("<<");` 2859. `out("/Producer (" + pdfEscape(encryptor("jsPDF " + jsPDF.version)) + ")");` 2860. `for (var key in documentProperties) {` 2861. `if (documentProperties.hasOwnProperty(key) && documentProperties[key]) {` 2862. `out(` 2863. `"/" +` 2864. `key.substr(0, 1).toUpperCase() +` 2865. `key.substr(1) +` 2866. `" (" +` 2867. `pdfEscape(encryptor(documentProperties[key])) +` 2868. `")"` 2869. `);` 2870. `}` 2871. `}` 2872. `out("/CreationDate (" + pdfEscape(encryptor(creationDate)) + ")");` 2873. `out(">>");` 2874. `out("endobj");` 2875. `});` 2877. `var putCatalog = (API.__private__.putCatalog = function(options) {` 2878. `options = options || {};` 2879. `var tmpRootDictionaryObjId =` 2880. `options.rootDictionaryObjId || rootDictionaryObjId;` 2881. `newObject();` 2882. `out("<<");` 2883. `out("/Type /Catalog");` 2884. `out("/Pages " + tmpRootDictionaryObjId + " 0 R");` 2885. `// PDF13ref Section 7.2.1` 2886. `if (!zoomMode) zoomMode = "fullwidth";` 2887. `switch (zoomMode) {` 2888. `case "fullwidth":` 2889. `out("/OpenAction [3 0 R /FitH null]");` 2890. `break;` 2891. `case "fullheight":` 2892. `out("/OpenAction [3 0 R /FitV null]");` 2893. `break;` 2894. `case "fullpage":` 2895. `out("/OpenAction [3 0 R /Fit]");` 2896. `break;` 2897. `case "original":` 2898. `out("/OpenAction [3 0 R /XYZ null null 1]");` 2899. `break;` 2900. `default:` 2901. `var pcn = "" + zoomMode;` 2902. `if (pcn.substr(pcn.length - 1) === "%")` 2903. `zoomMode = parseInt(zoomMode) / 100;` 2904. `if (typeof zoomMode === "number") {` 2905. `out("/OpenAction [3 0 R /XYZ null null " + f2(zoomMode) + "]");` 2906. `}` 2907. `}` 2908. `if (!layoutMode) layoutMode = "continuous";` 2909. `switch (layoutMode) {` 2910. `case "continuous":` 2911. `out("/PageLayout /OneColumn");` 2912. `break;` 2913. `case "single":` 2914. `out("/PageLayout /SinglePage");` 2915. `break;` 2916. `case "two":` 2917. `case "twoleft":` 2918. `out("/PageLayout /TwoColumnLeft");` 2919. `break;` 2920. `case "tworight":` 2921. `out("/PageLayout /TwoColumnRight");` 2922. `break;` 2923. `}` 2924. `if (pageMode) {` 2925. `/**` 2926. `* A name object specifying how the document should be displayed when opened:` 2927. `* UseNone : Neither document outline nor thumbnail images visible -- DEFAULT` 2928. `* UseOutlines : Document outline visible` 2929. `* UseThumbs : Thumbnail images visible` 2930. `* FullScreen : Full-screen mode, with no menu bar, window controls, or any other window visible` 2931. `*/` 2932. `out("/PageMode /" + pageMode);` 2933. `}` 2934. `events.publish("putCatalog");` 2935. `out(">>");` 2936. `out("endobj");` 2937. `});` 2939. `var putTrailer = (API.__private__.putTrailer = function() {` 2940. `out("trailer");` 2941. `out("<<");` 2942. `out("/Size " + (objectNumber + 1));` 2943. `// Root and Info must be the last and second last objects written respectively` 2944. `out("/Root " + objectNumber + " 0 R");` 2945. `out("/Info " + (objectNumber - 1) + " 0 R");` 2946. `if (encryptionOptions !== null) {` 2947. `out("/Encrypt " + encryption.oid + " 0 R");` 2948. `}` 2949. `out("/ID [ <" + fileId + "> <" + fileId + "> ]");` 2950. `out(">>");` 2951. `});` 2953. `var putHeader = (API.__private__.putHeader = function() {` 2954. `out("%PDF-" + pdfVersion);` 2955. `out("%\xBA\xDF\xAC\xE0");` 2956. `});` 2958. `var putXRef = (API.__private__.putXRef = function() {` 2959. `var p = "0000000000";` 2961. `out("xref");` 2962. `out("0 " + (objectNumber + 1));` 2963. `out("0000000000 65535 f ");` 2964. `for (var i = 1; i <= objectNumber; i++) {` 2965. `var offset = offsets[i];` 2966. `if (typeof offset === "function") {` 2967. `out((p + offsets[i]()).slice(-10) + " 00000 n ");` 2968. `} else {` 2969. `if (typeof offsets[i] !== "undefined") {` 2970. `out((p + offsets[i]).slice(-10) + " 00000 n ");` 2971. `} else {` 2972. `out("0000000000 00000 n ");` 2973. `}` 2974. `}` 2975. `}` 2976. `});` 2978. `var buildDocument = (API.__private__.buildDocument = function() {` 2979. `resetDocument();` 2980. `setOutputDestination(content);` 2982. `events.publish("buildDocument");` 2984. `putHeader();` 2985. `putPages();` 2986. `putAdditionalObjects();` 2987. `putResources();` 2988. `if (encryptionOptions !== null) putEncryptionDict();` 2989. `putInfo();` 2990. `putCatalog();` 2992. `var offsetOfXRef = contentLength;` 2993. `putXRef();` 2994. `putTrailer();` 2995. `out("startxref");` 2996. `out("" + offsetOfXRef);` 2997. `out("%%EOF");` 2999. `setOutputDestination(pages[currentPage]);` 3001. `return content.join("\n");` 3002. `});` 3004. `var getBlob = (API.__private__.getBlob = function(data) {` 3005. `return new Blob([getArrayBuffer(data)], {` 3006. `type: "application/pdf"` 3007. `});` 3008. `});` 3010. `/**` 3011. `* Generates the PDF document.` 3012. `*` 3013. ``* If `type` argument is undefined, output is raw body of resulting PDF returned as a string.`` 3014. `*` 3015. `* @param {string} type A string identifying one of the possible output types.
    ` 3016. `* Possible values are:
    ` 3017. `* 'arraybuffer' -> (ArrayBuffer)
    ` 3018. `* 'blob' -> (Blob)
    ` 3019. `* 'bloburi'/'bloburl' -> (string)
    ` 3020. `* 'datauristring'/'dataurlstring' -> (string)
    ` 3021. `* 'datauri'/'dataurl' -> (undefined) -> change location to generated datauristring/dataurlstring
    ` 3022. `* 'dataurlnewwindow' -> (window | null | undefined) throws error if global isn't a window object(node)
    ` 3023. `* 'pdfobjectnewwindow' -> (window | null) throws error if global isn't a window object(node)
    ` 3024. `* 'pdfjsnewwindow' -> (wind | null)` 3025. `* @param {Object|string} options An object providing some additional signalling to PDF generator.
    ` 3026. `* Possible options are 'filename'.
    ` 3027. `* A string can be passed instead of {filename:string} and defaults to 'generated.pdf'` 3028. `* @function` 3029. `* @instance` 3030. `* @returns {string|window|ArrayBuffer|Blob|jsPDF|null|undefined}` 3031. `* @memberof jsPDF#` 3032. `* @name output` 3033. `*/` 3034. `var output = (API.output = API.__private__.output = SAFE(function output(` 3035. `type,` 3036. `options` 3037. `) {` 3038. `options = options || {};` 3040. `if (typeof options === "string") {` 3041. `options = {` 3042. `filename: options` 3043. `};` 3044. `} else {` 3045. `options.filename = options.filename || "generated.pdf";` 3046. `}` 3048. `switch (type) {` 3049. `case undefined:` 3050. `return buildDocument();` 3051. `case "save":` 3052. `API.save(options.filename);` 3053. `break;` 3054. `case "arraybuffer":` 3055. `return getArrayBuffer(buildDocument());` 3056. `case "blob":` 3057. `return getBlob(buildDocument());` 3058. `case "bloburi":` 3059. `case "bloburl":` 3060. `// Developer is responsible of calling revokeObjectURL` 3061. `if (` 3062. `typeof globalObject.URL !== "undefined" &&` 3063. `typeof globalObject.URL.createObjectURL === "function"` 3064. `) {` 3065. `return (` 3066. `(globalObject.URL &&` 3067. `globalObject.URL.createObjectURL(getBlob(buildDocument()))) ||` 3068. `void 0` 3069. `);` 3070. `} else {` 3071. `console.warn(` 3072. `"bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser."` 3073. `);` 3074. `}` 3075. `break;` 3076. `case "datauristring":` 3077. `case "dataurlstring":` 3078. `var dataURI = "";` 3079. `var pdfDocument = buildDocument();` 3080. `try {` 3081. `dataURI = btoa(pdfDocument);` 3082. `} catch (e) {` 3083. `dataURI = btoa(unescape(encodeURIComponent(pdfDocument)));` 3084. `}` 3085. `return (` 3086. `"data:application/pdf;filename=" +` 3087. `options.filename +` 3088. `";base64," +` 3089. `dataURI` 3090. `);` 3091. `case "pdfobjectnewwindow":` 3092. `if (` 3093. `Object.prototype.toString.call(globalObject) === "[object Window]"` 3094. `) {` 3095. `var pdfObjectUrl =` 3096. `"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js";` 3097. `var integrity =` 3098. `' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';` 3100. `if (options.pdfObjectUrl) {` 3101. `pdfObjectUrl = options.pdfObjectUrl;` 3102. `integrity = "";` 3103. `}` 3105. `var htmlForNewWindow =` 3106. `"" +` 3107. `'";` 3116. `var nW = globalObject.open();` 3118. `if (nW !== null) {` 3119. `nW.document.write(htmlForNewWindow);` 3120. `}` 3121. `return nW;` 3122. `} else {` 3123. `throw new Error(` 3124. `"The option pdfobjectnewwindow just works in a browser-environment."` 3125. `);` 3126. `}` 3127. `case "pdfjsnewwindow":` 3128. `if (` 3129. `Object.prototype.toString.call(globalObject) === "[object Window]"` 3130. `) {` 3131. `var pdfJsUrl = options.pdfJsUrl || "examples/PDF.js/web/viewer.html";` 3132. `var htmlForPDFjsNewWindow =` 3133. `"" +` 3134. `"" +` 3135. `'' +` 3174. `"";` 3175. `var dataURLNewWindow = globalObject.open();` 3176. `if (dataURLNewWindow !== null) {` 3177. `dataURLNewWindow.document.write(htmlForDataURLNewWindow);` 3178. `dataURLNewWindow.document.title = options.filename;` 3179. `}` 3180. `if (dataURLNewWindow || typeof safari === "undefined")` 3181. `return dataURLNewWindow;` 3182. `} else {` 3183. `throw new Error(` 3184. `"The option dataurlnewwindow just works in a browser-environment."` 3185. `);` 3186. `}` 3187. `break;` 3188. `case "datauri":` 3189. `case "dataurl":` 3190. `return (globalObject.document.location.href = this.output(` 3191. `"datauristring",` 3192. `options` 3193. `));` 3194. `default:` 3195. `return null;` 3196. `}` 3197. `}));` 3199. `/**` 3200. `* Used to see if a supplied hotfix was requested when the pdf instance was created.` 3201. `* @param {string} hotfixName - The name of the hotfix to check.` 3202. `* @returns {boolean}` 3203. `*/` 3204. `var hasHotfix = function(hotfixName) {` 3205. `return (` 3206. `Array.isArray(hotfixes) === true && hotfixes.indexOf(hotfixName) > -1` 3207. `);` 3208. `};` 3210. `switch (unit) {` 3211. `case "pt":` 3212. `scaleFactor = 1;` 3213. `break;` 3214. `case "mm":` 3215. `scaleFactor = 72 / 25.4;` 3216. `break;` 3217. `case "cm":` 3218. `scaleFactor = 72 / 2.54;` 3219. `break;` 3220. `case "in":` 3221. `scaleFactor = 72;` 3222. `break;` 3223. `case "px":` 3224. `if (hasHotfix("px_scaling") == true) {` 3225. `scaleFactor = 72 / 96;` 3226. `} else {` 3227. `scaleFactor = 96 / 72;` 3228. `}` 3229. `break;` 3230. `case "pc":` 3231. `scaleFactor = 12;` 3232. `break;` 3233. `case "em":` 3234. `scaleFactor = 12;` 3235. `break;` 3236. `case "ex":` 3237. `scaleFactor = 6;` 3238. `break;` 3239. `default:` 3240. `if (typeof unit === "number") {` 3241. `scaleFactor = unit;` 3242. `} else {` 3243. `throw new Error("Invalid unit: " + unit);` 3244. `}` 3245. `}` 3247. `var encryption = null;` 3248. `setCreationDate();` 3249. `setFileId();` 3251. `var getEncryptor = function(objectId) {` 3252. `if (encryptionOptions !== null) {` 3253. `return encryption.encryptor(objectId, 0);` 3254. `}` 3255. `return function(data) {` 3256. `return data;` 3257. `};` 3258. `};` 3260. `//---------------------------------------` 3261. `// Public API` 3263. `var getPageInfo = (API.__private__.getPageInfo = API.getPageInfo = function(` 3264. `pageNumberOneBased` 3265. `) {` 3266. `if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) {` 3267. `throw new Error("Invalid argument passed to jsPDF.getPageInfo");` 3268. `}` 3269. `var objId = pagesContext[pageNumberOneBased].objId;` 3270. `return {` 3271. `objId: objId,` 3272. `pageNumber: pageNumberOneBased,` 3273. `pageContext: pagesContext[pageNumberOneBased]` 3274. `};` 3275. `});` 3277. `var getPageInfoByObjId = (API.__private__.getPageInfoByObjId = function(` 3278. `objId` 3279. `) {` 3280. `if (isNaN(objId) || objId % 1 !== 0) {` 3281. `throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");` 3282. `}` 3283. `for (var pageNumber in pagesContext) {` 3284. `if (pagesContext[pageNumber].objId === objId) {` 3285. `break;` 3286. `}` 3287. `}` 3288. `return getPageInfo(pageNumber);` 3289. `});` 3291. `var getCurrentPageInfo = (API.__private__.getCurrentPageInfo = API.getCurrentPageInfo = function() {` 3292. `return {` 3293. `objId: pagesContext[currentPage].objId,` 3294. `pageNumber: currentPage,` 3295. `pageContext: pagesContext[currentPage]` 3296. `};` 3297. `});` 3299. `/**` 3300. `* Adds (and transfers the focus to) new page to the PDF document.` 3301. `* @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

    ` 3302. `* 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]` 3303. `* @param orientation {string} Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l").` 3304. `* @function` 3305. `* @instance` 3306. `* @returns {jsPDF}` 3307. `*` 3308. `* @memberof jsPDF#` 3309. `* @name addPage` 3310. `*/` 3311. `API.addPage = function() {` 3312. `_addPage.apply(this, arguments);` 3313. `return this;` 3314. `};` 3315. `/**` 3316. `* Adds (and transfers the focus to) new page to the PDF document.` 3317. `* @function` 3318. `* @instance` 3319. `* @returns {jsPDF}` 3320. `*` 3321. `* @memberof jsPDF#` 3322. `* @name setPage` 3323. `* @param {number} page Switch the active page to the page number specified (indexed starting at 1).` 3324. `* @example` 3325. `* doc = jsPDF()` 3326. `* doc.addPage()` 3327. `* doc.addPage()` 3328. `* doc.text('I am on page 3', 10, 10)` 3329. `* doc.setPage(1)` 3330. `* doc.text('I am on page 1', 10, 10)` 3331. `*/` 3332. `API.setPage = function() {` 3333. `_setPage.apply(this, arguments);` 3334. `setOutputDestination.call(this, pages[currentPage]);` 3335. `return this;` 3336. `};` 3338. `/**` 3339. `* @name insertPage` 3340. `* @memberof jsPDF#` 3341. `*` 3342. `* @function` 3343. `* @instance` 3344. `* @param {Object} beforePage` 3345. `* @returns {jsPDF}` 3346. `*/` 3347. `API.insertPage = function(beforePage) {` 3348. `this.addPage();` 3349. `this.movePage(currentPage, beforePage);` 3350. `return this;` 3351. `};` 3353. `/**` 3354. `* @name movePage` 3355. `* @memberof jsPDF#` 3356. `* @function` 3357. `* @instance` 3358. `* @param {number} targetPage` 3359. `* @param {number} beforePage` 3360. `* @returns {jsPDF}` 3361. `*/` 3362. `API.movePage = function(targetPage, beforePage) {` 3363. `var tmpPages, tmpPagesContext;` 3364. `if (targetPage > beforePage) {` 3365. `tmpPages = pages[targetPage];` 3366. `tmpPagesContext = pagesContext[targetPage];` 3367. `for (var i = targetPage; i > beforePage; i--) {` 3368. `pages[i] = pages[i - 1];` 3369. `pagesContext[i] = pagesContext[i - 1];` 3370. `}` 3371. `pages[beforePage] = tmpPages;` 3372. `pagesContext[beforePage] = tmpPagesContext;` 3373. `this.setPage(beforePage);` 3374. `} else if (targetPage < beforePage) {` 3375. `tmpPages = pages[targetPage];` 3376. `tmpPagesContext = pagesContext[targetPage];` 3377. `for (var j = targetPage; j < beforePage; j++) {` 3378. `pages[j] = pages[j + 1];` 3379. `pagesContext[j] = pagesContext[j + 1];` 3380. `}` 3381. `pages[beforePage] = tmpPages;` 3382. `pagesContext[beforePage] = tmpPagesContext;` 3383. `this.setPage(beforePage);` 3384. `}` 3385. `return this;` 3386. `};` 3388. `/**` 3389. `* Deletes a page from the PDF.` 3390. `* @name deletePage` 3391. `* @memberof jsPDF#` 3392. `* @function` 3393. `* @param {number} targetPage` 3394. `* @instance` 3395. `* @returns {jsPDF}` 3396. `*/` 3397. `API.deletePage = function() {` 3398. `_deletePage.apply(this, arguments);` 3399. `return this;` 3400. `};` 3402. `/**` 3403. `* Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.` 3404. `*` 3405. `* @function` 3406. `* @instance` 3407. `* @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.` 3408. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page.` 3409. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page.` 3410. `* @param {Object} [options] - Collection of settings signaling how the text must be encoded.` 3411. `* @param {string} [options.align=left] - The alignment of the text, possible values: left, center, right, justify.` 3412. `* @param {string} [options.baseline=alphabetic] - Sets text baseline used when drawing the text, possible values: alphabetic, ideographic, bottom, top, middle, hanging` 3413. `* @param {number|Matrix} [options.angle=0] - Rotate the text clockwise or counterclockwise. Expects the angle in degree.` 3414. `* @param {number} [options.rotationDirection=1] - Direction of the rotation. 0 = clockwise, 1 = counterclockwise.` 3415. `* @param {number} [options.charSpace=0] - The space between each letter.` 3416. `* @param {number} [options.horizontalScale=1] - Horizontal scale of the text as a factor of the regular size.` 3417. `* @param {number} [options.lineHeightFactor=1.15] - The lineheight of each line.` 3418. `* @param {Object} [options.flags] - Flags for to8bitStream.` 3419. `* @param {boolean} [options.flags.noBOM=true] - Don't add BOM to Unicode-text.` 3420. `* @param {boolean} [options.flags.autoencode=true] - Autoencode the Text.` 3421. `* @param {number} [options.maxWidth=0] - Split the text by given width, 0 = no split.` 3422. `* @param {string} [options.renderingMode=fill] - Set how the text should be rendered, possible values: fill, stroke, fillThenStroke, invisible, fillAndAddForClipping, strokeAndAddPathForClipping, fillThenStrokeAndAddToPathForClipping, addToPathForClipping.` 3423. `* @param {boolean} [options.isInputVisual] - Option for the BidiEngine` 3424. `* @param {boolean} [options.isOutputVisual] - Option for the BidiEngine` 3425. `* @param {boolean} [options.isInputRtl] - Option for the BidiEngine` 3426. `* @param {boolean} [options.isOutputRtl] - Option for the BidiEngine` 3427. `* @param {boolean} [options.isSymmetricSwapping] - Option for the BidiEngine` 3428. `* @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.` 3429. `*` 3430. `* If it is a Matrix, this matrix gets directly applied to the text, which allows shearing` 3431. `* effects etc.; the x and y offsets are then applied AFTER the coordinate system has been established by this` 3432. `* matrix. This means passing a rotation matrix that is equivalent to some rotation angle will in general yield a` 3433. `* DIFFERENT result. A matrix is only allowed in "advanced" API mode.` 3434. `* @returns {jsPDF}` 3435. `* @memberof jsPDF#` 3436. `* @name text` 3437. `*/` 3438. `API.__private__.text = API.text = function(text, x, y, options, transform) {` 3439. `/*` 3440. `* Inserts something like this into PDF` 3441. `* BT` 3442. `* /F1 16 Tf % Font name + size` 3443. `* 16 TL % How many units down for next line in multiline text` 3444. `* 0 g % color` 3445. `* 28.35 813.54 Td % position` 3446. `* (line one) Tj` 3447. `* T* (line two) Tj` 3448. `* T* (line three) Tj` 3449. `* ET` 3450. `*/` 3451. `options = options || {};` 3452. `var scope = options.scope || this;` 3453. `var payload, da, angle, align, charSpace, maxWidth, flags, horizontalScale;` 3455. `// Pre-August-2012 the order of arguments was function(x, y, text, flags)` 3456. `// in effort to make all calls have similar signature like` 3457. `// function(data, coordinates... , miscellaneous)` 3458. `// this method had its args flipped.` 3459. `// code below allows backward compatibility with old arg order.` 3460. `if (` 3461. `typeof text === "number" &&` 3462. `typeof x === "number" &&` 3463. `(typeof y === "string" || Array.isArray(y))` 3464. `) {` 3465. `var tmp = y;` 3466. `y = x;` 3467. `x = text;` 3468. `text = tmp;` 3469. `}` 3471. `var transformationMatrix;` 3473. `if (arguments[3] instanceof Matrix === false) {` 3474. `flags = arguments[3];` 3475. `angle = arguments[4];` 3476. `align = arguments[5];` 3478. `if (typeof flags !== "object" || flags === null) {` 3479. `if (typeof angle === "string") {` 3480. `align = angle;` 3481. `angle = null;` 3482. `}` 3483. `if (typeof flags === "string") {` 3484. `align = flags;` 3485. `flags = null;` 3486. `}` 3487. `if (typeof flags === "number") {` 3488. `angle = flags;` 3489. `flags = null;` 3490. `}` 3491. `options = {` 3492. `flags: flags,` 3493. `angle: angle,` 3494. `align: align` 3495. `};` 3496. `}` 3497. `} else {` 3498. `advancedApiModeTrap(` 3499. `"The transform parameter of text() with a Matrix value"` 3500. `);` 3501. `transformationMatrix = transform;` 3502. `}` 3504. `if (isNaN(x) || isNaN(y) || typeof text === "undefined" || text === null) {` 3505. `throw new Error("Invalid arguments passed to jsPDF.text");` 3506. `}` 3508. `if (text.length === 0) {` 3509. `return scope;` 3510. `}` 3512. `var xtra = "";` 3513. `var isHex = false;` 3514. `var lineHeight =` 3515. `typeof options.lineHeightFactor === "number"` 3516. `? options.lineHeightFactor` 3517. `: lineHeightFactor;` 3518. `var scaleFactor = scope.internal.scaleFactor;` 3520. `function ESC(s) {` 3521. `s = s.split("\t").join(Array(options.TabLen || 9).join(" "));` 3522. `return pdfEscape(s, flags);` 3523. `}` 3525. `function transformTextToSpecialArray(text) {` 3526. `//we don't want to destroy original text array, so cloning it` 3527. `var sa = text.concat();` 3528. `var da = [];` 3529. `var len = sa.length;` 3530. `var curDa;` 3531. `//we do array.join('text that must not be PDFescaped")` 3532. `//thus, pdfEscape each component separately` 3533. `while (len--) {` 3534. `curDa = sa.shift();` 3535. `if (typeof curDa === "string") {` 3536. `da.push(curDa);` 3537. `} else {` 3538. `if (` 3539. `Array.isArray(text) &&` 3540. `(curDa.length === 1 ||` 3541. `(curDa[1] === undefined && curDa[2] === undefined))` 3542. `) {` 3543. `da.push(curDa[0]);` 3544. `} else {` 3545. `da.push([curDa[0], curDa[1], curDa[2]]);` 3546. `}` 3547. `}` 3548. `}` 3549. `return da;` 3550. `}` 3552. `function processTextByFunction(text, processingFunction) {` 3553. `var result;` 3554. `if (typeof text === "string") {` 3555. `result = processingFunction(text)[0];` 3556. `} else if (Array.isArray(text)) {` 3557. `//we don't want to destroy original text array, so cloning it` 3558. `var sa = text.concat();` 3559. `var da = [];` 3560. `var len = sa.length;` 3561. `var curDa;` 3562. `var tmpResult;` 3563. `//we do array.join('text that must not be PDFescaped")` 3564. `//thus, pdfEscape each component separately` 3565. `while (len--) {` 3566. `curDa = sa.shift();` 3567. `if (typeof curDa === "string") {` 3568. `da.push(processingFunction(curDa)[0]);` 3569. `} else if (Array.isArray(curDa) && typeof curDa[0] === "string") {` 3570. `tmpResult = processingFunction(curDa[0], curDa[1], curDa[2]);` 3571. `da.push([tmpResult[0], tmpResult[1], tmpResult[2]]);` 3572. `}` 3573. `}` 3574. `result = da;` 3575. `}` 3576. `return result;` 3577. `}` 3579. `//Check if text is of type String` 3580. `var textIsOfTypeString = false;` 3581. `var tmpTextIsOfTypeString = true;` 3583. `if (typeof text === "string") {` 3584. `textIsOfTypeString = true;` 3585. `} else if (Array.isArray(text)) {` 3586. `//we don't want to destroy original text array, so cloning it` 3587. `var sa = text.concat();` 3588. `da = [];` 3589. `var len = sa.length;` 3590. `var curDa;` 3591. `//we do array.join('text that must not be PDFescaped")` 3592. `//thus, pdfEscape each component separately` 3593. `while (len--) {` 3594. `curDa = sa.shift();` 3595. `if (` 3596. `typeof curDa !== "string" ||` 3597. `(Array.isArray(curDa) && typeof curDa[0] !== "string")` 3598. `) {` 3599. `tmpTextIsOfTypeString = false;` 3600. `}` 3601. `}` 3602. `textIsOfTypeString = tmpTextIsOfTypeString;` 3603. `}` 3604. `if (textIsOfTypeString === false) {` 3605. `throw new Error(` 3606. `'Type of text must be string or Array. "' +` 3607. `text +` 3608. `'" is not recognized.'` 3609. `);` 3610. `}` 3612. `//If there are any newlines in text, we assume` 3613. `//the user wanted to print multiple lines, so break the` 3614. `//text up into an array. If the text is already an array,` 3615. `//we assume the user knows what they are doing.` 3616. `//Convert text into an array anyway to simplify` 3617. `//later code.` 3619. `if (typeof text === "string") {` 3620. `if (text.match(/[\r?\n]/)) {` 3621. `text = text.split(/\r\n|\r|\n/g);` 3622. `} else {` 3623. `text = [text];` 3624. `}` 3625. `}` 3627. `//baseline` 3628. `var height = activeFontSize / scope.internal.scaleFactor;` 3629. `var descent = height * (lineHeight - 1);` 3631. `switch (options.baseline) {` 3632. `case "bottom":` 3633. `y -= descent;` 3634. `break;` 3635. `case "top":` 3636. `y += height - descent;` 3637. `break;` 3638. `case "hanging":` 3639. `y += height - 2 * descent;` 3640. `break;` 3641. `case "middle":` 3642. `y += height / 2 - descent;` 3643. `break;` 3644. `case "ideographic":` 3645. `case "alphabetic":` 3646. `default:` 3647. `// do nothing, everything is fine` 3648. `break;` 3649. `}` 3651. `//multiline` 3652. `maxWidth = options.maxWidth || 0;` 3654. `if (maxWidth > 0) {` 3655. `if (typeof text === "string") {` 3656. `text = scope.splitTextToSize(text, maxWidth);` 3657. `} else if (Object.prototype.toString.call(text) === "[object Array]") {` 3658. `text = text.reduce(function(acc, textLine) {` 3659. `return acc.concat(scope.splitTextToSize(textLine, maxWidth));` 3660. `}, []);` 3661. `}` 3662. `}` 3664. `//creating Payload-Object to make text byRef` 3665. `payload = {` 3666. `text: text,` 3667. `x: x,` 3668. `y: y,` 3669. `options: options,` 3670. `mutex: {` 3671. `pdfEscape: pdfEscape,` 3672. `activeFontKey: activeFontKey,` 3673. `fonts: fonts,` 3674. `activeFontSize: activeFontSize` 3675. `}` 3676. `};` 3677. `events.publish("preProcessText", payload);` 3679. `text = payload.text;` 3680. `options = payload.options;` 3682. `//angle` 3683. `angle = options.angle;` 3685. `if (` 3686. `transformationMatrix instanceof Matrix === false &&` 3687. `angle &&` 3688. `typeof angle === "number"` 3689. `) {` 3690. `angle *= Math.PI / 180;` 3692. `if (options.rotationDirection === 0) {` 3693. `angle = -angle;` 3694. `}` 3696. `if (apiMode === ApiMode.ADVANCED) {` 3697. `angle = -angle;` 3698. `}` 3700. `var c = Math.cos(angle);` 3701. `var s = Math.sin(angle);` 3702. `transformationMatrix = new Matrix(c, s, -s, c, 0, 0);` 3703. `} else if (angle && angle instanceof Matrix) {` 3704. `transformationMatrix = angle;` 3705. `}` 3707. `if (apiMode === ApiMode.ADVANCED && !transformationMatrix) {` 3708. `transformationMatrix = identityMatrix;` 3709. `}` 3711. `//charSpace` 3713. `charSpace = options.charSpace || activeCharSpace;` 3715. `if (typeof charSpace !== "undefined") {` 3716. `xtra += hpf(scale(charSpace)) + " Tc\n";` 3717. `this.setCharSpace(this.getCharSpace() || 0);` 3718. `}` 3720. `horizontalScale = options.horizontalScale;` 3721. `if (typeof horizontalScale !== "undefined") {` 3722. `xtra += hpf(horizontalScale * 100) + " Tz\n";` 3723. `}` 3725. `//lang` 3727. `var lang = options.lang;` 3729. `if (lang) {` 3730. `// xtra += "/Lang (" + lang +")\n";` 3731. `}` 3733. `//renderingMode` 3734. `var renderingMode = -1;` 3735. `var parmRenderingMode =` 3736. `typeof options.renderingMode !== "undefined"` 3737. `? options.renderingMode` 3738. `: options.stroke;` 3739. `var pageContext = scope.internal.getCurrentPageInfo().pageContext;` 3741. `switch (parmRenderingMode) {` 3742. `case 0:` 3743. `case false:` 3744. `case "fill":` 3745. `renderingMode = 0;` 3746. `break;` 3747. `case 1:` 3748. `case true:` 3749. `case "stroke":` 3750. `renderingMode = 1;` 3751. `break;` 3752. `case 2:` 3753. `case "fillThenStroke":` 3754. `renderingMode = 2;` 3755. `break;` 3756. `case 3:` 3757. `case "invisible":` 3758. `renderingMode = 3;` 3759. `break;` 3760. `case 4:` 3761. `case "fillAndAddForClipping":` 3762. `renderingMode = 4;` 3763. `break;` 3764. `case 5:` 3765. `case "strokeAndAddPathForClipping":` 3766. `renderingMode = 5;` 3767. `break;` 3768. `case 6:` 3769. `case "fillThenStrokeAndAddToPathForClipping":` 3770. `renderingMode = 6;` 3771. `break;` 3772. `case 7:` 3773. `case "addToPathForClipping":` 3774. `renderingMode = 7;` 3775. `break;` 3776. `}` 3778. `var usedRenderingMode =` 3779. `typeof pageContext.usedRenderingMode !== "undefined"` 3780. `? pageContext.usedRenderingMode` 3781. `: -1;` 3783. `//if the coder wrote it explicitly to use a specific` 3784. `//renderingMode, then use it` 3785. `if (renderingMode !== -1) {` 3786. `xtra += renderingMode + " Tr\n";` 3787. `//otherwise check if we used the rendering Mode already` 3788. `//if so then set the rendering Mode...` 3789. `} else if (usedRenderingMode !== -1) {` 3790. `xtra += "0 Tr\n";` 3791. `}` 3793. `if (renderingMode !== -1) {` 3794. `pageContext.usedRenderingMode = renderingMode;` 3795. `}` 3797. `//align` 3798. `align = options.align || "left";` 3799. `var leading = activeFontSize * lineHeight;` 3800. `var pageWidth = scope.internal.pageSize.getWidth();` 3801. `var activeFont = fonts[activeFontKey];` 3802. `charSpace = options.charSpace || activeCharSpace;` 3803. `maxWidth = options.maxWidth || 0;` 3805. `var lineWidths;` 3806. `flags = Object.assign({ autoencode: true, noBOM: true }, options.flags);` 3808. `var wordSpacingPerLine = [];` 3809. `var findWidth = function(v) {` 3810. `return (` 3811. `(scope.getStringUnitWidth(v, {` 3812. `font: activeFont,` 3813. `charSpace: charSpace,` 3814. `fontSize: activeFontSize,` 3815. `doKerning: false` 3816. `}) *` 3817. `activeFontSize) /` 3818. `scaleFactor` 3819. `);` 3820. `};` 3821. `if (Object.prototype.toString.call(text) === "[object Array]") {` 3822. `da = transformTextToSpecialArray(text);` 3823. `var newY;` 3824. `if (align !== "left") {` 3825. `lineWidths = da.map(findWidth);` 3826. `}` 3827. `//The first line uses the "main" Td setting,` 3828. `//and the subsequent lines are offset by the` 3829. `//previous line's x coordinate.` 3830. `var prevWidth = 0;` 3831. `var newX;` 3832. `if (align === "right") {` 3833. `//The passed in x coordinate defines the` 3834. `//rightmost point of the text.` 3835. `x -= lineWidths[0];` 3836. `text = [];` 3837. `len = da.length;` 3838. `for (var i = 0; i < len; i++) {` 3839. `if (i === 0) {` 3840. `newX = getHorizontalCoordinate(x);` 3841. `newY = getVerticalCoordinate(y);` 3842. `} else {` 3843. `newX = scale(prevWidth - lineWidths[i]);` 3844. `newY = -leading;` 3845. `}` 3846. `text.push([da[i], newX, newY]);` 3847. `prevWidth = lineWidths[i];` 3848. `}` 3849. `} else if (align === "center") {` 3850. `//The passed in x coordinate defines` 3851. `//the center point.` 3852. `x -= lineWidths[0] / 2;` 3853. `text = [];` 3854. `len = da.length;` 3855. `for (var j = 0; j < len; j++) {` 3856. `if (j === 0) {` 3857. `newX = getHorizontalCoordinate(x);` 3858. `newY = getVerticalCoordinate(y);` 3859. `} else {` 3860. `newX = scale((prevWidth - lineWidths[j]) / 2);` 3861. `newY = -leading;` 3862. `}` 3863. `text.push([da[j], newX, newY]);` 3864. `prevWidth = lineWidths[j];` 3865. `}` 3866. `} else if (align === "left") {` 3867. `text = [];` 3868. `len = da.length;` 3869. `for (var h = 0; h < len; h++) {` 3870. `text.push(da[h]);` 3871. `}` 3872. `} else if (align === "justify" && activeFont.encoding === "Identity-H") {` 3873. `// when using unicode fonts, wordSpacePerLine does not apply` 3874. `text = [];` 3875. `len = da.length;` 3876. `maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;` 3877. `let backToStartX = 0;` 3878. `for (var l = 0; l < len; l++) {` 3879. `newY = l === 0 ? getVerticalCoordinate(y) : -leading;` 3880. `newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX;` 3881. `if (l < len - 1) {` 3882. `let spacing = scale(` 3883. `(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)` 3884. `);` 3885. `let words = da[l].split(" ");` 3886. `text.push([words[0] + " ", newX, newY]);` 3887. `backToStartX = 0; // distance to reset back to the left` 3888. `for (let i = 1; i < words.length; i++) {` 3889. `let shiftAmount =` 3890. `(findWidth(words[i - 1] + " " + words[i]) -` 3891. `findWidth(words[i])) *` 3892. `scaleFactor +` 3893. `spacing;` 3894. `if (i == words.length - 1) text.push([words[i], shiftAmount, 0]);` 3895. `else text.push([words[i] + " ", shiftAmount, 0]);` 3896. `backToStartX -= shiftAmount;` 3897. `}` 3898. `} else {` 3899. `text.push([da[l], newX, newY]);` 3900. `}` 3901. `}` 3902. `text.push(["", backToStartX, 0]);` 3903. `} else if (align === "justify") {` 3904. `text = [];` 3905. `len = da.length;` 3906. `maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;` 3907. `for (var l = 0; l < len; l++) {` 3908. `newY = l === 0 ? getVerticalCoordinate(y) : -leading;` 3909. `newX = l === 0 ? getHorizontalCoordinate(x) : 0;` 3910. `if (l < len - 1) {` 3911. `wordSpacingPerLine.push(` 3912. `hpf(` 3913. `scale(` 3914. `(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)` 3915. `)` 3916. `)` 3917. `);` 3918. `} else {` 3919. `wordSpacingPerLine.push(0);` 3920. `}` 3921. `text.push([da[l], newX, newY]);` 3922. `}` 3923. `} else {` 3924. `throw new Error(` 3925. `'Unrecognized alignment option, use "left", "center", "right" or "justify".'` 3926. `);` 3927. `}` 3928. `}` 3930. `//R2L` 3931. `var doReversing = typeof options.R2L === "boolean" ? options.R2L : R2L;` 3932. `if (doReversing === true) {` 3933. `text = processTextByFunction(text, function(text, posX, posY) {` 3934. `return [`\ 3935. `text`\ 3936. `.split("")`\ 3937. `.reverse()`\ 3938. `.join(""),`\ 3939. `posX,`\ 3940. `posY`\ 3941. `];` 3942. `});` 3943. `}` 3945. `//creating Payload-Object to make text byRef` 3946. `payload = {` 3947. `text: text,` 3948. `x: x,` 3949. `y: y,` 3950. `options: options,` 3951. `mutex: {` 3952. `pdfEscape: pdfEscape,` 3953. `activeFontKey: activeFontKey,` 3954. `fonts: fonts,` 3955. `activeFontSize: activeFontSize` 3956. `}` 3957. `};` 3958. `events.publish("postProcessText", payload);` 3960. `text = payload.text;` 3961. `isHex = payload.mutex.isHex || false;` 3963. `//Escaping` 3964. `var activeFontEncoding = fonts[activeFontKey].encoding;` 3966. `if (` 3967. `activeFontEncoding === "WinAnsiEncoding" ||` 3968. `activeFontEncoding === "StandardEncoding"` 3969. `) {` 3970. `text = processTextByFunction(text, function(text, posX, posY) {` 3971. `return [ESC(text), posX, posY];` 3972. `});` 3973. `}` 3975. `da = transformTextToSpecialArray(text);` 3977. `text = [];` 3978. `var STRING = 0;` 3979. `var ARRAY = 1;` 3980. `var variant = Array.isArray(da[0]) ? ARRAY : STRING;` 3981. `var posX;` 3982. `var posY;` 3983. `var content;` 3984. `var wordSpacing = "";` 3986. `var generatePosition = function(` 3987. `parmPosX,` 3988. `parmPosY,` 3989. `parmTransformationMatrix` 3990. `) {` 3991. `var position = "";` 3992. `if (parmTransformationMatrix instanceof Matrix) {` 3993. `// It is kind of more intuitive to apply a plain rotation around the text anchor set by x and y` 3994. `// but when the user supplies an arbitrary transformation matrix, the x and y offsets should be applied` 3995. `// in the coordinate system established by this matrix` 3996. `if (typeof options.angle === "number") {` 3997. `parmTransformationMatrix = matrixMult(` 3998. `parmTransformationMatrix,` 3999. `new Matrix(1, 0, 0, 1, parmPosX, parmPosY)` 4000. `);` 4001. `} else {` 4002. `parmTransformationMatrix = matrixMult(` 4003. `new Matrix(1, 0, 0, 1, parmPosX, parmPosY),` 4004. `parmTransformationMatrix` 4005. `);` 4006. `}` 4008. `if (apiMode === ApiMode.ADVANCED) {` 4009. `parmTransformationMatrix = matrixMult(` 4010. `new Matrix(1, 0, 0, -1, 0, 0),` 4011. `parmTransformationMatrix` 4012. `);` 4013. `}` 4015. `position = parmTransformationMatrix.join(" ") + " Tm\n";` 4016. `} else {` 4017. `position = hpf(parmPosX) + " " + hpf(parmPosY) + " Td\n";` 4018. `}` 4019. `return position;` 4020. `};` 4022. `for (var lineIndex = 0; lineIndex < da.length; lineIndex++) {` 4023. `wordSpacing = "";` 4025. `switch (variant) {` 4026. `case ARRAY:` 4027. `content =` 4028. `(isHex ? "<" : "(") + da[lineIndex][0] + (isHex ? ">" : ")");` 4029. `posX = parseFloat(da[lineIndex][1]);` 4030. `posY = parseFloat(da[lineIndex][2]);` 4031. `break;` 4032. `case STRING:` 4033. `content = (isHex ? "<" : "(") + da[lineIndex] + (isHex ? ">" : ")");` 4034. `posX = getHorizontalCoordinate(x);` 4035. `posY = getVerticalCoordinate(y);` 4036. `break;` 4037. `}` 4039. `if (` 4040. `typeof wordSpacingPerLine !== "undefined" &&` 4041. `typeof wordSpacingPerLine[lineIndex] !== "undefined"` 4042. `) {` 4043. `wordSpacing = wordSpacingPerLine[lineIndex] + " Tw\n";` 4044. `}` 4046. `if (lineIndex === 0) {` 4047. `text.push(` 4048. `wordSpacing +` 4049. `generatePosition(posX, posY, transformationMatrix) +` 4050. `content` 4051. `);` 4052. `} else if (variant === STRING) {` 4053. `text.push(wordSpacing + content);` 4054. `} else if (variant === ARRAY) {` 4055. `text.push(` 4056. `wordSpacing +` 4057. `generatePosition(posX, posY, transformationMatrix) +` 4058. `content` 4059. `);` 4060. `}` 4061. `}` 4063. `text = variant === STRING ? text.join(" Tj\nT* ") : text.join(" Tj\n");` 4064. `text += " Tj\n";` 4066. `var result = "BT\n/";` 4067. `result += activeFontKey + " " + activeFontSize + " Tf\n"; // font face, style, size` 4068. `result += hpf(activeFontSize * lineHeight) + " TL\n"; // line spacing` 4069. `result += textColor + "\n";` 4070. `result += xtra;` 4071. `result += text;` 4072. `result += "ET";` 4074. `out(result);` 4075. `usedFonts[activeFontKey] = true;` 4076. `return scope;` 4077. `};` 4079. `// PDF supports these path painting and clip path operators:` 4080. `//` 4081. `// S - stroke` 4082. `// s - close/stroke` 4083. `// f (F) - fill non-zero` 4084. `// f* - fill evenodd` 4085. `// B - fill stroke nonzero` 4086. `// B* - fill stroke evenodd` 4087. `// b - close fill stroke nonzero` 4088. `// b* - close fill stroke evenodd` 4089. `// n - nothing (consume path)` 4090. `// W - clip nonzero` 4091. `// W* - clip evenodd` 4092. `//` 4093. `// In order to keep the API small, we omit the close-and-fill/stroke operators and provide a separate close()` 4094. `// method.` 4095. `/**` 4096. `*` 4097. `* @name clip` 4098. `* @function` 4099. `* @instance` 4100. `* @param {string} rule Only possible value is 'evenodd'` 4101. `* @returns {jsPDF}` 4102. `* @memberof jsPDF#` 4103. `* @description All .clip() after calling drawing ops with a style argument of null.` 4104. `*/` 4105. `var clip = (API.__private__.clip = API.clip = function(rule) {` 4106. `// Call .clip() after calling drawing ops with a style argument of null` 4107. `// W is the PDF clipping op` 4108. `if ("evenodd" === rule) {` 4109. `out("W*");` 4110. `} else {` 4111. `out("W");` 4112. `}` 4113. `return this;` 4114. `});` 4116. `/**` 4117. `* @name clipEvenOdd` 4118. `* @function` 4119. `* @instance` 4120. `* @returns {jsPDF}` 4121. `* @memberof jsPDF#` 4122. `* @description Modify the current clip path by intersecting it with the current path using the even-odd rule. Note` 4123. `* that this will NOT consume the current path. In order to only use this path for clipping call` 4124. `* {@link API.discardPath} afterwards.` 4125. `*/` 4126. `API.clipEvenOdd = function() {` 4127. `return clip("evenodd");` 4128. `};` 4130. `/**` 4131. `* Consumes the current path without any effect. Mainly used in combination with {@link clip} or` 4132. `* {@link clipEvenOdd}. The PDF "n" operator.` 4133. `* @name discardPath` 4134. `* @function` 4135. `* @instance` 4136. `* @returns {jsPDF}` 4137. `* @memberof jsPDF#` 4138. `*/` 4139. `API.__private__.discardPath = API.discardPath = function() {` 4140. `out("n");` 4141. `return this;` 4142. `};` 4144. `var isValidStyle = (API.__private__.isValidStyle = function(style) {` 4145. `var validStyleVariants = [`\ 4146. `undefined,`\ 4147. `null,`\ 4148. `"S",`\ 4149. `"D",`\ 4150. `"F",`\ 4151. `"DF",`\ 4152. `"FD",`\ 4153. `"f",`\ 4154. `"f*",`\ 4155. `"B",`\ 4156. `"B*",`\ 4157. `"n"`\ 4158. `];` 4159. `var result = false;` 4160. `if (validStyleVariants.indexOf(style) !== -1) {` 4161. `result = true;` 4162. `}` 4163. `return result;` 4164. `});` 4166. `API.__private__.setDefaultPathOperation = API.setDefaultPathOperation = function(` 4167. `operator` 4168. `) {` 4169. `if (isValidStyle(operator)) {` 4170. `defaultPathOperation = operator;` 4171. `}` 4172. `return this;` 4173. `};` 4175. `var getStyle = (API.__private__.getStyle = API.getStyle = function(style) {` 4176. `// see path-painting operators in PDF spec` 4177. `var op = defaultPathOperation; // stroke` 4179. `switch (style) {` 4180. `case "D":` 4181. `case "S":` 4182. `op = "S"; // stroke` 4183. `break;` 4184. `case "F":` 4185. `op = "f"; // fill` 4186. `break;` 4187. `case "FD":` 4188. `case "DF":` 4189. `op = "B";` 4190. `break;` 4191. `case "f":` 4192. `case "f*":` 4193. `case "B":` 4194. `case "B*":` 4195. `/*` 4196. `Allow direct use of these PDF path-painting operators:` 4197. `- f fill using nonzero winding number rule` 4198. `- f* fill using even-odd rule` 4199. `- B fill then stroke with fill using non-zero winding number rule` 4200. `- B* fill then stroke with fill using even-odd rule` 4201. `*/` 4202. `op = style;` 4203. `break;` 4204. `}` 4205. `return op;` 4206. `});` 4208. `/**` 4209. `* Close the current path. The PDF "h" operator.` 4210. `* @name close` 4211. `* @function` 4212. `* @instance` 4213. `* @returns {jsPDF}` 4214. `* @memberof jsPDF#` 4215. `*/` 4216. `var close = (API.close = function() {` 4217. `out("h");` 4218. `return this;` 4219. `});` 4221. `/**` 4222. `* Stroke the path. The PDF "S" operator.` 4223. `* @name stroke` 4224. `* @function` 4225. `* @instance` 4226. `* @returns {jsPDF}` 4227. `* @memberof jsPDF#` 4228. `*/` 4229. `API.stroke = function() {` 4230. `out("S");` 4231. `return this;` 4232. `};` 4234. `/**` 4235. `* Fill the current path using the nonzero winding number rule. If a pattern is provided, the path will be filled` 4236. `* with this pattern, otherwise with the current fill color. Equivalent to the PDF "f" operator.` 4237. `* @name fill` 4238. `* @function` 4239. `* @instance` 4240. `* @param {PatternData=} pattern If provided the path will be filled with this pattern` 4241. `* @returns {jsPDF}` 4242. `* @memberof jsPDF#` 4243. `*/` 4244. `API.fill = function(pattern) {` 4245. `fillWithOptionalPattern("f", pattern);` 4246. `return this;` 4247. `};` 4249. `/**` 4250. `* Fill the current path using the even-odd rule. The PDF f* operator.` 4251. `* @see API.fill` 4252. `* @name fillEvenOdd` 4253. `* @function` 4254. `* @instance` 4255. `* @param {PatternData=} pattern If provided the path will be filled with this pattern` 4256. `* @returns {jsPDF}` 4257. `* @memberof jsPDF#` 4258. `*/` 4259. `API.fillEvenOdd = function(pattern) {` 4260. `fillWithOptionalPattern("f*", pattern);` 4261. `return this;` 4262. `};` 4264. `/**` 4265. `* Fill using the nonzero winding number rule and then stroke the current Path. The PDF "B" operator.` 4266. `* @see API.fill` 4267. `* @name fillStroke` 4268. `* @function` 4269. `* @instance` 4270. `* @param {PatternData=} pattern If provided the path will be stroked with this pattern` 4271. `* @returns {jsPDF}` 4272. `* @memberof jsPDF#` 4273. `*/` 4274. `API.fillStroke = function(pattern) {` 4275. `fillWithOptionalPattern("B", pattern);` 4276. `return this;` 4277. `};` 4279. `/**` 4280. `* Fill using the even-odd rule and then stroke the current Path. The PDF "B" operator.` 4281. `* @see API.fill` 4282. `* @name fillStrokeEvenOdd` 4283. `* @function` 4284. `* @instance` 4285. `* @param {PatternData=} pattern If provided the path will be fill-stroked with this pattern` 4286. `* @returns {jsPDF}` 4287. `* @memberof jsPDF#` 4288. `*/` 4289. `API.fillStrokeEvenOdd = function(pattern) {` 4290. `fillWithOptionalPattern("B*", pattern);` 4291. `return this;` 4292. `};` 4294. `var fillWithOptionalPattern = function(style, pattern) {` 4295. `if (typeof pattern === "object") {` 4296. `fillWithPattern(pattern, style);` 4297. `} else {` 4298. `out(style);` 4299. `}` 4300. `};` 4302. `var putStyle = function(style) {` 4303. `if (` 4304. `style === null ||` 4305. `(apiMode === ApiMode.ADVANCED && style === undefined)` 4306. `) {` 4307. `return;` 4308. `}` 4310. `style = getStyle(style);` 4312. `// stroking / filling / both the path` 4313. `out(style);` 4314. `};` 4316. `function cloneTilingPattern(patternKey, boundingBox, xStep, yStep, matrix) {` 4317. `var clone = new TilingPattern(` 4318. `boundingBox || this.boundingBox,` 4319. `xStep || this.xStep,` 4320. `yStep || this.yStep,` 4321. `this.gState,` 4322. `matrix || this.matrix` 4323. `);` 4324. `clone.stream = this.stream;` 4325. `var key = patternKey + "$$" + this.cloneIndex++ + "$$";` 4326. `addPattern(key, clone);` 4327. `return clone;` 4328. `}` 4330. `var fillWithPattern = function(patternData, style) {` 4331. `var patternId = patternMap[patternData.key];` 4332. `var pattern = patterns[patternId];` 4334. `if (pattern instanceof ShadingPattern) {` 4335. `out("q");` 4337. `out(clipRuleFromStyle(style));` 4339. `if (pattern.gState) {` 4340. `API.setGState(pattern.gState);` 4341. `}` 4342. `out(patternData.matrix.toString() + " cm");` 4343. `out("/" + patternId + " sh");` 4344. `out("Q");` 4345. `} else if (pattern instanceof TilingPattern) {` 4346. `// pdf draws patterns starting at the bottom left corner and they are not affected by the global transformation,` 4347. `// so we must flip them` 4348. `var matrix = new Matrix(1, 0, 0, -1, 0, getPageHeight());` 4350. `if (patternData.matrix) {` 4351. `matrix = matrix.multiply(patternData.matrix || identityMatrix);` 4352. `// we cannot apply a matrix to the pattern on use so we must abuse the pattern matrix and create new instances` 4353. `// for each use` 4354. `patternId = cloneTilingPattern.call(` 4355. `pattern,` 4356. `patternData.key,` 4357. `patternData.boundingBox,` 4358. `patternData.xStep,` 4359. `patternData.yStep,` 4360. `matrix` 4361. `).id;` 4362. `}` 4364. `out("q");` 4365. `out("/Pattern cs");` 4366. `out("/" + patternId + " scn");` 4368. `if (pattern.gState) {` 4369. `API.setGState(pattern.gState);` 4370. `}` 4372. `out(style);` 4373. `out("Q");` 4374. `}` 4375. `};` 4377. `var clipRuleFromStyle = function(style) {` 4378. `switch (style) {` 4379. `case "f":` 4380. `case "F":` 4381. `return "W n";` 4382. `case "f*":` 4383. `return "W* n";` 4384. `case "B":` 4385. `return "W S";` 4386. `case "B*":` 4387. `return "W* S";` 4389. `// these two are for compatibility reasons (in the past, calling any primitive method with a shading pattern` 4390. `// and "n"/"S" as style would still fill/fill and stroke the path)` 4391. `case "S":` 4392. `return "W S";` 4393. `case "n":` 4394. `return "W n";` 4395. `}` 4396. `};` 4398. `/**` 4399. `* Begin a new subpath by moving the current point to coordinates (x, y). The PDF "m" operator.` 4400. `* @param {number} x` 4401. `* @param {number} y` 4402. `* @name moveTo` 4403. `* @function` 4404. `* @instance` 4405. `* @memberof jsPDF#` 4406. `* @returns {jsPDF}` 4407. `*/` 4408. `var moveTo = (API.moveTo = function(x, y) {` 4409. `out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " m");` 4410. `return this;` 4411. `});` 4413. `/**` 4414. `* Append a straight line segment from the current point to the point (x, y). The PDF "l" operator.` 4415. `* @param {number} x` 4416. `* @param {number} y` 4417. `* @memberof jsPDF#` 4418. `* @name lineTo` 4419. `* @function` 4420. `* @instance` 4421. `* @memberof jsPDF#` 4422. `* @returns {jsPDF}` 4423. `*/` 4424. `var lineTo = (API.lineTo = function(x, y) {` 4425. `out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " l");` 4426. `return this;` 4427. `});` 4429. `/**` 4430. `* Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point` 4431. `* (x3, y3), using (x1, y1) and (x2, y2) as Bézier control points. The new current point shall be (x3, x3).` 4432. `* @param {number} x1` 4433. `* @param {number} y1` 4434. `* @param {number} x2` 4435. `* @param {number} y2` 4436. `* @param {number} x3` 4437. `* @param {number} y3` 4438. `* @memberof jsPDF#` 4439. `* @name curveTo` 4440. `* @function` 4441. `* @instance` 4442. `* @memberof jsPDF#` 4443. `* @returns {jsPDF}` 4444. `*/` 4445. `var curveTo = (API.curveTo = function(x1, y1, x2, y2, x3, y3) {` 4446. `out(` 4447. `[`\ 4448. `hpf(scale(x1)),`\ 4449. `hpf(transformScaleY(y1)),`\ 4450. `hpf(scale(x2)),`\ 4451. `hpf(transformScaleY(y2)),`\ 4452. `hpf(scale(x3)),`\ 4453. `hpf(transformScaleY(y3)),`\ 4454. `"c"`\ 4455. `].join(" ")` 4456. `);` 4457. `return this;` 4458. `});` 4460. `/**` 4461. `* Draw a line on the current page.` 4462. `*` 4463. `* @name line` 4464. `* @function` 4465. `* @instance` 4466. `* @param {number} x1` 4467. `* @param {number} y1` 4468. `* @param {number} x2` 4469. `* @param {number} y2` 4470. `* @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'` 4471. `* @returns {jsPDF}` 4472. `* @memberof jsPDF#` 4473. `*/` 4474. `API.__private__.line = API.line = function(x1, y1, x2, y2, style) {` 4475. `if (` 4476. `isNaN(x1) ||` 4477. `isNaN(y1) ||` 4478. `isNaN(x2) ||` 4479. `isNaN(y2) ||` 4480. `!isValidStyle(style)` 4481. `) {` 4482. `throw new Error("Invalid arguments passed to jsPDF.line");` 4483. `}` 4484. `if (apiMode === ApiMode.COMPAT) {` 4485. `return this.lines([[x2 - x1, y2 - y1]], x1, y1, [1, 1], style || "S");` 4486. `} else {` 4487. `return this.lines([[x2 - x1, y2 - y1]], x1, y1, [1, 1]).stroke();` 4488. `}` 4489. `};` 4491. `/**` 4492. `* @typedef {Object} PatternData` 4493. `* {Matrix|undefined} matrix` 4494. `* {Number|undefined} xStep` 4495. `* {Number|undefined} yStep` 4496. `* {Array.|undefined} boundingBox` 4497. `*/` 4499. `/**` 4500. ``* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.`` 4501. ``* All data points in `lines` are relative to last line origin.`` 4502. ``* `x`, `y` become x1,y1 for first line / curve in the set.`` 4503. `* For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point.` 4504. `* 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.` 4505. `*` 4506. `* @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` 4507. `* @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).` 4508. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 4509. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4510. `* @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.` 4511. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4512. `* 'S' [default] - stroke,` 4513. `* 'F' - fill,` 4514. `* and 'DF' (or 'FD') - fill then stroke.` 4515. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4516. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4517. `*` 4518. `* In "advanced" API mode this parameter is deprecated.` 4519. `* @param {Boolean=} closed If true, the path is closed with a straight line from the end of the last curve to the starting point.` 4520. `* @function` 4521. `* @instance` 4522. `* @returns {jsPDF}` 4523. `* @memberof jsPDF#` 4524. `* @name lines` 4525. `*/` 4526. `API.__private__.lines = API.lines = function(` 4527. `lines,` 4528. `x,` 4529. `y,` 4530. `scale,` 4531. `style,` 4532. `closed` 4533. `) {` 4534. `var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4, tmp;` 4536. `// Pre-August-2012 the order of arguments was function(x, y, lines, scale, style)` 4537. `// in effort to make all calls have similar signature like` 4538. `// function(content, coordinateX, coordinateY , miscellaneous)` 4539. `// this method had its args flipped.` 4540. `// code below allows backward compatibility with old arg order.` 4541. `if (typeof lines === "number") {` 4542. `tmp = y;` 4543. `y = x;` 4544. `x = lines;` 4545. `lines = tmp;` 4546. `}` 4548. `scale = scale || [1, 1];` 4549. `closed = closed || false;` 4551. `if (` 4552. `isNaN(x) ||` 4553. `isNaN(y) ||` 4554. `!Array.isArray(lines) ||` 4555. `!Array.isArray(scale) ||` 4556. `!isValidStyle(style) ||` 4557. `typeof closed !== "boolean"` 4558. `) {` 4559. `throw new Error("Invalid arguments passed to jsPDF.lines");` 4560. `}` 4562. `// starting point` 4563. `moveTo(x, y);` 4565. `scalex = scale[0];` 4566. `scaley = scale[1];` 4567. `l = lines.length;` 4568. `//, x2, y2 // bezier only. In page default measurement "units", *after* scaling` 4569. `//, x3, y3 // bezier only. In page default measurement "units", *after* scaling` 4570. `// ending point for all, lines and bezier. . In page default measurement "units", *after* scaling` 4571. `x4 = x; // last / ending point = starting point for first item.` 4572. `y4 = y; // last / ending point = starting point for first item.` 4574. `for (i = 0; i < l; i++) {` 4575. `leg = lines[i];` 4576. `if (leg.length === 2) {` 4577. `// simple line` 4578. `x4 = leg[0] * scalex + x4; // here last x4 was prior ending point` 4579. `y4 = leg[1] * scaley + y4; // here last y4 was prior ending point` 4580. `lineTo(x4, y4);` 4581. `} else {` 4582. `// bezier curve` 4583. `x2 = leg[0] * scalex + x4; // here last x4 is prior ending point` 4584. `y2 = leg[1] * scaley + y4; // here last y4 is prior ending point` 4585. `x3 = leg[2] * scalex + x4; // here last x4 is prior ending point` 4586. `y3 = leg[3] * scaley + y4; // here last y4 is prior ending point` 4587. `x4 = leg[4] * scalex + x4; // here last x4 was prior ending point` 4588. `y4 = leg[5] * scaley + y4; // here last y4 was prior ending point` 4589. `curveTo(x2, y2, x3, y3, x4, y4);` 4590. `}` 4591. `}` 4593. `if (closed) {` 4594. `close();` 4595. `}` 4597. `putStyle(style);` 4598. `return this;` 4599. `};` 4601. `/**` 4602. `* Similar to {@link API.lines} but all coordinates are interpreted as absolute coordinates instead of relative.` 4603. `* @param {Array} lines An array of {op: operator, c: coordinates} object, where op is one of "m" (move to), "l" (line to)` 4604. `* "c" (cubic bezier curve) and "h" (close (sub)path)). c is an array of coordinates. "m" and "l" expect two, "c"` 4605. `* six and "h" an empty array (or undefined).` 4606. `* @function` 4607. `* @returns {jsPDF}` 4608. `* @memberof jsPDF#` 4609. `* @name path` 4610. `*/` 4611. `API.path = function(lines) {` 4612. `for (var i = 0; i < lines.length; i++) {` 4613. `var leg = lines[i];` 4614. `var coords = leg.c;` 4615. `switch (leg.op) {` 4616. `case "m":` 4617. `moveTo(coords[0], coords[1]);` 4618. `break;` 4619. `case "l":` 4620. `lineTo(coords[0], coords[1]);` 4621. `break;` 4622. `case "c":` 4623. `curveTo.apply(this, coords);` 4624. `break;` 4625. `case "h":` 4626. `close();` 4627. `break;` 4628. `}` 4629. `}` 4631. `return this;` 4632. `};` 4634. `/**` 4635. `* Adds a rectangle to PDF.` 4636. `*` 4637. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 4638. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4639. `* @param {number} w Width (in units declared at inception of PDF document)` 4640. `* @param {number} h Height (in units declared at inception of PDF document)` 4641. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4642. `* 'S' [default] - stroke,` 4643. `* 'F' - fill,` 4644. `* and 'DF' (or 'FD') - fill then stroke.` 4645. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4646. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4647. `*` 4648. `* In "advanced" API mode this parameter is deprecated.` 4649. `* @function` 4650. `* @instance` 4651. `* @returns {jsPDF}` 4652. `* @memberof jsPDF#` 4653. `* @name rect` 4654. `*/` 4655. `API.__private__.rect = API.rect = function(x, y, w, h, style) {` 4656. `if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h) || !isValidStyle(style)) {` 4657. `throw new Error("Invalid arguments passed to jsPDF.rect");` 4658. `}` 4659. `if (apiMode === ApiMode.COMPAT) {` 4660. `h = -h;` 4661. `}` 4663. `out(` 4664. `[`\ 4665. `hpf(scale(x)),`\ 4666. `hpf(transformScaleY(y)),`\ 4667. `hpf(scale(w)),`\ 4668. `hpf(scale(h)),`\ 4669. `"re"`\ 4670. `].join(" ")` 4671. `);` 4673. `putStyle(style);` 4674. `return this;` 4675. `};` 4677. `/**` 4678. `* Adds a triangle to PDF.` 4679. `*` 4680. `* @param {number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page` 4681. `* @param {number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4682. `* @param {number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page` 4683. `* @param {number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4684. `* @param {number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page` 4685. `* @param {number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4686. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4687. `* 'S' [default] - stroke,` 4688. `* 'F' - fill,` 4689. `* and 'DF' (or 'FD') - fill then stroke.` 4690. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4691. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4692. `*` 4693. `* In "advanced" API mode this parameter is deprecated.` 4694. `* @function` 4695. `* @instance` 4696. `* @returns {jsPDF}` 4697. `* @memberof jsPDF#` 4698. `* @name triangle` 4699. `*/` 4700. `API.__private__.triangle = API.triangle = function(` 4701. `x1,` 4702. `y1,` 4703. `x2,` 4704. `y2,` 4705. `x3,` 4706. `y3,` 4707. `style` 4708. `) {` 4709. `if (` 4710. `isNaN(x1) ||` 4711. `isNaN(y1) ||` 4712. `isNaN(x2) ||` 4713. `isNaN(y2) ||` 4714. `isNaN(x3) ||` 4715. `isNaN(y3) ||` 4716. `!isValidStyle(style)` 4717. `) {` 4718. `throw new Error("Invalid arguments passed to jsPDF.triangle");` 4719. `}` 4720. `this.lines(` 4721. `[`\ 4722. `[x2 - x1, y2 - y1], // vector to point 2`\ 4723. `[x3 - x2, y3 - y2], // vector to point 3`\ 4724. `[x1 - x3, y1 - y3] // closing vector back to point 1`\ 4725. `],` 4726. `x1,` 4727. `y1, // start of path` 4728. `[1, 1],` 4729. `style,` 4730. `true` 4731. `);` 4732. `return this;` 4733. `};` 4735. `/**` 4736. `* Adds a rectangle with rounded corners to PDF.` 4737. `*` 4738. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 4739. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4740. `* @param {number} w Width (in units declared at inception of PDF document)` 4741. `* @param {number} h Height (in units declared at inception of PDF document)` 4742. `* @param {number} rx Radius along x axis (in units declared at inception of PDF document)` 4743. `* @param {number} ry Radius along y axis (in units declared at inception of PDF document)` 4744. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4745. `* 'S' [default] - stroke,` 4746. `* 'F' - fill,` 4747. `* and 'DF' (or 'FD') - fill then stroke.` 4748. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4749. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4750. `*` 4751. `* In "advanced" API mode this parameter is deprecated.` 4752. `* @function` 4753. `* @instance` 4754. `* @returns {jsPDF}` 4755. `* @memberof jsPDF#` 4756. `* @name roundedRect` 4757. `*/` 4758. `API.__private__.roundedRect = API.roundedRect = function(` 4759. `x,` 4760. `y,` 4761. `w,` 4762. `h,` 4763. `rx,` 4764. `ry,` 4765. `style` 4766. `) {` 4767. `if (` 4768. `isNaN(x) ||` 4769. `isNaN(y) ||` 4770. `isNaN(w) ||` 4771. `isNaN(h) ||` 4772. `isNaN(rx) ||` 4773. `isNaN(ry) ||` 4774. `!isValidStyle(style)` 4775. `) {` 4776. `throw new Error("Invalid arguments passed to jsPDF.roundedRect");` 4777. `}` 4778. `var MyArc = (4 / 3) * (Math.SQRT2 - 1);` 4780. `rx = Math.min(rx, w * 0.5);` 4781. `ry = Math.min(ry, h * 0.5);` 4783. `this.lines(` 4784. `[`\ 4785. `[w - 2 * rx, 0],`\ 4786. `[rx * MyArc, 0, rx, ry - ry * MyArc, rx, ry],`\ 4787. `[0, h - 2 * ry],`\ 4788. `[0, ry * MyArc, -(rx * MyArc), ry, -rx, ry],`\ 4789. `[-w + 2 * rx, 0],`\ 4790. `[-(rx * MyArc), 0, -rx, -(ry * MyArc), -rx, -ry],`\ 4791. `[0, -h + 2 * ry],`\ 4792. `[0, -(ry * MyArc), rx * MyArc, -ry, rx, -ry]`\ 4793. `],` 4794. `x + rx,` 4795. `y, // start of path` 4796. `[1, 1],` 4797. `style,` 4798. `true` 4799. `);` 4800. `return this;` 4801. `};` 4803. `/**` 4804. `* Adds an ellipse to PDF.` 4805. `*` 4806. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 4807. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4808. `* @param {number} rx Radius along x axis (in units declared at inception of PDF document)` 4809. `* @param {number} ry Radius along y axis (in units declared at inception of PDF document)` 4810. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4811. `* 'S' [default] - stroke,` 4812. `* 'F' - fill,` 4813. `* and 'DF' (or 'FD') - fill then stroke.` 4814. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4815. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4816. `*` 4817. `* In "advanced" API mode this parameter is deprecated.` 4818. `* @function` 4819. `* @instance` 4820. `* @returns {jsPDF}` 4821. `* @memberof jsPDF#` 4822. `* @name ellipse` 4823. `*/` 4824. `API.__private__.ellipse = API.ellipse = function(x, y, rx, ry, style) {` 4825. `if (` 4826. `isNaN(x) ||` 4827. `isNaN(y) ||` 4828. `isNaN(rx) ||` 4829. `isNaN(ry) ||` 4830. `!isValidStyle(style)` 4831. `) {` 4832. `throw new Error("Invalid arguments passed to jsPDF.ellipse");` 4833. `}` 4834. `var lx = (4 / 3) * (Math.SQRT2 - 1) * rx,` 4835. `ly = (4 / 3) * (Math.SQRT2 - 1) * ry;` 4837. `moveTo(x + rx, y);` 4838. `curveTo(x + rx, y - ly, x + lx, y - ry, x, y - ry);` 4839. `curveTo(x - lx, y - ry, x - rx, y - ly, x - rx, y);` 4840. `curveTo(x - rx, y + ly, x - lx, y + ry, x, y + ry);` 4841. `curveTo(x + lx, y + ry, x + rx, y + ly, x + rx, y);` 4843. `putStyle(style);` 4844. `return this;` 4845. `};` 4847. `/**` 4848. `* Adds an circle to PDF.` 4849. `*` 4850. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 4851. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 4852. `* @param {number} r Radius (in units declared at inception of PDF document)` 4853. `* @param {string=} style A string specifying the painting style or null. Valid styles include:` 4854. `* 'S' [default] - stroke,` 4855. `* 'F' - fill,` 4856. `* and 'DF' (or 'FD') - fill then stroke.` 4857. `* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple` 4858. `* method calls. The last drawing method call used to define the shape should not have a null style argument.` 4859. `*` 4860. `* In "advanced" API mode this parameter is deprecated.` 4861. `* @function` 4862. `* @instance` 4863. `* @returns {jsPDF}` 4864. `* @memberof jsPDF#` 4865. `* @name circle` 4866. `*/` 4867. `API.__private__.circle = API.circle = function(x, y, r, style) {` 4868. `if (isNaN(x) || isNaN(y) || isNaN(r) || !isValidStyle(style)) {` 4869. `throw new Error("Invalid arguments passed to jsPDF.circle");` 4870. `}` 4871. `return this.ellipse(x, y, r, r, style);` 4872. `};` 4874. `/**` 4875. `* Sets text font face, variant for upcoming text elements.` 4876. `* See output of jsPDF.getFontList() for possible font names, styles.` 4877. `*` 4878. `* @param {string} fontName Font name or family. Example: "times".` 4879. `* @param {string} fontStyle Font style or variant. Example: "italic".` 4880. `* @param {number | string} fontWeight Weight of the Font. Example: "normal" | 400` 4881. `* @function` 4882. `* @instance` 4883. `* @returns {jsPDF}` 4884. `* @memberof jsPDF#` 4885. `* @name setFont` 4886. `*/` 4887. `API.setFont = function(fontName, fontStyle, fontWeight) {` 4888. `if (fontWeight) {` 4889. `fontStyle = combineFontStyleAndFontWeight(fontStyle, fontWeight);` 4890. `}` 4891. `activeFontKey = getFont(fontName, fontStyle, {` 4892. `disableWarning: false` 4893. `});` 4894. `return this;` 4895. `};` 4897. `/**` 4898. `* Gets text font face, variant for upcoming text elements.` 4899. `*` 4900. `* @function` 4901. `* @instance` 4902. `* @returns {Object}` 4903. `* @memberof jsPDF#` 4904. `* @name getFont` 4905. `*/` 4906. `var getFontEntry = (API.__private__.getFont = API.getFont = function() {` 4907. `return fonts[getFont.apply(API, arguments)];` 4908. `});` 4910. `/**` 4911. `* Returns an object - a tree of fontName to fontStyle relationships available to` 4912. `* active PDF document.` 4913. `*` 4914. `* @public` 4915. `* @function` 4916. `* @instance` 4917. `* @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }` 4918. `* @memberof jsPDF#` 4919. `* @name getFontList` 4920. `*/` 4921. `API.__private__.getFontList = API.getFontList = function() {` 4922. `var list = {},` 4923. `fontName,` 4924. `fontStyle;` 4926. `for (fontName in fontmap) {` 4927. `if (fontmap.hasOwnProperty(fontName)) {` 4928. `list[fontName] = [];` 4929. `for (fontStyle in fontmap[fontName]) {` 4930. `if (fontmap[fontName].hasOwnProperty(fontStyle)) {` 4931. `list[fontName].push(fontStyle);` 4932. `}` 4933. `}` 4934. `}` 4935. `}` 4936. `return list;` 4937. `};` 4939. `/**` 4940. `* Add a custom font to the current instance.` 4941. `*` 4942. `* @param {string} postScriptName PDF specification full name for the font.` 4943. `* @param {string} id PDF-document-instance-specific label assinged to the font.` 4944. `* @param {string} fontStyle Style of the Font.` 4945. `* @param {number | string} fontWeight Weight of the Font.` 4946. `* @param {Object} encoding Encoding_name-to-Font_metrics_object mapping.` 4947. `* @function` 4948. `* @instance` 4949. `* @memberof jsPDF#` 4950. `* @name addFont` 4951. `* @returns {string} fontId` 4952. `*/` 4953. `API.addFont = function(` 4954. `postScriptName,` 4955. `fontName,` 4956. `fontStyle,` 4957. `fontWeight,` 4958. `encoding` 4959. `) {` 4960. `var encodingOptions = [`\ 4961. `"StandardEncoding",`\ 4962. `"MacRomanEncoding",`\ 4963. `"Identity-H",`\ 4964. `"WinAnsiEncoding"`\ 4965. `];` 4966. `if (arguments[3] && encodingOptions.indexOf(arguments[3]) !== -1) {` 4967. `//IE 11 fix` 4968. `encoding = arguments[3];` 4969. `} else if (arguments[3] && encodingOptions.indexOf(arguments[3]) == -1) {` 4970. `fontStyle = combineFontStyleAndFontWeight(fontStyle, fontWeight);` 4971. `}` 4972. `encoding = encoding || "Identity-H";` 4973. `return addFont.call(this, postScriptName, fontName, fontStyle, encoding);` 4974. `};` 4976. `var lineWidth = options.lineWidth || 0.200025; // 2mm` 4977. `/**` 4978. `* Gets the line width, default: 0.200025.` 4979. `*` 4980. `* @function` 4981. `* @instance` 4982. `* @returns {number} lineWidth` 4983. `* @memberof jsPDF#` 4984. `* @name getLineWidth` 4985. `*/` 4986. `var getLineWidth = (API.__private__.getLineWidth = API.getLineWidth = function() {` 4987. `return lineWidth;` 4988. `});` 4990. `/**` 4991. `* Sets line width for upcoming lines.` 4992. `*` 4993. `* @param {number} width Line width (in units declared at inception of PDF document).` 4994. `* @function` 4995. `* @instance` 4996. `* @returns {jsPDF}` 4997. `* @memberof jsPDF#` 4998. `* @name setLineWidth` 4999. `*/` 5000. `var setLineWidth = (API.__private__.setLineWidth = API.setLineWidth = function(` 5001. `width` 5002. `) {` 5003. `lineWidth = width;` 5004. `out(hpf(scale(width)) + " w");` 5005. `return this;` 5006. `});` 5008. `/**` 5009. `* Sets the dash pattern for upcoming lines.` 5010. `*` 5011. `* To reset the settings simply call the method without any parameters.` 5012. `* @param {Array} dashArray An array containing 0-2 numbers. The first number sets the length of the` 5013. `* dashes, the second number the length of the gaps. If the second number is missing, the gaps are considered` 5014. `* to be as long as the dashes. An empty array means solid, unbroken lines.` 5015. `* @param {number} dashPhase The phase lines start with.` 5016. `* @function` 5017. `* @instance` 5018. `* @returns {jsPDF}` 5019. `* @memberof jsPDF#` 5020. `* @name setLineDashPattern` 5021. `*/` 5022. `API.__private__.setLineDash = jsPDF.API.setLineDash = jsPDF.API.setLineDashPattern = function(` 5023. `dashArray,` 5024. `dashPhase` 5025. `) {` 5026. `dashArray = dashArray || [];` 5027. `dashPhase = dashPhase || 0;` 5029. `if (isNaN(dashPhase) || !Array.isArray(dashArray)) {` 5030. `throw new Error("Invalid arguments passed to jsPDF.setLineDash");` 5031. `}` 5033. `dashArray = dashArray` 5034. `.map(function(x) {` 5035. `return hpf(scale(x));` 5036. `})` 5037. `.join(" ");` 5038. `dashPhase = hpf(scale(dashPhase));` 5040. `out("[" + dashArray + "] " + dashPhase + " d");` 5041. `return this;` 5042. `};` 5044. `var lineHeightFactor;` 5046. `var getLineHeight = (API.__private__.getLineHeight = API.getLineHeight = function() {` 5047. `return activeFontSize * lineHeightFactor;` 5048. `});` 5050. `API.__private__.getLineHeight = API.getLineHeight = function() {` 5051. `return activeFontSize * lineHeightFactor;` 5052. `};` 5054. `/**` 5055. `* Sets the LineHeightFactor of proportion.` 5056. `*` 5057. `* @param {number} value LineHeightFactor value. Default: 1.15.` 5058. `* @function` 5059. `* @instance` 5060. `* @returns {jsPDF}` 5061. `* @memberof jsPDF#` 5062. `* @name setLineHeightFactor` 5063. `*/` 5064. `var setLineHeightFactor = (API.__private__.setLineHeightFactor = API.setLineHeightFactor = function(` 5065. `value` 5066. `) {` 5067. `value = value || 1.15;` 5068. `if (typeof value === "number") {` 5069. `lineHeightFactor = value;` 5070. `}` 5071. `return this;` 5072. `});` 5074. `/**` 5075. `* Gets the LineHeightFactor, default: 1.15.` 5076. `*` 5077. `* @function` 5078. `* @instance` 5079. `* @returns {number} lineHeightFactor` 5080. `* @memberof jsPDF#` 5081. `* @name getLineHeightFactor` 5082. `*/` 5083. `var getLineHeightFactor = (API.__private__.getLineHeightFactor = API.getLineHeightFactor = function() {` 5084. `return lineHeightFactor;` 5085. `});` 5087. `setLineHeightFactor(options.lineHeight);` 5089. `var getHorizontalCoordinate = (API.__private__.getHorizontalCoordinate = function(` 5090. `value` 5091. `) {` 5092. `return scale(value);` 5093. `});` 5095. `var getVerticalCoordinate = (API.__private__.getVerticalCoordinate = function(` 5096. `value` 5097. `) {` 5098. `if (apiMode === ApiMode.ADVANCED) {` 5099. `return value;` 5100. `} else {` 5101. `var pageHeight =` 5102. `pagesContext[currentPage].mediaBox.topRightY -` 5103. `pagesContext[currentPage].mediaBox.bottomLeftY;` 5104. `return pageHeight - scale(value);` 5105. `}` 5106. `});` 5108. `var getHorizontalCoordinateString = (API.__private__.getHorizontalCoordinateString = API.getHorizontalCoordinateString = function(` 5109. `value` 5110. `) {` 5111. `return hpf(getHorizontalCoordinate(value));` 5112. `});` 5114. `var getVerticalCoordinateString = (API.__private__.getVerticalCoordinateString = API.getVerticalCoordinateString = function(` 5115. `value` 5116. `) {` 5117. `return hpf(getVerticalCoordinate(value));` 5118. `});` 5120. `var strokeColor = options.strokeColor || "0 G";` 5122. `/**` 5123. `* Gets the stroke color for upcoming elements.` 5124. `*` 5125. `* @function` 5126. `* @instance` 5127. `* @returns {string} colorAsHex` 5128. `* @memberof jsPDF#` 5129. `* @name getDrawColor` 5130. `*/` 5131. `API.__private__.getStrokeColor = API.getDrawColor = function() {` 5132. `return decodeColorString(strokeColor);` 5133. `};` 5135. `/**` 5136. `* Sets the stroke color for upcoming elements.` 5137. `*` 5138. `* Depending on the number of arguments given, Gray, RGB, or CMYK` 5139. `* color space is implied.` 5140. `*` 5141. `* When only ch1 is given, "Gray" color space is implied and it` 5142. `* must be a value in the range from 0.00 (solid black) to to 1.00 (white)` 5143. `* if values are communicated as String types, or in range from 0 (black)` 5144. `* to 255 (white) if communicated as Number type.` 5145. `* The RGB-like 0-255 range is provided for backward compatibility.` 5146. `*` 5147. `* When only ch1,ch2,ch3 are given, "RGB" color space is implied and each` 5148. `* value must be in the range from 0.00 (minimum intensity) to to 1.00` 5149. `* (max intensity) if values are communicated as String types, or` 5150. `* from 0 (min intensity) to to 255 (max intensity) if values are communicated` 5151. `* as Number types.` 5152. `* The RGB-like 0-255 range is provided for backward compatibility.` 5153. `*` 5154. `* When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each` 5155. `* value must be a in the range from 0.00 (0% concentration) to to` 5156. `* 1.00 (100% concentration)` 5157. `*` 5158. `* Because JavaScript treats fixed point numbers badly (rounds to` 5159. `* floating point nearest to binary representation) it is highly advised to` 5160. `* communicate the fractional numbers as String types, not JavaScript Number type.` 5161. `*` 5162. `* @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'.` 5163. `* @param {Number} ch2 Color channel value.` 5164. `* @param {Number} ch3 Color channel value.` 5165. `* @param {Number} ch4 Color channel value.` 5166. `*` 5167. `* @function` 5168. `* @instance` 5169. `* @returns {jsPDF}` 5170. `* @memberof jsPDF#` 5171. `* @name setDrawColor` 5172. `*/` 5173. `API.__private__.setStrokeColor = API.setDrawColor = function(` 5174. `ch1,` 5175. `ch2,` 5176. `ch3,` 5177. `ch4` 5178. `) {` 5179. `var options = {` 5180. `ch1: ch1,` 5181. `ch2: ch2,` 5182. `ch3: ch3,` 5183. `ch4: ch4,` 5184. `pdfColorType: "draw",` 5185. `precision: 2` 5186. `};` 5188. `strokeColor = encodeColorString(options);` 5189. `out(strokeColor);` 5190. `return this;` 5191. `};` 5193. `var fillColor = options.fillColor || "0 g";` 5195. `/**` 5196. `* Gets the fill color for upcoming elements.` 5197. `*` 5198. `* @function` 5199. `* @instance` 5200. `* @returns {string} colorAsHex` 5201. `* @memberof jsPDF#` 5202. `* @name getFillColor` 5203. `*/` 5204. `API.__private__.getFillColor = API.getFillColor = function() {` 5205. `return decodeColorString(fillColor);` 5206. `};` 5208. `/**` 5209. `* Sets the fill color for upcoming elements.` 5210. `*` 5211. `* Depending on the number of arguments given, Gray, RGB, or CMYK` 5212. `* color space is implied.` 5213. `*` 5214. `* When only ch1 is given, "Gray" color space is implied and it` 5215. `* must be a value in the range from 0.00 (solid black) to to 1.00 (white)` 5216. `* if values are communicated as String types, or in range from 0 (black)` 5217. `* to 255 (white) if communicated as Number type.` 5218. `* The RGB-like 0-255 range is provided for backward compatibility.` 5219. `*` 5220. `* When only ch1,ch2,ch3 are given, "RGB" color space is implied and each` 5221. `* value must be in the range from 0.00 (minimum intensity) to to 1.00` 5222. `* (max intensity) if values are communicated as String types, or` 5223. `* from 0 (min intensity) to to 255 (max intensity) if values are communicated` 5224. `* as Number types.` 5225. `* The RGB-like 0-255 range is provided for backward compatibility.` 5226. `*` 5227. `* When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each` 5228. `* value must be a in the range from 0.00 (0% concentration) to to` 5229. `* 1.00 (100% concentration)` 5230. `*` 5231. `* Because JavaScript treats fixed point numbers badly (rounds to` 5232. `* floating point nearest to binary representation) it is highly advised to` 5233. `* communicate the fractional numbers as String types, not JavaScript Number type.` 5234. `*` 5235. `* @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'.` 5236. `* @param {Number} ch2 Color channel value.` 5237. `* @param {Number} ch3 Color channel value.` 5238. `* @param {Number} ch4 Color channel value.` 5239. `*` 5240. `* @function` 5241. `* @instance` 5242. `* @returns {jsPDF}` 5243. `* @memberof jsPDF#` 5244. `* @name setFillColor` 5245. `*/` 5246. `API.__private__.setFillColor = API.setFillColor = function(` 5247. `ch1,` 5248. `ch2,` 5249. `ch3,` 5250. `ch4` 5251. `) {` 5252. `var options = {` 5253. `ch1: ch1,` 5254. `ch2: ch2,` 5255. `ch3: ch3,` 5256. `ch4: ch4,` 5257. `pdfColorType: "fill",` 5258. `precision: 2` 5259. `};` 5261. `fillColor = encodeColorString(options);` 5262. `out(fillColor);` 5263. `return this;` 5264. `};` 5266. `var textColor = options.textColor || "0 g";` 5267. `/**` 5268. `* Gets the text color for upcoming elements.` 5269. `*` 5270. `* @function` 5271. `* @instance` 5272. `* @returns {string} colorAsHex` 5273. `* @memberof jsPDF#` 5274. `* @name getTextColor` 5275. `*/` 5276. `var getTextColor = (API.__private__.getTextColor = API.getTextColor = function() {` 5277. `return decodeColorString(textColor);` 5278. `});` 5279. `/**` 5280. `* Sets the text color for upcoming elements.` 5281. `*` 5282. `* Depending on the number of arguments given, Gray, RGB, or CMYK` 5283. `* color space is implied.` 5284. `*` 5285. `* When only ch1 is given, "Gray" color space is implied and it` 5286. `* must be a value in the range from 0.00 (solid black) to to 1.00 (white)` 5287. `* if values are communicated as String types, or in range from 0 (black)` 5288. `* to 255 (white) if communicated as Number type.` 5289. `* The RGB-like 0-255 range is provided for backward compatibility.` 5290. `*` 5291. `* When only ch1,ch2,ch3 are given, "RGB" color space is implied and each` 5292. `* value must be in the range from 0.00 (minimum intensity) to to 1.00` 5293. `* (max intensity) if values are communicated as String types, or` 5294. `* from 0 (min intensity) to to 255 (max intensity) if values are communicated` 5295. `* as Number types.` 5296. `* The RGB-like 0-255 range is provided for backward compatibility.` 5297. `*` 5298. `* When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each` 5299. `* value must be a in the range from 0.00 (0% concentration) to to` 5300. `* 1.00 (100% concentration)` 5301. `*` 5302. `* Because JavaScript treats fixed point numbers badly (rounds to` 5303. `* floating point nearest to binary representation) it is highly advised to` 5304. `* communicate the fractional numbers as String types, not JavaScript Number type.` 5305. `*` 5306. `* @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'.` 5307. `* @param {Number} ch2 Color channel value.` 5308. `* @param {Number} ch3 Color channel value.` 5309. `* @param {Number} ch4 Color channel value.` 5310. `*` 5311. `* @function` 5312. `* @instance` 5313. `* @returns {jsPDF}` 5314. `* @memberof jsPDF#` 5315. `* @name setTextColor` 5316. `*/` 5317. `API.__private__.setTextColor = API.setTextColor = function(` 5318. `ch1,` 5319. `ch2,` 5320. `ch3,` 5321. `ch4` 5322. `) {` 5323. `var options = {` 5324. `ch1: ch1,` 5325. `ch2: ch2,` 5326. `ch3: ch3,` 5327. `ch4: ch4,` 5328. `pdfColorType: "text",` 5329. `precision: 3` 5330. `};` 5331. `textColor = encodeColorString(options);` 5333. `return this;` 5334. `};` 5336. `var activeCharSpace = options.charSpace;` 5338. `/**` 5339. `* Get global value of CharSpace.` 5340. `*` 5341. `* @function` 5342. `* @instance` 5343. `* @returns {number} charSpace` 5344. `* @memberof jsPDF#` 5345. `* @name getCharSpace` 5346. `*/` 5347. `var getCharSpace = (API.__private__.getCharSpace = API.getCharSpace = function() {` 5348. `return parseFloat(activeCharSpace || 0);` 5349. `});` 5351. `/**` 5352. `* Set global value of CharSpace.` 5353. `*` 5354. `* @param {number} charSpace` 5355. `* @function` 5356. `* @instance` 5357. `* @returns {jsPDF} jsPDF-instance` 5358. `* @memberof jsPDF#` 5359. `* @name setCharSpace` 5360. `*/` 5361. `API.__private__.setCharSpace = API.setCharSpace = function(charSpace) {` 5362. `if (isNaN(charSpace)) {` 5363. `throw new Error("Invalid argument passed to jsPDF.setCharSpace");` 5364. `}` 5365. `activeCharSpace = charSpace;` 5366. `return this;` 5367. `};` 5369. `var lineCapID = 0;` 5370. `/**` 5371. `* Is an Object providing a mapping from human-readable to` 5372. `* integer flag values designating the varieties of line cap` 5373. `* and join styles.` 5374. `*` 5375. `* @memberof jsPDF#` 5376. `* @name CapJoinStyles` 5377. `*/` 5378. `API.CapJoinStyles = {` 5379. `0: 0,` 5380. `butt: 0,` 5381. `but: 0,` 5382. `miter: 0,` 5383. `1: 1,` 5384. `round: 1,` 5385. `rounded: 1,` 5386. `circle: 1,` 5387. `2: 2,` 5388. `projecting: 2,` 5389. `project: 2,` 5390. `square: 2,` 5391. `bevel: 2` 5392. `};` 5394. `/**` 5395. `* Sets the line cap styles.` 5396. `* See {jsPDF.CapJoinStyles} for variants.` 5397. `*` 5398. `* @param {String|Number} style A string or number identifying the type of line cap.` 5399. `* @function` 5400. `* @instance` 5401. `* @returns {jsPDF}` 5402. `* @memberof jsPDF#` 5403. `* @name setLineCap` 5404. `*/` 5405. `API.__private__.setLineCap = API.setLineCap = function(style) {` 5406. `var id = API.CapJoinStyles[style];` 5407. `if (id === undefined) {` 5408. `throw new Error(` 5409. `"Line cap style of '" +` 5410. `style +` 5411. `"' is not recognized. See or extend .CapJoinStyles property for valid styles"` 5412. `);` 5413. `}` 5414. `lineCapID = id;` 5415. `out(id + " J");` 5417. `return this;` 5418. `};` 5420. `var lineJoinID = 0;` 5421. `/**` 5422. `* Sets the line join styles.` 5423. `* See {jsPDF.CapJoinStyles} for variants.` 5424. `*` 5425. `* @param {String|Number} style A string or number identifying the type of line join.` 5426. `* @function` 5427. `* @instance` 5428. `* @returns {jsPDF}` 5429. `* @memberof jsPDF#` 5430. `* @name setLineJoin` 5431. `*/` 5432. `API.__private__.setLineJoin = API.setLineJoin = function(style) {` 5433. `var id = API.CapJoinStyles[style];` 5434. `if (id === undefined) {` 5435. `throw new Error(` 5436. `"Line join style of '" +` 5437. `style +` 5438. `"' is not recognized. See or extend .CapJoinStyles property for valid styles"` 5439. `);` 5440. `}` 5441. `lineJoinID = id;` 5442. `out(id + " j");` 5444. `return this;` 5445. `};` 5447. `var miterLimit;` 5448. `/**` 5449. `* Sets the miterLimit property, which effects the maximum miter length.` 5450. `*` 5451. `* @param {number} length The length of the miter` 5452. `* @function` 5453. `* @instance` 5454. `* @returns {jsPDF}` 5455. `* @memberof jsPDF#` 5456. `* @name setLineMiterLimit` 5457. `*/` 5458. `API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function(` 5459. `length` 5460. `) {` 5461. `length = length || 0;` 5462. `if (isNaN(length)) {` 5463. `throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");` 5464. `}` 5465. `out(hpf(scale(length)) + " M");` 5467. `return this;` 5468. `};` 5470. `/**` 5471. `* An object representing a pdf graphics state.` 5472. `* @class GState` 5473. `*/` 5475. `/**` 5476. `*` 5477. `* @param parameters A parameter object that contains all properties this graphics state wants to set.` 5478. `* Supported are: opacity, stroke-opacity` 5479. `* @constructor` 5480. `*/` 5481. `API.GState = GState;` 5483. `/**` 5484. `* Sets a either previously added {@link GState} (via {@link addGState}) or a new {@link GState}.` 5485. `* @param {String|GState} gState If type is string, a previously added GState is used, if type is GState` 5486. `* it will be added before use.` 5487. `* @function` 5488. `* @returns {jsPDF}` 5489. `* @memberof jsPDF#` 5490. `* @name setGState` 5491. `*/` 5492. `API.setGState = function(gState) {` 5493. `if (typeof gState === "string") {` 5494. `gState = gStates[gStatesMap[gState]];` 5495. `} else {` 5496. `gState = addGState(null, gState);` 5497. `}` 5499. `if (!gState.equals(activeGState)) {` 5500. `out("/" + gState.id + " gs");` 5501. `activeGState = gState;` 5502. `}` 5503. `};` 5505. `/**` 5506. `* Adds a new Graphics State. Duplicates are automatically eliminated.` 5507. `* @param {String} key Might also be null, if no later reference to this gState is needed` 5508. `* @param {Object} gState The gState object` 5509. `*/` 5510. `var addGState = function(key, gState) {` 5511. `// only add it if it is not already present (the keys provided by the user must be unique!)` 5512. `if (key && gStatesMap[key]) return;` 5513. `var duplicate = false;` 5514. `for (var s in gStates) {` 5515. `if (gStates.hasOwnProperty(s)) {` 5516. `if (gStates[s].equals(gState)) {` 5517. `duplicate = true;` 5518. `break;` 5519. `}` 5520. `}` 5521. `}` 5523. `if (duplicate) {` 5524. `gState = gStates[s];` 5525. `} else {` 5526. `var gStateKey = "GS" + (Object.keys(gStates).length + 1).toString(10);` 5527. `gStates[gStateKey] = gState;` 5528. `gState.id = gStateKey;` 5529. `}` 5531. `// several user keys may point to the same GState object` 5532. `key && (gStatesMap[key] = gState.id);` 5534. `events.publish("addGState", gState);` 5536. `return gState;` 5537. `};` 5539. `/**` 5540. `* Adds a new {@link GState} for later use. See {@link setGState}.` 5541. `* @param {String} key` 5542. `* @param {GState} gState` 5543. `* @function` 5544. `* @instance` 5545. `* @returns {jsPDF}` 5546. `*` 5547. `* @memberof jsPDF#` 5548. `* @name addGState` 5549. `*/` 5550. `API.addGState = function(key, gState) {` 5551. `addGState(key, gState);` 5552. `return this;` 5553. `};` 5555. `/**` 5556. `* Saves the current graphics state ("pushes it on the stack"). It can be restored by {@link restoreGraphicsState}` 5557. `* later. Here, the general pdf graphics state is meant, also including the current transformation matrix,` 5558. `* fill and stroke colors etc.` 5559. `* @function` 5560. `* @returns {jsPDF}` 5561. `* @memberof jsPDF#` 5562. `* @name saveGraphicsState` 5563. `*/` 5564. `API.saveGraphicsState = function() {` 5565. `out("q");` 5566. `// as we cannot set font key and size independently we must keep track of both` 5567. `fontStateStack.push({` 5568. `key: activeFontKey,` 5569. `size: activeFontSize,` 5570. `color: textColor` 5571. `});` 5572. `return this;` 5573. `};` 5575. `/**` 5576. `* Restores a previously saved graphics state saved by {@link saveGraphicsState} ("pops the stack").` 5577. `* @function` 5578. `* @returns {jsPDF}` 5579. `* @memberof jsPDF#` 5580. `* @name restoreGraphicsState` 5581. `*/` 5582. `API.restoreGraphicsState = function() {` 5583. `out("Q");` 5585. `// restore previous font state` 5586. `var fontState = fontStateStack.pop();` 5587. `activeFontKey = fontState.key;` 5588. `activeFontSize = fontState.size;` 5589. `textColor = fontState.color;` 5591. `activeGState = null;` 5593. `return this;` 5594. `};` 5596. `/**` 5597. `* Appends this matrix to the left of all previously applied matrices.` 5598. `*` 5599. `* @param {Matrix} matrix` 5600. `* @function` 5601. `* @returns {jsPDF}` 5602. `* @memberof jsPDF#` 5603. `* @name setCurrentTransformationMatrix` 5604. `*/` 5605. `API.setCurrentTransformationMatrix = function(matrix) {` 5606. `out(matrix.toString() + " cm");` 5607. `return this;` 5608. `};` 5610. `/**` 5611. `* Inserts a debug comment into the generated pdf.` 5612. `* @function` 5613. `* @instance` 5614. `* @param {String} text` 5615. `* @returns {jsPDF}` 5616. `* @memberof jsPDF#` 5617. `* @name comment` 5618. `*/` 5619. `API.comment = function(text) {` 5620. `out("#" + text);` 5621. `return this;` 5622. `};` 5624. `/**` 5625. `* Point` 5626. `*/` 5627. `var Point = function(x, y) {` 5628. `var _x = x || 0;` 5629. `Object.defineProperty(this, "x", {` 5630. `enumerable: true,` 5631. `get: function() {` 5632. `return _x;` 5633. `},` 5634. `set: function(value) {` 5635. `if (!isNaN(value)) {` 5636. `_x = parseFloat(value);` 5637. `}` 5638. `}` 5639. `});` 5641. `var _y = y || 0;` 5642. `Object.defineProperty(this, "y", {` 5643. `enumerable: true,` 5644. `get: function() {` 5645. `return _y;` 5646. `},` 5647. `set: function(value) {` 5648. `if (!isNaN(value)) {` 5649. `_y = parseFloat(value);` 5650. `}` 5651. `}` 5652. `});` 5654. `var _type = "pt";` 5655. `Object.defineProperty(this, "type", {` 5656. `enumerable: true,` 5657. `get: function() {` 5658. `return _type;` 5659. `},` 5660. `set: function(value) {` 5661. `_type = value.toString();` 5662. `}` 5663. `});` 5664. `return this;` 5665. `};` 5667. `/**` 5668. `* Rectangle` 5669. `*/` 5670. `var Rectangle = function(x, y, w, h) {` 5671. `Point.call(this, x, y);` 5672. `this.type = "rect";` 5674. `var _w = w || 0;` 5675. `Object.defineProperty(this, "w", {` 5676. `enumerable: true,` 5677. `get: function() {` 5678. `return _w;` 5679. `},` 5680. `set: function(value) {` 5681. `if (!isNaN(value)) {` 5682. `_w = parseFloat(value);` 5683. `}` 5684. `}` 5685. `});` 5687. `var _h = h || 0;` 5688. `Object.defineProperty(this, "h", {` 5689. `enumerable: true,` 5690. `get: function() {` 5691. `return _h;` 5692. `},` 5693. `set: function(value) {` 5694. `if (!isNaN(value)) {` 5695. `_h = parseFloat(value);` 5696. `}` 5697. `}` 5698. `});` 5700. `return this;` 5701. `};` 5703. `/**` 5704. `* FormObject/RenderTarget` 5705. `*/` 5707. `var RenderTarget = function() {` 5708. `this.page = page;` 5709. `this.currentPage = currentPage;` 5710. `this.pages = pages.slice(0);` 5711. `this.pagesContext = pagesContext.slice(0);` 5712. `this.x = pageX;` 5713. `this.y = pageY;` 5714. `this.matrix = pageMatrix;` 5715. `this.width = getPageWidth(currentPage);` 5716. `this.height = getPageHeight(currentPage);` 5717. `this.outputDestination = outputDestination;` 5719. `this.id = ""; // set by endFormObject()` 5720. `this.objectNumber = -1; // will be set by putXObject()` 5721. `};` 5723. `RenderTarget.prototype.restore = function() {` 5724. `page = this.page;` 5725. `currentPage = this.currentPage;` 5726. `pagesContext = this.pagesContext;` 5727. `pages = this.pages;` 5728. `pageX = this.x;` 5729. `pageY = this.y;` 5730. `pageMatrix = this.matrix;` 5731. `setPageWidth(currentPage, this.width);` 5732. `setPageHeight(currentPage, this.height);` 5733. `outputDestination = this.outputDestination;` 5734. `};` 5736. `var beginNewRenderTarget = function(x, y, width, height, matrix) {` 5737. `// save current state` 5738. `renderTargetStack.push(new RenderTarget());` 5740. `// clear pages` 5741. `page = currentPage = 0;` 5742. `pages = [];` 5743. `pageX = x;` 5744. `pageY = y;` 5746. `pageMatrix = matrix;` 5748. `beginPage([width, height]);` 5749. `};` 5751. `var endFormObject = function(key) {` 5752. `// only add it if it is not already present (the keys provided by the user must be unique!)` 5753. `if (renderTargetMap[key]) {` 5754. `renderTargetStack.pop().restore();` 5755. `return;` 5756. `}` 5758. `// save the created xObject` 5759. `var newXObject = new RenderTarget();` 5761. `var xObjectId = "Xo" + (Object.keys(renderTargets).length + 1).toString(10);` 5762. `newXObject.id = xObjectId;` 5764. `renderTargetMap[key] = xObjectId;` 5765. `renderTargets[xObjectId] = newXObject;` 5767. `events.publish("addFormObject", newXObject);` 5769. `// restore state from stack` 5770. `renderTargetStack.pop().restore();` 5771. `};` 5773. `/**` 5774. `* Starts a new pdf form object, which means that all consequent draw calls target a new independent object` 5775. `* until {@link endFormObject} is called. The created object can be referenced and drawn later using` 5776. `* {@link doFormObject}. Nested form objects are possible.` 5777. `* x, y, width, height set the bounding box that is used to clip the content.` 5778. `*` 5779. `* @param {number} x` 5780. `* @param {number} y` 5781. `* @param {number} width` 5782. `* @param {number} height` 5783. `* @param {Matrix} matrix The matrix that will be applied to convert the form objects coordinate system to` 5784. `* the parent's.` 5785. `* @function` 5786. `* @returns {jsPDF}` 5787. `* @memberof jsPDF#` 5788. `* @name beginFormObject` 5789. `*/` 5790. `API.beginFormObject = function(x, y, width, height, matrix) {` 5791. `// The user can set the output target to a new form object. Nested form objects are possible.` 5792. `// Currently, they use the resource dictionary of the surrounding stream. This should be changed, as` 5793. `// the PDF-Spec states:` 5794. `// "In PDF 1.2 and later versions, form XObjects may be independent of the content streams in which` 5795. `// they appear, and this is strongly recommended although not requiredIn PDF 1.2 and later versions,` 5796. `// form XObjects may be independent of the content streams in which they appear, and this is strongly` 5797. `// recommended although not required"` 5798. `beginNewRenderTarget(x, y, width, height, matrix);` 5799. `return this;` 5800. `};` 5802. `/**` 5803. `* Completes and saves the form object.` 5804. `* @param {String} key The key by which this form object can be referenced.` 5805. `* @function` 5806. `* @returns {jsPDF}` 5807. `* @memberof jsPDF#` 5808. `* @name endFormObject` 5809. `*/` 5810. `API.endFormObject = function(key) {` 5811. `endFormObject(key);` 5812. `return this;` 5813. `};` 5815. `/**` 5816. `* Draws the specified form object by referencing to the respective pdf XObject created with` 5817. `* {@link API.beginFormObject} and {@link endFormObject}.` 5818. `* The location is determined by matrix.` 5819. `*` 5820. `* @param {String} key The key to the form object.` 5821. `* @param {Matrix} matrix The matrix applied before drawing the form object.` 5822. `* @function` 5823. `* @returns {jsPDF}` 5824. `* @memberof jsPDF#` 5825. `* @name doFormObject` 5826. `*/` 5827. `API.doFormObject = function(key, matrix) {` 5828. `var xObject = renderTargets[renderTargetMap[key]];` 5829. `out("q");` 5830. `out(matrix.toString() + " cm");` 5831. `out("/" + xObject.id + " Do");` 5832. `out("Q");` 5833. `return this;` 5834. `};` 5836. `/**` 5837. `* Returns the form object specified by key.` 5838. `* @param key {String}` 5839. `* @returns {{x: number, y: number, width: number, height: number, matrix: Matrix}}` 5840. `* @function` 5841. `* @returns {jsPDF}` 5842. `* @memberof jsPDF#` 5843. `* @name getFormObject` 5844. `*/` 5845. `API.getFormObject = function(key) {` 5846. `var xObject = renderTargets[renderTargetMap[key]];` 5847. `return {` 5848. `x: xObject.x,` 5849. `y: xObject.y,` 5850. `width: xObject.width,` 5851. `height: xObject.height,` 5852. `matrix: xObject.matrix` 5853. `};` 5854. `};` 5856. `/**` 5857. `* Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf').` 5858. `* Uses FileSaver.js-method saveAs.` 5859. `*` 5860. `* @memberof jsPDF#` 5861. `* @name save` 5862. `* @function` 5863. `* @instance` 5864. `* @param {string} filename The filename including extension.` 5865. `* @param {Object} options An Object with additional options, possible options: 'returnPromise'.` 5866. `* @returns {jsPDF|Promise} jsPDF-instance */` 5867. `API.save = function(filename, options) {` 5868. `filename = filename || "generated.pdf";` 5870. `options = options || {};` 5871. `options.returnPromise = options.returnPromise || false;` 5873. `// @if MODULE_FORMAT!='cjs'` 5874. `if (options.returnPromise === false) {` 5875. `saveAs(getBlob(buildDocument()), filename);` 5876. `if (typeof saveAs.unload === "function") {` 5877. `if (globalObject.setTimeout) {` 5878. `setTimeout(saveAs.unload, 911);` 5879. `}` 5880. `}` 5881. `return this;` 5882. `} else {` 5883. `return new Promise(function(resolve, reject) {` 5884. `try {` 5885. `var result = saveAs(getBlob(buildDocument()), filename);` 5886. `if (typeof saveAs.unload === "function") {` 5887. `if (globalObject.setTimeout) {` 5888. `setTimeout(saveAs.unload, 911);` 5889. `}` 5890. `}` 5891. `resolve(result);` 5892. `} catch (e) {` 5893. `reject(e.message);` 5894. `}` 5895. `});` 5896. `}` 5897. `// @endif` 5899. `// @if MODULE_FORMAT='cjs'` 5900. `// eslint-disable-next-line no-unreachable` 5901. `var fs = require("fs");` 5902. `var buffer = Buffer.from(getArrayBuffer(buildDocument()));` 5903. `if (options.returnPromise === false) {` 5904. `fs.writeFileSync(filename, buffer);` 5905. `} else {` 5906. `return new Promise(function(resolve, reject) {` 5907. `fs.writeFile(filename, buffer, function(err) {` 5908. `if (err) {` 5909. `reject(err);` 5910. `} else {` 5911. `resolve();` 5912. `}` 5913. `});` 5914. `});` 5915. `}` 5916. `// @endif` 5917. `};` 5919. `// applying plugins (more methods) ON TOP of built-in API.` 5920. `// this is intentional as we allow plugins to override` 5921. `// built-ins` 5922. `for (var plugin in jsPDF.API) {` 5923. `if (jsPDF.API.hasOwnProperty(plugin)) {` 5924. `if (plugin === "events" && jsPDF.API.events.length) {` 5925. `(function(events, newEvents) {` 5926. `// jsPDF.API.events is a JS Array of Arrays` 5927. `// where each Array is a pair of event name, handler` 5928. `// Events were added by plugins to the jsPDF instantiator.` 5929. `// These are always added to the new instance and some ran` 5930. `// during instantiation.` 5931. `var eventname, handler_and_args, i;` 5933. `for (i = newEvents.length - 1; i !== -1; i--) {` 5934. `// subscribe takes 3 args: 'topic', function, runonce_flag` 5935. `// if undefined, runonce is false.` 5936. `// users can attach callback directly,` 5937. `// or they can attach an array with [callback, runonce_flag]` 5938. `// that's what the "apply" magic is for below.` 5939. `eventname = newEvents[i][0];` 5940. `handler_and_args = newEvents[i][1];` 5941. `events.subscribe.apply(` 5942. `events,` 5943. `[eventname].concat(` 5944. `typeof handler_and_args === "function"` 5945. `? [handler_and_args]` 5946. `: handler_and_args` 5947. `)` 5948. `);` 5949. `}` 5950. `})(events, jsPDF.API.events);` 5951. `} else {` 5952. `API[plugin] = jsPDF.API[plugin];` 5953. `}` 5954. `}` 5955. `}` 5957. `var getPageWidth = (API.getPageWidth = function(pageNumber) {` 5958. `pageNumber = pageNumber || currentPage;` 5959. `return (` 5960. `(pagesContext[pageNumber].mediaBox.topRightX -` 5961. `pagesContext[pageNumber].mediaBox.bottomLeftX) /` 5962. `scaleFactor` 5963. `);` 5964. `});` 5966. `var setPageWidth = (API.setPageWidth = function(pageNumber, value) {` 5967. `pagesContext[pageNumber].mediaBox.topRightX =` 5968. `value * scaleFactor + pagesContext[pageNumber].mediaBox.bottomLeftX;` 5969. `});` 5971. `var getPageHeight = (API.getPageHeight = function(pageNumber) {` 5972. `pageNumber = pageNumber || currentPage;` 5973. `return (` 5974. `(pagesContext[pageNumber].mediaBox.topRightY -` 5975. `pagesContext[pageNumber].mediaBox.bottomLeftY) /` 5976. `scaleFactor` 5977. `);` 5978. `});` 5980. `var setPageHeight = (API.setPageHeight = function(pageNumber, value) {` 5981. `pagesContext[pageNumber].mediaBox.topRightY =` 5982. `value * scaleFactor + pagesContext[pageNumber].mediaBox.bottomLeftY;` 5983. `});` 5985. `/**` 5986. `* Object exposing internal API to plugins` 5987. `* @public` 5988. `* @ignore` 5989. `*/` 5990. `API.internal = {` 5991. `pdfEscape: pdfEscape,` 5992. `getStyle: getStyle,` 5993. `getFont: getFontEntry,` 5994. `getFontSize: getFontSize,` 5995. `getCharSpace: getCharSpace,` 5996. `getTextColor: getTextColor,` 5997. `getLineHeight: getLineHeight,` 5998. `getLineHeightFactor: getLineHeightFactor,` 5999. `getLineWidth: getLineWidth,` 6000. `write: write,` 6001. `getHorizontalCoordinate: getHorizontalCoordinate,` 6002. `getVerticalCoordinate: getVerticalCoordinate,` 6003. `getCoordinateString: getHorizontalCoordinateString,` 6004. `getVerticalCoordinateString: getVerticalCoordinateString,` 6005. `collections: {},` 6006. `newObject: newObject,` 6007. `newAdditionalObject: newAdditionalObject,` 6008. `newObjectDeferred: newObjectDeferred,` 6009. `newObjectDeferredBegin: newObjectDeferredBegin,` 6010. `getFilters: getFilters,` 6011. `putStream: putStream,` 6012. `events: events,` 6013. `scaleFactor: scaleFactor,` 6014. `pageSize: {` 6015. `getWidth: function() {` 6016. `return getPageWidth(currentPage);` 6017. `},` 6018. `setWidth: function(value) {` 6019. `setPageWidth(currentPage, value);` 6020. `},` 6021. `getHeight: function() {` 6022. `return getPageHeight(currentPage);` 6023. `},` 6024. `setHeight: function(value) {` 6025. `setPageHeight(currentPage, value);` 6026. `}` 6027. `},` 6028. `encryptionOptions: encryptionOptions,` 6029. `encryption: encryption,` 6030. `getEncryptor: getEncryptor,` 6031. `output: output,` 6032. `getNumberOfPages: getNumberOfPages,` 6033. `pages: pages,` 6034. `out: out,` 6035. `f2: f2,` 6036. `f3: f3,` 6037. `getPageInfo: getPageInfo,` 6038. `getPageInfoByObjId: getPageInfoByObjId,` 6039. `getCurrentPageInfo: getCurrentPageInfo,` 6040. `getPDFVersion: getPdfVersion,` 6041. `Point: Point,` 6042. `Rectangle: Rectangle,` 6043. `Matrix: Matrix,` 6044. `hasHotfix: hasHotfix //Expose the hasHotfix check so plugins can also check them.` 6045. `};` 6047. `Object.defineProperty(API.internal.pageSize, "width", {` 6048. `get: function() {` 6049. `return getPageWidth(currentPage);` 6050. `},` 6051. `set: function(value) {` 6052. `setPageWidth(currentPage, value);` 6053. `},` 6054. `enumerable: true,` 6055. `configurable: true` 6056. `});` 6057. `Object.defineProperty(API.internal.pageSize, "height", {` 6058. `get: function() {` 6059. `return getPageHeight(currentPage);` 6060. `},` 6061. `set: function(value) {` 6062. `setPageHeight(currentPage, value);` 6063. `},` 6064. `enumerable: true,` 6065. `configurable: true` 6066. `});` 6068. `//////////////////////////////////////////////////////` 6069. `// continuing initialization of jsPDF Document object` 6070. `//////////////////////////////////////////////////////` 6071. `// Add the first page automatically` 6072. `addFonts.call(API, standardFonts);` 6073. `activeFontKey = "F1";` 6074. `_addPage(format, orientation);` 6076. `events.publish("initialized");` 6077. `return API;` 6078. `}` 6080. `/**` 6081. `* jsPDF.API is a STATIC property of jsPDF class.` 6082. `* jsPDF.API is an object you can add methods and properties to.` 6083. `* The methods / properties you add will show up in new jsPDF objects.` 6084. `*` 6085. `* One property is prepopulated. It is the 'events' Object. Plugin authors can add topics,` 6086. `* callbacks to this object. These will be reassigned to all new instances of jsPDF.` 6087. `*` 6088. `* @static` 6089. `* @public` 6090. `* @memberof jsPDF#` 6091. `* @name API` 6092. `*` 6093. `* @example` 6094. `* jsPDF.API.mymethod = function(){` 6095. `* // 'this' will be ref to internal API object. see jsPDF source` 6096. `* // , so you can refer to built-in methods like so:` 6097. `* // this.line(....)` 6098. `* // this.text(....)` 6099. `* }` 6100. `* var pdfdoc = new jsPDF()` 6101. `* pdfdoc.mymethod() // <- !!!!!!` 6102. `*/` 6103. `jsPDF.API = {` 6104. `events: []` 6105. `};` 6106. `/**` 6107. `* The version of jsPDF.` 6108. `* @name version` 6109. `* @type {string}` 6110. `* @memberof jsPDF#` 6111. `*/` 6112. `jsPDF.version = "0.0.0";` 6114. `export { jsPDF, ShadingPattern, TilingPattern, GState };` 6115. `export default jsPDF;` --- # modules/svg.js - Documentation modules/svg.js ============== 1. `/** @license` 2. `* Copyright (c) 2012 Willow Systems Corporation, https://github.com/willowsystems` 3. `*` 4. `* Permission is hereby granted, free of charge, to any person obtaining` 5. `* a copy of this software and associated documentation files (the` 6. `* "Software"), to deal in the Software without restriction, including` 7. `* without limitation the rights to use, copy, modify, merge, publish,` 8. `* distribute, sublicense, and/or sell copies of the Software, and to` 9. `* permit persons to whom the Software is furnished to do so, subject to` 10. `* the following conditions:` 11. `*` 12. `* The above copyright notice and this permission notice shall be` 13. `* included in all copies or substantial portions of the Software.` 14. `*` 15. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 16. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 17. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 18. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 19. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 20. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 21. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 22. `* ====================================================================` 23. `*/` 25. `import { jsPDF } from "../jspdf.js";` 26. `import { console } from "../libs/console.js";` 27. `import { globalObject } from "../libs/globalObject.js";` 29. `/**` 30. `* jsPDF SVG plugin` 31. `*` 32. `* @name svg` 33. `* @module` 34. `*/` 35. `(function(jsPDFAPI) {` 36. `"use strict";` 38. `function loadCanvg() {` 39. `return (function() {` 40. `if (globalObject["canvg"]) {` 41. `return Promise.resolve(globalObject["canvg"]);` 42. `}` 44. `// @if MODULE_FORMAT='es'` 45. `return import("canvg");` 46. `// @endif` 48. `// @if MODULE_FORMAT!='es'` 49. `if (typeof exports === "object" && typeof module !== "undefined") {` 50. `return new Promise(function(resolve, reject) {` 51. `try {` 52. `resolve(require("canvg"));` 53. `} catch (e) {` 54. `reject(e);` 55. `}` 56. `});` 57. `}` 58. `if (typeof define === "function" && define.amd) {` 59. `return new Promise(function(resolve, reject) {` 60. `try {` 61. `require(["canvg"], resolve);` 62. `} catch (e) {` 63. `reject(e);` 64. `}` 65. `});` 66. `}` 67. `return Promise.reject(new Error("Could not load canvg"));` 68. `// @endif` 69. `})()` 70. `.catch(function(e) {` 71. `return Promise.reject(new Error("Could not load canvg: " + e));` 72. `})` 73. `.then(function(canvg) {` 74. `return canvg.default ? canvg.default : canvg;` 75. `});` 76. `}` 78. `/**` 79. `* Parses SVG XML and saves it as image into the PDF.` 80. `*` 81. `* Depends on canvas-element and canvg` 82. `*` 83. `* @name addSvgAsImage` 84. `* @public` 85. `* @function` 86. `* @param {string} SVG-Data as Text` 87. `* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page` 88. `* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page` 89. `* @param {number} width of SVG-Image (in units declared at inception of PDF document)` 90. `* @param {number} height of SVG-Image (in units declared at inception of PDF document)` 91. `* @param {string} alias of SVG-Image (if used multiple times)` 92. `* @param {string} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'` 93. `* @param {number} rotation of the image in degrees (0-359)` 94. `*` 95. `* @returns jsPDF jsPDF-instance` 96. `*/` 97. `jsPDFAPI.addSvgAsImage = function(` 98. `svg,` 99. `x,` 100. `y,` 101. `w,` 102. `h,` 103. `alias,` 104. `compression,` 105. `rotation` 106. `) {` 107. `if (isNaN(x) || isNaN(y)) {` 108. `console.error("jsPDF.addSvgAsImage: Invalid coordinates", arguments);` 109. `throw new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");` 110. `}` 112. `if (isNaN(w) || isNaN(h)) {` 113. `console.error("jsPDF.addSvgAsImage: Invalid measurements", arguments);` 114. `throw new Error(` 115. `"Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage"` 116. `);` 117. `}` 119. `var canvas = document.createElement("canvas");` 120. `canvas.width = w;` 121. `canvas.height = h;` 122. `var ctx = canvas.getContext("2d");` 123. `ctx.fillStyle = "#fff"; /// set white fill style` 124. `ctx.fillRect(0, 0, canvas.width, canvas.height);` 126. `var options = {` 127. `ignoreMouse: true,` 128. `ignoreAnimation: true,` 129. `ignoreDimensions: true` 130. `};` 131. `var doc = this;` 132. `return loadCanvg()` 133. `.then(` 134. `function(canvg) {` 135. `return canvg.fromString(ctx, svg, options);` 136. `},` 137. `function() {` 138. `return Promise.reject(new Error("Could not load canvg."));` 139. `}` 140. `)` 141. `.then(function(instance) {` 142. `return instance.render(options);` 143. `})` 144. `.then(function() {` 145. `doc.addImage(` 146. `canvas.toDataURL("image/jpeg", 1.0),` 147. `x,` 148. `y,` 149. `w,` 150. `h,` 151. `compression,` 152. `rotation` 153. `);` 154. `});` 155. `};` 156. `})(jsPDF.API);` --- # modules/webp_support.js - Documentation modules/webp\_support.js ======================== 1. `/**` 2. `* @license` 3. `* Copyright (c) 2019 Aras Abbasi` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 10. `import { JPEGEncoder } from "../libs/JPEGEncoder.js";` 11. `import { WebPDecoder } from "../libs/WebPDecoder.js";` 13. `/**` 14. `* jsPDF webp Support PlugIn` 15. `*` 16. `* @name webp_support` 17. `* @module` 18. `*/` 19. `(function(jsPDFAPI) {` 20. `"use strict";` 22. `jsPDFAPI.processWEBP = function(imageData, index, alias, compression) {` 23. `var reader = new WebPDecoder(imageData, false);` 24. `var width = reader.width,` 25. `height = reader.height;` 26. `var qu = 100;` 27. `var pixels = reader.getData();` 29. `var rawImageData = {` 30. `data: pixels,` 31. `width: width,` 32. `height: height` 33. `};` 35. `var encoder = new JPEGEncoder(qu);` 36. `var data = encoder.encode(rawImageData, qu);` 37. `return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);` 38. `};` 39. `})(jsPDF.API);` --- # modules/vfs.js - Documentation modules/vfs.js ============== 1. `/**` 2. `* @license` 3. `* jsPDF virtual FileSystem functionality` 4. `*` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 11. `/**` 12. `* Use the vFS to handle files` 13. `*` 14. `* @name vFS` 15. `* @module` 16. `*/` 17. `(function(jsPDFAPI) {` 18. `"use strict";` 20. `var _initializeVFS = function() {` 21. `if (typeof this.internal.vFS === "undefined") {` 22. `this.internal.vFS = {};` 23. `}` 24. `return true;` 25. `};` 27. `/**` 28. `* Check if the file exists in the vFS` 29. `*` 30. `* @name existsFileInVFS` 31. `* @function` 32. `* @param {string} Possible filename in the vFS.` 33. `* @returns {boolean}` 34. `* @example` 35. `* doc.existsFileInVFS("someFile.txt");` 36. `*/` 37. `jsPDFAPI.existsFileInVFS = function(filename) {` 38. `_initializeVFS.call(this);` 39. `return typeof this.internal.vFS[filename] !== "undefined";` 40. `};` 42. `/**` 43. `* Add a file to the vFS` 44. `*` 45. `* @name addFileToVFS` 46. `* @function` 47. `* @param {string} filename The name of the file which should be added.` 48. `* @param {string} filecontent The content of the file.` 49. `* @returns {jsPDF}` 50. `* @example` 51. `* doc.addFileToVFS("someFile.txt", "BADFACE1");` 52. `*/` 53. `jsPDFAPI.addFileToVFS = function(filename, filecontent) {` 54. `_initializeVFS.call(this);` 55. `this.internal.vFS[filename] = filecontent;` 56. `return this;` 57. `};` 59. `/**` 60. `* Get the file from the vFS` 61. `*` 62. `* @name getFileFromVFS` 63. `* @function` 64. `* @param {string} The name of the file which gets requested.` 65. `* @returns {string}` 66. `* @example` 67. `* doc.getFileFromVFS("someFile.txt");` 68. `*/` 69. `jsPDFAPI.getFileFromVFS = function(filename) {` 70. `_initializeVFS.call(this);` 72. `if (typeof this.internal.vFS[filename] !== "undefined") {` 73. `return this.internal.vFS[filename];` 74. `}` 75. `return null;` 76. `};` 77. `})(jsPDF.API);` --- # modules/total_pages.js - Documentation modules/total\_pages.js ======================= 1. `/**` 2. `* @license` 3. `* ====================================================================` 4. `* Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 29. `/**` 30. `* jsPDF total_pages plugin` 31. `* @name total_pages` 32. `* @module` 33. `*/` 34. `(function(jsPDFAPI) {` 35. `"use strict";` 36. `/**` 37. `* @name putTotalPages` 38. `* @function` 39. `* @param {string} pageExpression Regular Expression` 40. `* @returns {jsPDF} jsPDF-instance` 41. `*/` 43. `jsPDFAPI.putTotalPages = function(pageExpression) {` 44. `"use strict";` 46. `var replaceExpression;` 47. `var totalNumberOfPages = 0;` 48. `if (parseInt(this.internal.getFont().id.substr(1), 10) < 15) {` 49. `replaceExpression = new RegExp(pageExpression, "g");` 50. `totalNumberOfPages = this.internal.getNumberOfPages();` 51. `} else {` 52. `replaceExpression = new RegExp(` 53. `this.pdfEscape16(pageExpression, this.internal.getFont()),` 54. `"g"` 55. `);` 56. `totalNumberOfPages = this.pdfEscape16(` 57. `this.internal.getNumberOfPages() + "",` 58. `this.internal.getFont()` 59. `);` 60. `}` 62. `for (var n = 1; n <= this.internal.getNumberOfPages(); n++) {` 63. `for (var i = 0; i < this.internal.pages[n].length; i++) {` 64. `this.internal.pages[n][i] = this.internal.pages[n][i].replace(` 65. `replaceExpression,` 66. `totalNumberOfPages` 67. `);` 68. `}` 69. `}` 71. `return this;` 72. `};` 73. `})(jsPDF.API);` --- # modules/split_text_to_size.js - Documentation modules/split\_text\_to\_size.js ================================ 1. `/** @license` 2. `* MIT license.` 3. `* Copyright (c) 2012 Willow Systems Corporation, https://github.com/willowsystems` 4. `* 2014 Diego Casorran, https://github.com/diegocr` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 29. `/**` 30. `* jsPDF split_text_to_size plugin` 31. `*` 32. `* @name split_text_to_size` 33. `* @module` 34. `*/` 35. `(function(API) {` 36. `"use strict";` 37. `/**` 38. `* Returns an array of length matching length of the 'word' string, with each` 39. `* cell occupied by the width of the char in that position.` 40. `*` 41. `* @name getCharWidthsArray` 42. `* @function` 43. `* @param {string} text` 44. `* @param {Object} options` 45. `* @returns {Array}` 46. `*/` 47. `var getCharWidthsArray = (API.getCharWidthsArray = function(text, options) {` 48. `options = options || {};` 50. `var activeFont = options.font || this.internal.getFont();` 51. `var fontSize = options.fontSize || this.internal.getFontSize();` 52. `var charSpace = options.charSpace || this.internal.getCharSpace();` 54. `var widths = options.widths` 55. `? options.widths` 56. `: activeFont.metadata.Unicode.widths;` 57. `var widthsFractionOf = widths.fof ? widths.fof : 1;` 58. `var kerning = options.kerning` 59. `? options.kerning` 60. `: activeFont.metadata.Unicode.kerning;` 61. `var kerningFractionOf = kerning.fof ? kerning.fof : 1;` 62. `var doKerning = options.doKerning === false ? false : true;` 63. `var kerningValue = 0;` 65. `var i;` 66. `var length = text.length;` 67. `var char_code;` 68. `var prior_char_code = 0; //for kerning` 69. `var default_char_width = widths[0] || widthsFractionOf;` 70. `var output = [];` 72. `for (i = 0; i < length; i++) {` 73. `char_code = text.charCodeAt(i);` 75. `if (typeof activeFont.metadata.widthOfString === "function") {` 76. `output.push(` 77. `(activeFont.metadata.widthOfGlyph(` 78. `activeFont.metadata.characterToGlyph(char_code)` 79. `) +` 80. `charSpace * (1000 / fontSize) || 0) / 1000` 81. `);` 82. `} else {` 83. `if (` 84. `doKerning &&` 85. `typeof kerning[char_code] === "object" &&` 86. `!isNaN(parseInt(kerning[char_code][prior_char_code], 10))` 87. `) {` 88. `kerningValue =` 89. `kerning[char_code][prior_char_code] / kerningFractionOf;` 90. `} else {` 91. `kerningValue = 0;` 92. `}` 93. `output.push(` 94. `(widths[char_code] || default_char_width) / widthsFractionOf +` 95. `kerningValue` 96. `);` 97. `}` 98. `prior_char_code = char_code;` 99. `}` 101. `return output;` 102. `});` 104. `/**` 105. `* Returns a widths of string in a given font, if the font size is set as 1 point.` 106. `*` 107. `* In other words, this is "proportional" value. For 1 unit of font size, the length` 108. `* of the string will be that much.` 109. `*` 110. `* Multiply by font size to get actual width in *points*` 111. `* Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc.` 112. `*` 113. `* @name getStringUnitWidth` 114. `* @public` 115. `* @function` 116. `* @param {string} text` 117. `* @param {string} options` 118. `* @returns {number} result` 119. `*/` 120. `var getStringUnitWidth = (API.getStringUnitWidth = function(text, options) {` 121. `options = options || {};` 123. `var fontSize = options.fontSize || this.internal.getFontSize();` 124. `var font = options.font || this.internal.getFont();` 125. `var charSpace = options.charSpace || this.internal.getCharSpace();` 126. `var result = 0;` 128. `if (API.processArabic) {` 129. `text = API.processArabic(text);` 130. `}` 132. `if (typeof font.metadata.widthOfString === "function") {` 133. `result =` 134. `font.metadata.widthOfString(text, fontSize, charSpace) / fontSize;` 135. `} else {` 136. `result = getCharWidthsArray` 137. `.apply(this, arguments)` 138. `.reduce(function(pv, cv) {` 139. `return pv + cv;` 140. `}, 0);` 141. `}` 142. `return result;` 143. `});` 145. `/**` 146. `returns array of lines` 147. `*/` 148. `var splitLongWord = function(word, widths_array, firstLineMaxLen, maxLen) {` 149. `var answer = [];` 151. `// 1st, chop off the piece that can fit on the hanging line.` 152. `var i = 0,` 153. `l = word.length,` 154. `workingLen = 0;` 155. `while (i !== l && workingLen + widths_array[i] < firstLineMaxLen) {` 156. `workingLen += widths_array[i];` 157. `i++;` 158. `}` 159. `// this is first line.` 160. `answer.push(word.slice(0, i));` 162. `// 2nd. Split the rest into maxLen pieces.` 163. `var startOfLine = i;` 164. `workingLen = 0;` 165. `while (i !== l) {` 166. `if (workingLen + widths_array[i] > maxLen) {` 167. `answer.push(word.slice(startOfLine, i));` 168. `workingLen = 0;` 169. `startOfLine = i;` 170. `}` 171. `workingLen += widths_array[i];` 172. `i++;` 173. `}` 174. `if (startOfLine !== i) {` 175. `answer.push(word.slice(startOfLine, i));` 176. `}` 178. `return answer;` 179. `};` 181. `// Note, all sizing inputs for this function must be in "font measurement units"` 182. `// By default, for PDF, it's "point".` 183. `var splitParagraphIntoLines = function(text, maxlen, options) {` 184. `// at this time works only on Western scripts, ones with space char` 185. `// separating the words. Feel free to expand.` 187. `if (!options) {` 188. `options = {};` 189. `}` 191. `var line = [],` 192. `lines = [line],` 193. `line_length = options.textIndent || 0,` 194. `separator_length = 0,` 195. `current_word_length = 0,` 196. `word,` 197. `widths_array,` 198. `words = text.split(" "),` 199. `spaceCharWidth = getCharWidthsArray.apply(this, [" ", options])[0],` 200. `i,` 201. `l,` 202. `tmp,` 203. `lineIndent;` 205. `if (options.lineIndent === -1) {` 206. `lineIndent = words[0].length + 2;` 207. `} else {` 208. `lineIndent = options.lineIndent || 0;` 209. `}` 210. `if (lineIndent) {` 211. `var pad = Array(lineIndent).join(" "),` 212. `wrds = [];` 213. `words.map(function(wrd) {` 214. `wrd = wrd.split(/\s*\n/);` 215. `if (wrd.length > 1) {` 216. `wrds = wrds.concat(` 217. `wrd.map(function(wrd, idx) {` 218. `return (idx && wrd.length ? "\n" : "") + wrd;` 219. `})` 220. `);` 221. `} else {` 222. `wrds.push(wrd[0]);` 223. `}` 224. `});` 225. `words = wrds;` 226. `lineIndent = getStringUnitWidth.apply(this, [pad, options]);` 227. `}` 229. `for (i = 0, l = words.length; i < l; i++) {` 230. `var force = 0;` 232. `word = words[i];` 233. `if (lineIndent && word[0] == "\n") {` 234. `word = word.substr(1);` 235. `force = 1;` 236. `}` 237. `widths_array = getCharWidthsArray.apply(this, [word, options]);` 238. `current_word_length = widths_array.reduce(function(pv, cv) {` 239. `return pv + cv;` 240. `}, 0);` 242. `if (` 243. `line_length + separator_length + current_word_length > maxlen ||` 244. `force` 245. `) {` 246. `if (current_word_length > maxlen) {` 247. `// this happens when you have space-less long URLs for example.` 248. `// we just chop these to size. We do NOT insert hiphens` 249. `tmp = splitLongWord.apply(this, [`\ 250. `word,`\ 251. `widths_array,`\ 252. `maxlen - (line_length + separator_length),`\ 253. `maxlen`\ 254. `]);` 255. `// first line we add to existing line object` 256. `line.push(tmp.shift()); // it's ok to have extra space indicator there` 257. `// last line we make into new line object` 258. `line = [tmp.pop()];` 259. `// lines in the middle we apped to lines object as whole lines` 260. `while (tmp.length) {` 261. `lines.push([tmp.shift()]); // single fragment occupies whole line` 262. `}` 263. `current_word_length = widths_array` 264. `.slice(word.length - (line[0] ? line[0].length : 0))` 265. `.reduce(function(pv, cv) {` 266. `return pv + cv;` 267. `}, 0);` 268. `} else {` 269. `// just put it on a new line` 270. `line = [word];` 271. `}` 273. `// now we attach new line to lines` 274. `lines.push(line);` 275. `line_length = current_word_length + lineIndent;` 276. `separator_length = spaceCharWidth;` 277. `} else {` 278. `line.push(word);` 280. `line_length += separator_length + current_word_length;` 281. `separator_length = spaceCharWidth;` 282. `}` 283. `}` 285. `var postProcess;` 286. `if (lineIndent) {` 287. `postProcess = function(ln, idx) {` 288. `return (idx ? pad : "") + ln.join(" ");` 289. `};` 290. `} else {` 291. `postProcess = function(ln) {` 292. `return ln.join(" ");` 293. `};` 294. `}` 296. `return lines.map(postProcess);` 297. `};` 299. `/**` 300. `* Splits a given string into an array of strings. Uses 'size' value` 301. `* (in measurement units declared as default for the jsPDF instance)` 302. `* and the font's "widths" and "Kerning" tables, where available, to` 303. `* determine display length of a given string for a given font.` 304. `*` 305. `* We use character's 100% of unit size (height) as width when Width` 306. `* table or other default width is not available.` 307. `*` 308. `* @name splitTextToSize` 309. `* @public` 310. `* @function` 311. `* @param {string} text Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string.` 312. `* @param {number} size Nominal number, measured in units default to this instance of jsPDF.` 313. `* @param {Object} options Optional flags needed for chopper to do the right thing.` 314. `* @returns {Array} array Array with strings chopped to size.` 315. `*/` 316. `API.splitTextToSize = function(text, maxlen, options) {` 317. `"use strict";` 319. `options = options || {};` 321. `var fsize = options.fontSize || this.internal.getFontSize(),` 322. `newOptions = function(options) {` 323. `var widths = {` 324. `0: 1` 325. `},` 326. `kerning = {};` 328. `if (!options.widths || !options.kerning) {` 329. `var f = this.internal.getFont(options.fontName, options.fontStyle),` 330. `encoding = "Unicode";` 331. `// NOT UTF8, NOT UTF16BE/LE, NOT UCS2BE/LE` 332. `// Actual JavaScript-native String's 16bit char codes used.` 333. `// no multi-byte logic here` 335. `if (f.metadata[encoding]) {` 336. `return {` 337. `widths: f.metadata[encoding].widths || widths,` 338. `kerning: f.metadata[encoding].kerning || kerning` 339. `};` 340. `} else {` 341. `return {` 342. `font: f.metadata,` 343. `fontSize: this.internal.getFontSize(),` 344. `charSpace: this.internal.getCharSpace()` 345. `};` 346. `}` 347. `} else {` 348. `return {` 349. `widths: options.widths,` 350. `kerning: options.kerning` 351. `};` 352. `}` 353. `}.call(this, options);` 355. `// first we split on end-of-line chars` 356. `var paragraphs;` 357. `if (Array.isArray(text)) {` 358. `paragraphs = text;` 359. `} else {` 360. `paragraphs = String(text).split(/\r?\n/);` 361. `}` 363. `// now we convert size (max length of line) into "font size units"` 364. `// at present time, the "font size unit" is always 'point'` 365. `// 'proportional' means, "in proportion to font size"` 366. `var fontUnit_maxLen = (1.0 * this.internal.scaleFactor * maxlen) / fsize;` 367. `// at this time, fsize is always in "points" regardless of the default measurement unit of the doc.` 368. `// this may change in the future?` 369. `// until then, proportional_maxlen is likely to be in 'points'` 371. `// If first line is to be indented (shorter or longer) than maxLen` 372. `// we indicate that by using CSS-style "text-indent" option.` 373. `// here it's in font units too (which is likely 'points')` 374. `// it can be negative (which makes the first line longer than maxLen)` 375. `newOptions.textIndent = options.textIndent` 376. `? (options.textIndent * 1.0 * this.internal.scaleFactor) / fsize` 377. `: 0;` 378. `newOptions.lineIndent = options.lineIndent;` 380. `var i,` 381. `l,` 382. `output = [];` 383. `for (i = 0, l = paragraphs.length; i < l; i++) {` 384. `output = output.concat(` 385. `splitParagraphIntoLines.apply(this, [`\ 386. `paragraphs[i],`\ 387. `fontUnit_maxLen,`\ 388. `newOptions`\ 389. `])` 390. `);` 391. `}` 393. `return output;` 394. `};` 395. `})(jsPDF.API);` --- # modules/xmp_metadata.js - Documentation modules/xmp\_metadata.js ======================== 1. `/** ====================================================================` 2. `* @license` 3. `* jsPDF XMP metadata plugin` 4. `* Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi` 5. `*` 6. `* Permission is hereby granted, free of charge, to any person obtaining` 7. `* a copy of this software and associated documentation files (the` 8. `* "Software"), to deal in the Software without restriction, including` 9. `* without limitation the rights to use, copy, modify, merge, publish,` 10. `* distribute, sublicense, and/or sell copies of the Software, and to` 11. `* permit persons to whom the Software is furnished to do so, subject to` 12. `* the following conditions:` 13. `*` 14. `* The above copyright notice and this permission notice shall be` 15. `* included in all copies or substantial portions of the Software.` 16. `*` 17. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 18. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 19. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 20. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 21. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 22. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 23. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 24. `* ====================================================================` 25. `*/` 27. `import { jsPDF } from "../jspdf.js";` 29. `/**` 30. `* @name xmp_metadata` 31. `* @module` 32. `*/` 33. `(function(jsPDFAPI) {` 34. `"use strict";` 36. `var postPutResources = function() {` 37. `var xmpmeta_beginning = '';` 38. `var rdf_beginning =` 39. `'';` 42. `var rdf_ending = "";` 43. `var xmpmeta_ending = "";` 44. `var utf8_xmpmeta_beginning = unescape(` 45. `encodeURIComponent(xmpmeta_beginning)` 46. `);` 47. `var utf8_rdf_beginning = unescape(encodeURIComponent(rdf_beginning));` 48. `var utf8_metadata = unescape(` 49. `encodeURIComponent(this.internal.__metadata__.metadata)` 50. `);` 51. `var utf8_rdf_ending = unescape(encodeURIComponent(rdf_ending));` 52. `var utf8_xmpmeta_ending = unescape(encodeURIComponent(xmpmeta_ending));` 54. `var total_len =` 55. `utf8_rdf_beginning.length +` 56. `utf8_metadata.length +` 57. `utf8_rdf_ending.length +` 58. `utf8_xmpmeta_beginning.length +` 59. `utf8_xmpmeta_ending.length;` 61. `this.internal.__metadata__.metadata_object_number = this.internal.newObject();` 62. `this.internal.write(` 63. `"<< /Type /Metadata /Subtype /XML /Length " + total_len + " >>"` 64. `);` 65. `this.internal.write("stream");` 66. `this.internal.write(` 67. `utf8_xmpmeta_beginning +` 68. `utf8_rdf_beginning +` 69. `utf8_metadata +` 70. `utf8_rdf_ending +` 71. `utf8_xmpmeta_ending` 72. `);` 73. `this.internal.write("endstream");` 74. `this.internal.write("endobj");` 75. `};` 77. `var putCatalog = function() {` 78. `if (this.internal.__metadata__.metadata_object_number) {` 79. `this.internal.write(` 80. `"/Metadata " +` 81. `this.internal.__metadata__.metadata_object_number +` 82. `" 0 R"` 83. `);` 84. `}` 85. `};` 87. `/**` 88. `* Adds XMP formatted metadata to PDF` 89. `*` 90. `* @name addMetadata` 91. `* @function` 92. `* @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.` 93. `* @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash.` 94. `* @returns {jsPDF} jsPDF-instance` 95. `*/` 96. `jsPDFAPI.addMetadata = function(metadata, namespaceuri) {` 97. `if (typeof this.internal.__metadata__ === "undefined") {` 98. `this.internal.__metadata__ = {` 99. `metadata: metadata,` 100. `namespaceuri: namespaceuri || "http://jspdf.default.namespaceuri/"` 101. `};` 102. `this.internal.events.subscribe("putCatalog", putCatalog);` 104. `this.internal.events.subscribe("postPutResources", postPutResources);` 105. `}` 106. `return this;` 107. `};` 108. `})(jsPDF.API);` --- # modules/standard_fonts_metrics.js - Documentation modules/standard\_fonts\_metrics.js =================================== 1. `/** @license` 2. `jsPDF standard_fonts_metrics plugin` 3. `* Copyright (c) 2012 Willow Systems Corporation, https://github.com/willowsystems` 4. `* MIT license.` 5. `* Permission is hereby granted, free of charge, to any person obtaining` 6. `* a copy of this software and associated documentation files (the` 7. `* "Software"), to deal in the Software without restriction, including` 8. `* without limitation the rights to use, copy, modify, merge, publish,` 9. `* distribute, sublicense, and/or sell copies of the Software, and to` 10. `* permit persons to whom the Software is furnished to do so, subject to` 11. `* the following conditions:` 12. `*` 13. `* The above copyright notice and this permission notice shall be` 14. `* included in all copies or substantial portions of the Software.` 15. `*` 16. `* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,` 17. `* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF` 18. `* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND` 19. `* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE` 20. `* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION` 21. `* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION` 22. `* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.` 23. `* ====================================================================` 24. `*/` 26. `import { jsPDF } from "../jspdf.js";` 28. `/**` 29. `* This file adds the standard font metrics to jsPDF.` 30. `*` 31. `* Font metrics data is reprocessed derivative of contents of` 32. `* "Font Metrics for PDF Core 14 Fonts" package, which exhibits the following copyright and license:` 33. `*` 34. `* Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.` 35. `*` 36. `* This file and the 14 PostScript(R) AFM files it accompanies may be used,` 37. `* copied, and distributed for any purpose and without charge, with or without` 38. `* modification, provided that all copyright notices are retained; that the AFM` 39. `* files are not distributed without this file; that all modifications to this` 40. `* file or any of the AFM files are prominently noted in the modified file(s);` 41. `* and that this paragraph is not modified. Adobe Systems has no responsibility` 42. `* or obligation to support the use of the AFM files.` 43. `*` 44. `* @name standard_fonts_metrics` 45. `* @module` 46. `*/` 48. `(function(API) {` 49. `"use strict";` 50. `API.__fontmetrics__ = API.__fontmetrics__ || {};` 52. `var decoded = "0123456789abcdef",` 53. `encoded = "klmnopqrstuvwxyz",` 54. `mappingUncompress = {},` 55. `mappingCompress = {};` 57. `for (var i = 0; i < encoded.length; i++) {` 58. `mappingUncompress[encoded[i]] = decoded[i];` 59. `mappingCompress[decoded[i]] = encoded[i];` 60. `}` 62. `var hex = function(value) {` 63. `return "0x" + parseInt(value, 10).toString(16);` 64. `};` 66. `var compress = (API.__fontmetrics__.compress = function(data) {` 67. `var vals = ["{"];` 68. `var value, keystring, valuestring, numberprefix;` 70. `for (var key in data) {` 71. `value = data[key];` 73. `if (!isNaN(parseInt(key, 10))) {` 74. `key = parseInt(key, 10);` 75. `keystring = hex(key).slice(2);` 76. `keystring =` 77. `keystring.slice(0, -1) + mappingCompress[keystring.slice(-1)];` 78. `} else {` 79. `keystring = "'" + key + "'";` 80. `}` 82. `if (typeof value == "number") {` 83. `if (value < 0) {` 84. `valuestring = hex(value).slice(3);` 85. `numberprefix = "-";` 86. `} else {` 87. `valuestring = hex(value).slice(2);` 88. `numberprefix = "";` 89. `}` 90. `valuestring =` 91. `numberprefix +` 92. `valuestring.slice(0, -1) +` 93. `mappingCompress[valuestring.slice(-1)];` 94. `} else {` 95. `if (typeof value === "object") {` 96. `valuestring = compress(value);` 97. `} else {` 98. `throw new Error(` 99. `"Don't know what to do with value type " + typeof value + "."` 100. `);` 101. `}` 102. `}` 103. `vals.push(keystring + valuestring);` 104. `}` 105. `vals.push("}");` 106. `return vals.join("");` 107. `});` 109. `/**` 110. `* Uncompresses data compressed into custom, base16-like format.` 111. `*` 112. `* @public` 113. `* @function` 114. `* @param` 115. `* @returns {Type}` 116. `*/` 117. `var uncompress = (API.__fontmetrics__.uncompress = function(data) {` 118. `if (typeof data !== "string") {` 119. `throw new Error("Invalid argument passed to uncompress.");` 120. `}` 122. `var output = {},` 123. `sign = 1,` 124. `stringparts, // undef. will be [] in string mode` 125. `activeobject = output,` 126. `parentchain = [],` 127. `parent_key_pair,` 128. `keyparts = "",` 129. `valueparts = "",` 130. `key, // undef. will be Truthy when Key is resolved.` 131. `datalen = data.length - 1, // stripping ending }` 132. `ch;` 134. `for (var i = 1; i < datalen; i += 1) {` 135. `// - { } ' are special.` 137. `ch = data[i];` 139. `if (ch == "'") {` 140. `if (stringparts) {` 141. `// end of string mode` 142. `key = stringparts.join("");` 143. `stringparts = undefined;` 144. `} else {` 145. `// start of string mode` 146. `stringparts = [];` 147. `}` 148. `} else if (stringparts) {` 149. `stringparts.push(ch);` 150. `} else if (ch == "{") {` 151. `// start of object` 152. `parentchain.push([activeobject, key]);` 153. `activeobject = {};` 154. `key = undefined;` 155. `} else if (ch == "}") {` 156. `// end of object` 157. `parent_key_pair = parentchain.pop();` 158. `parent_key_pair[0][parent_key_pair[1]] = activeobject;` 159. `key = undefined;` 160. `activeobject = parent_key_pair[0];` 161. `} else if (ch == "-") {` 162. `sign = -1;` 163. `} else {` 164. `// must be number` 165. `if (key === undefined) {` 166. `if (mappingUncompress.hasOwnProperty(ch)) {` 167. `keyparts += mappingUncompress[ch];` 168. `key = parseInt(keyparts, 16) * sign;` 169. `sign = +1;` 170. `keyparts = "";` 171. `} else {` 172. `keyparts += ch;` 173. `}` 174. `} else {` 175. `if (mappingUncompress.hasOwnProperty(ch)) {` 176. `valueparts += mappingUncompress[ch];` 177. `activeobject[key] = parseInt(valueparts, 16) * sign;` 178. `sign = +1;` 179. `key = undefined;` 180. `valueparts = "";` 181. `} else {` 182. `valueparts += ch;` 183. `}` 184. `}` 185. `}` 186. `}` 187. `return output;` 188. `});` 190. `// encoding = 'Unicode'` 191. `// NOT UTF8, NOT UTF16BE/LE, NOT UCS2BE/LE. NO clever BOM behavior` 192. `// Actual 16bit char codes used.` 193. `// no multi-byte logic here` 195. `// Unicode characters to WinAnsiEncoding:` 196. `// {402: 131, 8211: 150, 8212: 151, 8216: 145, 8217: 146, 8218: 130, 8220: 147, 8221: 148, 8222: 132, 8224: 134, 8225: 135, 8226: 149, 8230: 133, 8364: 128, 8240:137, 8249: 139, 8250: 155, 710: 136, 8482: 153, 338: 140, 339: 156, 732: 152, 352: 138, 353: 154, 376: 159, 381: 142, 382: 158}` 197. `// as you can see, all Unicode chars are outside of 0-255 range. No char code conflicts.` 198. `// this means that you can give Win cp1252 encoded strings to jsPDF for rendering directly` 199. `// as well as give strings with some (supported by these fonts) Unicode characters and` 200. `// these will be mapped to win cp1252` 201. `// for example, you can send char code (cp1252) 0x80 or (unicode) 0x20AC, getting "Euro" glyph displayed in both cases.` 203. `var encodingBlock = {` 204. `codePages: ["WinAnsiEncoding"],` 205. `WinAnsiEncoding: uncompress(` 206. `"{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}"` 207. `)` 208. `};` 209. `var encodings = {` 210. `Unicode: {` 211. `Courier: encodingBlock,` 212. `"Courier-Bold": encodingBlock,` 213. `"Courier-BoldOblique": encodingBlock,` 214. `"Courier-Oblique": encodingBlock,` 215. `Helvetica: encodingBlock,` 216. `"Helvetica-Bold": encodingBlock,` 217. `"Helvetica-BoldOblique": encodingBlock,` 218. `"Helvetica-Oblique": encodingBlock,` 219. `"Times-Roman": encodingBlock,` 220. `"Times-Bold": encodingBlock,` 221. `"Times-BoldItalic": encodingBlock,` 222. `"Times-Italic": encodingBlock` 223. `// , 'Symbol'` 224. `// , 'ZapfDingbats'` 225. `}` 226. `};` 228. `var fontMetrics = {` 229. `Unicode: {` 230. `// all sizing numbers are n/fontMetricsFractionOf = one font size unit` 231. `// this means that if fontMetricsFractionOf = 1000, and letter A's width is 476, it's` 232. `// width is 476/1000 or 47.6% of its height (regardless of font size)` 233. `// At this time this value applies to "widths" and "kerning" numbers.` 235. `// char code 0 represents "default" (average) width - use it for chars missing in this table.` 236. `// key 'fof' represents the "fontMetricsFractionOf" value` 238. `"Courier-Oblique": uncompress(` 239. `"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"` 240. `),` 241. `"Times-BoldItalic": uncompress(` 242. `"{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"` 243. `),` 244. `"Helvetica-Bold": uncompress(` 245. `"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"` 246. `),` 247. `Courier: uncompress("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),` 248. `"Courier-BoldOblique": uncompress(` 249. `"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"` 250. `),` 251. `"Times-Bold": uncompress(` 252. `"{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"` 253. `),` 254. `Symbol: uncompress(` 255. `"{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"` 256. `),` 257. `Helvetica: uncompress(` 258. `"{'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}}}"` 259. `),` 260. `"Helvetica-BoldOblique": uncompress(` 261. `"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"` 262. `),` 263. `ZapfDingbats: uncompress("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),` 264. `"Courier-Bold": uncompress("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),` 265. `"Times-Italic": uncompress(` 266. `"{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"` 267. `),` 268. `"Times-Roman": uncompress(` 269. `"{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"` 270. `),` 271. `"Helvetica-Oblique": uncompress(` 272. `"{'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}}}"` 273. `)` 274. `}` 275. `};` 277. `/*` 278. `This event handler is fired when a new jsPDF object is initialized` 279. `This event handler appends metrics data to standard fonts within` 280. `that jsPDF instance. The metrics are mapped over Unicode character` 281. `codes, NOT CIDs or other codes matching the StandardEncoding table of the` 282. `standard PDF fonts.` 283. `Future:` 284. `Also included is the encoding maping table, converting Unicode (UCS-2, UTF-16)` 285. `char codes to StandardEncoding character codes. The encoding table is to be used` 286. `somewhere around "pdfEscape" call.` 287. `*/` 288. `API.events.push([`\ 289. `"addFont",`\ 290. `function(data) {`\ 291. `var font = data.font;`\ \ 293. `var metrics = fontMetrics["Unicode"][font.postScriptName];`\ 294. `if (metrics) {`\ 295. `font.metadata["Unicode"] = {};`\ 296. `font.metadata["Unicode"].widths = metrics.widths;`\ 297. `font.metadata["Unicode"].kerning = metrics.kerning;`\ 298. `}`\ \ 300. `var encodingBlock = encodings["Unicode"][font.postScriptName];`\ 301. `if (encodingBlock) {`\ 302. `font.metadata["Unicode"].encoding = encodingBlock;`\ 303. `font.encoding = encodingBlock.codePages[0];`\ 304. `}`\ 305. `}`\ 306. `]); // end of adding event handler` 307. `})(jsPDF.API);` --- # modules/viewerpreferences.js - Documentation modules/viewerpreferences.js ============================ 1. `/**` 2. `* @license` 3. `* jsPDF viewerPreferences Plugin` 4. `* @author Aras Abbasi (github.com/arasabbasi)` 5. `* Licensed under the MIT License.` 6. `* http://opensource.org/licenses/mit-license` 7. `*/` 9. `import { jsPDF } from "../jspdf.js";` 11. `/**` 12. `* Adds the ability to set ViewerPreferences and by thus` 13. `* controlling the way the document is to be presented on the` 14. `* screen or in print.` 15. `* @name viewerpreferences` 16. `* @module` 17. `*/` 18. `(function(jsPDFAPI) {` 19. `"use strict";` 20. `/**` 21. `* Set the ViewerPreferences of the generated PDF` 22. `*` 23. `* @name viewerPreferences` 24. `* @function` 25. `* @public` 26. `* @param {Object} options Array with the ViewerPreferences
    ` 27. `* Example: doc.viewerPreferences({"FitWindow":true});
    ` 28. `*
    ` 29. `* You can set following preferences:
    ` 30. `*
    ` 31. `* HideToolbar (boolean)
    ` 32. `* Default value: false
    ` 33. `*
    ` 34. `* HideMenubar (boolean)
    ` 35. `* Default value: false.
    ` 36. `*
    ` 37. `* HideWindowUI (boolean)
    ` 38. `* Default value: false.
    ` 39. `*
    ` 40. `* FitWindow (boolean)
    ` 41. `* Default value: false.
    ` 42. `*
    ` 43. `* CenterWindow (boolean)
    ` 44. `* Default value: false
    ` 45. `*
    ` 46. `* DisplayDocTitle (boolean)
    ` 47. `* Default value: false.
    ` 48. `*
    ` 49. `* NonFullScreenPageMode (string)
    ` 50. `* Possible values: UseNone, UseOutlines, UseThumbs, UseOC
    ` 51. `* Default value: UseNone
    ` 52. `*
    ` 53. `* Direction (string)
    ` 54. `* Possible values: L2R, R2L
    ` 55. `* Default value: L2R.
    ` 56. `*
    ` 57. `* ViewArea (string)
    ` 58. `* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    ` 59. `* Default value: CropBox.
    ` 60. `*
    ` 61. `* ViewClip (string)
    ` 62. `* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    ` 63. `* Default value: CropBox
    ` 64. `*
    ` 65. `* PrintArea (string)
    ` 66. `* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    ` 67. `* Default value: CropBox
    ` 68. `*
    ` 69. `* PrintClip (string)
    ` 70. `* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
    ` 71. `* Default value: CropBox.
    ` 72. `*
    ` 73. `* PrintScaling (string)
    ` 74. `* Possible values: AppDefault, None
    ` 75. `* Default value: AppDefault.
    ` 76. `*
    ` 77. `* Duplex (string)
    ` 78. `* Possible values: Simplex, DuplexFlipLongEdge, DuplexFlipShortEdge` 79. `* Default value: none
    ` 80. `*
    ` 81. `* PickTrayByPDFSize (boolean)
    ` 82. `* Default value: false
    ` 83. `*
    ` 84. `* PrintPageRange (Array)
    ` 85. `* Example: [[1,5], [7,9]]
    ` 86. `* Default value: as defined by PDF viewer application
    ` 87. `*
    ` 88. `* NumCopies (Number)
    ` 89. `* Possible values: 1, 2, 3, 4, 5
    ` 90. `* Default value: 1
    ` 91. `*
    ` 92. `* For more information see the PDF Reference, sixth edition on Page 577` 93. `* @param {boolean} doReset True to reset the settings` 94. `* @function` 95. `* @returns jsPDF jsPDF-instance` 96. `* @example` 97. `* var doc = new jsPDF()` 98. `* doc.text('This is a test', 10, 10)` 99. `* doc.viewerPreferences({'FitWindow': true}, true)` 100. `* doc.save("viewerPreferences.pdf")` 101. `*` 102. `* // Example printing 10 copies, using cropbox, and hiding UI.` 103. `* doc.viewerPreferences({` 104. `* 'HideWindowUI': true,` 105. `* 'PrintArea': 'CropBox',` 106. `* 'NumCopies': 10` 107. `* })` 108. `*/` 109. `jsPDFAPI.viewerPreferences = function(options, doReset) {` 110. `options = options || {};` 111. `doReset = doReset || false;` 113. `var configuration;` 114. `var configurationTemplate = {` 115. `HideToolbar: {` 116. `defaultValue: false,` 117. `value: false,` 118. `type: "boolean",` 119. `explicitSet: false,` 120. `valueSet: [true, false],` 121. `pdfVersion: 1.3` 122. `},` 123. `HideMenubar: {` 124. `defaultValue: false,` 125. `value: false,` 126. `type: "boolean",` 127. `explicitSet: false,` 128. `valueSet: [true, false],` 129. `pdfVersion: 1.3` 130. `},` 131. `HideWindowUI: {` 132. `defaultValue: false,` 133. `value: false,` 134. `type: "boolean",` 135. `explicitSet: false,` 136. `valueSet: [true, false],` 137. `pdfVersion: 1.3` 138. `},` 139. `FitWindow: {` 140. `defaultValue: false,` 141. `value: false,` 142. `type: "boolean",` 143. `explicitSet: false,` 144. `valueSet: [true, false],` 145. `pdfVersion: 1.3` 146. `},` 147. `CenterWindow: {` 148. `defaultValue: false,` 149. `value: false,` 150. `type: "boolean",` 151. `explicitSet: false,` 152. `valueSet: [true, false],` 153. `pdfVersion: 1.3` 154. `},` 155. `DisplayDocTitle: {` 156. `defaultValue: false,` 157. `value: false,` 158. `type: "boolean",` 159. `explicitSet: false,` 160. `valueSet: [true, false],` 161. `pdfVersion: 1.4` 162. `},` 163. `NonFullScreenPageMode: {` 164. `defaultValue: "UseNone",` 165. `value: "UseNone",` 166. `type: "name",` 167. `explicitSet: false,` 168. `valueSet: ["UseNone", "UseOutlines", "UseThumbs", "UseOC"],` 169. `pdfVersion: 1.3` 170. `},` 171. `Direction: {` 172. `defaultValue: "L2R",` 173. `value: "L2R",` 174. `type: "name",` 175. `explicitSet: false,` 176. `valueSet: ["L2R", "R2L"],` 177. `pdfVersion: 1.3` 178. `},` 179. `ViewArea: {` 180. `defaultValue: "CropBox",` 181. `value: "CropBox",` 182. `type: "name",` 183. `explicitSet: false,` 184. `valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],` 185. `pdfVersion: 1.4` 186. `},` 187. `ViewClip: {` 188. `defaultValue: "CropBox",` 189. `value: "CropBox",` 190. `type: "name",` 191. `explicitSet: false,` 192. `valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],` 193. `pdfVersion: 1.4` 194. `},` 195. `PrintArea: {` 196. `defaultValue: "CropBox",` 197. `value: "CropBox",` 198. `type: "name",` 199. `explicitSet: false,` 200. `valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],` 201. `pdfVersion: 1.4` 202. `},` 203. `PrintClip: {` 204. `defaultValue: "CropBox",` 205. `value: "CropBox",` 206. `type: "name",` 207. `explicitSet: false,` 208. `valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],` 209. `pdfVersion: 1.4` 210. `},` 211. `PrintScaling: {` 212. `defaultValue: "AppDefault",` 213. `value: "AppDefault",` 214. `type: "name",` 215. `explicitSet: false,` 216. `valueSet: ["AppDefault", "None"],` 217. `pdfVersion: 1.6` 218. `},` 219. `Duplex: {` 220. `defaultValue: "",` 221. `value: "none",` 222. `type: "name",` 223. `explicitSet: false,` 224. `valueSet: [`\ 225. `"Simplex",`\ 226. `"DuplexFlipShortEdge",`\ 227. `"DuplexFlipLongEdge",`\ 228. `"none"`\ 229. `],` 230. `pdfVersion: 1.7` 231. `},` 232. `PickTrayByPDFSize: {` 233. `defaultValue: false,` 234. `value: false,` 235. `type: "boolean",` 236. `explicitSet: false,` 237. `valueSet: [true, false],` 238. `pdfVersion: 1.7` 239. `},` 240. `PrintPageRange: {` 241. `defaultValue: "",` 242. `value: "",` 243. `type: "array",` 244. `explicitSet: false,` 245. `valueSet: null,` 246. `pdfVersion: 1.7` 247. `},` 248. `NumCopies: {` 249. `defaultValue: 1,` 250. `value: 1,` 251. `type: "integer",` 252. `explicitSet: false,` 253. `valueSet: null,` 254. `pdfVersion: 1.7` 255. `}` 256. `};` 258. `var configurationKeys = Object.keys(configurationTemplate);` 260. `var rangeArray = [];` 261. `var i = 0;` 262. `var j = 0;` 263. `var k = 0;` 264. `var isValid;` 266. `var method;` 267. `var value;` 269. `function arrayContainsElement(array, element) {` 270. `var iterator;` 271. `var result = false;` 273. `for (iterator = 0; iterator < array.length; iterator += 1) {` 274. `if (array[iterator] === element) {` 275. `result = true;` 276. `}` 277. `}` 278. `return result;` 279. `}` 281. `if (this.internal.viewerpreferences === undefined) {` 282. `this.internal.viewerpreferences = {};` 283. `this.internal.viewerpreferences.configuration = JSON.parse(` 284. `JSON.stringify(configurationTemplate)` 285. `);` 286. `this.internal.viewerpreferences.isSubscribed = false;` 287. `}` 288. `configuration = this.internal.viewerpreferences.configuration;` 290. `if (options === "reset" || doReset === true) {` 291. `var len = configurationKeys.length;` 293. `for (k = 0; k < len; k += 1) {` 294. `configuration[configurationKeys[k]].value =` 295. `configuration[configurationKeys[k]].defaultValue;` 296. `configuration[configurationKeys[k]].explicitSet = false;` 297. `}` 298. `}` 300. `if (typeof options === "object") {` 301. `for (method in options) {` 302. `value = options[method];` 303. `if (` 304. `arrayContainsElement(configurationKeys, method) &&` 305. `value !== undefined` 306. `) {` 307. `if (` 308. `configuration[method].type === "boolean" &&` 309. `typeof value === "boolean"` 310. `) {` 311. `configuration[method].value = value;` 312. `} else if (` 313. `configuration[method].type === "name" &&` 314. `arrayContainsElement(configuration[method].valueSet, value)` 315. `) {` 316. `configuration[method].value = value;` 317. `} else if (` 318. `configuration[method].type === "integer" &&` 319. `Number.isInteger(value)` 320. `) {` 321. `configuration[method].value = value;` 322. `} else if (configuration[method].type === "array") {` 323. `for (i = 0; i < value.length; i += 1) {` 324. `isValid = true;` 325. `if (value[i].length === 1 && typeof value[i][0] === "number") {` 326. `rangeArray.push(String(value[i] - 1));` 327. `} else if (value[i].length > 1) {` 328. `for (j = 0; j < value[i].length; j += 1) {` 329. `if (typeof value[i][j] !== "number") {` 330. `isValid = false;` 331. `}` 332. `}` 333. `if (isValid === true) {` 334. `rangeArray.push([value[i][0] - 1, value[i][1] - 1].join(" "));` 335. `}` 336. `}` 337. `}` 338. `configuration[method].value = "[" + rangeArray.join(" ") + "]";` 339. `} else {` 340. `configuration[method].value = configuration[method].defaultValue;` 341. `}` 343. `configuration[method].explicitSet = true;` 344. `}` 345. `}` 346. `}` 348. `if (this.internal.viewerpreferences.isSubscribed === false) {` 349. `this.internal.events.subscribe("putCatalog", function() {` 350. `var pdfDict = [];` 351. `var vPref;` 352. `for (vPref in configuration) {` 353. `if (configuration[vPref].explicitSet === true) {` 354. `if (configuration[vPref].type === "name") {` 355. `pdfDict.push("/" + vPref + " /" + configuration[vPref].value);` 356. `} else {` 357. `pdfDict.push("/" + vPref + " " + configuration[vPref].value);` 358. `}` 359. `}` 360. `}` 361. `if (pdfDict.length !== 0) {` 362. `this.internal.write(` 363. `"/ViewerPreferences\n<<\n" + pdfDict.join("\n") + "\n>>"` 364. `);` 365. `}` 366. `});` 367. `this.internal.viewerpreferences.isSubscribed = true;` 368. `}` 370. `this.internal.viewerpreferences.configuration = configuration;` 371. `return this;` 372. `};` 373. `})(jsPDF.API);` --- # modules/context2d.js - Documentation modules/context2d.js ==================== 1. `/* eslint-disable no-fallthrough */` 2. `/* eslint-disable no-console */` 3. `/**` 4. `* @license` 5. `* jsPDF Context2D PlugIn Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv` 6. `*` 7. `* Licensed under the MIT License. http://opensource.org/licenses/mit-license` 8. `*/` 10. `import { jsPDF } from "../jspdf.js";` 11. `import { RGBColor } from "../libs/rgbcolor.js";` 12. `import { console } from "../libs/console.js";` 13. `import {` 14. `buildFontFaceMap,` 15. `parseFontFamily,` 16. `resolveFontFace` 17. `} from "../libs/fontFace.js";` 19. `/**` 20. `* This plugin mimics the HTML5 CanvasRenderingContext2D.` 21. `*` 22. `* The goal is to provide a way for current canvas implementations to print directly to a PDF.` 23. `*` 24. `* @name context2d` 25. `* @module` 26. `*/` 27. `(function(jsPDFAPI) {` 28. `"use strict";` 29. `var ContextLayer = function(ctx) {` 30. `ctx = ctx || {};` 31. `this.isStrokeTransparent = ctx.isStrokeTransparent || false;` 32. `this.strokeOpacity = ctx.strokeOpacity || 1;` 33. `this.strokeStyle = ctx.strokeStyle || "#000000";` 34. `this.fillStyle = ctx.fillStyle || "#000000";` 35. `this.isFillTransparent = ctx.isFillTransparent || false;` 36. `this.fillOpacity = ctx.fillOpacity || 1;` 37. `this.font = ctx.font || "10px sans-serif";` 38. `this.textBaseline = ctx.textBaseline || "alphabetic";` 39. `this.textAlign = ctx.textAlign || "left";` 40. `this.lineWidth = ctx.lineWidth || 1;` 41. `this.lineJoin = ctx.lineJoin || "miter";` 42. `this.lineCap = ctx.lineCap || "butt";` 43. `this.path = ctx.path || [];` 44. `this.transform =` 45. `typeof ctx.transform !== "undefined"` 46. `? ctx.transform.clone()` 47. `: new Matrix();` 48. `this.globalCompositeOperation = ctx.globalCompositeOperation || "normal";` 49. `this.globalAlpha = ctx.globalAlpha || 1.0;` 50. `this.clip_path = ctx.clip_path || [];` 51. `this.currentPoint = ctx.currentPoint || new Point();` 52. `this.miterLimit = ctx.miterLimit || 10.0;` 53. `this.lastPoint = ctx.lastPoint || new Point();` 54. `this.lineDashOffset = ctx.lineDashOffset || 0.0;` 55. `this.lineDash = ctx.lineDash || [];` 56. `this.margin = ctx.margin || [0, 0, 0, 0];` 57. `this.prevPageLastElemOffset = ctx.prevPageLastElemOffset || 0;` 59. `this.ignoreClearRect =` 60. `typeof ctx.ignoreClearRect === "boolean" ? ctx.ignoreClearRect : true;` 61. `return this;` 62. `};` 64. `//stub` 65. `var f2,` 66. `getHorizontalCoordinateString,` 67. `getVerticalCoordinateString,` 68. `getHorizontalCoordinate,` 69. `getVerticalCoordinate,` 70. `Point,` 71. `Rectangle,` 72. `Matrix,` 73. `_ctx;` 74. `jsPDFAPI.events.push([`\ 75. `"initialized",`\ 76. `function() {`\ 77. `this.context2d = new Context2D(this);`\ \ 79. `f2 = this.internal.f2;`\ 80. `getHorizontalCoordinateString = this.internal.getCoordinateString;`\ 81. `getVerticalCoordinateString = this.internal.getVerticalCoordinateString;`\ 82. `getHorizontalCoordinate = this.internal.getHorizontalCoordinate;`\ 83. `getVerticalCoordinate = this.internal.getVerticalCoordinate;`\ 84. `Point = this.internal.Point;`\ 85. `Rectangle = this.internal.Rectangle;`\ 86. `Matrix = this.internal.Matrix;`\ 87. `_ctx = new ContextLayer();`\ 88. `}`\ 89. `]);` 91. `var Context2D = function(pdf) {` 92. `Object.defineProperty(this, "canvas", {` 93. `get: function() {` 94. `return { parentNode: false, style: false };` 95. `}` 96. `});` 98. `var _pdf = pdf;` 99. `Object.defineProperty(this, "pdf", {` 100. `get: function() {` 101. `return _pdf;` 102. `}` 103. `});` 105. `var _pageWrapXEnabled = false;` 106. `/**` 107. `* @name pageWrapXEnabled` 108. `* @type {boolean}` 109. `* @default false` 110. `*/` 111. `Object.defineProperty(this, "pageWrapXEnabled", {` 112. `get: function() {` 113. `return _pageWrapXEnabled;` 114. `},` 115. `set: function(value) {` 116. `_pageWrapXEnabled = Boolean(value);` 117. `}` 118. `});` 120. `var _pageWrapYEnabled = false;` 121. `/**` 122. `* @name pageWrapYEnabled` 123. `* @type {boolean}` 124. `* @default true` 125. `*/` 126. `Object.defineProperty(this, "pageWrapYEnabled", {` 127. `get: function() {` 128. `return _pageWrapYEnabled;` 129. `},` 130. `set: function(value) {` 131. `_pageWrapYEnabled = Boolean(value);` 132. `}` 133. `});` 135. `var _posX = 0;` 136. `/**` 137. `* @name posX` 138. `* @type {number}` 139. `* @default 0` 140. `*/` 141. `Object.defineProperty(this, "posX", {` 142. `get: function() {` 143. `return _posX;` 144. `},` 145. `set: function(value) {` 146. `if (!isNaN(value)) {` 147. `_posX = value;` 148. `}` 149. `}` 150. `});` 152. `var _posY = 0;` 153. `/**` 154. `* @name posY` 155. `* @type {number}` 156. `* @default 0` 157. `*/` 158. `Object.defineProperty(this, "posY", {` 159. `get: function() {` 160. `return _posY;` 161. `},` 162. `set: function(value) {` 163. `if (!isNaN(value)) {` 164. `_posY = value;` 165. `}` 166. `}` 167. `});` 169. `/**` 170. `* Gets or sets the page margin when using auto paging. Has no effect when {@link autoPaging} is off.` 171. `* @name margin` 172. `* @type {number|number[]}` 173. `* @default [0, 0, 0, 0]` 174. `*/` 175. `Object.defineProperty(this, "margin", {` 176. `get: function() {` 177. `return _ctx.margin;` 178. `},` 179. `set: function(value) {` 180. `var margin;` 181. `if (typeof value === "number") {` 182. `margin = [value, value, value, value];` 183. `} else {` 184. `margin = new Array(4);` 185. `margin[0] = value[0];` 186. `margin[1] = value.length >= 2 ? value[1] : margin[0];` 187. `margin[2] = value.length >= 3 ? value[2] : margin[0];` 188. `margin[3] = value.length >= 4 ? value[3] : margin[1];` 189. `}` 190. `_ctx.margin = margin;` 191. `}` 192. `});` 194. `var _autoPaging = false;` 195. `/**` 196. `* Gets or sets the auto paging mode. When auto paging is enabled, the context2d will automatically draw on the` 197. `* next page if a shape or text chunk doesn't fit entirely on the current page. The context2d will create new` 198. `* pages if required.` 199. `*` 200. `* Context2d supports different modes:` 201. `*
      ` 202. `*
    • ` 203. `* false: Auto paging is disabled.` 204. `*
    • ` 205. `*
    • ` 206. `* true or 'slice': Will cut shapes or text chunks across page breaks. Will possibly` 207. `* slice text in half, making it difficult to read.` 208. `*
    • ` 209. `*
    • ` 210. `* 'text': Trys not to cut text in half across page breaks. Works best for documents consisting` 211. `* mostly of a single column of text.` 212. `*
    • ` 213. `*
    ` 214. `* @name Context2D#autoPaging` 215. `* @type {boolean|"slice"|"text"}` 216. `* @default false` 217. `*/` 218. `Object.defineProperty(this, "autoPaging", {` 219. `get: function() {` 220. `return _autoPaging;` 221. `},` 222. `set: function(value) {` 223. `_autoPaging = value;` 224. `}` 225. `});` 227. `var lastBreak = 0;` 228. `/**` 229. `* @name lastBreak` 230. `* @type {number}` 231. `* @default 0` 232. `*/` 233. `Object.defineProperty(this, "lastBreak", {` 234. `get: function() {` 235. `return lastBreak;` 236. `},` 237. `set: function(value) {` 238. `lastBreak = value;` 239. `}` 240. `});` 242. `var pageBreaks = [];` 243. `/**` 244. `* Y Position of page breaks.` 245. `* @name pageBreaks` 246. `* @type {number}` 247. `* @default 0` 248. `*/` 249. `Object.defineProperty(this, "pageBreaks", {` 250. `get: function() {` 251. `return pageBreaks;` 252. `},` 253. `set: function(value) {` 254. `pageBreaks = value;` 255. `}` 256. `});` 258. `/**` 259. `* @name ctx` 260. `* @type {object}` 261. `* @default {}` 262. `*/` 263. `Object.defineProperty(this, "ctx", {` 264. `get: function() {` 265. `return _ctx;` 266. `},` 267. `set: function(value) {` 268. `if (value instanceof ContextLayer) {` 269. `_ctx = value;` 270. `}` 271. `}` 272. `});` 274. `/**` 275. `* @name path` 276. `* @type {array}` 277. `* @default []` 278. `*/` 279. `Object.defineProperty(this, "path", {` 280. `get: function() {` 281. `return _ctx.path;` 282. `},` 283. `set: function(value) {` 284. `_ctx.path = value;` 285. `}` 286. `});` 288. `/**` 289. `* @name ctxStack` 290. `* @type {array}` 291. `* @default []` 292. `*/` 293. `var _ctxStack = [];` 294. `Object.defineProperty(this, "ctxStack", {` 295. `get: function() {` 296. `return _ctxStack;` 297. `},` 298. `set: function(value) {` 299. `_ctxStack = value;` 300. `}` 301. `});` 303. `/**` 304. `* Sets or returns the color, gradient, or pattern used to fill the drawing` 305. `*` 306. `* @name fillStyle` 307. `* @default #000000` 308. `* @property {(color|gradient|pattern)} value The color of the drawing. Default value is #000000
    ` 309. `* A gradient object (linear or radial) used to fill the drawing (not supported by context2d)
    ` 310. `* A pattern object to use to fill the drawing (not supported by context2d)` 311. `*/` 312. `Object.defineProperty(this, "fillStyle", {` 313. `get: function() {` 314. `return this.ctx.fillStyle;` 315. `},` 316. `set: function(value) {` 317. `var rgba;` 318. `rgba = getRGBA(value);` 320. `this.ctx.fillStyle = rgba.style;` 321. `this.ctx.isFillTransparent = rgba.a === 0;` 322. `this.ctx.fillOpacity = rgba.a;` 324. `this.pdf.setFillColor(rgba.r, rgba.g, rgba.b, { a: rgba.a });` 325. `this.pdf.setTextColor(rgba.r, rgba.g, rgba.b, { a: rgba.a });` 326. `}` 327. `});` 329. `/**` 330. `* Sets or returns the color, gradient, or pattern used for strokes` 331. `*` 332. `* @name strokeStyle` 333. `* @default #000000` 334. `* @property {color} color A CSS color value that indicates the stroke color of the drawing. Default value is #000000 (not supported by context2d)` 335. `* @property {gradient} gradient A gradient object (linear or radial) used to create a gradient stroke (not supported by context2d)` 336. `* @property {pattern} pattern A pattern object used to create a pattern stroke (not supported by context2d)` 337. `*/` 338. `Object.defineProperty(this, "strokeStyle", {` 339. `get: function() {` 340. `return this.ctx.strokeStyle;` 341. `},` 342. `set: function(value) {` 343. `var rgba = getRGBA(value);` 345. `this.ctx.strokeStyle = rgba.style;` 346. `this.ctx.isStrokeTransparent = rgba.a === 0;` 347. `this.ctx.strokeOpacity = rgba.a;` 349. `if (rgba.a === 0) {` 350. `this.pdf.setDrawColor(255, 255, 255);` 351. `} else if (rgba.a === 1) {` 352. `this.pdf.setDrawColor(rgba.r, rgba.g, rgba.b);` 353. `} else {` 354. `this.pdf.setDrawColor(rgba.r, rgba.g, rgba.b);` 355. `}` 356. `}` 357. `});` 359. `/**` 360. `* Sets or returns the style of the end caps for a line` 361. `*` 362. `* @name lineCap` 363. `* @default butt` 364. `* @property {(butt|round|square)} lineCap butt A flat edge is added to each end of the line
    ` 365. `* round A rounded end cap is added to each end of the line
    ` 366. `* square A square end cap is added to each end of the line
    ` 367. `*/` 368. `Object.defineProperty(this, "lineCap", {` 369. `get: function() {` 370. `return this.ctx.lineCap;` 371. `},` 372. `set: function(value) {` 373. `if (["butt", "round", "square"].indexOf(value) !== -1) {` 374. `this.ctx.lineCap = value;` 375. `this.pdf.setLineCap(value);` 376. `}` 377. `}` 378. `});` 380. `/**` 381. `* Sets or returns the current line width` 382. `*` 383. `* @name lineWidth` 384. `* @default 1` 385. `* @property {number} lineWidth The current line width, in pixels` 386. `*/` 387. `Object.defineProperty(this, "lineWidth", {` 388. `get: function() {` 389. `return this.ctx.lineWidth;` 390. `},` 391. `set: function(value) {` 392. `if (!isNaN(value)) {` 393. `this.ctx.lineWidth = value;` 394. `this.pdf.setLineWidth(value);` 395. `}` 396. `}` 397. `});` 399. `/**` 400. `* Sets or returns the type of corner created, when two lines meet` 401. `*/` 402. `Object.defineProperty(this, "lineJoin", {` 403. `get: function() {` 404. `return this.ctx.lineJoin;` 405. `},` 406. `set: function(value) {` 407. `if (["bevel", "round", "miter"].indexOf(value) !== -1) {` 408. `this.ctx.lineJoin = value;` 409. `this.pdf.setLineJoin(value);` 410. `}` 411. `}` 412. `});` 414. `/**` 415. `* 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.` 416. `*` 417. `* @name miterLimit` 418. `* @default 10` 419. `*/` 420. `Object.defineProperty(this, "miterLimit", {` 421. `get: function() {` 422. `return this.ctx.miterLimit;` 423. `},` 424. `set: function(value) {` 425. `if (!isNaN(value)) {` 426. `this.ctx.miterLimit = value;` 427. `this.pdf.setMiterLimit(value);` 428. `}` 429. `}` 430. `});` 432. `Object.defineProperty(this, "textBaseline", {` 433. `get: function() {` 434. `return this.ctx.textBaseline;` 435. `},` 436. `set: function(value) {` 437. `this.ctx.textBaseline = value;` 438. `}` 439. `});` 441. `Object.defineProperty(this, "textAlign", {` 442. `get: function() {` 443. `return this.ctx.textAlign;` 444. `},` 445. `set: function(value) {` 446. `if (["right", "end", "center", "left", "start"].indexOf(value) !== -1) {` 447. `this.ctx.textAlign = value;` 448. `}` 449. `}` 450. `});` 452. `var _fontFaceMap = null;` 454. `function getFontFaceMap(pdf, fontFaces) {` 455. `if (_fontFaceMap === null) {` 456. `var fontMap = pdf.getFontList();` 458. `var convertedFontFaces = convertToFontFaces(fontMap);` 460. `_fontFaceMap = buildFontFaceMap(convertedFontFaces.concat(fontFaces));` 461. `}` 463. `return _fontFaceMap;` 464. `}` 466. `function convertToFontFaces(fontMap) {` 467. `var fontFaces = [];` 469. `Object.keys(fontMap).forEach(function(family) {` 470. `var styles = fontMap[family];` 472. `styles.forEach(function(style) {` 473. `var fontFace = null;` 475. `switch (style) {` 476. `case "bold":` 477. `fontFace = {` 478. `family: family,` 479. `weight: "bold"` 480. `};` 481. `break;` 483. `case "italic":` 484. `fontFace = {` 485. `family: family,` 486. `style: "italic"` 487. `};` 488. `break;` 490. `case "bolditalic":` 491. `fontFace = {` 492. `family: family,` 493. `weight: "bold",` 494. `style: "italic"` 495. `};` 496. `break;` 498. `case "":` 499. `case "normal":` 500. `fontFace = {` 501. `family: family` 502. `};` 503. `break;` 504. `}` 506. `// If font-face is still null here, it is a font with some styling we don't recognize and` 507. `// cannot map or it is a font added via the fontFaces option of .html().` 508. `if (fontFace !== null) {` 509. `fontFace.ref = {` 510. `name: family,` 511. `style: style` 512. `};` 514. `fontFaces.push(fontFace);` 515. `}` 516. `});` 517. `});` 519. `return fontFaces;` 520. `}` 522. `var _fontFaces = null;` 523. `/**` 524. `* A map of available font-faces, as passed in the options of` 525. `* .html(). If set a limited implementation of the font style matching` 526. `* algorithm defined by https://www.w3.org/TR/css-fonts-3/#font-matching-algorithm` 527. `* will be used. If not set it will fallback to previous behavior.` 528. `*/` 530. `Object.defineProperty(this, "fontFaces", {` 531. `get: function() {` 532. `return _fontFaces;` 533. `},` 534. `set: function(value) {` 535. `_fontFaceMap = null;` 536. `_fontFaces = value;` 537. `}` 538. `});` 540. `Object.defineProperty(this, "font", {` 541. `get: function() {` 542. `return this.ctx.font;` 543. `},` 544. `set: function(value) {` 545. `this.ctx.font = value;` 546. `var rx, matches;` 548. `//source: https://stackoverflow.com/a/10136041` 549. `// eslint-disable-next-line no-useless-escape` 550. `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;` 551. `matches = rx.exec(value);` 552. `if (matches !== null) {` 553. `var fontStyle = matches[1];` 554. `var fontVariant = matches[2];` 555. `var fontWeight = matches[3];` 556. `var fontSize = matches[4];` 557. `var lineHeight = matches[5];` 558. `var fontFamily = matches[6];` 559. `} else {` 560. `return;` 561. `}` 562. `var rxFontSize = /^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i;` 563. `var fontSizeUnit = rxFontSize.exec(fontSize)[2];` 565. `if ("px" === fontSizeUnit) {` 566. `fontSize = Math.floor(` 567. `parseFloat(fontSize) * this.pdf.internal.scaleFactor` 568. `);` 569. `} else if ("em" === fontSizeUnit) {` 570. `fontSize = Math.floor(parseFloat(fontSize) * this.pdf.getFontSize());` 571. `} else {` 572. `fontSize = Math.floor(` 573. `parseFloat(fontSize) * this.pdf.internal.scaleFactor` 574. `);` 575. `}` 577. `this.pdf.setFontSize(fontSize);` 578. `var parts = parseFontFamily(fontFamily);` 580. `if (this.fontFaces) {` 581. `var fontFaceMap = getFontFaceMap(this.pdf, this.fontFaces);` 583. `var rules = parts.map(function(ff) {` 584. `return {` 585. `family: ff,` 586. `stretch: "normal", // TODO: Extract font-stretch from font rule (perhaps write proper parser for it?)` 587. `weight: fontWeight,` 588. `style: fontStyle` 589. `};` 590. `});` 592. `var font = resolveFontFace(fontFaceMap, rules);` 593. `this.pdf.setFont(font.ref.name, font.ref.style);` 594. `return;` 595. `}` 597. `var style = "";` 598. `if (` 599. `fontWeight === "bold" ||` 600. `parseInt(fontWeight, 10) >= 700 ||` 601. `fontStyle === "bold"` 602. `) {` 603. `style = "bold";` 604. `}` 606. `if (fontStyle === "italic") {` 607. `style += "italic";` 608. `}` 610. `if (style.length === 0) {` 611. `style = "normal";` 612. `}` 613. `var jsPdfFontName = "";` 615. `var fallbackFonts = {` 616. `arial: "Helvetica",` 617. `Arial: "Helvetica",` 618. `verdana: "Helvetica",` 619. `Verdana: "Helvetica",` 620. `helvetica: "Helvetica",` 621. `Helvetica: "Helvetica",` 622. `"sans-serif": "Helvetica",` 623. `fixed: "Courier",` 624. `monospace: "Courier",` 625. `terminal: "Courier",` 626. `cursive: "Times",` 627. `fantasy: "Times",` 628. `serif: "Times"` 629. `};` 631. `for (var i = 0; i < parts.length; i++) {` 632. `if (` 633. `this.pdf.internal.getFont(parts[i], style, {` 634. `noFallback: true,` 635. `disableWarning: true` 636. `}) !== undefined` 637. `) {` 638. `jsPdfFontName = parts[i];` 639. `break;` 640. `} else if (` 641. `style === "bolditalic" &&` 642. `this.pdf.internal.getFont(parts[i], "bold", {` 643. `noFallback: true,` 644. `disableWarning: true` 645. `}) !== undefined` 646. `) {` 647. `jsPdfFontName = parts[i];` 648. `style = "bold";` 649. `} else if (` 650. `this.pdf.internal.getFont(parts[i], "normal", {` 651. `noFallback: true,` 652. `disableWarning: true` 653. `}) !== undefined` 654. `) {` 655. `jsPdfFontName = parts[i];` 656. `style = "normal";` 657. `break;` 658. `}` 659. `}` 660. `if (jsPdfFontName === "") {` 661. `for (var j = 0; j < parts.length; j++) {` 662. `if (fallbackFonts[parts[j]]) {` 663. `jsPdfFontName = fallbackFonts[parts[j]];` 664. `break;` 665. `}` 666. `}` 667. `}` 668. `jsPdfFontName = jsPdfFontName === "" ? "Times" : jsPdfFontName;` 669. `this.pdf.setFont(jsPdfFontName, style);` 670. `}` 671. `});` 673. `Object.defineProperty(this, "globalCompositeOperation", {` 674. `get: function() {` 675. `return this.ctx.globalCompositeOperation;` 676. `},` 677. `set: function(value) {` 678. `this.ctx.globalCompositeOperation = value;` 679. `}` 680. `});` 682. `Object.defineProperty(this, "globalAlpha", {` 683. `get: function() {` 684. `return this.ctx.globalAlpha;` 685. `},` 686. `set: function(value) {` 687. `this.ctx.globalAlpha = value;` 688. `}` 689. `});` 691. `/**` 692. `* A float specifying the amount of the line dash offset. The default value is 0.0.` 693. `*` 694. `* @name lineDashOffset` 695. `* @default 0.0` 696. `*/` 697. `Object.defineProperty(this, "lineDashOffset", {` 698. `get: function() {` 699. `return this.ctx.lineDashOffset;` 700. `},` 701. `set: function(value) {` 702. `this.ctx.lineDashOffset = value;` 703. `setLineDash.call(this);` 704. `}` 705. `});` 707. `// Not HTML API` 708. `Object.defineProperty(this, "lineDash", {` 709. `get: function() {` 710. `return this.ctx.lineDash;` 711. `},` 712. `set: function(value) {` 713. `this.ctx.lineDash = value;` 714. `setLineDash.call(this);` 715. `}` 716. `});` 718. `// Not HTML API` 719. `Object.defineProperty(this, "ignoreClearRect", {` 720. `get: function() {` 721. `return this.ctx.ignoreClearRect;` 722. `},` 723. `set: function(value) {` 724. `this.ctx.ignoreClearRect = Boolean(value);` 725. `}` 726. `});` 727. `};` 729. `/**` 730. `* Sets the line dash pattern used when stroking lines.` 731. `* @name setLineDash` 732. `* @function` 733. `* @description It uses an array of values that specify alternating lengths of lines and gaps which describe the pattern.` 734. `*/` 735. `Context2D.prototype.setLineDash = function(dashArray) {` 736. `this.lineDash = dashArray;` 737. `};` 739. `/**` 740. `* gets the current line dash pattern.` 741. `* @name getLineDash` 742. `* @function` 743. `* @returns {Array} An Array of numbers that specify distances to alternately draw a line and a gap (in coordinate space units). If the number, when setting the elements, is odd, the elements of the array get copied and concatenated. For example, setting the line dash to [5, 15, 25] will result in getting back [5, 15, 25, 5, 15, 25].` 744. `*/` 745. `Context2D.prototype.getLineDash = function() {` 746. `if (this.lineDash.length % 2) {` 747. `// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getLineDash#return_value` 748. `return this.lineDash.concat(this.lineDash);` 749. `} else {` 750. `// The copied value is returned to prevent contamination from outside.` 751. `return this.lineDash.slice();` 752. `}` 753. `};` 755. `Context2D.prototype.fill = function() {` 756. `pathPreProcess.call(this, "fill", false);` 757. `};` 759. `/**` 760. `* Actually draws the path you have defined` 761. `*` 762. `* @name stroke` 763. `* @function` 764. `* @description The stroke() method actually draws the path you have defined with all those moveTo() and lineTo() methods. The default color is black.` 765. `*/` 766. `Context2D.prototype.stroke = function() {` 767. `pathPreProcess.call(this, "stroke", false);` 768. `};` 770. `/**` 771. `* Begins a path, or resets the current` 772. `*` 773. `* @name beginPath` 774. `* @function` 775. `* @description The beginPath() method begins a path, or resets the current path.` 776. `*/` 777. `Context2D.prototype.beginPath = function() {` 778. `this.path = [`\ 779. `{`\ 780. `type: "begin"`\ 781. `}`\ 782. `];` 783. `};` 785. `/**` 786. `* Moves the path to the specified point in the canvas, without creating a line` 787. `*` 788. `* @name moveTo` 789. `* @function` 790. `* @param x {Number} The x-coordinate of where to move the path to` 791. `* @param y {Number} The y-coordinate of where to move the path to` 792. `*/` 793. `Context2D.prototype.moveTo = function(x, y) {` 794. `if (isNaN(x) || isNaN(y)) {` 795. `console.error("jsPDF.context2d.moveTo: Invalid arguments", arguments);` 796. `throw new Error("Invalid arguments passed to jsPDF.context2d.moveTo");` 797. `}` 799. `var pt = this.ctx.transform.applyToPoint(new Point(x, y));` 801. `this.path.push({` 802. `type: "mt",` 803. `x: pt.x,` 804. `y: pt.y` 805. `});` 806. `this.ctx.lastPoint = new Point(x, y);` 807. `};` 809. `/**` 810. `* Creates a path from the current point back to the starting point` 811. `*` 812. `* @name closePath` 813. `* @function` 814. `* @description The closePath() method creates a path from the current point back to the starting point.` 815. `*/` 816. `Context2D.prototype.closePath = function() {` 817. `var pathBegin = new Point(0, 0);` 818. `var i = 0;` 819. `for (i = this.path.length - 1; i !== -1; i--) {` 820. `if (this.path[i].type === "begin") {` 821. `if (` 822. `typeof this.path[i + 1] === "object" &&` 823. `typeof this.path[i + 1].x === "number"` 824. `) {` 825. `pathBegin = new Point(this.path[i + 1].x, this.path[i + 1].y);` 826. `break;` 827. `}` 828. `}` 829. `}` 830. `this.path.push({` 831. `type: "close"` 832. `});` 833. `this.ctx.lastPoint = new Point(pathBegin.x, pathBegin.y);` 834. `};` 836. `/**` 837. `* Adds a new point and creates a line to that point from the last specified point in the canvas` 838. `*` 839. `* @name lineTo` 840. `* @function` 841. `* @param x The x-coordinate of where to create the line to` 842. `* @param y The y-coordinate of where to create the line to` 843. `* @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).` 844. `*/` 845. `Context2D.prototype.lineTo = function(x, y) {` 846. `if (isNaN(x) || isNaN(y)) {` 847. `console.error("jsPDF.context2d.lineTo: Invalid arguments", arguments);` 848. `throw new Error("Invalid arguments passed to jsPDF.context2d.lineTo");` 849. `}` 851. `var pt = this.ctx.transform.applyToPoint(new Point(x, y));` 853. `this.path.push({` 854. `type: "lt",` 855. `x: pt.x,` 856. `y: pt.y` 857. `});` 858. `this.ctx.lastPoint = new Point(pt.x, pt.y);` 859. `};` 861. `/**` 862. `* Clips a region of any shape and size from the original canvas` 863. `*` 864. `* @name clip` 865. `* @function` 866. `* @description The clip() method clips a region of any shape and size from the original canvas.` 867. `*/` 868. `Context2D.prototype.clip = function() {` 869. `this.ctx.clip_path = JSON.parse(JSON.stringify(this.path));` 870. `pathPreProcess.call(this, null, true);` 871. `};` 873. `/**` 874. `* Creates a cubic Bézier curve` 875. `*` 876. `* @name quadraticCurveTo` 877. `* @function` 878. `* @param cpx {Number} The x-coordinate of the Bézier control point` 879. `* @param cpy {Number} The y-coordinate of the Bézier control point` 880. `* @param x {Number} The x-coordinate of the ending point` 881. `* @param y {Number} The y-coordinate of the ending point` 882. `* @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.` 883. `*/` 884. `Context2D.prototype.quadraticCurveTo = function(cpx, cpy, x, y) {` 885. `if (isNaN(x) || isNaN(y) || isNaN(cpx) || isNaN(cpy)) {` 886. `console.error(` 887. `"jsPDF.context2d.quadraticCurveTo: Invalid arguments",` 888. `arguments` 889. `);` 890. `throw new Error(` 891. `"Invalid arguments passed to jsPDF.context2d.quadraticCurveTo"` 892. `);` 893. `}` 895. `var pt0 = this.ctx.transform.applyToPoint(new Point(x, y));` 896. `var pt1 = this.ctx.transform.applyToPoint(new Point(cpx, cpy));` 898. `this.path.push({` 899. `type: "qct",` 900. `x1: pt1.x,` 901. `y1: pt1.y,` 902. `x: pt0.x,` 903. `y: pt0.y` 904. `});` 905. `this.ctx.lastPoint = new Point(pt0.x, pt0.y);` 906. `};` 908. `/**` 909. `* Creates a cubic Bézier curve` 910. `*` 911. `* @name bezierCurveTo` 912. `* @function` 913. `* @param cp1x {Number} The x-coordinate of the first Bézier control point` 914. `* @param cp1y {Number} The y-coordinate of the first Bézier control point` 915. `* @param cp2x {Number} The x-coordinate of the second Bézier control point` 916. `* @param cp2y {Number} The y-coordinate of the second Bézier control point` 917. `* @param x {Number} The x-coordinate of the ending point` 918. `* @param y {Number} The y-coordinate of the ending point` 919. `* @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.` 920. `*/` 921. `Context2D.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {` 922. `if (` 923. `isNaN(x) ||` 924. `isNaN(y) ||` 925. `isNaN(cp1x) ||` 926. `isNaN(cp1y) ||` 927. `isNaN(cp2x) ||` 928. `isNaN(cp2y)` 929. `) {` 930. `console.error(` 931. `"jsPDF.context2d.bezierCurveTo: Invalid arguments",` 932. `arguments` 933. `);` 934. `throw new Error(` 935. `"Invalid arguments passed to jsPDF.context2d.bezierCurveTo"` 936. `);` 937. `}` 938. `var pt0 = this.ctx.transform.applyToPoint(new Point(x, y));` 939. `var pt1 = this.ctx.transform.applyToPoint(new Point(cp1x, cp1y));` 940. `var pt2 = this.ctx.transform.applyToPoint(new Point(cp2x, cp2y));` 942. `this.path.push({` 943. `type: "bct",` 944. `x1: pt1.x,` 945. `y1: pt1.y,` 946. `x2: pt2.x,` 947. `y2: pt2.y,` 948. `x: pt0.x,` 949. `y: pt0.y` 950. `});` 951. `this.ctx.lastPoint = new Point(pt0.x, pt0.y);` 952. `};` 954. `/**` 955. `* Creates an arc/curve (used to create circles, or parts of circles)` 956. `*` 957. `* @name arc` 958. `* @function` 959. `* @param x {Number} The x-coordinate of the center of the circle` 960. `* @param y {Number} The y-coordinate of the center of the circle` 961. `* @param radius {Number} The radius of the circle` 962. `* @param startAngle {Number} The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)` 963. `* @param endAngle {Number} The ending angle, in radians` 964. `* @param counterclockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.` 965. `* @description The arc() method creates an arc/curve (used to create circles, or parts of circles).` 966. `*/` 967. `Context2D.prototype.arc = function(` 968. `x,` 969. `y,` 970. `radius,` 971. `startAngle,` 972. `endAngle,` 973. `counterclockwise` 974. `) {` 975. `if (` 976. `isNaN(x) ||` 977. `isNaN(y) ||` 978. `isNaN(radius) ||` 979. `isNaN(startAngle) ||` 980. `isNaN(endAngle)` 981. `) {` 982. `console.error("jsPDF.context2d.arc: Invalid arguments", arguments);` 983. `throw new Error("Invalid arguments passed to jsPDF.context2d.arc");` 984. `}` 985. `counterclockwise = Boolean(counterclockwise);` 987. `if (!this.ctx.transform.isIdentity) {` 988. `var xpt = this.ctx.transform.applyToPoint(new Point(x, y));` 989. `x = xpt.x;` 990. `y = xpt.y;` 992. `var x_radPt = this.ctx.transform.applyToPoint(new Point(0, radius));` 993. `var x_radPt0 = this.ctx.transform.applyToPoint(new Point(0, 0));` 994. `radius = Math.sqrt(` 995. `Math.pow(x_radPt.x - x_radPt0.x, 2) +` 996. `Math.pow(x_radPt.y - x_radPt0.y, 2)` 997. `);` 998. `}` 999. `if (Math.abs(endAngle - startAngle) >= 2 * Math.PI) {` 1000. `startAngle = 0;` 1001. `endAngle = 2 * Math.PI;` 1002. `}` 1004. `this.path.push({` 1005. `type: "arc",` 1006. `x: x,` 1007. `y: y,` 1008. `radius: radius,` 1009. `startAngle: startAngle,` 1010. `endAngle: endAngle,` 1011. `counterclockwise: counterclockwise` 1012. `});` 1013. `// this.ctx.lastPoint(new Point(pt.x,pt.y));` 1014. `};` 1016. `/**` 1017. `* Creates an arc/curve between two tangents` 1018. `*` 1019. `* @name arcTo` 1020. `* @function` 1021. `* @param x1 {Number} The x-coordinate of the first tangent` 1022. `* @param y1 {Number} The y-coordinate of the first tangent` 1023. `* @param x2 {Number} The x-coordinate of the second tangent` 1024. `* @param y2 {Number} The y-coordinate of the second tangent` 1025. `* @param radius The radius of the arc` 1026. `* @description The arcTo() method creates an arc/curve between two tangents on the canvas.` 1027. `*/` 1028. `// eslint-disable-next-line no-unused-vars` 1029. `Context2D.prototype.arcTo = function(x1, y1, x2, y2, radius) {` 1030. `throw new Error("arcTo not implemented.");` 1031. `};` 1033. `/**` 1034. `* Creates a rectangle` 1035. `*` 1036. `* @name rect` 1037. `* @function` 1038. `* @param x {Number} The x-coordinate of the upper-left corner of the rectangle` 1039. `* @param y {Number} The y-coordinate of the upper-left corner of the rectangle` 1040. `* @param w {Number} The width of the rectangle, in pixels` 1041. `* @param h {Number} The height of the rectangle, in pixels` 1042. `* @description The rect() method creates a rectangle.` 1043. `*/` 1044. `Context2D.prototype.rect = function(x, y, w, h) {` 1045. `if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {` 1046. `console.error("jsPDF.context2d.rect: Invalid arguments", arguments);` 1047. `throw new Error("Invalid arguments passed to jsPDF.context2d.rect");` 1048. `}` 1049. `this.moveTo(x, y);` 1050. `this.lineTo(x + w, y);` 1051. `this.lineTo(x + w, y + h);` 1052. `this.lineTo(x, y + h);` 1053. `this.lineTo(x, y);` 1054. `this.lineTo(x + w, y);` 1055. `this.lineTo(x, y);` 1056. `};` 1058. `/**` 1059. `* Draws a "filled" rectangle` 1060. `*` 1061. `* @name fillRect` 1062. `* @function` 1063. `* @param x {Number} The x-coordinate of the upper-left corner of the rectangle` 1064. `* @param y {Number} The y-coordinate of the upper-left corner of the rectangle` 1065. `* @param w {Number} The width of the rectangle, in pixels` 1066. `* @param h {Number} The height of the rectangle, in pixels` 1067. `* @description The fillRect() method draws a "filled" rectangle. The default color of the fill is black.` 1068. `*/` 1069. `Context2D.prototype.fillRect = function(x, y, w, h) {` 1070. `if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {` 1071. `console.error("jsPDF.context2d.fillRect: Invalid arguments", arguments);` 1072. `throw new Error("Invalid arguments passed to jsPDF.context2d.fillRect");` 1073. `}` 1074. `if (isFillTransparent.call(this)) {` 1075. `return;` 1076. `}` 1077. `var tmp = {};` 1078. `if (this.lineCap !== "butt") {` 1079. `tmp.lineCap = this.lineCap;` 1080. `this.lineCap = "butt";` 1081. `}` 1082. `if (this.lineJoin !== "miter") {` 1083. `tmp.lineJoin = this.lineJoin;` 1084. `this.lineJoin = "miter";` 1085. `}` 1087. `this.beginPath();` 1088. `this.rect(x, y, w, h);` 1089. `this.fill();` 1091. `if (tmp.hasOwnProperty("lineCap")) {` 1092. `this.lineCap = tmp.lineCap;` 1093. `}` 1094. `if (tmp.hasOwnProperty("lineJoin")) {` 1095. `this.lineJoin = tmp.lineJoin;` 1096. `}` 1097. `};` 1099. `/**` 1100. `* Draws a rectangle (no fill)` 1101. `*` 1102. `* @name strokeRect` 1103. `* @function` 1104. `* @param x {Number} The x-coordinate of the upper-left corner of the rectangle` 1105. `* @param y {Number} The y-coordinate of the upper-left corner of the rectangle` 1106. `* @param w {Number} The width of the rectangle, in pixels` 1107. `* @param h {Number} The height of the rectangle, in pixels` 1108. `* @description The strokeRect() method draws a rectangle (no fill). The default color of the stroke is black.` 1109. `*/` 1110. `Context2D.prototype.strokeRect = function strokeRect(x, y, w, h) {` 1111. `if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {` 1112. `console.error("jsPDF.context2d.strokeRect: Invalid arguments", arguments);` 1113. `throw new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");` 1114. `}` 1115. `if (isStrokeTransparent.call(this)) {` 1116. `return;` 1117. `}` 1118. `this.beginPath();` 1119. `this.rect(x, y, w, h);` 1120. `this.stroke();` 1121. `};` 1123. `/**` 1124. `* Clears the specified pixels within a given rectangle` 1125. `*` 1126. `* @name clearRect` 1127. `* @function` 1128. `* @param x {Number} The x-coordinate of the upper-left corner of the rectangle` 1129. `* @param y {Number} The y-coordinate of the upper-left corner of the rectangle` 1130. `* @param w {Number} The width of the rectangle to clear, in pixels` 1131. `* @param h {Number} The height of the rectangle to clear, in pixels` 1132. `* @description We cannot clear PDF commands that were already written to PDF, so we use white instead.
    ` 1133. `* As a special case, read a special flag (ignoreClearRect) and do nothing if it is set.` 1134. `* This results in all calls to clearRect() to do nothing, and keep the canvas transparent.` 1135. `* This flag is stored in the save/restore context and is managed the same way as other drawing states.` 1136. `*` 1137. `*/` 1138. `Context2D.prototype.clearRect = function(x, y, w, h) {` 1139. `if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {` 1140. `console.error("jsPDF.context2d.clearRect: Invalid arguments", arguments);` 1141. `throw new Error("Invalid arguments passed to jsPDF.context2d.clearRect");` 1142. `}` 1143. `if (this.ignoreClearRect) {` 1144. `return;` 1145. `}` 1147. `this.fillStyle = "#ffffff";` 1148. `this.fillRect(x, y, w, h);` 1149. `};` 1151. `/**` 1152. `* Saves the state of the current context` 1153. `*` 1154. `* @name save` 1155. `* @function` 1156. `*/` 1157. `Context2D.prototype.save = function(doStackPush) {` 1158. `doStackPush = typeof doStackPush === "boolean" ? doStackPush : true;` 1159. `var tmpPageNumber = this.pdf.internal.getCurrentPageInfo().pageNumber;` 1160. `for (var i = 0; i < this.pdf.internal.getNumberOfPages(); i++) {` 1161. `this.pdf.setPage(i + 1);` 1162. `this.pdf.internal.out("q");` 1163. `}` 1164. `this.pdf.setPage(tmpPageNumber);` 1166. `if (doStackPush) {` 1167. `this.ctx.fontSize = this.pdf.internal.getFontSize();` 1168. `var ctx = new ContextLayer(this.ctx);` 1169. `this.ctxStack.push(this.ctx);` 1170. `this.ctx = ctx;` 1171. `}` 1172. `};` 1174. `/**` 1175. `* Returns previously saved path state and attributes` 1176. `*` 1177. `* @name restore` 1178. `* @function` 1179. `*/` 1180. `Context2D.prototype.restore = function(doStackPop) {` 1181. `doStackPop = typeof doStackPop === "boolean" ? doStackPop : true;` 1182. `var tmpPageNumber = this.pdf.internal.getCurrentPageInfo().pageNumber;` 1183. `for (var i = 0; i < this.pdf.internal.getNumberOfPages(); i++) {` 1184. `this.pdf.setPage(i + 1);` 1185. `this.pdf.internal.out("Q");` 1186. `}` 1187. `this.pdf.setPage(tmpPageNumber);` 1189. `if (doStackPop && this.ctxStack.length !== 0) {` 1190. `this.ctx = this.ctxStack.pop();` 1191. `this.fillStyle = this.ctx.fillStyle;` 1192. `this.strokeStyle = this.ctx.strokeStyle;` 1193. `this.font = this.ctx.font;` 1194. `this.lineCap = this.ctx.lineCap;` 1195. `this.lineWidth = this.ctx.lineWidth;` 1196. `this.lineJoin = this.ctx.lineJoin;` 1197. `this.lineDash = this.ctx.lineDash;` 1198. `this.lineDashOffset = this.ctx.lineDashOffset;` 1199. `}` 1200. `};` 1202. `/**` 1203. `* @name toDataURL` 1204. `* @function` 1205. `*/` 1206. `Context2D.prototype.toDataURL = function() {` 1207. `throw new Error("toDataUrl not implemented.");` 1208. `};` 1210. `//helper functions` 1212. `/**` 1213. `* Get the decimal values of r, g, b and a` 1214. `*` 1215. `* @name getRGBA` 1216. `* @function` 1217. `* @private` 1218. `* @ignore` 1219. `*/` 1220. `var getRGBA = function(style) {` 1221. `var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;` 1222. `var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/;` 1223. `var rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/;` 1225. `var r, g, b, a;` 1227. `if (style.isCanvasGradient === true) {` 1228. `style = style.getColor();` 1229. `}` 1231. `if (!style) {` 1232. `return { r: 0, g: 0, b: 0, a: 0, style: style };` 1233. `}` 1235. `if (rxTransparent.test(style)) {` 1236. `r = 0;` 1237. `g = 0;` 1238. `b = 0;` 1239. `a = 0;` 1240. `} else {` 1241. `var matches = rxRgb.exec(style);` 1242. `if (matches !== null) {` 1243. `r = parseInt(matches[1]);` 1244. `g = parseInt(matches[2]);` 1245. `b = parseInt(matches[3]);` 1246. `a = 1;` 1247. `} else {` 1248. `matches = rxRgba.exec(style);` 1249. `if (matches !== null) {` 1250. `r = parseInt(matches[1]);` 1251. `g = parseInt(matches[2]);` 1252. `b = parseInt(matches[3]);` 1253. `a = parseFloat(matches[4]);` 1254. `} else {` 1255. `a = 1;` 1257. `if (typeof style === "string" && style.charAt(0) !== "#") {` 1258. `var rgbColor = new RGBColor(style);` 1259. `if (rgbColor.ok) {` 1260. `style = rgbColor.toHex();` 1261. `} else {` 1262. `style = "#000000";` 1263. `}` 1264. `}` 1266. `if (style.length === 4) {` 1267. `r = style.substring(1, 2);` 1268. `r += r;` 1269. `g = style.substring(2, 3);` 1270. `g += g;` 1271. `b = style.substring(3, 4);` 1272. `b += b;` 1273. `} else {` 1274. `r = style.substring(1, 3);` 1275. `g = style.substring(3, 5);` 1276. `b = style.substring(5, 7);` 1277. `}` 1278. `r = parseInt(r, 16);` 1279. `g = parseInt(g, 16);` 1280. `b = parseInt(b, 16);` 1281. `}` 1282. `}` 1283. `}` 1284. `return { r: r, g: g, b: b, a: a, style: style };` 1285. `};` 1287. `/**` 1288. `* @name isFillTransparent` 1289. `* @function` 1290. `* @private` 1291. `* @ignore` 1292. `* @returns {Boolean}` 1293. `*/` 1294. `var isFillTransparent = function() {` 1295. `return this.ctx.isFillTransparent || this.globalAlpha == 0;` 1296. `};` 1298. `/**` 1299. `* @name isStrokeTransparent` 1300. `* @function` 1301. `* @private` 1302. `* @ignore` 1303. `* @returns {Boolean}` 1304. `*/` 1305. `var isStrokeTransparent = function() {` 1306. `return Boolean(this.ctx.isStrokeTransparent || this.globalAlpha == 0);` 1307. `};` 1309. `/**` 1310. `* Draws "filled" text on the canvas` 1311. `*` 1312. `* @name fillText` 1313. `* @function` 1314. `* @param text {String} Specifies the text that will be written on the canvas` 1315. `* @param x {Number} The x coordinate where to start painting the text (relative to the canvas)` 1316. `* @param y {Number} The y coordinate where to start painting the text (relative to the canvas)` 1317. `* @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels` 1318. `* @description The fillText() method draws filled text on the canvas. The default color of the text is black.` 1319. `*/` 1320. `Context2D.prototype.fillText = function(text, x, y, maxWidth) {` 1321. `if (isNaN(x) || isNaN(y) || typeof text !== "string") {` 1322. `console.error("jsPDF.context2d.fillText: Invalid arguments", arguments);` 1323. `throw new Error("Invalid arguments passed to jsPDF.context2d.fillText");` 1324. `}` 1325. `maxWidth = isNaN(maxWidth) ? undefined : maxWidth;` 1326. `if (isFillTransparent.call(this)) {` 1327. `return;` 1328. `}` 1330. `var degs = rad2deg(this.ctx.transform.rotation);` 1332. `// We only use X axis as scale hint` 1333. `var scale = this.ctx.transform.scaleX;` 1335. `putText.call(this, {` 1336. `text: text,` 1337. `x: x,` 1338. `y: y,` 1339. `scale: scale,` 1340. `angle: degs,` 1341. `align: this.textAlign,` 1342. `maxWidth: maxWidth` 1343. `});` 1344. `};` 1346. `/**` 1347. `* Draws text on the canvas (no fill)` 1348. `*` 1349. `* @name strokeText` 1350. `* @function` 1351. `* @param text {String} Specifies the text that will be written on the canvas` 1352. `* @param x {Number} The x coordinate where to start painting the text (relative to the canvas)` 1353. `* @param y {Number} The y coordinate where to start painting the text (relative to the canvas)` 1354. `* @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels` 1355. `* @description The strokeText() method draws text (with no fill) on the canvas. The default color of the text is black.` 1356. `*/` 1357. `Context2D.prototype.strokeText = function(text, x, y, maxWidth) {` 1358. `if (isNaN(x) || isNaN(y) || typeof text !== "string") {` 1359. `console.error("jsPDF.context2d.strokeText: Invalid arguments", arguments);` 1360. `throw new Error("Invalid arguments passed to jsPDF.context2d.strokeText");` 1361. `}` 1362. `if (isStrokeTransparent.call(this)) {` 1363. `return;` 1364. `}` 1366. `maxWidth = isNaN(maxWidth) ? undefined : maxWidth;` 1368. `var degs = rad2deg(this.ctx.transform.rotation);` 1369. `var scale = this.ctx.transform.scaleX;` 1371. `putText.call(this, {` 1372. `text: text,` 1373. `x: x,` 1374. `y: y,` 1375. `scale: scale,` 1376. `renderingMode: "stroke",` 1377. `angle: degs,` 1378. `align: this.textAlign,` 1379. `maxWidth: maxWidth` 1380. `});` 1381. `};` 1383. `/**` 1384. `* Returns an object that contains the width of the specified text` 1385. `*` 1386. `* @name measureText` 1387. `* @function` 1388. `* @param text {String} The text to be measured` 1389. `* @description The measureText() method returns an object that contains the width of the specified text, in pixels.` 1390. `* @returns {Number}` 1391. `*/` 1392. `Context2D.prototype.measureText = function(text) {` 1393. `if (typeof text !== "string") {` 1394. `console.error(` 1395. `"jsPDF.context2d.measureText: Invalid arguments",` 1396. `arguments` 1397. `);` 1398. `throw new Error(` 1399. `"Invalid arguments passed to jsPDF.context2d.measureText"` 1400. `);` 1401. `}` 1402. `var pdf = this.pdf;` 1403. `var k = this.pdf.internal.scaleFactor;` 1405. `var fontSize = pdf.internal.getFontSize();` 1406. `var txtWidth =` 1407. `(pdf.getStringUnitWidth(text) * fontSize) / pdf.internal.scaleFactor;` 1408. `txtWidth *= Math.round(((k * 96) / 72) * 10000) / 10000;` 1410. `var TextMetrics = function(options) {` 1411. `options = options || {};` 1412. `var _width = options.width || 0;` 1413. `Object.defineProperty(this, "width", {` 1414. `get: function() {` 1415. `return _width;` 1416. `}` 1417. `});` 1418. `return this;` 1419. `};` 1420. `return new TextMetrics({ width: txtWidth });` 1421. `};` 1423. `//Transformations` 1425. `/**` 1426. `* Scales the current drawing bigger or smaller` 1427. `*` 1428. `* @name scale` 1429. `* @function` 1430. `* @param scalewidth {Number} Scales the width of the current drawing (1=100%, 0.5=50%, 2=200%, etc.)` 1431. `* @param scaleheight {Number} Scales the height of the current drawing (1=100%, 0.5=50%, 2=200%, etc.)` 1432. `* @description The scale() method scales the current drawing, bigger or smaller.` 1433. `*/` 1434. `Context2D.prototype.scale = function(scalewidth, scaleheight) {` 1435. `if (isNaN(scalewidth) || isNaN(scaleheight)) {` 1436. `console.error("jsPDF.context2d.scale: Invalid arguments", arguments);` 1437. `throw new Error("Invalid arguments passed to jsPDF.context2d.scale");` 1438. `}` 1439. `var matrix = new Matrix(scalewidth, 0.0, 0.0, scaleheight, 0.0, 0.0);` 1440. `this.ctx.transform = this.ctx.transform.multiply(matrix);` 1441. `};` 1443. `/**` 1444. `* Rotates the current drawing` 1445. `*` 1446. `* @name rotate` 1447. `* @function` 1448. `* @param angle {Number} The rotation angle, in radians.` 1449. `* @description To calculate from degrees to radians: degrees*Math.PI/180.
    ` 1450. `* Example: to rotate 5 degrees, specify the following: 5*Math.PI/180` 1451. `*/` 1452. `Context2D.prototype.rotate = function(angle) {` 1453. `if (isNaN(angle)) {` 1454. `console.error("jsPDF.context2d.rotate: Invalid arguments", arguments);` 1455. `throw new Error("Invalid arguments passed to jsPDF.context2d.rotate");` 1456. `}` 1457. `var matrix = new Matrix(` 1458. `Math.cos(angle),` 1459. `Math.sin(angle),` 1460. `-Math.sin(angle),` 1461. `Math.cos(angle),` 1462. `0.0,` 1463. `0.0` 1464. `);` 1465. `this.ctx.transform = this.ctx.transform.multiply(matrix);` 1466. `};` 1468. `/**` 1469. `* Remaps the (0,0) position on the canvas` 1470. `*` 1471. `* @name translate` 1472. `* @function` 1473. `* @param x {Number} The value to add to horizontal (x) coordinates` 1474. `* @param y {Number} The value to add to vertical (y) coordinates` 1475. `* @description The translate() method remaps the (0,0) position on the canvas.` 1476. `*/` 1477. `Context2D.prototype.translate = function(x, y) {` 1478. `if (isNaN(x) || isNaN(y)) {` 1479. `console.error("jsPDF.context2d.translate: Invalid arguments", arguments);` 1480. `throw new Error("Invalid arguments passed to jsPDF.context2d.translate");` 1481. `}` 1482. `var matrix = new Matrix(1.0, 0.0, 0.0, 1.0, x, y);` 1483. `this.ctx.transform = this.ctx.transform.multiply(matrix);` 1484. `};` 1486. `/**` 1487. `* Replaces the current transformation matrix for the drawing` 1488. `*` 1489. `* @name transform` 1490. `* @function` 1491. `* @param a {Number} Horizontal scaling` 1492. `* @param b {Number} Horizontal skewing` 1493. `* @param c {Number} Vertical skewing` 1494. `* @param d {Number} Vertical scaling` 1495. `* @param e {Number} Horizontal moving` 1496. `* @param f {Number} Vertical moving` 1497. `* @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.` 1498. `*/` 1499. `Context2D.prototype.transform = function(a, b, c, d, e, f) {` 1500. `if (isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d) || isNaN(e) || isNaN(f)) {` 1501. `console.error("jsPDF.context2d.transform: Invalid arguments", arguments);` 1502. `throw new Error("Invalid arguments passed to jsPDF.context2d.transform");` 1503. `}` 1504. `var matrix = new Matrix(a, b, c, d, e, f);` 1505. `this.ctx.transform = this.ctx.transform.multiply(matrix);` 1506. `};` 1508. `/**` 1509. `* Resets the current transform to the identity matrix. Then runs transform()` 1510. `*` 1511. `* @name setTransform` 1512. `* @function` 1513. `* @param a {Number} Horizontal scaling` 1514. `* @param b {Number} Horizontal skewing` 1515. `* @param c {Number} Vertical skewing` 1516. `* @param d {Number} Vertical scaling` 1517. `* @param e {Number} Horizontal moving` 1518. `* @param f {Number} Vertical moving` 1519. `* @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.` 1520. `*/` 1521. `Context2D.prototype.setTransform = function(a, b, c, d, e, f) {` 1522. `a = isNaN(a) ? 1 : a;` 1523. `b = isNaN(b) ? 0 : b;` 1524. `c = isNaN(c) ? 0 : c;` 1525. `d = isNaN(d) ? 1 : d;` 1526. `e = isNaN(e) ? 0 : e;` 1527. `f = isNaN(f) ? 0 : f;` 1528. `this.ctx.transform = new Matrix(a, b, c, d, e, f);` 1529. `};` 1531. `/**` 1532. `* Should only be used if pageWrapYEnabled is true` 1533. `*` 1534. `* @name setPageByYPosition` 1535. `* @function` 1536. `* @private` 1537. `* @ignore` 1538. `* @returns One-based Page Number` 1539. `*/` 1540. `var setPageByYPosition = function(y) {` 1541. `if (this.pageWrapYEnabled) {` 1542. `this.lastBreak = 0;` 1543. `var manualBreaks = 0;` 1544. `var autoBreaks = 0;` 1545. `for (var i = 0; i < this.pageBreaks.length; i++) {` 1546. `if (y >= this.pageBreaks[i]) {` 1547. `manualBreaks++;` 1548. `if (this.lastBreak === 0) {` 1549. `autoBreaks++;` 1550. `}` 1551. `var spaceBetweenLastBreak = this.pageBreaks[i] - this.lastBreak;` 1552. `this.lastBreak = this.pageBreaks[i];` 1553. `var pagesSinceLastBreak = Math.floor(` 1554. `spaceBetweenLastBreak / this.pageWrapY` 1555. `);` 1556. `autoBreaks += pagesSinceLastBreak;` 1557. `}` 1558. `}` 1559. `if (this.lastBreak === 0) {` 1560. `var pagesSinceLastBreak = Math.floor(y / this.pageWrapY) + 1;` 1561. `autoBreaks += pagesSinceLastBreak;` 1562. `}` 1563. `return autoBreaks + manualBreaks;` 1564. `} else {` 1565. `return this.pdf.internal.getCurrentPageInfo().pageNumber;` 1566. `}` 1567. `};` 1569. `var hasMargins = function() {` 1570. `return (` 1571. `this.margin[0] > 0 ||` 1572. `this.margin[1] > 0 ||` 1573. `this.margin[2] > 0 ||` 1574. `this.margin[3] > 0` 1575. `);` 1576. `};` 1578. `/**` 1579. `* Draws an image, canvas, or video onto the canvas` 1580. `*` 1581. `* @function` 1582. `* @param img {} Specifies the image, canvas, or video element to use` 1583. `* @param sx {Number} Optional. The x coordinate where to start clipping` 1584. `* @param sy {Number} Optional. The y coordinate where to start clipping` 1585. `* @param swidth {Number} Optional. The width of the clipped image` 1586. `* @param sheight {Number} Optional. The height of the clipped image` 1587. `* @param x {Number} The x coordinate where to place the image on the canvas` 1588. `* @param y {Number} The y coordinate where to place the image on the canvas` 1589. `* @param width {Number} Optional. The width of the image to use (stretch or reduce the image)` 1590. `* @param height {Number} Optional. The height of the image to use (stretch or reduce the image)` 1591. `*/` 1592. `Context2D.prototype.drawImage = function(` 1593. `img,` 1594. `sx,` 1595. `sy,` 1596. `swidth,` 1597. `sheight,` 1598. `x,` 1599. `y,` 1600. `width,` 1601. `height` 1602. `) {` 1603. `var imageProperties = this.pdf.getImageProperties(img);` 1604. `var factorX = 1;` 1605. `var factorY = 1;` 1606. `var isClip;` 1608. `var clipFactorX = 1;` 1609. `var clipFactorY = 1;` 1611. `if (typeof swidth !== "undefined" && typeof width !== "undefined") {` 1612. `isClip = true;` 1613. `clipFactorX = width / swidth;` 1614. `clipFactorY = height / sheight;` 1615. `factorX = ((imageProperties.width / swidth) * width) / swidth;` 1616. `factorY = ((imageProperties.height / sheight) * height) / sheight;` 1617. `}` 1619. `//is sx and sy are set and x and y not, set x and y with values of sx and sy` 1620. `if (typeof x === "undefined") {` 1621. `x = sx;` 1622. `y = sy;` 1623. `sx = 0;` 1624. `sy = 0;` 1625. `}` 1627. `if (typeof swidth !== "undefined" && typeof width === "undefined") {` 1628. `width = swidth;` 1629. `height = sheight;` 1630. `}` 1631. `if (typeof swidth === "undefined" && typeof width === "undefined") {` 1632. `width = imageProperties.width;` 1633. `height = imageProperties.height;` 1634. `}` 1636. `var decomposedTransformationMatrix = this.ctx.transform.decompose();` 1637. `var angle = rad2deg(decomposedTransformationMatrix.rotate.shx);` 1638. `var matrix = new Matrix();` 1639. `matrix = matrix.multiply(decomposedTransformationMatrix.translate);` 1640. `matrix = matrix.multiply(decomposedTransformationMatrix.skew);` 1641. `matrix = matrix.multiply(decomposedTransformationMatrix.scale);` 1642. `var xRect = matrix.applyToRectangle(` 1643. `new Rectangle(` 1644. `x - sx * clipFactorX,` 1645. `y - sy * clipFactorY,` 1646. `swidth * factorX,` 1647. `sheight * factorY` 1648. `)` 1649. `);` 1650. `var pageArray = getPagesByPath.call(this, xRect);` 1651. `var pages = [];` 1652. `for (var ii = 0; ii < pageArray.length; ii += 1) {` 1653. `if (pages.indexOf(pageArray[ii]) === -1) {` 1654. `pages.push(pageArray[ii]);` 1655. `}` 1656. `}` 1658. `sortPages(pages);` 1660. `var clipPath;` 1661. `if (this.autoPaging) {` 1662. `var min = pages[0];` 1663. `var max = pages[pages.length - 1];` 1664. `for (var i = min; i < max + 1; i++) {` 1665. `this.pdf.setPage(i);` 1667. `var pageWidthMinusMargins =` 1668. `this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1];` 1669. `var topMargin = i === 1 ? this.posY + this.margin[0] : this.margin[0];` 1670. `var firstPageHeight =` 1671. `this.pdf.internal.pageSize.height -` 1672. `this.posY -` 1673. `this.margin[0] -` 1674. `this.margin[2];` 1675. `var pageHeightMinusMargins =` 1676. `this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2];` 1677. `var previousPageHeightSum =` 1678. `i === 1 ? 0 : firstPageHeight + (i - 2) * pageHeightMinusMargins;` 1680. `if (this.ctx.clip_path.length !== 0) {` 1681. `var tmpPaths = this.path;` 1682. `clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path));` 1683. `this.path = pathPositionRedo(` 1684. `clipPath,` 1685. `this.posX + this.margin[3],` 1686. `-previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset` 1687. `);` 1688. `drawPaths.call(this, "fill", true);` 1689. `this.path = tmpPaths;` 1690. `}` 1691. `var tmpRect = JSON.parse(JSON.stringify(xRect));` 1692. `tmpRect = pathPositionRedo(` 1693. `[tmpRect],` 1694. `this.posX + this.margin[3],` 1695. `-previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset` 1696. `)[0];` 1698. `const needsClipping = (i > min || i < max) && hasMargins.call(this);` 1700. `if (needsClipping) {` 1701. `this.pdf.saveGraphicsState();` 1702. `this.pdf` 1703. `.rect(` 1704. `this.margin[3],` 1705. `this.margin[0],` 1706. `pageWidthMinusMargins,` 1707. `pageHeightMinusMargins,` 1708. `null` 1709. `)` 1710. `.clip()` 1711. `.discardPath();` 1712. `}` 1713. `this.pdf.addImage(` 1714. `img,` 1715. `"JPEG",` 1716. `tmpRect.x,` 1717. `tmpRect.y,` 1718. `tmpRect.w,` 1719. `tmpRect.h,` 1720. `null,` 1721. `null,` 1722. `angle` 1723. `);` 1724. `if (needsClipping) {` 1725. `this.pdf.restoreGraphicsState();` 1726. `}` 1727. `}` 1728. `} else {` 1729. `this.pdf.addImage(` 1730. `img,` 1731. `"JPEG",` 1732. `xRect.x,` 1733. `xRect.y,` 1734. `xRect.w,` 1735. `xRect.h,` 1736. `null,` 1737. `null,` 1738. `angle` 1739. `);` 1740. `}` 1741. `};` 1743. `var getPagesByPath = function(path, pageWrapX, pageWrapY) {` 1744. `var result = [];` 1745. `pageWrapX = pageWrapX || this.pdf.internal.pageSize.width;` 1746. `pageWrapY =` 1747. `pageWrapY ||` 1748. `this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2];` 1749. `var yOffset = this.posY + this.ctx.prevPageLastElemOffset;` 1751. `switch (path.type) {` 1752. `default:` 1753. `case "mt":` 1754. `case "lt":` 1755. `result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1);` 1756. `break;` 1757. `case "arc":` 1758. `result.push(` 1759. `Math.floor((path.y + yOffset - path.radius) / pageWrapY) + 1` 1760. `);` 1761. `result.push(` 1762. `Math.floor((path.y + yOffset + path.radius) / pageWrapY) + 1` 1763. `);` 1764. `break;` 1765. `case "qct":` 1766. `var rectOfQuadraticCurve = getQuadraticCurveBoundary(` 1767. `this.ctx.lastPoint.x,` 1768. `this.ctx.lastPoint.y,` 1769. `path.x1,` 1770. `path.y1,` 1771. `path.x,` 1772. `path.y` 1773. `);` 1774. `result.push(` 1775. `Math.floor((rectOfQuadraticCurve.y + yOffset) / pageWrapY) + 1` 1776. `);` 1777. `result.push(` 1778. `Math.floor(` 1779. `(rectOfQuadraticCurve.y + rectOfQuadraticCurve.h + yOffset) /` 1780. `pageWrapY` 1781. `) + 1` 1782. `);` 1783. `break;` 1784. `case "bct":` 1785. `var rectOfBezierCurve = getBezierCurveBoundary(` 1786. `this.ctx.lastPoint.x,` 1787. `this.ctx.lastPoint.y,` 1788. `path.x1,` 1789. `path.y1,` 1790. `path.x2,` 1791. `path.y2,` 1792. `path.x,` 1793. `path.y` 1794. `);` 1795. `result.push(` 1796. `Math.floor((rectOfBezierCurve.y + yOffset) / pageWrapY) + 1` 1797. `);` 1798. `result.push(` 1799. `Math.floor(` 1800. `(rectOfBezierCurve.y + rectOfBezierCurve.h + yOffset) / pageWrapY` 1801. `) + 1` 1802. `);` 1803. `break;` 1804. `case "rect":` 1805. `result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1);` 1806. `result.push(Math.floor((path.y + path.h + yOffset) / pageWrapY) + 1);` 1807. `}` 1809. `for (var i = 0; i < result.length; i += 1) {` 1810. `while (this.pdf.internal.getNumberOfPages() < result[i]) {` 1811. `addPage.call(this);` 1812. `}` 1813. `}` 1814. `return result;` 1815. `};` 1817. `var addPage = function() {` 1818. `var fillStyle = this.fillStyle;` 1819. `var strokeStyle = this.strokeStyle;` 1820. `var font = this.font;` 1821. `var lineCap = this.lineCap;` 1822. `var lineWidth = this.lineWidth;` 1823. `var lineJoin = this.lineJoin;` 1824. `this.pdf.addPage();` 1825. `this.fillStyle = fillStyle;` 1826. `this.strokeStyle = strokeStyle;` 1827. `this.font = font;` 1828. `this.lineCap = lineCap;` 1829. `this.lineWidth = lineWidth;` 1830. `this.lineJoin = lineJoin;` 1831. `};` 1833. `var pathPositionRedo = function(paths, x, y) {` 1834. `for (var i = 0; i < paths.length; i++) {` 1835. `switch (paths[i].type) {` 1836. `case "bct":` 1837. `paths[i].x2 += x;` 1838. `paths[i].y2 += y;` 1839. `case "qct":` 1840. `paths[i].x1 += x;` 1841. `paths[i].y1 += y;` 1842. `case "mt":` 1843. `case "lt":` 1844. `case "arc":` 1845. `default:` 1846. `paths[i].x += x;` 1847. `paths[i].y += y;` 1848. `}` 1849. `}` 1850. `return paths;` 1851. `};` 1853. `var sortPages = function(pages) {` 1854. `return pages.sort(function(a, b) {` 1855. `return a - b;` 1856. `});` 1857. `};` 1859. `var pathPreProcess = function(rule, isClip) {` 1860. `var fillStyle = this.fillStyle;` 1861. `var strokeStyle = this.strokeStyle;` 1862. `var lineCap = this.lineCap;` 1863. `var oldLineWidth = this.lineWidth;` 1864. `var lineWidth = Math.abs(oldLineWidth * this.ctx.transform.scaleX);` 1865. `var lineJoin = this.lineJoin;` 1867. `var origPath = JSON.parse(JSON.stringify(this.path));` 1868. `var xPath = JSON.parse(JSON.stringify(this.path));` 1869. `var clipPath;` 1870. `var tmpPath;` 1871. `var pages = [];` 1873. `for (var i = 0; i < xPath.length; i++) {` 1874. `if (typeof xPath[i].x !== "undefined") {` 1875. `var page = getPagesByPath.call(this, xPath[i]);` 1877. `for (var ii = 0; ii < page.length; ii += 1) {` 1878. `if (pages.indexOf(page[ii]) === -1) {` 1879. `pages.push(page[ii]);` 1880. `}` 1881. `}` 1882. `}` 1883. `}` 1885. `for (var j = 0; j < pages.length; j++) {` 1886. `while (this.pdf.internal.getNumberOfPages() < pages[j]) {` 1887. `addPage.call(this);` 1888. `}` 1889. `}` 1890. `sortPages(pages);` 1892. `if (this.autoPaging) {` 1893. `var min = pages[0];` 1894. `var max = pages[pages.length - 1];` 1895. `for (var k = min; k < max + 1; k++) {` 1896. `this.pdf.setPage(k);` 1898. `this.fillStyle = fillStyle;` 1899. `this.strokeStyle = strokeStyle;` 1900. `this.lineCap = lineCap;` 1901. `this.lineWidth = lineWidth;` 1902. `this.lineJoin = lineJoin;` 1904. `var pageWidthMinusMargins =` 1905. `this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1];` 1906. `var topMargin = k === 1 ? this.posY + this.margin[0] : this.margin[0];` 1907. `var firstPageHeight =` 1908. `this.pdf.internal.pageSize.height -` 1909. `this.posY -` 1910. `this.margin[0] -` 1911. `this.margin[2];` 1912. `var pageHeightMinusMargins =` 1913. `this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2];` 1914. `var previousPageHeightSum =` 1915. `k === 1 ? 0 : firstPageHeight + (k - 2) * pageHeightMinusMargins;` 1917. `if (this.ctx.clip_path.length !== 0) {` 1918. `var tmpPaths = this.path;` 1919. `clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path));` 1920. `this.path = pathPositionRedo(` 1921. `clipPath,` 1922. `this.posX + this.margin[3],` 1923. `-previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset` 1924. `);` 1925. `drawPaths.call(this, rule, true);` 1926. `this.path = tmpPaths;` 1927. `}` 1928. `tmpPath = JSON.parse(JSON.stringify(origPath));` 1929. `this.path = pathPositionRedo(` 1930. `tmpPath,` 1931. `this.posX + this.margin[3],` 1932. `-previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset` 1933. `);` 1934. `if (isClip === false || k === 0) {` 1935. `const needsClipping = (k > min || k < max) && hasMargins.call(this);` 1936. `if (needsClipping) {` 1937. `this.pdf.saveGraphicsState();` 1938. `this.pdf` 1939. `.rect(` 1940. `this.margin[3],` 1941. `this.margin[0],` 1942. `pageWidthMinusMargins,` 1943. `pageHeightMinusMargins,` 1944. `null` 1945. `)` 1946. `.clip()` 1947. `.discardPath();` 1948. `}` 1949. `drawPaths.call(this, rule, isClip);` 1950. `if (needsClipping) {` 1951. `this.pdf.restoreGraphicsState();` 1952. `}` 1953. `}` 1954. `this.lineWidth = oldLineWidth;` 1955. `}` 1956. `} else {` 1957. `this.lineWidth = lineWidth;` 1958. `drawPaths.call(this, rule, isClip);` 1959. `this.lineWidth = oldLineWidth;` 1960. `}` 1961. `this.path = origPath;` 1962. `};` 1964. `/**` 1965. `* Processes the paths` 1966. `*` 1967. `* @function` 1968. `* @param rule {String}` 1969. `* @param isClip {Boolean}` 1970. `* @private` 1971. `* @ignore` 1972. `*/` 1973. `var drawPaths = function(rule, isClip) {` 1974. `if (rule === "stroke" && !isClip && isStrokeTransparent.call(this)) {` 1975. `return;` 1976. `}` 1978. `if (rule !== "stroke" && !isClip && isFillTransparent.call(this)) {` 1979. `return;` 1980. `}` 1982. `var moves = [];` 1984. `//var alpha = (this.ctx.fillOpacity < 1) ? this.ctx.fillOpacity : this.ctx.globalAlpha;` 1985. `var delta;` 1986. `var xPath = this.path;` 1987. `for (var i = 0; i < xPath.length; i++) {` 1988. `var pt = xPath[i];` 1990. `switch (pt.type) {` 1991. `case "begin":` 1992. `moves.push({` 1993. `begin: true` 1994. `});` 1995. `break;` 1997. `case "close":` 1998. `moves.push({` 1999. `close: true` 2000. `});` 2001. `break;` 2003. `case "mt":` 2004. `moves.push({` 2005. `start: pt,` 2006. `deltas: [],` 2007. `abs: []` 2008. `});` 2009. `break;` 2011. `case "lt":` 2012. `var iii = moves.length;` 2013. `if (xPath[i - 1] && !isNaN(xPath[i - 1].x)) {` 2014. `delta = [pt.x - xPath[i - 1].x, pt.y - xPath[i - 1].y];` 2015. `if (iii > 0) {` 2016. `for (iii; iii >= 0; iii--) {` 2017. `if (` 2018. `moves[iii - 1].close !== true &&` 2019. `moves[iii - 1].begin !== true` 2020. `) {` 2021. `moves[iii - 1].deltas.push(delta);` 2022. `moves[iii - 1].abs.push(pt);` 2023. `break;` 2024. `}` 2025. `}` 2026. `}` 2027. `}` 2028. `break;` 2030. `case "bct":` 2031. `delta = [`\ 2032. `pt.x1 - xPath[i - 1].x,`\ 2033. `pt.y1 - xPath[i - 1].y,`\ 2034. `pt.x2 - xPath[i - 1].x,`\ 2035. `pt.y2 - xPath[i - 1].y,`\ 2036. `pt.x - xPath[i - 1].x,`\ 2037. `pt.y - xPath[i - 1].y`\ 2038. `];` 2039. `moves[moves.length - 1].deltas.push(delta);` 2040. `break;` 2042. `case "qct":` 2043. `var x1 = xPath[i - 1].x + (2.0 / 3.0) * (pt.x1 - xPath[i - 1].x);` 2044. `var y1 = xPath[i - 1].y + (2.0 / 3.0) * (pt.y1 - xPath[i - 1].y);` 2045. `var x2 = pt.x + (2.0 / 3.0) * (pt.x1 - pt.x);` 2046. `var y2 = pt.y + (2.0 / 3.0) * (pt.y1 - pt.y);` 2047. `var x3 = pt.x;` 2048. `var y3 = pt.y;` 2049. `delta = [`\ 2050. `x1 - xPath[i - 1].x,`\ 2051. `y1 - xPath[i - 1].y,`\ 2052. `x2 - xPath[i - 1].x,`\ 2053. `y2 - xPath[i - 1].y,`\ 2054. `x3 - xPath[i - 1].x,`\ 2055. `y3 - xPath[i - 1].y`\ 2056. `];` 2057. `moves[moves.length - 1].deltas.push(delta);` 2058. `break;` 2060. `case "arc":` 2061. `moves.push({` 2062. `deltas: [],` 2063. `abs: [],` 2064. `arc: true` 2065. `});` 2067. `if (Array.isArray(moves[moves.length - 1].abs)) {` 2068. `moves[moves.length - 1].abs.push(pt);` 2069. `}` 2070. `break;` 2071. `}` 2072. `}` 2073. `var style;` 2074. `if (!isClip) {` 2075. `if (rule === "stroke") {` 2076. `style = "stroke";` 2077. `} else {` 2078. `style = "fill";` 2079. `}` 2080. `} else {` 2081. `style = null;` 2082. `}` 2084. `var began = false;` 2085. `for (var k = 0; k < moves.length; k++) {` 2086. `if (moves[k].arc) {` 2087. `var arcs = moves[k].abs;` 2089. `for (var ii = 0; ii < arcs.length; ii++) {` 2090. `var arc = arcs[ii];` 2092. `if (arc.type === "arc") {` 2093. `drawArc.call(` 2094. `this,` 2095. `arc.x,` 2096. `arc.y,` 2097. `arc.radius,` 2098. `arc.startAngle,` 2099. `arc.endAngle,` 2100. `arc.counterclockwise,` 2101. `undefined,` 2102. `isClip,` 2103. `!began` 2104. `);` 2105. `} else {` 2106. `drawLine.call(this, arc.x, arc.y);` 2107. `}` 2108. `began = true;` 2109. `}` 2110. `} else if (moves[k].close === true) {` 2111. `this.pdf.internal.out("h");` 2112. `began = false;` 2113. `} else if (moves[k].begin !== true) {` 2114. `var x = moves[k].start.x;` 2115. `var y = moves[k].start.y;` 2116. `drawLines.call(this, moves[k].deltas, x, y);` 2117. `began = true;` 2118. `}` 2119. `}` 2121. `if (style) {` 2122. `putStyle.call(this, style);` 2123. `}` 2124. `if (isClip) {` 2125. `doClip.call(this);` 2126. `}` 2127. `};` 2129. `var getBaseline = function(y) {` 2130. `var height =` 2131. `this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor;` 2132. `var descent = height * (this.pdf.internal.getLineHeightFactor() - 1);` 2133. `switch (this.ctx.textBaseline) {` 2134. `case "bottom":` 2135. `return y - descent;` 2136. `case "top":` 2137. `return y + height - descent;` 2138. `case "hanging":` 2139. `return y + height - 2 * descent;` 2140. `case "middle":` 2141. `return y + height / 2 - descent;` 2142. `case "ideographic":` 2143. `// TODO not implemented` 2144. `return y;` 2145. `case "alphabetic":` 2146. `default:` 2147. `return y;` 2148. `}` 2149. `};` 2151. `var getTextBottom = function(yBaseLine) {` 2152. `var height =` 2153. `this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor;` 2154. `var descent = height * (this.pdf.internal.getLineHeightFactor() - 1);` 2155. `return yBaseLine + descent;` 2156. `};` 2158. `Context2D.prototype.createLinearGradient = function createLinearGradient() {` 2159. `var canvasGradient = function canvasGradient() {};` 2161. `canvasGradient.colorStops = [];` 2162. `canvasGradient.addColorStop = function(offset, color) {` 2163. `this.colorStops.push([offset, color]);` 2164. `};` 2166. `canvasGradient.getColor = function() {` 2167. `if (this.colorStops.length === 0) {` 2168. `return "#000000";` 2169. `}` 2171. `return this.colorStops[0][1];` 2172. `};` 2174. `canvasGradient.isCanvasGradient = true;` 2175. `return canvasGradient;` 2176. `};` 2177. `Context2D.prototype.createPattern = function createPattern() {` 2178. `return this.createLinearGradient();` 2179. `};` 2180. `Context2D.prototype.createRadialGradient = function createRadialGradient() {` 2181. `return this.createLinearGradient();` 2182. `};` 2184. `/**` 2185. `*` 2186. `* @param x Edge point X` 2187. `* @param y Edge point Y` 2188. `* @param r Radius` 2189. `* @param a1 start angle` 2190. `* @param a2 end angle` 2191. `* @param counterclockwise` 2192. `* @param style` 2193. `* @param isClip` 2194. `*/` 2195. `var drawArc = function(` 2196. `x,` 2197. `y,` 2198. `r,` 2199. `a1,` 2200. `a2,` 2201. `counterclockwise,` 2202. `style,` 2203. `isClip,` 2204. `includeMove` 2205. `) {` 2206. `// http://hansmuller-flex.blogspot.com/2011/10/more-about-approximating-circular-arcs.html` 2207. `var curves = createArc.call(this, r, a1, a2, counterclockwise);` 2209. `for (var i = 0; i < curves.length; i++) {` 2210. `var curve = curves[i];` 2211. `if (i === 0) {` 2212. `if (includeMove) {` 2213. `doMove.call(this, curve.x1 + x, curve.y1 + y);` 2214. `} else {` 2215. `drawLine.call(this, curve.x1 + x, curve.y1 + y);` 2216. `}` 2217. `}` 2218. `drawCurve.call(` 2219. `this,` 2220. `x,` 2221. `y,` 2222. `curve.x2,` 2223. `curve.y2,` 2224. `curve.x3,` 2225. `curve.y3,` 2226. `curve.x4,` 2227. `curve.y4` 2228. `);` 2229. `}` 2231. `if (!isClip) {` 2232. `putStyle.call(this, style);` 2233. `} else {` 2234. `doClip.call(this);` 2235. `}` 2236. `};` 2238. `var putStyle = function(style) {` 2239. `switch (style) {` 2240. `case "stroke":` 2241. `this.pdf.internal.out("S");` 2242. `break;` 2243. `case "fill":` 2244. `this.pdf.internal.out("f");` 2245. `break;` 2246. `}` 2247. `};` 2249. `var doClip = function() {` 2250. `this.pdf.clip();` 2251. `this.pdf.discardPath();` 2252. `};` 2254. `var doMove = function(x, y) {` 2255. `this.pdf.internal.out(` 2256. `getHorizontalCoordinateString(x) +` 2257. `" " +` 2258. `getVerticalCoordinateString(y) +` 2259. `" m"` 2260. `);` 2261. `};` 2263. `var putText = function(options) {` 2264. `var textAlign;` 2265. `switch (options.align) {` 2266. `case "right":` 2267. `case "end":` 2268. `textAlign = "right";` 2269. `break;` 2270. `case "center":` 2271. `textAlign = "center";` 2272. `break;` 2273. `case "left":` 2274. `case "start":` 2275. `default:` 2276. `textAlign = "left";` 2277. `break;` 2278. `}` 2280. `var textDimensions = this.pdf.getTextDimensions(options.text);` 2281. `var yBaseLine = getBaseline.call(this, options.y);` 2282. `var yBottom = getTextBottom.call(this, yBaseLine);` 2283. `var yTop = yBottom - textDimensions.h;` 2285. `var pt = this.ctx.transform.applyToPoint(new Point(options.x, yBaseLine));` 2286. `var decomposedTransformationMatrix = this.ctx.transform.decompose();` 2287. `var matrix = new Matrix();` 2288. `matrix = matrix.multiply(decomposedTransformationMatrix.translate);` 2289. `matrix = matrix.multiply(decomposedTransformationMatrix.skew);` 2290. `matrix = matrix.multiply(decomposedTransformationMatrix.scale);` 2292. `var baselineRect = this.ctx.transform.applyToRectangle(` 2293. `new Rectangle(options.x, yBaseLine, textDimensions.w, textDimensions.h)` 2294. `);` 2295. `var textBounds = matrix.applyToRectangle(` 2296. `new Rectangle(options.x, yTop, textDimensions.w, textDimensions.h)` 2297. `);` 2298. `var pageArray = getPagesByPath.call(this, textBounds);` 2299. `var pages = [];` 2300. `for (var ii = 0; ii < pageArray.length; ii += 1) {` 2301. `if (pages.indexOf(pageArray[ii]) === -1) {` 2302. `pages.push(pageArray[ii]);` 2303. `}` 2304. `}` 2306. `sortPages(pages);` 2308. `var clipPath, oldSize, oldLineWidth;` 2309. `if (this.autoPaging) {` 2310. `var min = pages[0];` 2311. `var max = pages[pages.length - 1];` 2312. `for (var i = min; i < max + 1; i++) {` 2313. `this.pdf.setPage(i);` 2315. `var topMargin = i === 1 ? this.posY + this.margin[0] : this.margin[0];` 2316. `var firstPageHeight =` 2317. `this.pdf.internal.pageSize.height -` 2318. `this.posY -` 2319. `this.margin[0] -` 2320. `this.margin[2];` 2321. `var pageHeightMinusBottomMargin =` 2322. `this.pdf.internal.pageSize.height - this.margin[2];` 2323. `var pageHeightMinusMargins =` 2324. `pageHeightMinusBottomMargin - this.margin[0];` 2325. `var pageWidthMinusRightMargin =` 2326. `this.pdf.internal.pageSize.width - this.margin[1];` 2327. `var pageWidthMinusMargins = pageWidthMinusRightMargin - this.margin[3];` 2328. `var previousPageHeightSum =` 2329. `i === 1 ? 0 : firstPageHeight + (i - 2) * pageHeightMinusMargins;` 2331. `if (this.ctx.clip_path.length !== 0) {` 2332. `var tmpPaths = this.path;` 2333. `clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path));` 2334. `this.path = pathPositionRedo(` 2335. `clipPath,` 2336. `this.posX + this.margin[3],` 2337. `-1 * previousPageHeightSum + topMargin` 2338. `);` 2339. `drawPaths.call(this, "fill", true);` 2340. `this.path = tmpPaths;` 2341. `}` 2342. `var textBoundsOnPage = pathPositionRedo(` 2343. `[JSON.parse(JSON.stringify(textBounds))],` 2344. `this.posX + this.margin[3],` 2345. `-previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset` 2346. `)[0];` 2348. `if (options.scale >= 0.01) {` 2349. `oldSize = this.pdf.internal.getFontSize();` 2350. `this.pdf.setFontSize(oldSize * options.scale);` 2351. `oldLineWidth = this.lineWidth;` 2352. `this.lineWidth = oldLineWidth * options.scale;` 2353. `}` 2355. `var doSlice = this.autoPaging !== "text";` 2357. `if (` 2358. `doSlice ||` 2359. `textBoundsOnPage.y + textBoundsOnPage.h <= pageHeightMinusBottomMargin` 2360. `) {` 2361. `if (` 2362. `doSlice ||` 2363. `(textBoundsOnPage.y >= topMargin &&` 2364. `textBoundsOnPage.x <= pageWidthMinusRightMargin)` 2365. `) {` 2366. `var croppedText = doSlice` 2367. `? options.text` 2368. `: this.pdf.splitTextToSize(` 2369. `options.text,` 2370. `options.maxWidth ||` 2371. `pageWidthMinusRightMargin - textBoundsOnPage.x` 2372. `)[0];` 2373. `var baseLineRectOnPage = pathPositionRedo(` 2374. `[JSON.parse(JSON.stringify(baselineRect))],` 2375. `this.posX + this.margin[3],` 2376. `-previousPageHeightSum +` 2377. `topMargin +` 2378. `this.ctx.prevPageLastElemOffset` 2379. `)[0];` 2381. `const needsClipping =` 2382. `doSlice && (i > min || i < max) && hasMargins.call(this);` 2384. `if (needsClipping) {` 2385. `this.pdf.saveGraphicsState();` 2386. `this.pdf` 2387. `.rect(` 2388. `this.margin[3],` 2389. `this.margin[0],` 2390. `pageWidthMinusMargins,` 2391. `pageHeightMinusMargins,` 2392. `null` 2393. `)` 2394. `.clip()` 2395. `.discardPath();` 2396. `}` 2398. `this.pdf.text(` 2399. `croppedText,` 2400. `baseLineRectOnPage.x,` 2401. `baseLineRectOnPage.y,` 2402. `{` 2403. `angle: options.angle,` 2404. `align: textAlign,` 2405. `renderingMode: options.renderingMode` 2406. `}` 2407. `);` 2409. `if (needsClipping) {` 2410. `this.pdf.restoreGraphicsState();` 2411. `}` 2412. `}` 2413. `} else {` 2414. `// This text is the last element of the page, but it got cut off due to the margin` 2415. `// so we render it in the next page` 2417. `if (textBoundsOnPage.y < pageHeightMinusBottomMargin) {` 2418. `// As a result, all other elements have their y offset increased` 2419. `this.ctx.prevPageLastElemOffset +=` 2420. `pageHeightMinusBottomMargin - textBoundsOnPage.y;` 2421. `}` 2422. `}` 2424. `if (options.scale >= 0.01) {` 2425. `this.pdf.setFontSize(oldSize);` 2426. `this.lineWidth = oldLineWidth;` 2427. `}` 2428. `}` 2429. `} else {` 2430. `if (options.scale >= 0.01) {` 2431. `oldSize = this.pdf.internal.getFontSize();` 2432. `this.pdf.setFontSize(oldSize * options.scale);` 2433. `oldLineWidth = this.lineWidth;` 2434. `this.lineWidth = oldLineWidth * options.scale;` 2435. `}` 2436. `this.pdf.text(options.text, pt.x + this.posX, pt.y + this.posY, {` 2437. `angle: options.angle,` 2438. `align: textAlign,` 2439. `renderingMode: options.renderingMode,` 2440. `maxWidth: options.maxWidth` 2441. `});` 2443. `if (options.scale >= 0.01) {` 2444. `this.pdf.setFontSize(oldSize);` 2445. `this.lineWidth = oldLineWidth;` 2446. `}` 2447. `}` 2448. `};` 2450. `var drawLine = function(x, y, prevX, prevY) {` 2451. `prevX = prevX || 0;` 2452. `prevY = prevY || 0;` 2454. `this.pdf.internal.out(` 2455. `getHorizontalCoordinateString(x + prevX) +` 2456. `" " +` 2457. `getVerticalCoordinateString(y + prevY) +` 2458. `" l"` 2459. `);` 2460. `};` 2462. `var drawLines = function(lines, x, y) {` 2463. `return this.pdf.lines(lines, x, y, null, null);` 2464. `};` 2466. `var drawCurve = function(x, y, x1, y1, x2, y2, x3, y3) {` 2467. `this.pdf.internal.out(` 2468. `[`\ 2469. `f2(getHorizontalCoordinate(x1 + x)),`\ 2470. `f2(getVerticalCoordinate(y1 + y)),`\ 2471. `f2(getHorizontalCoordinate(x2 + x)),`\ 2472. `f2(getVerticalCoordinate(y2 + y)),`\ 2473. `f2(getHorizontalCoordinate(x3 + x)),`\ 2474. `f2(getVerticalCoordinate(y3 + y)),`\ 2475. `"c"`\ 2476. `].join(" ")` 2477. `);` 2478. `};` 2480. `/**` 2481. `* 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.` 2482. `*` 2483. `* 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.` 2484. `* @function createArc` 2485. `*/` 2486. `var createArc = function(radius, startAngle, endAngle, anticlockwise) {` 2487. `var EPSILON = 0.00001; // Roughly 1/1000th of a degree, see below` 2488. `var twoPi = Math.PI * 2;` 2489. `var halfPi = Math.PI / 2.0;` 2491. `while (startAngle > endAngle) {` 2492. `startAngle = startAngle - twoPi;` 2493. `}` 2494. `var totalAngle = Math.abs(endAngle - startAngle);` 2495. `if (totalAngle < twoPi) {` 2496. `if (anticlockwise) {` 2497. `totalAngle = twoPi - totalAngle;` 2498. `}` 2499. `}` 2501. `// Compute the sequence of arc curves, up to PI/2 at a time.` 2502. `var curves = [];` 2504. `// clockwise or counterclockwise` 2505. `var sgn = anticlockwise ? -1 : +1;` 2507. `var a1 = startAngle;` 2508. `for (; totalAngle > EPSILON; ) {` 2509. `var remain = sgn * Math.min(totalAngle, halfPi);` 2510. `var a2 = a1 + remain;` 2511. `curves.push(createSmallArc.call(this, radius, a1, a2));` 2512. `totalAngle -= Math.abs(a2 - a1);` 2513. `a1 = a2;` 2514. `}` 2516. `return curves;` 2517. `};` 2519. `/**` 2520. `* 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.` 2521. `*` 2522. `* 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.` 2523. `*` 2524. `* 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.` 2525. `*/` 2526. `var createSmallArc = function(r, a1, a2) {` 2527. `var a = (a2 - a1) / 2.0;` 2529. `var x4 = r * Math.cos(a);` 2530. `var y4 = r * Math.sin(a);` 2531. `var x1 = x4;` 2532. `var y1 = -y4;` 2534. `var q1 = x1 * x1 + y1 * y1;` 2535. `var q2 = q1 + x1 * x4 + y1 * y4;` 2536. `var k2 = ((4 / 3) * (Math.sqrt(2 * q1 * q2) - q2)) / (x1 * y4 - y1 * x4);` 2538. `var x2 = x1 - k2 * y1;` 2539. `var y2 = y1 + k2 * x1;` 2540. `var x3 = x2;` 2541. `var y3 = -y2;` 2543. `var ar = a + a1;` 2544. `var cos_ar = Math.cos(ar);` 2545. `var sin_ar = Math.sin(ar);` 2547. `return {` 2548. `x1: r * Math.cos(a1),` 2549. `y1: r * Math.sin(a1),` 2550. `x2: x2 * cos_ar - y2 * sin_ar,` 2551. `y2: x2 * sin_ar + y2 * cos_ar,` 2552. `x3: x3 * cos_ar - y3 * sin_ar,` 2553. `y3: x3 * sin_ar + y3 * cos_ar,` 2554. `x4: r * Math.cos(a2),` 2555. `y4: r * Math.sin(a2)` 2556. `};` 2557. `};` 2559. `var rad2deg = function(value) {` 2560. `return (value * 180) / Math.PI;` 2561. `};` 2563. `var getQuadraticCurveBoundary = function(sx, sy, cpx, cpy, ex, ey) {` 2564. `var midX1 = sx + (cpx - sx) * 0.5;` 2565. `var midY1 = sy + (cpy - sy) * 0.5;` 2566. `var midX2 = ex + (cpx - ex) * 0.5;` 2567. `var midY2 = ey + (cpy - ey) * 0.5;` 2568. `var resultX1 = Math.min(sx, ex, midX1, midX2);` 2569. `var resultX2 = Math.max(sx, ex, midX1, midX2);` 2570. `var resultY1 = Math.min(sy, ey, midY1, midY2);` 2571. `var resultY2 = Math.max(sy, ey, midY1, midY2);` 2572. `return new Rectangle(` 2573. `resultX1,` 2574. `resultY1,` 2575. `resultX2 - resultX1,` 2576. `resultY2 - resultY1` 2577. `);` 2578. `};` 2580. `//De Casteljau algorithm` 2581. `var getBezierCurveBoundary = function(ax, ay, bx, by, cx, cy, dx, dy) {` 2582. `var tobx = bx - ax;` 2583. `var toby = by - ay;` 2584. `var tocx = cx - bx;` 2585. `var tocy = cy - by;` 2586. `var todx = dx - cx;` 2587. `var tody = dy - cy;` 2588. `var precision = 40;` 2589. `var d,` 2590. `i,` 2591. `px,` 2592. `py,` 2593. `qx,` 2594. `qy,` 2595. `rx,` 2596. `ry,` 2597. `tx,` 2598. `ty,` 2599. `sx,` 2600. `sy,` 2601. `x,` 2602. `y,` 2603. `minx,` 2604. `miny,` 2605. `maxx,` 2606. `maxy,` 2607. `toqx,` 2608. `toqy,` 2609. `torx,` 2610. `tory,` 2611. `totx,` 2612. `toty;` 2613. `for (i = 0; i < precision + 1; i++) {` 2614. `d = i / precision;` 2615. `px = ax + d * tobx;` 2616. `py = ay + d * toby;` 2617. `qx = bx + d * tocx;` 2618. `qy = by + d * tocy;` 2619. `rx = cx + d * todx;` 2620. `ry = cy + d * tody;` 2621. `toqx = qx - px;` 2622. `toqy = qy - py;` 2623. `torx = rx - qx;` 2624. `tory = ry - qy;` 2626. `sx = px + d * toqx;` 2627. `sy = py + d * toqy;` 2628. `tx = qx + d * torx;` 2629. `ty = qy + d * tory;` 2630. `totx = tx - sx;` 2631. `toty = ty - sy;` 2633. `x = sx + d * totx;` 2634. `y = sy + d * toty;` 2635. `if (i == 0) {` 2636. `minx = x;` 2637. `miny = y;` 2638. `maxx = x;` 2639. `maxy = y;` 2640. `} else {` 2641. `minx = Math.min(minx, x);` 2642. `miny = Math.min(miny, y);` 2643. `maxx = Math.max(maxx, x);` 2644. `maxy = Math.max(maxy, y);` 2645. `}` 2646. `}` 2647. `return new Rectangle(` 2648. `Math.round(minx),` 2649. `Math.round(miny),` 2650. `Math.round(maxx - minx),` 2651. `Math.round(maxy - miny)` 2652. `);` 2653. `};` 2655. `var getPrevLineDashValue = function(lineDash, lineDashOffset) {` 2656. `return JSON.stringify({` 2657. `lineDash: lineDash,` 2658. `lineDashOffset: lineDashOffset` 2659. `});` 2660. `};` 2662. `var setLineDash = function() {` 2663. `// Avoid unnecessary line dash declarations.` 2664. `if (` 2665. `!this.prevLineDash &&` 2666. `!this.ctx.lineDash.length &&` 2667. `!this.ctx.lineDashOffset` 2668. `) {` 2669. `return;` 2670. `}` 2672. `// Avoid unnecessary line dash declarations.` 2673. `const nextLineDash = getPrevLineDashValue(` 2674. `this.ctx.lineDash,` 2675. `this.ctx.lineDashOffset` 2676. `);` 2677. `if (this.prevLineDash !== nextLineDash) {` 2678. `this.pdf.setLineDash(this.ctx.lineDash, this.ctx.lineDashOffset);` 2679. `this.prevLineDash = nextLineDash;` 2680. `}` 2681. `};` 2682. `})(jsPDF.API);` --- # Unknown 404: Not Found --- # Unknown 404: Not Found --- # Unknown 404: Not Found --- # Unknown 404: Not Found ---