diff --git a/deletedocs.js b/deletedocs.js
new file mode 100644
index 000000000..9c346ab9f
--- /dev/null
+++ b/deletedocs.js
@@ -0,0 +1,6 @@
+const deleteFolder = require('folder-delete');
+
+try {
+deleteFolder('docs', {debugLog: false});
+} catch (e) {
+}
\ No newline at end of file
diff --git a/jsdoc.json b/jsdoc.json
index eb1f13b82..ed6966cd8 100644
--- a/jsdoc.json
+++ b/jsdoc.json
@@ -3,9 +3,10 @@
"allowUnknownTags": false
},
"source": {
- "include": "./",
- "includePattern": "(.js|README.md)$",
- "excludePattern": "(node_modules/|docs|dist|examples|libs|tests|saucelabs.karma.conf.js)"
+ "include": ["./"],
+ "includePattern": "(.js)$",
+ "exclude": ["./node_modules", "./deprecated", "./fontconverter", "./tests"],
+ "excludePattern": "(main*.js|node_modules|docs|dist|examples|libs|tests|saucelabs.karma.conf.js|karma.conf.js|build.js|rollup.config.js)"
},
"plugins": [
"node_modules/jsdoc/plugins/markdown"
diff --git a/jspdf.js b/jspdf.js
index 422855974..93dde2c20 100644
--- a/jspdf.js
+++ b/jspdf.js
@@ -1,4 +1,4 @@
-/** @preserve
+/** @license
* jsPDF - PDF Document creation from JavaScript
* Version ${versionID} Built on ${builtOn}
* CommitID ${commitID}
@@ -48,13 +48,13 @@
* Creates new jsPDF document object instance.
* @name jsPDF
* @class
- * @param orientation {String/Object} Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l")
+ * @param orientation {string/Object} Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l")
* Can also be an options object.
- * @param unit {String} Measurement unit to be used when coordinates are specified.
+ * @param unit {string} Measurement unit to be used when coordinates are specified.
* Possible values are "pt" (points), "mm" (Default), "cm", "in" or "px".
- * @param format {String/Array} The format of the first page. Can be
- a0 - a10
- b0 - b10
- c0 - c10
- c0 - c10
- dl
- letter
- government-letter
- legal
- junior-legal
- ledger
- tabloid
- credit-card
+ * @param format {string/Array} The format of the first page. Can be - a0 - a10
- b0 - b10
- c0 - c10
- c0 - c10
- dl
- letter
- government-letter
- legal
- junior-legal
- ledger
- tabloid
- credit-card
* Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array , e.g. [595.28, 841.89]
- * @returns {jsPDF}
+ * @returns {jsPDF} jsPDF-instance
* @description
* If the first parameter (orientation) is an object, it will be interpreted as an object of named parameters
* ```
@@ -115,13 +115,12 @@ var jsPDF = (function (global) {
/**
* jsPDF's Internal PubSub Implementation.
- * See mrrio.github.io/jsPDF/doc/symbols/PubSub.html
* Backward compatible rewritten on 2014 by
* Diego Casorran, https://github.com/diegocr
*
* @class
* @name PubSub
- * @ignore This should not be in the public docs.
+ * @ignore
*/
function PubSub(context) {
var topics = {};
@@ -595,20 +594,6 @@ var jsPDF = (function (global) {
}
fontmap[fontName][fontStyle] = fontKey;
},
- /**
- * FontObject describes a particular font as member of an instnace of jsPDF
- *
- * It's a collection of properties like 'id' (to be used in PDF stream),
- * 'fontName' (font's family name), 'fontStyle' (font's style variant label)
- *
- * @class
- * @public
- * @property id {String} PDF-document-instance-specific label assinged to the font.
- * @property postScriptName {String} PDF specification full name for the font
- * @property encoding {Object} Encoding_name-to-Font_metrics_object mapping.
- * @name FontObject
- * @ignore This should not be in the public docs.
- */
addFont = function(postScriptName, fontName, fontStyle, encoding) {
var fontKey = 'F' + (Object.keys(fonts).length + 1).toString(10),
// This is FontObject
@@ -998,9 +983,10 @@ var jsPDF = (function (global) {
* to be added to the PDF document stream.
* @private
* @function
- * @param fontName {String} can be undefined on "falthy" to indicate "use current"
- * @param fontStyle {String} can be undefined on "falthy" to indicate "use current"
- * @returns {String} Font key.
+ * @param fontName {string} can be undefined on "falthy" to indicate "use current"
+ * @param fontStyle {string} can be undefined on "falthy" to indicate "use current"
+ * @returns {string} Font key.
+ * @ignore
*/
getFont = function(fontName, fontStyle, options) {
var key = undefined, originalFontName, fontNameLowerCase;
@@ -1008,17 +994,17 @@ var jsPDF = (function (global) {
fontName = fontName !== undefined ? fontName : fonts[activeFontKey].fontName;
fontStyle = fontStyle !== undefined ? fontStyle : fonts[activeFontKey].fontStyle;
- fontNameLowerCase = fontName.toLowerCase();
-
- if (fontmap[fontNameLowerCase] !== undefined && fontmap[fontNameLowerCase][fontStyle] !== undefined) {
- key = fontmap[fontNameLowerCase][fontStyle];
- } else if ( fontmap[fontName] !== undefined && fontmap[fontName][fontStyle] !== undefined) {
- key = fontmap[fontName][fontStyle];
- } else {
- if (options.disableWarning === false) {
- console.warn("Unable to look up font label for font '" + fontName + "', '" + fontStyle + "'. Refer to getFontList() for available fonts.");
- }
- }
+ fontNameLowerCase = fontName.toLowerCase();
+
+ if (fontmap[fontNameLowerCase] !== undefined && fontmap[fontNameLowerCase][fontStyle] !== undefined) {
+ key = fontmap[fontNameLowerCase][fontStyle];
+ } else if ( fontmap[fontName] !== undefined && fontmap[fontName][fontStyle] !== undefined) {
+ key = fontmap[fontName][fontStyle];
+ } else {
+ if (options.disableWarning === false) {
+ console.warn("Unable to look up font label for font '" + fontName + "', '" + fontStyle + "'. Refer to getFontList() for available fonts.");
+ }
+ }
if (!key && !options.noFallback) {
key = fontmap['times'][fontStyle];
@@ -1126,22 +1112,9 @@ var jsPDF = (function (global) {
type: "application/pdf"
});
},
- /**
- * Generates the PDF document.
- *
- * If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
- *
- * @param {String} type A string identifying one of the possible output types.
- * @param {Object} options An object providing some additional signalling to PDF generator.
- *
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name output
- */
output = SAFE(function (type, options) {
- options = options || {};
- options.filename = options.filename || 'generated.pdf';
+ options = options || {};
+ options.filename = options.filename || 'generated.pdf';
var datauri = ('' + type).substr(0, 6) === 'dataur' ?
'data:application/pdf;filename=' + options.filename + ';base64,' + btoa(buildDocument()) : 0;
@@ -1175,15 +1148,15 @@ var jsPDF = (function (global) {
case 'dataurlstring':
return datauri;
case 'dataurlnewwindow':
- var htmlForNewWindow = '' +
- '' +
- '' +
- '' +
- '';
- var nW = global.open();
- if (nW !== null) {
- nW.document.write(htmlForNewWindow)
- }
+ var htmlForNewWindow = '' +
+ '' +
+ '' +
+ '' +
+ '';
+ var nW = global.open();
+ if (nW !== null) {
+ nW.document.write(htmlForNewWindow)
+ }
if (nW || typeof safari === "undefined") return nW;
/* pass through */
case 'datauri':
@@ -1198,7 +1171,7 @@ var jsPDF = (function (global) {
/**
* Used to see if a supplied hotfix was requested when the pdf instance was created.
- * @param {String} hotfixName - The name of the hotfix to check.
+ * @param {string} hotfixName - The name of the hotfix to check.
* @returns {boolean}
*/
hasHotfix = function (hotfixName) {
@@ -1248,18 +1221,11 @@ var jsPDF = (function (global) {
/**
* Object exposing internal API to plugins
* @public
+ * @ignore
*/
API.internal = {
'pdfEscape': pdfEscape,
'getStyle': getStyle,
- /**
- * Returns {FontObject} describing a particular font.
- * @public
- * @function
- * @param fontName {String} (Optional) Font's family name
- * @param fontStyle {String} (Optional) Font's style variation name (Example:"Italic")
- * @returns {FontObject}
- */
'getFont': function () {
return fonts[getFont.apply(API, arguments)];
},
@@ -1349,45 +1315,67 @@ var jsPDF = (function (global) {
};
/**
- * Adds (and transfers the focus to) new page to the PDF document.
- * @param format {String/Array} The format of the new page. Can be - a0 - a10
- b0 - b10
- c0 - c10
- c0 - c10
- dl
- letter
- government-letter
- legal
- junior-legal
- ledger
- tabloid
- credit-card
- * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array , e.g. [595.28, 841.89]
- * @param orientation {String} Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l")
- * @function
- * @returns {jsPDF}
- *
- * @methodOf jsPDF#
- * @name addPage
- */
+ * Adds (and transfers the focus to) new page to the PDF document.
+ * @param format {String/Array} The format of the new page. Can be - a0 - a10
- b0 - b10
- c0 - c10
- c0 - c10
- dl
- letter
- government-letter
- legal
- junior-legal
- ledger
- tabloid
- credit-card
+ * Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array , e.g. [595.28, 841.89]
+ * @param orientation {string} Orientation of the new page. Possible values are "portrait" or "landscape" (or shortcuts "p" (Default), "l")
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ *
+ * @memberOf jsPDF
+ * @name addPage
+ */
API.addPage = function () {
_addPage.apply(this, arguments);
return this;
};
/**
- * Adds (and transfers the focus to) new page to the PDF document.
- * @function
- * @returns {jsPDF}
- *
- * @methodOf jsPDF#
- * @name setPage
- * @param {Number} page Switch the active page to the page number specified
- * @example
- * doc = jsPDF()
- * doc.addPage()
- * doc.addPage()
- * doc.text('I am on page 3', 10, 10)
- * doc.setPage(1)
- * doc.text('I am on page 1', 10, 10)
- */
+ * Adds (and transfers the focus to) new page to the PDF document.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ *
+ * @memberOf jsPDF
+ * @name setPage
+ * @param {number} page Switch the active page to the page number specified
+ * @example
+ * doc = jsPDF()
+ * doc.addPage()
+ * doc.addPage()
+ * doc.text('I am on page 3', 10, 10)
+ * doc.setPage(1)
+ * doc.text('I am on page 1', 10, 10)
+ */
API.setPage = function () {
_setPage.apply(this, arguments);
return this;
};
+
+ /**
+ * @name insertPage
+ * @memberOf jsPDF
+ *
+ * @function
+ * @instance
+ * @param {Object} beforePage
+ * @returns {jsPDF}
+ */
API.insertPage = function (beforePage) {
this.addPage();
this.movePage(currentPage, beforePage);
return this;
};
+
+ /**
+ * @name movePage
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ * @param {Object} targetPage
+ * @param {Object} beforePage
+ * @returns {jsPDF}
+ */
API.movePage = function (targetPage, beforePage) {
if (targetPage > beforePage) {
var tmpPages = pages[targetPage];
@@ -1419,25 +1407,64 @@ var jsPDF = (function (global) {
return this;
};
+ /**
+ * @name deletePage
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ */
API.deletePage = function () {
_deletePage.apply(this, arguments);
return this;
};
+ /**
+ * @name setCreationDate
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ * @param {Object} date
+ * @returns {jsPDF}
+ */
API.setCreationDate = function (date) {
setCreationDate(date);
return this;
}
+ /**
+ * @name getCreationDate
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ * @param {Object} type
+ * @returns {Object}
+ */
API.getCreationDate = function (type) {
return getCreationDate(type);
}
+ /**
+ * @name setFileId
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ * @param {string} value GUID
+ * @returns {jsPDF}
+ */
API.setFileId = function (value) {
setFileId(value);
return this;
}
+ /**
+ * @name getFileId
+ * @memberOf jsPDF
+ * @function
+ * @instance
+ *
+ * @returns {string} GUID
+ */
API.getFileId = function () {
return getFileId();
}
@@ -1446,6 +1473,10 @@ var jsPDF = (function (global) {
/**
* Set the display mode options of the page like zoom and layout.
*
+ * @name setDisplayMode
+ * @memberOf jsPDF
+ * @function
+ * @instance
* @param {integer|String} zoom You can pass an integer or percentage as
* a string. 2 will scale the document up 2x, '200%' will scale up by the
* same amount. You can also set it to 'fullwidth', 'fullheight',
@@ -1453,18 +1484,16 @@ var jsPDF = (function (global) {
*
* Only certain PDF readers support this, such as Adobe Acrobat
*
- * @param {String} layout Layout mode can be: 'continuous' - this is the
+ * @param {string} layout Layout mode can be: 'continuous' - this is the
* default continuous scroll. 'single' - the single page mode only shows one
* page at a time. 'twoleft' - two column left mode, first page starts on
* the left, and 'tworight' - pages are laid out in two columns, with the
* first page on the right. This would be used for books.
- * @param {String} pmode 'UseOutlines' - it shows the
+ * @param {string} pmode 'UseOutlines' - it shows the
* outline of the document on the left. 'UseThumbs' - shows thumbnails along
* the left. 'FullScreen' - prompts the user to enter fullscreen mode.
*
- * @function
* @returns {jsPDF}
- * @name setDisplayMode
*/
API.setDisplayMode = function (zoom, layout, pmode) {
zoomMode = zoom;
@@ -1476,21 +1505,22 @@ var jsPDF = (function (global) {
throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' + pmode + '" is not recognized.')
}
return this;
- };
+ };
- /**
- * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
- *
- * @function
- * @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Object} options Collection of settings signalling how the text must be encoded. Defaults are sane. If you think you want to pass some flags, you likely can read the source.
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name text
- */
- API.text = function(text, x, y, options) {
+ /**
+ * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
+ *
+ * @function
+ * @instance
+ * @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {Object} options Collection of settings signalling how the text must be encoded. Defaults are sane. If you think you want to pass some flags, you likely can read the source.
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name text
+ */
+ API.text = function(text, x, y, options) {
/**
* Inserts something like this into PDF
* BT
@@ -1539,30 +1569,30 @@ var jsPDF = (function (global) {
}
function processTextByFunction(text, processingFunction) {
- var result;
- if (typeof text === 'string') {
- result = processingFunction(text)[0];
- } else if (Object.prototype.toString.call(text) === '[object Array]') {
- //we don't want to destroy original text array, so cloning it
- var sa = text.concat();
- var da = [];
- var len = sa.length;
- var curDa;
- var tmpResult;
- //we do array.join('text that must not be PDFescaped")
- //thus, pdfEscape each component separately
- while (len--) {
- curDa = sa.shift();
- if (typeof curDa === "string") {
- da.push(processingFunction(curDa)[0]);
- } else if(((Object.prototype.toString.call(curDa) === '[object Array]') && curDa[0] === "string")){
- tmpResult = processingFunction(curDa[0], curDa[1], curDa[2]);
- da.push([tmpResult[0], tmpResult[1], tmpResult[2]]);
- }
- }
- result = da;
- }
- return result;
+ var result;
+ if (typeof text === 'string') {
+ result = processingFunction(text)[0];
+ } else if (Object.prototype.toString.call(text) === '[object Array]') {
+ //we don't want to destroy original text array, so cloning it
+ var sa = text.concat();
+ var da = [];
+ var len = sa.length;
+ var curDa;
+ var tmpResult;
+ //we do array.join('text that must not be PDFescaped")
+ //thus, pdfEscape each component separately
+ while (len--) {
+ curDa = sa.shift();
+ if (typeof curDa === "string") {
+ da.push(processingFunction(curDa)[0]);
+ } else if(((Object.prototype.toString.call(curDa) === '[object Array]') && curDa[0] === "string")){
+ tmpResult = processingFunction(curDa[0], curDa[1], curDa[2]);
+ da.push([tmpResult[0], tmpResult[1], tmpResult[2]]);
+ }
+ }
+ result = da;
+ }
+ return result;
}
//backwardsCompatibility
@@ -1949,21 +1979,22 @@ var jsPDF = (function (global) {
out(result);
return scope;
- };
+ };
/**
- * Letter spacing method to print text with gaps
- *
- * @function
- * @param {String|Array} text String to be added to the page.
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} spacing Spacing (in units declared at inception)
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name lstext
- * @deprecated We'll be removing this function. It doesn't take character width into account.
- */
+ * Letter spacing method to print text with gaps
+ *
+ * @function
+ * @instance
+ * @param {String|Array} text String to be added to the page.
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} spacing Spacing (in units declared at inception)
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name lstext
+ * @deprecated We'll be removing this function. It doesn't take character width into account.
+ */
API.lstext = function (text, x, y, spacing) {
console.warn('jsPDF.lstext is deprecated');
for (var i = 0, len = text.length; i < len; i++, x += spacing) this
@@ -1971,12 +2002,35 @@ var jsPDF = (function (global) {
return this;
};
+ /**
+ * Draw a line on the current page
+ *
+ * @name line
+ * @function
+ * @instance
+ * @param {number} x1
+ * @param {number} y1
+ * @param {number} x2
+ * @param {number} y2
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ */
API.line = function (x1, y1, x2, y2) {
return this.lines([
[x2 - x1, y2 - y1]
], x1, y1);
};
+ /**
+ *
+ * @name clip
+ * @function
+ * @instance
+ * @param {string} rule
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @description all .clip() after calling drawing ops with a style argument of null
+ */
API.clip = function (rule) {
// Call .clip() after calling drawing ops with a style argument of null
// W is the PDF clipping op
@@ -1995,31 +2049,33 @@ var jsPDF = (function (global) {
* This fixes the previous function clip(). Perhaps the 'stroke path' hack was due to the missing 'n' instruction?
* We introduce the fixed version so as to not break API.
* @param fillRule
+ * @ignore
*/
API.clip_fixed = function (rule) {
- console.log("clip_fixed is deprecated");
- API.clip(rule);
+ console.log("clip_fixed is deprecated");
+ API.clip(rule);
};
/**
- * 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, 10) // line, line, bezier curve, line
- * @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @param {Boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name lines
- */
+ * 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, 10) // line, line, bezier curve, line
+ * @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @param {boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name lines
+ */
API.lines = function (lines, x, y, scale, style, closed) {
var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4;
@@ -2086,18 +2142,19 @@ var jsPDF = (function (global) {
};
/**
- * Adds a rectangle to PDF
- *
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} w Width (in units declared at inception of PDF document)
- * @param {Number} h Height (in units declared at inception of PDF document)
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name rect
- */
+ * Adds a rectangle to PDF
+ *
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} w Width (in units declared at inception of PDF document)
+ * @param {number} h Height (in units declared at inception of PDF document)
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name rect
+ */
API.rect = function (x, y, w, h, style) {
var op = getStyle(style);
out([
@@ -2116,20 +2173,21 @@ var jsPDF = (function (global) {
};
/**
- * Adds a triangle to PDF
- *
- * @param {Number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name triangle
- */
+ * Adds a triangle to PDF
+ *
+ * @param {number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name triangle
+ */
API.triangle = function (x1, y1, x2, y2, x3, y3, style) {
this.lines(
[
@@ -2146,20 +2204,21 @@ var jsPDF = (function (global) {
};
/**
- * Adds a rectangle with rounded corners to PDF
- *
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} w Width (in units declared at inception of PDF document)
- * @param {Number} h Height (in units declared at inception of PDF document)
- * @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
- * @param {Number} rx Radius along y axis (in units declared at inception of PDF document)
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name roundedRect
- */
+ * Adds a rectangle with rounded corners to PDF
+ *
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} w Width (in units declared at inception of PDF document)
+ * @param {number} h Height (in units declared at inception of PDF document)
+ * @param {number} rx Radius along x axis (in units declared at inception of PDF document)
+ * @param {number} rx Radius along y axis (in units declared at inception of PDF document)
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name roundedRect
+ */
API.roundedRect = function (x, y, w, h, rx, ry, style) {
var MyArc = 4 / 3 * (Math.SQRT2 - 1);
this.lines(
@@ -2181,18 +2240,19 @@ var jsPDF = (function (global) {
};
/**
- * Adds an ellipse to PDF
- *
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
- * @param {Number} rx Radius along y axis (in units declared at inception of PDF document)
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name ellipse
- */
+ * Adds an ellipse to PDF
+ *
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} rx Radius along x axis (in units declared at inception of PDF document)
+ * @param {number} rx Radius along y axis (in units declared at inception of PDF document)
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name ellipse
+ */
API.ellipse = function (x, y, rx, ry, style) {
var lx = 4 / 3 * (Math.SQRT2 - 1) * rx,
ly = 4 / 3 * (Math.SQRT2 - 1) * ry;
@@ -2245,30 +2305,32 @@ var jsPDF = (function (global) {
};
/**
- * Adds an circle to PDF
- *
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} r Radius (in units declared at inception of PDF document)
- * @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name circle
- */
+ * Adds an circle to PDF
+ *
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} r Radius (in units declared at inception of PDF document)
+ * @param {string} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name circle
+ */
API.circle = function (x, y, r, style) {
return this.ellipse(x, y, r, r, style);
};
/**
- * Adds a properties to the PDF document
- *
- * @param {Object} A property_name-to-property_value object structure.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setProperties
- */
+ * Adds a properties to the PDF document
+ *
+ * @param {Object} A property_name-to-property_value object structure.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setProperties
+ */
API.setProperties = function (properties) {
// copying only those properties we can render.
for (var property in documentProperties) {
@@ -2281,46 +2343,49 @@ var jsPDF = (function (global) {
};
/**
- * Sets font size for upcoming text elements.
- *
- * @param {Number} size Font size in points.
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setFontSize
- */
+ * Sets font size for upcoming text elements.
+ *
+ * @param {number} size Font size in points.
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setFontSize
+ */
API.setFontSize = function (size) {
activeFontSize = size;
return this;
};
/**
- * Sets text font face, variant for upcoming text elements.
- * See output of jsPDF.getFontList() for possible font names, styles.
- *
- * @param {String} fontName Font name or family. Example: "times"
- * @param {String} fontStyle Font style or variant. Example: "italic"
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setFont
- */
+ * Sets text font face, variant for upcoming text elements.
+ * See output of jsPDF.getFontList() for possible font names, styles.
+ *
+ * @param {string} fontName Font name or family. Example: "times"
+ * @param {string} fontStyle Font style or variant. Example: "italic"
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setFont
+ */
API.setFont = function (fontName, fontStyle) {
activeFontKey = getFont(fontName, fontStyle, {disableWarning: false});
return this;
};
/**
- * Switches font style or variant for upcoming text elements,
- * while keeping the font face or family same.
- * See output of jsPDF.getFontList() for possible font names, styles.
- *
- * @param {String} style Font style or variant. Example: "italic"
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setFontStyle
- */
+ * Switches font style or variant for upcoming text elements,
+ * while keeping the font face or family same.
+ * See output of jsPDF.getFontList() for possible font names, styles.
+ *
+ * @param {string} style Font style or variant. Example: "italic"
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setFontStyle
+ */
API.setFontStyle = API.setFontType = function (style) {
activeFontKey = getFont(undefined, style);
// if font is not found, the above line blows up and we never go further
@@ -2328,15 +2393,16 @@ var jsPDF = (function (global) {
};
/**
- * Returns an object - a tree of fontName to fontStyle relationships available to
- * active PDF document.
- *
- * @public
- * @function
- * @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }
- * @methodOf jsPDF#
- * @name getFontList
- */
+ * Returns an object - a tree of fontName to fontStyle relationships available to
+ * active PDF document.
+ *
+ * @public
+ * @function
+ * @instance
+ * @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }
+ * @memberOf jsPDF
+ * @name getFontList
+ */
API.getFontList = function () {
// TODO: iterate over fonts array or return copy of fontmap instead in case more are ever added.
var list = {},
@@ -2357,30 +2423,32 @@ var jsPDF = (function (global) {
};
/**
- * Add a custom font.
- *
- * @param {String} Postscript name of the Font. Example: "Menlo-Regular"
- * @param {String} Name of font-family from @font-face definition. Example: "Menlo Regular"
- * @param {String} Font style. Example: "normal"
- * @function
- * @returns the {fontKey} (same as the internal method)
- * @methodOf jsPDF#
- * @name addFont
- */
+ * Add a custom font to the current instance.
+ *
+ * @property {string} postScriptName PDF specification full name for the font
+ * @property {string} id PDF-document-instance-specific label assinged to the font.
+ * @property {string} fontStyle Style of the Font.
+ * @property {Object} encoding Encoding_name-to-Font_metrics_object mapping.
+ * @function
+ * @instance
+ * @memberOf jsPDF
+ * @name addFont
+ */
API.addFont = function(postScriptName, fontName, fontStyle, encoding) {
encoding = encoding || 'Identity-H';
addFont(postScriptName, fontName, fontStyle, encoding);
};
/**
- * Sets line width for upcoming lines.
- *
- * @param {Number} width Line width (in units declared at inception of PDF document)
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setLineWidth
- */
+ * Sets line width for upcoming lines.
+ *
+ * @param {number} width Line width (in units declared at inception of PDF document)
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setLineWidth
+ */
API.setLineWidth = function (width) {
out((width * k).toFixed(2) + ' w');
return this;
@@ -2413,14 +2481,15 @@ var jsPDF = (function (global) {
* floating point nearest to binary representation) it is highly advised to
* communicate the fractional numbers as String types, not JavaScript Number type.
*
- * @param {Number|String} ch1 Color channel value or {String} ch1 color value in hexadecimal, example: '#FFFFFF'
+ * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'
* @param {Number|String} ch2 Color channel value
* @param {Number|String} ch3 Color channel value
* @param {Number|String} ch4 Color channel value
*
* @function
+ * @instance
* @returns {jsPDF}
- * @methodOf jsPDF#
+ * @memberOf jsPDF
* @name setDrawColor
*/
API.setDrawColor = function(ch1, ch2, ch3, ch4) {
@@ -2438,43 +2507,43 @@ var jsPDF = (function (global) {
};
/**
- * Sets the fill color for upcoming elements.
- *
- * Depending on the number of arguments given, Gray, RGB, or CMYK
- * color space is implied.
- *
- * When only ch1 is given, "Gray" color space is implied and it
- * must be a value in the range from 0.00 (solid black) to to 1.00 (white)
- * if values are communicated as String types, or in range from 0 (black)
- * to 255 (white) if communicated as Number type.
- * The RGB-like 0-255 range is provided for backward compatibility.
- *
- * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
- * value must be in the range from 0.00 (minimum intensity) to to 1.00
- * (max intensity) if values are communicated as String types, or
- * from 0 (min intensity) to to 255 (max intensity) if values are communicated
- * as Number types.
- * The RGB-like 0-255 range is provided for backward compatibility.
- *
- * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
- * value must be a in the range from 0.00 (0% concentration) to to
- * 1.00 (100% concentration)
- *
- * Because JavaScript treats fixed point numbers badly (rounds to
- * floating point nearest to binary representation) it is highly advised to
- * communicate the fractional numbers as String types, not JavaScript Number type.
- *
- * @param {Number|String} ch1 Color channel value or {String} ch1 color value in hexadecimal, example: '#FFFFFF'
- * @param {Number|String} ch2 Color channel value
- * @param {Number|String} ch3 Color channel value
- * @param {Number|String} ch4 Color channel value
- *
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setFillColor
- */
-
+ * Sets the fill color for upcoming elements.
+ *
+ * Depending on the number of arguments given, Gray, RGB, or CMYK
+ * color space is implied.
+ *
+ * When only ch1 is given, "Gray" color space is implied and it
+ * must be a value in the range from 0.00 (solid black) to to 1.00 (white)
+ * if values are communicated as String types, or in range from 0 (black)
+ * to 255 (white) if communicated as Number type.
+ * The RGB-like 0-255 range is provided for backward compatibility.
+ *
+ * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
+ * value must be in the range from 0.00 (minimum intensity) to to 1.00
+ * (max intensity) if values are communicated as String types, or
+ * from 0 (min intensity) to to 255 (max intensity) if values are communicated
+ * as Number types.
+ * The RGB-like 0-255 range is provided for backward compatibility.
+ *
+ * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
+ * value must be a in the range from 0.00 (0% concentration) to to
+ * 1.00 (100% concentration)
+ *
+ * Because JavaScript treats fixed point numbers badly (rounds to
+ * floating point nearest to binary representation) it is highly advised to
+ * communicate the fractional numbers as String types, not JavaScript Number type.
+ *
+ * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'
+ * @param {Number|String} ch2 Color channel value
+ * @param {Number|String} ch3 Color channel value
+ * @param {Number|String} ch4 Color channel value
+ *
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setFillColor
+ */
API.setFillColor = function(ch1, ch2, ch3, ch4) {
var options = {
"ch1" : ch1,
@@ -2490,42 +2559,43 @@ var jsPDF = (function (global) {
};
/**
- * Sets the text color for upcoming elements.
- *
- * Depending on the number of arguments given, Gray, RGB, or CMYK
- * color space is implied.
- *
- * When only ch1 is given, "Gray" color space is implied and it
- * must be a value in the range from 0.00 (solid black) to to 1.00 (white)
- * if values are communicated as String types, or in range from 0 (black)
- * to 255 (white) if communicated as Number type.
- * The RGB-like 0-255 range is provided for backward compatibility.
- *
- * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
- * value must be in the range from 0.00 (minimum intensity) to to 1.00
- * (max intensity) if values are communicated as String types, or
- * from 0 (min intensity) to to 255 (max intensity) if values are communicated
- * as Number types.
- * The RGB-like 0-255 range is provided for backward compatibility.
- *
- * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
- * value must be a in the range from 0.00 (0% concentration) to to
- * 1.00 (100% concentration)
- *
- * Because JavaScript treats fixed point numbers badly (rounds to
- * floating point nearest to binary representation) it is highly advised to
- * communicate the fractional numbers as String types, not JavaScript Number type.
- *
- * @param {Number|String} ch1 Color channel value or {String} ch1 color value in hexadecimal, example: '#FFFFFF'
- * @param {Number|String} ch2 Color channel value
- * @param {Number|String} ch3 Color channel value
- * @param {Number|String} ch4 Color channel value
- *
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setTextColor
- */
+ * Sets the text color for upcoming elements.
+ *
+ * Depending on the number of arguments given, Gray, RGB, or CMYK
+ * color space is implied.
+ *
+ * When only ch1 is given, "Gray" color space is implied and it
+ * must be a value in the range from 0.00 (solid black) to to 1.00 (white)
+ * if values are communicated as String types, or in range from 0 (black)
+ * to 255 (white) if communicated as Number type.
+ * The RGB-like 0-255 range is provided for backward compatibility.
+ *
+ * When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
+ * value must be in the range from 0.00 (minimum intensity) to to 1.00
+ * (max intensity) if values are communicated as String types, or
+ * from 0 (min intensity) to to 255 (max intensity) if values are communicated
+ * as Number types.
+ * The RGB-like 0-255 range is provided for backward compatibility.
+ *
+ * When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
+ * value must be a in the range from 0.00 (0% concentration) to to
+ * 1.00 (100% concentration)
+ *
+ * Because JavaScript treats fixed point numbers badly (rounds to
+ * floating point nearest to binary representation) it is highly advised to
+ * communicate the fractional numbers as String types, not JavaScript Number type.
+ *
+ * @param {Number|String} ch1 Color channel value or {string} ch1 color value in hexadecimal, example: '#FFFFFF'
+ * @param {Number|String} ch2 Color channel value
+ * @param {Number|String} ch3 Color channel value
+ * @param {Number|String} ch4 Color channel value
+ *
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setTextColor
+ */
API.setTextColor = function(ch1, ch2, ch3, ch4) {
var options = {
"ch1" : ch1,
@@ -2540,33 +2610,31 @@ var jsPDF = (function (global) {
return this;
};
-
/**
- * Initializes the default character set that the user wants to be global..
- *
- * @param {Number} charSpace
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setCharSpace
- */
-
+ * Initializes the default character set that the user wants to be global..
+ *
+ * @param {number} charSpace
+ * @function
+ * @instance
+ * @returns {jsPDF} jsPDF-instance
+ * @memberOf jsPDF
+ * @name setCharSpace
+ */
API.setCharSpace = function (charSpace) {
activeCharSpace = charSpace;
return this;
};
-
/**
- * Initializes the default character set that the user wants to be global..
- *
- * @param {Boolean} boolean
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setR2L
- */
-
+ * Initializes the default character set that the user wants to be global..
+ *
+ * @param {boolean} boolean
+ * @function
+ * @instance
+ * @returns {jsPDF} jsPDF-instance
+ * @memberOf jsPDF
+ * @name setR2L
+ */
API.setR2L = function (boolean) {
R2L = boolean;
return this;
@@ -2577,8 +2645,7 @@ var jsPDF = (function (global) {
* integer flag values designating the varieties of line cap
* and join styles.
*
- * @returns {Object}
- * @fieldOf jsPDF#
+ * @memberOf jsPDF
* @name CapJoinStyles
*/
API.CapJoinStyles = {
@@ -2598,15 +2665,16 @@ var jsPDF = (function (global) {
};
/**
- * Sets the line cap styles
- * See {jsPDF.CapJoinStyles} for variants
- *
- * @param {String|Number} style A string or number identifying the type of line cap
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setLineCap
- */
+ * Sets the line cap styles
+ * See {jsPDF.CapJoinStyles} for variants
+ *
+ * @param {String|Number} style A string or number identifying the type of line cap
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setLineCap
+ */
API.setLineCap = function (style) {
var id = this.CapJoinStyles[style];
if (id === undefined) {
@@ -2621,15 +2689,16 @@ var jsPDF = (function (global) {
};
/**
- * Sets the line join styles
- * See {jsPDF.CapJoinStyles} for variants
- *
- * @param {String|Number} style A string or number identifying the type of line join
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name setLineJoin
- */
+ * Sets the line join styles
+ * See {jsPDF.CapJoinStyles} for variants
+ *
+ * @param {String|Number} style A string or number identifying the type of line join
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name setLineJoin
+ */
API.setLineJoin = function (style) {
var id = this.CapJoinStyles[style];
if (id === undefined) {
@@ -2643,18 +2712,32 @@ var jsPDF = (function (global) {
return this;
};
- // Output is both an internal (for plugins) and external function
+ /**
+ * Generates the PDF document.
+ *
+ * If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
+ *
+ * @param {string} type A string identifying one of the possible output types.
+ * @param {Object} options An object providing some additional signalling to PDF generator.
+ *
+ * @function
+ * @instance
+ * @returns {jsPDF}
+ * @memberOf jsPDF
+ * @name output
+ */
API.output = output;
/**
- * Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf')
- * @param {String} filename The filename including extension.
- *
- * @function
- * @returns {jsPDF}
- * @methodOf jsPDF#
- * @name save
- */
+ * Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf')
+ *
+ * @memberOf jsPDF
+ * @name save
+ * @function
+ * @instance
+ * @param {string} filename The filename including extension.
+ * @returns {jsPDF} jsPDF-instance
+ */
API.save = function (filename) {
API.output('save', filename);
};
@@ -2714,9 +2797,6 @@ var jsPDF = (function (global) {
*
* 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.
- * Examples:
- * jsPDF.API.events['initialized'] = function(){ 'this' is API object }
- * jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }
*
* @static
* @public
@@ -2736,6 +2816,12 @@ var jsPDF = (function (global) {
jsPDF.API = {
events: []
};
+ /**
+ * The version of jsPDF
+ * @name version
+ * @type {number}
+ * @memberOf jsPDF
+ */
jsPDF.version = ("${versionID}" === ("${vers" + "ionID}")) ? "0.0.0" : "${versionID}";
if (typeof define === 'function' && define.amd) {
diff --git a/package.json b/package.json
index 89feae5e0..2f68bfd14 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"html2canvas": "1.0.0-alpha.12",
"omggif": "1.0.7",
"promise-polyfill": "8.1.0",
- "stackblur": "^1.0.0"
+ "stackblur-canvas": "1.4.1"
},
"devDependencies": {
"@babel/core": "^7.0.0",
@@ -34,6 +34,7 @@
"codeclimate-test-reporter": "0.5.0",
"diff": "3.5.0",
"docdash": "1.0.0",
+ "folder-delete": "1.0.3",
"gulp-babel": "^8.0.0",
"jasmine-core": "3.2.1",
"js-yaml": "3.12.0",
@@ -61,6 +62,7 @@
"version": "npm run build && git add -A dist",
"test": "./node_modules/.bin/karma start saucelabs.karma.conf.js --single-run --verbose && for a in coverage/*; do codeclimate-test-reporter < \"$a/lcov.info\"; break; done",
"test-local": "node tests/utils/reference-server.js & karma start",
- "generate-docs": "node_modules/.bin/jsdoc -c jsdoc.json --readme README.md"
+ "delete-docs": "node deletedocs.js",
+ "generate-docs": "./node_modules/.bin/jsdoc -c jsdoc.json --readme README.md"
}
}
diff --git a/plugins/acroform.js b/plugins/acroform.js
index 8e621a7c0..dbe1b310c 100644
--- a/plugins/acroform.js
+++ b/plugins/acroform.js
@@ -1,10 +1,17 @@
/**
- * jsPDF AcroForm Plugin Copyright (c) 2016 Alexander Weidt,
+ * @license
+ * Copyright (c) 2016 Alexander Weidt,
* https://github.com/BiggA94
*
* Licensed under the MIT License. http://opensource.org/licenses/mit-license
*/
+ /**
+ * jsPDF AcroForm Plugin
+ *
+ * @name AcroForm
+ * @module
+ */
(function (jsPDFAPI, globalObj) {
'use strict';
@@ -376,7 +383,7 @@
};
/**
- * small workaround for calculating the TextMetric approximately
+ * Small workaround for calculating the TextMetric approximately.
*
* @param text
* @param fontsize
@@ -1181,7 +1188,12 @@
return child;
};
-
+ /**
+ * @name AcroFormCheckBox
+ *
+ * @memberOf AcroForm
+ * @function
+ */
var AcroFormCheckBox = function () {
AcroFormButton.call(this);
this.appearanceStreamContent = AcroFormAppearance.CheckBox.createAppearanceStream();
@@ -1525,8 +1537,9 @@
/**
* Creates the Actual AppearanceDictionary-References
*
- * @param name
- * @returns
+ * @param {string} name
+ * @returns {Object}
+ * @ignore
*/
createAppearanceStream: function (name) {
var appearanceStreamContent = {
@@ -1661,6 +1674,14 @@
// Public:
+ /**
+ * Add an AcroForm-Field to the {jsPDF}-instance
+ *
+ * @memberOf AcroForm
+ * @name addField
+ * @param {Object} fieldObject
+ * @returns {jsPDF}
+ */
jsPDFAPI.addField = function (fieldObject) {
initializeAcroForm.call(this);
// var opt = parseOptions(fieldObject);
@@ -1681,7 +1702,9 @@
};
/**
- * Button FT = Btn
+ * @name addButton
+ * @param {AcroFormButton}
+ * @memberOf AcroForm
*/
jsPDFAPI.addButton = function (opts) {
initializeAcroForm.call(this);
diff --git a/plugins/addimage.js b/plugins/addimage.js
index a7bf5bac9..79b13b91a 100644
--- a/plugins/addimage.js
+++ b/plugins/addimage.js
@@ -1,4 +1,4 @@
-/** @preserve
+/** @license
* jsPDF addImage plugin
* Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/
* 2013 Chris Dowling, https://github.com/gingerchris
@@ -27,7 +27,10 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-
+/**
+* @name addImage
+* @module
+*/
;(function(jsPDFAPI) {
'use strict'
@@ -63,11 +66,10 @@
* @name getImageFileTypeByImageData
* @public
* @function
- * @param {String} imageData as base64 encoded DataUrl
- * @param {String} format of file if filetype-recognition fails, e.g. 'JPEG'
+ * @param {string|arraybuffer} imageData imageData as base64 encoded DataUrl or arraybuffer
+ * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG'
*
- * @returns {String} filetype of Image
- * @methodOf jsPDF#
+ * @returns {string} filetype of Image
*/
jsPDFAPI.getImageFileTypeByImageData = function (imageData, fallbackFormat) {
fallbackFormat = fallbackFormat || 'UNKNOWN';
@@ -372,11 +374,23 @@
SLOW: 'SLOW'
};
+ /**
+ * @name sHashCode
+ * @function
+ * @param {string} str
+ * @returns {string}
+ */
jsPDFAPI.sHashCode = function(str) {
str = str || "";
return Array.prototype.reduce && str.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
};
+ /**
+ * @name isString
+ * @function
+ * @param {any} object
+ * @returns {boolean}
+ */
jsPDFAPI.isString = function(object) {
return typeof object === 'string';
};
@@ -389,7 +403,6 @@
* @param {String} possible Base64-String
*
* @returns {boolean}
- * @methodOf jsPDF#
*/
jsPDFAPI.validateStringAsBase64 = function(possibleBase64String) {
possibleBase64String = possibleBase64String || '';
@@ -413,8 +426,11 @@
/**
* Strips out and returns info from a valid base64 data URI
- * @param {String[dataURI]} a valid data URI of format 'data:[][;base64],'
- * @returns an Array containing the following
+ *
+ * @name extractInfoFromBase64DataURI
+ * @function
+ * @param {string} dataUrl a valid data URI of format 'data:[][;base64],'
+ * @returns {Array}an Array containing the following
* [0] the complete data URI
* [1]
* [2] format - the second part of the mime-type i.e 'png' in 'image/png'
@@ -427,8 +443,9 @@
/**
* Check to see if ArrayBuffer is supported
*
+ * @name supportsArrayBuffer
+ * @function
* @returns {boolean}
- * @methodOf jsPDF#
*/
jsPDFAPI.supportsArrayBuffer = function() {
return typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined';
@@ -436,10 +453,12 @@
/**
* Tests supplied object to determine if ArrayBuffer
- * @param {Object[object]}
+ *
+ * @name isArrayBuffer
+ * @function
+ * @param {Object} object an Object
*
* @returns {boolean}
- * @methodOf jsPDF#
*/
jsPDFAPI.isArrayBuffer = function(object) {
if(!this.supportsArrayBuffer())
@@ -449,7 +468,11 @@
/**
* Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface
- * @param {Object[object]}
+ *
+ * @name isArrayBufferView
+ * @function
+ * @param {Object} object an Object
+ * @returns {boolean}
*/
jsPDFAPI.isArrayBufferView = function(object) {
if(!this.supportsArrayBuffer())
@@ -533,10 +556,11 @@
* Need to test if this is a better solution for larger files
*
* @name arrayBufferToBase64
+ * @param {arraybuffer} arrayBuffer
* @public
* @function
*
- * @returns {String}
+ * @returns {string}
*/
jsPDFAPI.arrayBufferToBase64 = function(arrayBuffer) {
var base64 = ''
@@ -591,16 +615,25 @@
};
/**
- * Converts an ArrayBuffer directly to base64
- *
- * Taken from http://jsperf.com/encoding-xhr-image-data/31
- *
- * Need to test if this is a better solution for larger files
- *
- * @public
+ *
+ * @name createImageInfo
+ * @param {Object} data
+ * @param {number} wd width
+ * @param {number} ht height
+ * @param {Object} cs colorSpace
+ * @param {number} bpc bits per channel
+ * @param {any} f
+ * @param {number} imageIndex
+ * @param {string} alias
+ * @param {any} dp
+ * @param {any} trns
+ * @param {any} pal
+ * @param {any} smask
+ * @param {any} p
+ * @public
* @function
*
- * @returns {String}
+ * @returns {Object}
*/
jsPDFAPI.createImageInfo = function(data, wd, ht, cs, bpc, f, imageIndex, alias, dp, trns, pal, smask, p) {
var info = {
@@ -629,18 +662,17 @@
* @name addImage
* @public
* @function
- * @param {String/Image-Element/Canvas-Element/Uint8Array} imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement
- * @param {String} format of file if filetype-recognition fails, e.g. 'JPEG'
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} width of the image (in units declared at inception of PDF document)
- * @param {Number} height of the Image (in units declared at inception of PDF document)
- * @param {String} alias of the image (if used multiple times)
- * @param {String} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'
- * @param {Number} rotation of the image in degrees (0-359)
+ * @param {string/Image-Element/Canvas-Element/Uint8Array} imageData imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement
+ * @param {string} format format of file if filetype-recognition fails, e.g. 'JPEG'
+ * @param {number} x x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} width width of the image (in units declared at inception of PDF document)
+ * @param {number} height height of the Image (in units declared at inception of PDF document)
+ * @param {string} alias alias of the image (if used multiple times)
+ * @param {string} compression compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'
+ * @param {number} rotation rotation of the image in degrees (0-359)
*
* @returns jsPDF
- * @methodOf jsPDF#
*/
jsPDFAPI.addImage = function(imageData, format, x, y, w, h, alias, compression, rotation) {
'use strict'
@@ -737,6 +769,12 @@
return this
};
+ /**
+ * @name convertStringToImageData
+ * @function
+ * @param {string} stringData
+ * @returns {string} binary data
+ */
jsPDFAPI.convertStringToImageData = function (stringData) {
var base64Info;
var imageData = '';
@@ -833,6 +871,9 @@
return data.subarray(offset, offset+ 5);
};
+ /**
+ * @ignore
+ */
jsPDFAPI.processJPEG = function(data, index, alias, compression, dataAsBinaryString, colorSpace) {
'use strict'
var filter = this.decode.DCT_DECODE,
@@ -877,11 +918,20 @@
return this.createImageInfo(data, dims.width, dims.height, colorSpace, bpc, filter, index, alias);
};
+ /**
+ * @ignore
+ */
jsPDFAPI.processJPG = function(/*data, index, alias, compression, dataAsBinaryString*/) {
return this.processJPEG.apply(this, arguments);
}
-
+ /**
+ * @name loadImageFile
+ * @function
+ * @param {string} path
+ * @param {boolean} sync
+ * @param {function} callback
+ */
jsPDFAPI.loadImageFile = function (path, sync, callback) {
sync = sync || true;
callback = callback || function () {};
@@ -930,6 +980,12 @@
}
}
+ /**
+ * @name getImageProperties
+ * @function
+ * @param {Object} imageData
+ * @returns {Object}
+ */
jsPDFAPI.getImageProperties = function (imageData) {
var info;
var tmpImageData = '';
diff --git a/plugins/annotations.js b/plugins/annotations.js
index ec9bb4bd4..f648033f6 100644
--- a/plugins/annotations.js
+++ b/plugins/annotations.js
@@ -1,5 +1,5 @@
/**
- * jsPDF Annotations PlugIn
+ * @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
@@ -7,6 +7,8 @@
*/
/**
+ * 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.
*
@@ -30,6 +32,8 @@
* actions other than URL and GotoPage
* background / hover actions
*
+ * @name annotations
+ * @module
*/
/*
@@ -48,7 +52,6 @@
FitBH
FitBV
*/
-
(function(jsPDFAPI) {
'use strict';
@@ -209,6 +212,11 @@
this.internal.write("]");
} ]);
+ /**
+ * @name createAnnotation
+ * @function
+ * @param {Object} options
+ */
jsPDFAPI.createAnnotation = function(options) {
switch (options.type) {
case 'link':
@@ -222,9 +230,18 @@
}
/**
+ * Create a link
+ *
* valid options
* pageNumber or url [required]
* If pageNumber is specified, top and zoom may also be specified
+ * @name link
+ * @function
+ * @param {number} x
+ * @param {number} y
+ * @param {number} w
+ * @param {number} h
+ * @param {Object} options
*/
jsPDFAPI.link = function(x,y,w,h,options) {
'use strict';
@@ -241,6 +258,14 @@
/**
* Currently only supports single line text.
* Returns the width of the text/link
+ *
+ * @name textWithLink
+ * @function
+ * @param {string} text
+ * @param {number} x
+ * @param {number} y
+ * @param {Object} options
+ * @returns {number} width the width of the text/link
*/
jsPDFAPI.textWithLink = function(text,x,y,options) {
'use strict';
@@ -255,6 +280,12 @@
};
//TODO move into external library
+ /**
+ * @name getTextWidth
+ * @function
+ * @param {string} text
+ * @returns {number} txtWidth
+ */
jsPDFAPI.getTextWidth = function(text) {
'use strict';
var fontSize = this.internal.getFontSize();
@@ -263,6 +294,11 @@
};
//TODO move into external library
+ /**
+ * @name getLineHeight
+ * @function
+ * @returns {number} lineHeight
+ */
jsPDFAPI.getLineHeight = function() {
return this.internal.getLineHeight();
};
diff --git a/plugins/arabic.js b/plugins/arabic.js
index 93ee64036..c591a89aa 100644
--- a/plugins/arabic.js
+++ b/plugins/arabic.js
@@ -1,3 +1,17 @@
+/**
+ * @license
+ * Copyright (c) 2017 Aras Abbasi
+ *
+ * Licensed under the MIT License.
+ * http://opensource.org/licenses/mit-license
+ */
+
+/**
+* jsPDF arabic parser PlugIn
+*
+* @name arabic
+* @module
+*/
(function (jsPDFAPI) {
"use strict";
@@ -245,6 +259,13 @@
return replacementTable[character] || character;
}
+ /**
+ * @name processArabic
+ * @function
+ * @param {string} text
+ * @param {boolean} reverse
+ * @returns {string}
+ */
var processArabic = jsPDFAPI.processArabic = function (text, reverse) {
text = text || "";
reverse = reverse || false;
diff --git a/plugins/autoprint.js b/plugins/autoprint.js
index 77af263b3..9366517c9 100644
--- a/plugins/autoprint.js
+++ b/plugins/autoprint.js
@@ -1,26 +1,31 @@
-/**
+/** @license
* jsPDF Autoprint Plugin
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
+
+ /**
+ * @name autoprint
+ * @module
+ */
+(function (jsPDFAPI) {
+ 'use strict';
/**
* Makes the PDF automatically print. This works in Chrome, Firefox, Acrobat
* Reader.
*
- * @returns {jsPDF}
* @name autoPrint
+ * @function
+ * @param {Object} options (optional) Set the attribute variant to 'non-conform' (default) or 'javascript' to activate different methods of automatic printing when opening in a PDF-viewer .
+ * @returns {jsPDF}
* @example
- * var doc = new jsPDF()
- * doc.text(10, 10, 'This is a test')
- * doc.autoPrint()
- * doc.save('autoprint.pdf')
+ * var doc = new jsPDF();
+ * doc.text(10, 10, 'This is a test');
+ * doc.autoPrint({variant: 'non-conform'});
+ * doc.save('autoprint.pdf');
*/
-
-(function (jsPDFAPI) {
- 'use strict';
-
jsPDFAPI.autoPrint = function (options) {
'use strict'
var refAutoPrintTag;
diff --git a/plugins/bmp_support.js b/plugins/bmp_support.js
index 328e495d0..c9fe2e92e 100644
--- a/plugins/bmp_support.js
+++ b/plugins/bmp_support.js
@@ -1,11 +1,15 @@
/**
- * jsPDF bmp Support PlugIn
* Copyright (c) 2018 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
+/**
+* jsPDF bmp Support PlugIn
+* @name bmp_support
+* @module
+*/
(function (jsPDFAPI) {
'use strict';
diff --git a/plugins/canvas.js b/plugins/canvas.js
index f47457a69..9f85e88fb 100644
--- a/plugins/canvas.js
+++ b/plugins/canvas.js
@@ -1,5 +1,5 @@
/**
- * jsPDF Canvas PlugIn
+ * @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
@@ -7,11 +7,13 @@
*/
/**
+ * jsPDF Canvas PlugIn
* This plugin mimics the HTML5 Canvas
*
* The goal is to provide a way for current canvas users to print directly to a PDF.
+ * @name canvas
+ * @module
*/
-
(function(jsPDFAPI) {
'use strict';
@@ -21,7 +23,17 @@
}
]);
+ /**
+ * @name canvas
+ * @static
+ * @type {Object}
+ */
jsPDFAPI.canvas = {
+ /**
+ * @name getContext
+ * @function
+ * @param {string} the context type
+ */
getContext : function(name) {
this.pdf.context2d._canvas = this;
return this.pdf.context2d;
@@ -32,6 +44,12 @@
autoContext2dResizeY: true
}
+ /**
+ * Width of the canvas
+ *
+ * @name width
+ * @property {number} width
+ */
Object.defineProperty(jsPDFAPI.canvas, 'width', {
get : function() {
return this._width;
@@ -44,6 +62,12 @@
}
});
+ /**
+ * Height of the canvas
+ *
+ * @name height
+ * @property {number} height
+ */
Object.defineProperty(jsPDFAPI.canvas, 'height', {
get : function() {
return this._height;
diff --git a/plugins/cell.js b/plugins/cell.js
index 1a3a72966..5ca717a51 100644
--- a/plugins/cell.js
+++ b/plugins/cell.js
@@ -1,5 +1,6 @@
-/** ====================================================================
- * jsPDF Cell plugin
+/**
+ * @license
+ * ====================================================================
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
* 2013 Lee Driscoll, https://github.com/lsdriscoll
@@ -28,6 +29,10 @@
* ====================================================================
*/
+/**
+* @name cell
+* @module
+*/
(function (jsPDFAPI) {
'use strict';
/*jslint browser:true */
@@ -49,10 +54,21 @@
},
NO_MARGINS = {left:0, top:0, bottom: 0};
+ /**
+ * @name setHeaderFunction
+ * @function
+ * @param {function} func
+ */
jsPDFAPI.setHeaderFunction = function (func) {
headerFunction = func;
};
+ /**
+ * @name getTextDimensions
+ * @function
+ * @param {string} txt
+ * @returns {Object} dimensions
+ */
jsPDFAPI.getTextDimensions = function (txt) {
fontName = this.internal.getFont().fontName;
fontSize = this.table_font_size || this.internal.getFontSize();
@@ -88,6 +104,10 @@
return dimensions;
};
+ /**
+ * @name cellAddPage
+ * @function
+ */
jsPDFAPI.cellAddPage = function () {
var margins = this.margins || NO_MARGINS;
@@ -98,11 +118,27 @@
pages += 1;
};
+ /**
+ * @name cellInitialize
+ * @function
+ */
jsPDFAPI.cellInitialize = function () {
lastCellPos = { x: undefined, y: undefined, w: undefined, h: undefined, ln: undefined };
pages = 1;
};
+ /**
+ * @name cell
+ * @function
+ * @param {number} x
+ * @param {number} y
+ * @param {number} w
+ * @param {number} h
+ * @param {string} txt
+ * @param {number} ln lineNumber
+ * @param {string] align
+ * @return {jsPDF} jsPDF-instance
+ */
jsPDFAPI.cell = function (x, y, w, h, txt, ln, align) {
var curCell = getLastCellPosition();
var pgAdded = false;
@@ -154,9 +190,12 @@
/**
* Return the maximum value from an array
- * @param array
+ *
+ * @name arrayMax
+ * @function
+ * @param {Array} array
* @param comparisonFn
- * @returns {*}
+ * @returns {number}
*/
jsPDFAPI.arrayMax = function (array, comparisonFn) {
var max = array[0],
@@ -183,6 +222,8 @@
/**
* Create a table from a set of data.
+ * @name table
+ * @function
* @param {Integer} [x] : left-position for top-left corner of table
* @param {Integer} [y] top-position for top-left corner of table
* @param {Object[]} [data] As array of objects containing key-value pairs corresponding to a row of data.
@@ -192,6 +233,7 @@
* @param {Object} [config.autoSize] True to dynamically set the column widths to match the widest cell value
* @param {Object} [config.margins] margin values for left, top, bottom, and width
* @param {Object} [config.fontSize] Integer fontSize to use (optional)
+ * @returns {jsPDF} jsPDF-instance
*/
jsPDFAPI.table = function (x,y, data, headers, config) {
@@ -343,9 +385,13 @@
};
/**
* Calculate the height for containing the highest column
+ *
+ * @name calculateLineHeight
+ * @function
* @param {String[]} headerNames is the header, used as keys to the data
* @param {Integer[]} columnWidths is size of each column
* @param {Object[]} model is the line of data we want to calculate the height of
+ * @returns {number} lineHeight
*/
jsPDFAPI.calculateLineHeight = function (headerNames, columnWidths, model) {
var header, lineHeight = 0;
@@ -361,6 +407,9 @@
/**
* Store the config for outputting a table header
+ *
+ * @name setTableHeaderRow
+ * @function
* @param {Object[]} config
* An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell
* except the ln parameter is excluded
@@ -371,7 +420,11 @@
/**
* Output the store header row
- * @param lineNumber The line number to output the header at
+ *
+ * @name printHeaderRow
+ * @function
+ * @param {number} lineNumber The line number to output the header at
+ * @param {boolean} new_page
*/
jsPDFAPI.printHeaderRow = function (lineNumber, new_page) {
if (!this.tableHeaderRow) {
diff --git a/plugins/context2d.js b/plugins/context2d.js
index 8a2db8129..9ed55b2a7 100644
--- a/plugins/context2d.js
+++ b/plugins/context2d.js
@@ -4,21 +4,19 @@
* Licensed under the MIT License. http://opensource.org/licenses/mit-license
*/
-/**
- * This plugin mimics the HTML5 Canvas's context2d.
- *
- * The goal is to provide a way for current canvas implementations to print directly to a PDF.
- */
-
/**
* TODO implement stroke opacity (refactor from fill() method )
* TODO transform angle and radii parameters
*/
/**
- * require('jspdf.js'); require('lib/css_colors.js');
- */
-
+* This plugin mimics the HTML5 Canvas's context2d.
+*
+* The goal is to provide a way for current canvas implementations to print directly to a PDF.
+*
+* @name context2d
+* @module
+*/
(function (jsPDFAPI, globalObj) {
'use strict';
@@ -31,13 +29,41 @@
this.context2d.path = [];
}
]);
-
jsPDFAPI.context2d = {
+ /**
+ * @name pageWrapXEnabled
+ * @type {boolean}
+ * @default false
+ */
pageWrapXEnabled: false,
+ /**
+ * @name pageWrapYEnabled
+ * @type {boolean}
+ * @default false
+ */
pageWrapYEnabled: false,
+ /**
+ * @name pageWrapX
+ * @type {number}
+ * @default 9999999
+ */
pageWrapX: 9999999,
+ /**
+ * @name pageWrapY
+ * @type {number}
+ * @default 9999999
+ */
pageWrapY: 9999999,
+ /**
+ * @name ctx
+ * @type {Object}
+ */
ctx: new context(),
+ /**
+ * @name f2
+ * @type {function}
+ * @ignore
+ */
f2: function (number) {
return number.toFixed(2);
},
@@ -107,7 +133,7 @@
/**
* Creates a path from the current point back to the starting point
*
- * @closePath
+ * @name closePath
* @function
* @description The closePath() method creates a path from the current point back to the starting point.
*/
@@ -192,6 +218,7 @@
/**
* Creates a cubic Bézier curve
*
+ * @name bezierCurveTo
* @function
* @param cp1x {Number} The x-coordinate of the first Bézier control point
* @param cp1y {Number} The y-coordinate of the first Bézier control point
@@ -237,6 +264,7 @@
* Creates an arc/curve (used to create circles, or parts of circles)
*
* @name arc
+ * @function
* @param x {Number} The x-coordinate of the center of the circle
* @param y {Number} The y-coordinate of the center of the circle
* @param radius {Number} The radius of the circle
@@ -277,6 +305,7 @@
* Creates an arc/curve between two tangents
*
* @name arcTo
+ * @function
* @param x1 {Number} The x-coordinate of the first tangent
* @param y1 {Number} The y-coordinate of the first tangent
* @param x2 {Number} The x-coordinate of the second tangent
@@ -456,14 +485,6 @@
console.log("createEvent not implemented (yet)");
},
- /**
- * @name getContext
- * @function
- */
- getContext: function() {
- console.log("getContext not implemented (yet)");
- },
-
/**
* @name toDataURL
* @function
@@ -514,7 +535,7 @@
* @name _getRGBA
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_getRGBA: function (style) {
var r, g, b, a;
@@ -584,7 +605,7 @@
* @name _isFilllTransparent
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
* @returns {Boolean}
*/
_isFillTransparent: function () {
@@ -595,7 +616,7 @@
* @name _isStrokeTransparent
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
* @returns {Boolean}
*/
_isStrokeTransparent: function () {
@@ -609,7 +630,7 @@
* @name _setFillStyle
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setFillStyle: function (style) {
var rgba;
@@ -634,7 +655,7 @@
* @name _setStrokeStyle
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setStrokeStyle: function (style) {
var rgba = this._getRGBA(style);
@@ -662,7 +683,7 @@
* @function
* @param {String} The font property uses the same syntax as the CSS font property.
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setFont: function (font) {
this.ctx.font = font;
@@ -752,7 +773,7 @@
* @name _setTextBaseline
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setTextBaseline: function (baseline) {
this.ctx.textBaseline = baseline;
@@ -762,7 +783,7 @@
* @name _getTextBaseline
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
* @returns {Number}
*/
_getTextBaseline: function () {
@@ -773,7 +794,7 @@
* @name _setTextAlign
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setTextAlign: function _setTextAlign(canvasAlign) {
switch (canvasAlign) {
@@ -795,7 +816,7 @@
* @name _getTextAlign
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
* @returns {String}
*/
_getTextAlign: function () {
@@ -924,7 +945,7 @@
* @name _setLineWidth
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setLineWidth: function (width) {
this.ctx.lineWidth = width;
@@ -935,7 +956,7 @@
* @name _setLineCap
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setLineCap: function (style) {
this.ctx.lineCap = style;
@@ -947,7 +968,7 @@
* @name _setLineJoin
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_setLineJoin: function (style) {
this.ctx.lineJoin = style;
@@ -959,7 +980,7 @@
* @name _getLineJoin
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_getLineJoin: function () {
return this.ctx.lineJoin;
@@ -970,7 +991,7 @@
* @name _wrapX
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_wrapX: function (x) {
if (this.pageWrapXEnabled) {
@@ -984,7 +1005,7 @@
* @name _wrapY
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_wrapY: function (y) {
if (this.pageWrapYEnabled) {
@@ -1077,7 +1098,7 @@
* @name _getTransform
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_getTransform: function () {
return this.ctx._transform;
@@ -1093,7 +1114,7 @@
* @name _page
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
* @returns One-based Page Number
*/
_page: function (y) {
@@ -1176,9 +1197,9 @@
* @function
* @param m1
* @param m2
- * @returns {*[]}
+ * @returns {Array}
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_multiply: function (m2, m1) {
var sx = m1[0];
@@ -1204,7 +1225,7 @@
* @name _matrix_rotation
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_rotation: function (m) {
return Math.atan2(m[2], m[0]);
@@ -1215,7 +1236,7 @@
* @name _matrix_decompose
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_decompose: function (matrix) {
@@ -1256,7 +1277,7 @@
* @name _matrix_map_point
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_map_point: function (m1, pt) {
var sx = m1[0];
@@ -1278,7 +1299,7 @@
* @name _matrix_map_point_obj
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_map_point_obj: function (m1, pt) {
var xpt = this._matrix_map_point(m1, [pt.x, pt.y]);
@@ -1289,7 +1310,7 @@
* @name _matrix_map_rect
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_map_rect: function (m1, rect) {
var p1 = this._matrix_map_point(m1, [rect.x, rect.y]);
@@ -1301,7 +1322,7 @@
* @name _matrix_is_identity
* @function
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_matrix_is_identity: function (m1) {
if (m1[0] != 1) {
@@ -1331,7 +1352,7 @@
* @param rule {String}
* @param isClip {Boolean}
* @private
- * @ignore This is an internal function and should not be in the public docs.
+ * @ignore
*/
_drawPaths: function _drawPaths(rule, isClip) {
var isStroke = rule === 'stroke';
@@ -1639,13 +1660,14 @@
var c2d = jsPDFAPI.context2d;
- /**
+
+ /**
* Sets or returns the color, gradient, or pattern used to fill the drawing
*
- * @function
- * @param color|gradient|pattern A CSS color value that indicates the fill
- * color of the drawing. Default value is #000000
- * A gradient object (linear or radial) used to fill the drawing (not supported by context2d)
+ * @name fillStyle
+ * @default #000000
+ * @property {(color|gradient|pattern)} value The color of the drawing. Default value is #000000
+ * A gradient object (linear or radial) used to fill the drawing (not supported by context2d)
* A pattern object to use to fill the drawing (not supported by context2d)
*/
Object.defineProperty(c2d, 'fillStyle', {
@@ -1656,6 +1678,16 @@
return this.ctx.fillStyle;
}
});
+
+ /**
+ * Sets or returns the color, gradient, or pattern used for strokes
+ *
+ * @name strokeStyle
+ * @default #000000
+ * @property {color} color A CSS color value that indicates the stroke color of the drawing. Default value is #000000 (not supported by context2d)
+ * @property {gradient} gradient A gradient object (linear or radial) used to create a gradient stroke (not supported by context2d)
+ * @property {pattern} pattern A pattern object used to create a pattern stroke (not supported by context2d)
+ */
Object.defineProperty(c2d, 'strokeStyle', {
set: function (value) {
this._setStrokeStyle(value);
@@ -1669,6 +1701,12 @@
/**
* Sets or returns the style of the end caps for a line
+ *
+ * @name lineCap
+ * @default butt
+ * @property {(butt|round|square)} lineCap butt A flat edge is added to each end of the line
+ * round A rounded end cap is added to each end of the line
+ * square A square end cap is added to each end of the line
*/
Object.defineProperty(c2d, 'lineCap', {
set: function (val) {
@@ -1681,6 +1719,10 @@
/**
* Sets or returns the current line width
+ *
+ * @name lineWidth
+ * @default 1
+ * @property {number} lineWidth The current line width, in pixels
*/
Object.defineProperty(c2d, 'lineWidth', {
set: function (value) {
diff --git a/plugins/gif_support.js b/plugins/gif_support.js
index c50c8ada5..2d84c2335 100644
--- a/plugins/gif_support.js
+++ b/plugins/gif_support.js
@@ -1,11 +1,17 @@
/**
- * jsPDF gif Support PlugIn
+ * @license
* Copyright (c) 2017 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
+/**
+* jsPDF gif Support PlugIn
+*
+* @name gif_support
+* @module
+*/
(function (jsPDFAPI) {
'use strict';
diff --git a/plugins/html.js b/plugins/html.js
index c34d69d9f..f60c56089 100644
--- a/plugins/html.js
+++ b/plugins/html.js
@@ -1,5 +1,4 @@
/**
- * jsPDF html PlugIn
* Copyright (c) 2018 Erik Koopmans
* Released under the MIT License.
*
@@ -7,6 +6,12 @@
* http://opensource.org/licenses/mit-license
*/
+/**
+ * jsPDF html PlugIn
+ *
+ * @name html
+ * @module
+ */
(function (jsPDFAPI, global) {
'use strict';
@@ -265,7 +270,10 @@
// Handle old-fashioned 'onrendered' argument.
var options = Object.assign({}, this.opt.html2canvas);
delete options.onrendered;
-
+
+ if (!this.isHtml2CanvasLoaded()) {
+ return;
+ }
return html2canvas(this.prop.container, options);
}).then(function toCanvas_post(canvas) {
// Handle old-fashioned 'onrendered' argument.
@@ -306,8 +314,10 @@
options.windowHeight = options.windowHeight || 0;
options.windowHeight = (options.windowHeight == 0) ? Math.max(this.prop.container.clientHeight, this.prop.container.scrollHeight, this.prop.container.offsetHeight) : options.windowHeight;
+ if (!this.isHtml2CanvasLoaded()) {
+ return;
+ }
- // options.scrollY = options.windowHeight;
return html2canvas(this.prop.container, options);
}).then(function toContext2d_post(canvas) {
// Handle old-fashioned 'onrendered' argument.
@@ -400,12 +410,24 @@
}
});
};
+
+ Worker.prototype.isHtml2CanvasLoaded = function () {
+ var result = typeof global.html2canvas !== "undefined";
+ if (!result) {
+ console.error("html2canvas not loaded.");
+ }
+ return result;
+ }
Worker.prototype.save = function save(filename) {
// Set up function prerequisites.
var prereqs = [
function checkPdf() { return this.prop.pdf || this.toPdf(); }
];
+
+ if (!this.isHtml2CanvasLoaded()) {
+ return;
+ }
// Fulfill prereqs, update the filename (if provided), and save the PDF.
return this.thenList(prereqs).set(
@@ -421,6 +443,9 @@
function checkPdf() { return this.prop.pdf || this.toPdf(); }
];
+ if (!this.isHtml2CanvasLoaded()) {
+ return;
+ }
// Fulfill prereqs, update the filename (if provided), and save the PDF.
return this.thenList(prereqs)
.then(function doCallback_main() {
@@ -719,8 +744,11 @@
/**
* Generate a PDF from an HTML element or string using.
*
+ * @name html
+ * @function
* @param {Element|string} source The source element or HTML string.
* @param {Object=} options An object of optional settings.
+ * @description The Plugin needs html2canvas from niklasvh
*/
jsPDFAPI.html = function (src, options) {
'use strict';
diff --git a/plugins/javascript.js b/plugins/javascript.js
index 3741a0696..079e33345 100644
--- a/plugins/javascript.js
+++ b/plugins/javascript.js
@@ -1,5 +1,6 @@
-/** ====================================================================
- * jsPDF JavaScript plugin
+/**
+ * @license
+ * ====================================================================
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -24,15 +25,26 @@
*/
/*global jsPDF */
-
+/**
+ * jsPDF JavaScript plugin
+ *
+ * @name javascript
+ * @module
+*/
(function (jsPDFAPI) {
'use strict';
var jsNamesObj, jsJsObj, text;
- jsPDFAPI.addJS = function (txt) {
- text = txt;
+ /**
+ * @name addJS
+ * @function
+ * @param {string} javascript The javascript to be embedded into the PDF-file.
+ * @returns {jsPDF}
+ */
+ jsPDFAPI.addJS = function (javascript) {
+ text = javascript;
this.internal.events.subscribe(
'postPutResources',
- function (txt) {
+ function (javascript) {
jsNamesObj = this.internal.newObject();
this.internal.out('<<');
this.internal.out('/Names [(EmbeddedJS) ' + (jsNamesObj + 1) + ' 0 R]');
diff --git a/plugins/outline.js b/plugins/outline.js
index 2fc6feb33..385bf6a60 100644
--- a/plugins/outline.js
+++ b/plugins/outline.js
@@ -1,5 +1,5 @@
/**
- * jsPDF Outline PlugIn
+ * @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
@@ -7,7 +7,11 @@
*/
/**
+ * jsPDF Outline PlugIn
+ *
* Generates a PDF Outline
+ * @name outline
+ * @module
*/
;
(function(jsPDFAPI) {
diff --git a/plugins/png_support.js b/plugins/png_support.js
index 10195b73a..5a78abaac 100755
--- a/plugins/png_support.js
+++ b/plugins/png_support.js
@@ -1,6 +1,6 @@
-/**@preserve
- * ====================================================================
- * jsPDF PNG PlugIn
+/**
+ * @license
+ *
* Copyright (c) 2014 James Robb, https://github.com/jamesbrobb
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -23,7 +23,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
-
+
+ /**
+ * jsPDF PNG PlugIn
+ * @name png_support
+ * @module
+ */
(function(jsPDFAPI) {
'use strict'
@@ -357,10 +362,12 @@
console.log("pixelBitlength: " + img.pixelBitlength);
console.log("hasAlphaChannel: " + img.hasAlphaChannel);
};
-
-
-
-
+ /**
+ *
+ * @name processPNG
+ * @function
+ * @ignore
+ */
jsPDFAPI.processPNG = function(imageData, imageIndex, alias, compression, dataAsBinaryString) {
'use strict'
diff --git a/plugins/setlanguage.js b/plugins/setlanguage.js
index 27ee83065..20cc578dc 100644
--- a/plugins/setlanguage.js
+++ b/plugins/setlanguage.js
@@ -1,18 +1,25 @@
/**
- * jsPDF setLanguage Plugin
- *
+ * @license
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
+/**
+ * jsPDF setLanguage Plugin
+ *
+ * @name setLanguage
+ * @module
+ */
(function (jsPDFAPI) {
"use strict";
/**
- * Add Language Tag to PDF
+ * Add Language Tag to the generated PDF
*
- * @returns {jsPDF}
* @name setLanguage
+ * @function
+ * @param {string} langCode The Language code as ISO-639-1 (e.g. 'en') or as country language code (e.g. 'en-GB').
+ * @returns {jsPDF}
* @example
* var doc = new jsPDF()
* doc.text(10, 10, 'This is a test')
diff --git a/plugins/split_text_to_size.js b/plugins/split_text_to_size.js
index 891b45eb1..b78d8d96d 100644
--- a/plugins/split_text_to_size.js
+++ b/plugins/split_text_to_size.js
@@ -1,9 +1,8 @@
-/** @preserve
- * jsPDF split_text_to_size plugin - MIT license.
+/** @license
+ * MIT license.
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* 2014 Diego Casorran, https://github.com/diegocr
- */
-/**
+ *
* 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
@@ -24,17 +23,23 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
-
+
+/**
+* jsPDF split_text_to_size plugin
+*
+* @name split_text_to_size
+* @module
+*/
(function (API) {
'use strict'
/**
* Returns an array of length matching length of the 'word' string, with each
* cell occupied by the width of the char in that position.
*
+ * @name getCharWidthsArray
* @function
- * @param word {String}
- * @param widths {Object}
- * @param kerning {Object}
+ * @param {string} text
+ * @param {Object} options
* @returns {Array}
*/
var getCharWidthsArray = API.getCharWidthsArray = function (text, options) {
@@ -78,8 +83,8 @@
* @name getArraySum
* @public
* @function
- * @param {array} array of numbers
- * @returns {Number}
+ * @param {Array} array Array of numbers
+ * @returns {number}
*/
var getArraySum = API.getArraySum = function (array) {
var i = array.length,
@@ -91,18 +96,20 @@
return output;
}
/**
- Returns a widths of string in a given font, if the font size is set as 1 point.
-
- In other words, this is "proportional" value. For 1 unit of font size, the length
- of the string will be that much.
-
- Multiply by font size to get actual width in *points*
- Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc.
-
- @public
- @function
- @param
- @returns {Type}
+ * Returns a widths of string in a given font, if the font size is set as 1 point.
+ *
+ * In other words, this is "proportional" value. For 1 unit of font size, the length
+ * of the string will be that much.
+ *
+ * Multiply by font size to get actual width in *points*
+ * Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc.
+ *
+ * @name getStringUnitWidth
+ * @public
+ * @function
+ * @param {string} text
+ * @param {string} options
+ * @returns {number} result
*/
var getStringUnitWidth = API.getStringUnitWidth = function (text, options) {
options = options || {};
@@ -253,20 +260,21 @@
}
/**
- 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.
-
- @public
- @function
- @param text {String} Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string.
- @param size {Number} Nominal number, measured in units default to this instance of jsPDF.
- @param options {Object} Optional flags needed for chopper to do the right thing.
- @returns {Array} with strings chopped to size.
+ * Splits a given string into an array of strings. Uses 'size' value
+ * (in measurement units declared as default for the jsPDF instance)
+ * and the font's "widths" and "Kerning" tables, where available, to
+ * determine display length of a given string for a given font.
+ *
+ * We use character's 100% of unit size (height) as width when Width
+ * table or other default width is not available.
+ *
+ * @name splitTextToSize
+ * @public
+ * @function
+ * @param {string} text Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string.
+ * @param {number} size Nominal number, measured in units default to this instance of jsPDF.
+ * @param {Object} options Optional flags needed for chopper to do the right thing.
+ * @returns {Array} array Array with strings chopped to size.
*/
API.splitTextToSize = function (text, maxlen, options) {
'use strict'
diff --git a/plugins/standard_fonts_metrics.js b/plugins/standard_fonts_metrics.js
index 5ba7d90a5..78034a700 100644
--- a/plugins/standard_fonts_metrics.js
+++ b/plugins/standard_fonts_metrics.js
@@ -1,9 +1,7 @@
-/** @preserve
-jsPDF standard_fonts_metrics plugin
-Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
-MIT license.
-*/
-/**
+/** @license
+ jsPDF standard_fonts_metrics plugin
+ * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
+ * MIT license.
* 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
@@ -24,6 +22,26 @@ MIT license.
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
+
+ /**
+ * This file adds the standard font metrics to jsPDF.
+ *
+ * Font metrics data is reprocessed derivative of contents of
+ * "Font Metrics for PDF Core 14 Fonts" package, which exhibits the following copyright and license:
+ *
+ * Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.
+ *
+ * This file and the 14 PostScript(R) AFM files it accompanies may be used,
+ * copied, and distributed for any purpose and without charge, with or without
+ * modification, provided that all copyright notices are retained; that the AFM
+ * files are not distributed without this file; that all modifications to this
+ * file or any of the AFM files are prominently noted in the modified file(s);
+ * and that this paragraph is not modified. Adobe Systems has no responsibility
+ * or obligation to support the use of the AFM files.
+ *
+ * @name standard_fonts_metrics
+ * @module
+ */
;(function(API) {
'use strict'
@@ -280,22 +298,6 @@ var encodingBlock = {
// , 'Symbol'
// , 'ZapfDingbats'
}}
-/**
-Resources:
-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.
-
-*/
, fontMetrics = {'Unicode':{
// all sizing numbers are n/fontMetricsFractionOf = one font size unit
// this means that if fontMetricsFractionOf = 1000, and letter A's width is 476, it's
diff --git a/plugins/svg.js b/plugins/svg.js
index b450f3809..2873601d7 100644
--- a/plugins/svg.js
+++ b/plugins/svg.js
@@ -1,8 +1,6 @@
-/** @preserve
-jsPDF SVG plugin
-Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
-*/
-/**
+/** @license
+ * Copyright (c) 2012 Willow Systems Corporation, willow-systems.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
@@ -24,6 +22,12 @@ Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* ====================================================================
*/
+/**
+* jsPDF SVG plugin
+*
+* @name svg
+* @module
+*/
;(function(jsPDFAPI) {
'use strict'
@@ -36,14 +40,14 @@ Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
*
* @name addSvg
* @public
- * @function
- * @param {String} SVG-Data as Text
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} width of SVG (in units declared at inception of PDF document)
- * @param {Number} height of SVG (in units declared at inception of PDF document)
+ * @function
+ * @param {string} SVG-Data as Text
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} width of SVG (in units declared at inception of PDF document)
+ * @param {number} height of SVG (in units declared at inception of PDF document)
* @returns {Object} jsPDF-instance
-*/
+ */
jsPDFAPI.addSvg = function(svgtext, x, y, w, h) {
// 'this' is _jsPDF object returned when jsPDF is inited (new jsPDF())
@@ -194,17 +198,16 @@ jsPDFAPI.addSVG = jsPDFAPI.addSvg;
* @name addSvgAsImage
* @public
* @function
- * @param {String} SVG-Data as Text
- * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
- * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
- * @param {Number} width of SVG-Image (in units declared at inception of PDF document)
- * @param {Number} height of SVG-Image (in units declared at inception of PDF document)
- * @param {String} alias of SVG-Image (if used multiple times)
- * @param {String} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'
- * @param {Number} rotation of the image in degrees (0-359)
+ * @param {string} SVG-Data as Text
+ * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
+ * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
+ * @param {number} width of SVG-Image (in units declared at inception of PDF document)
+ * @param {number} height of SVG-Image (in units declared at inception of PDF document)
+ * @param {string} alias of SVG-Image (if used multiple times)
+ * @param {string} compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'
+ * @param {number} rotation of the image in degrees (0-359)
*
- * @returns jsPDF
- * @methodOf jsPDF#
+ * @returns jsPDF jsPDF-instance
*/
jsPDFAPI.addSvgAsImage = function(svg, x, y, w, h, alias, compression, rotation) {
diff --git a/plugins/total_pages.js b/plugins/total_pages.js
index 1509d969f..adce39550 100644
--- a/plugins/total_pages.js
+++ b/plugins/total_pages.js
@@ -1,5 +1,6 @@
-/** ====================================================================
- * jsPDF total_pages plugin
+/**
+ * @license
+ * ====================================================================
* Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -22,10 +23,20 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
-
+/**
+ * jsPDF total_pages plugin
+ * @name total_pages
+ * @module
+ */
(function(jsPDFAPI) {
'use strict';
+/**
+* @name putTotalPages
+* @function
+* @param {string} pageExpression Regular Expression
+* @returns {jsPDF} jsPDF-instance
+*/
jsPDFAPI.putTotalPages = function(pageExpression) {
'use strict';
var replaceExpression = new RegExp(pageExpression, 'g');
diff --git a/plugins/ttfsupport.js b/plugins/ttfsupport.js
index b73fd01f2..d8924e35e 100644
--- a/plugins/ttfsupport.js
+++ b/plugins/ttfsupport.js
@@ -1,8 +1,12 @@
/**
- *
+ * @license
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
+/**
+* @name ttfsupport
+* @module
+*/
(function (jsPDF, global) {
"use strict";
diff --git a/plugins/utf8.js b/plugins/utf8.js
index b1caf84f2..aa868c3ac 100644
--- a/plugins/utf8.js
+++ b/plugins/utf8.js
@@ -1,3 +1,7 @@
+/**
+* @name utf8
+* @module
+*/
(function (jsPDF, global) {
'use strict';
var jsPDFAPI = jsPDF.API;
diff --git a/plugins/vfs.js b/plugins/vfs.js
index f69a6f72a..8b905ac4f 100644
--- a/plugins/vfs.js
+++ b/plugins/vfs.js
@@ -7,16 +7,22 @@
/**
* Use the vFS to handle files
+ *
+ * @name vFS
+ * @module
*/
-
(function (jsPDFAPI) {
"use strict";
var vFS = {};
- /* Check if the file exists in the vFS
- * @returns {boolean}
+ /**
+ * Check if the file exists in the vFS
+ *
* @name existsFileInVFS
+ * @function
+ * @param {string} Possible filename in the vFS.
+ * @returns {boolean}
* @example
* doc.existsFileInVFS("someFile.txt");
*/
@@ -24,9 +30,14 @@
return vFS.hasOwnProperty(filename);
}
- /* Add a file to the vFS
- * @returns {jsPDF}
+ /**
+ * Add a file to the vFS
+ *
* @name addFileToVFS
+ * @function
+ * @param {string} filename The name of the file which should be added.
+ * @param {string} filecontent The content of the file.
+ * @returns {jsPDF}
* @example
* doc.addFileToVFS("someFile.txt", "BADFACE1");
*/
@@ -35,9 +46,12 @@
return this;
};
- /* Get the file from the vFS
- * @returns {string}
- * @name addFileToVFS
+ /**
+ * Get the file from the vFS
+ *
+ * @name getFileFromVFS
+ * @function
+ * @returns {string} The name of the file which gets requested.
* @example
* doc.getFileFromVFS("someFile.txt");
*/
diff --git a/plugins/viewerpreferences.js b/plugins/viewerpreferences.js
index a86e204fb..92846ff6c 100644
--- a/plugins/viewerpreferences.js
+++ b/plugins/viewerpreferences.js
@@ -9,13 +9,17 @@
* Adds the ability to set ViewerPreferences and by thus
* controlling the way the document is to be presented on the
* screen or in print.
+ * @name viewerpreferences
+ * @module
*/
-
(function (jsPDFAPI) {
"use strict";
/**
* Set the ViewerPreferences of the generated PDF
*
+ * @name viewerPreferences
+ * @function
+ * @public
* @param {Object} options Array with the ViewerPreferences
* Example: doc.viewerPreferences({"FitWindow":true});
*
@@ -39,35 +43,35 @@
* DisplayDocTitle (boolean)
* Default value: false.
*
- * NonFullScreenPageMode (String)
+ * NonFullScreenPageMode (string)
* Possible values: UseNone, UseOutlines, UseThumbs, UseOC
* Default value: UseNone
*
- * Direction (String)
+ * Direction (string)
* Possible values: L2R, R2L
* Default value: L2R.
*
- * ViewArea (String)
+ * ViewArea (string)
* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
* Default value: CropBox.
*
- * ViewClip (String)
+ * ViewClip (string)
* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
* Default value: CropBox
*
- * PrintArea (String)
+ * PrintArea (string)
* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
* Default value: CropBox
*
- * PrintClip (String)
+ * PrintClip (string)
* Possible values: MediaBox, CropBox, TrimBox, BleedBox, ArtBox
* Default value: CropBox.
*
- * PrintScaling (String)
+ * PrintScaling (string)
* Possible values: AppDefault, None
* Default value: AppDefault.
*
- * Duplex (String)
+ * Duplex (string)
* Possible values: Simplex, DuplexFlipLongEdge, DuplexFlipShortEdge
* Default value: none
*
@@ -85,8 +89,7 @@
* For more information see the PDF Reference, sixth edition on Page 577
* @param {boolean} doReset True to reset the settings
* @function
- * @returns jsPDF
- * @methodOf jsPDF#
+ * @returns jsPDF jsPDF-instance
* @example
* var doc = new jsPDF()
* doc.text('This is a test', 10, 10)
@@ -99,7 +102,6 @@
* 'PrintArea': 'CropBox',
* 'NumCopies': 10
* })
- * @name viewerPreferences
*/
jsPDFAPI.viewerPreferences = function (options, doReset) {
options = options || {};
diff --git a/plugins/xmp_metadata.js b/plugins/xmp_metadata.js
index 2f6e7dae1..f1f48a44b 100644
--- a/plugins/xmp_metadata.js
+++ b/plugins/xmp_metadata.js
@@ -26,22 +26,24 @@
/*global jsPDF */
/**
-* Adds XMP formatted metadata to PDF
-*
-* @param {String} metadata The actual metadata to be added. The metadata shall be stored as XMP simple value. Note that if the metadata string contains XML markup characters "<", ">" or "&", those characters should be written using XML entities.
-* @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash.
-* @function
-* @returns {jsPDF}
-* @methodOf jsPDF#
-* @name addMetadata
+* @name xmp_metadata
+* @module
*/
-
(function (jsPDFAPI) {
'use strict';
var xmpmetadata = "";
var xmpnamespaceuri = "";
var metadata_object_number = "";
+ /**
+ * Adds XMP formatted metadata to PDF
+ *
+ * @name addMetadata
+ * @function
+ * @param {String} metadata The actual metadata to be added. The metadata shall be stored as XMP simple value. Note that if the metadata string contains XML markup characters "<", ">" or "&", those characters should be written using XML entities.
+ * @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash.
+ * @returns {jsPDF} jsPDF-instance
+ */
jsPDFAPI.addMetadata = function (metadata,namespaceuri) {
xmpnamespaceuri = namespaceuri || "http://jspdf.default.namespaceuri/"; //The namespace URI for an XMP name shall not be empty
xmpmetadata = metadata;