(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.jspdf = factory());
}(this, function () { 'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
/** @preserve
* jsPDF - PDF Document creation from JavaScript
* Version 1.3.2 Built on 2016-09-30T20:33:17.116Z
* CommitID 7d854cc77d
*
* Copyright (c) 2010-2014 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
* 2010 Aaron Spike, https://github.com/acspike
* 2012 Willow Systems Corporation, willow-systems.com
* 2012 Pablo Hess, https://github.com/pablohess
* 2012 Florian Jenett, https://github.com/fjenett
* 2013 Warren Weckesser, https://github.com/warrenweckesser
* 2013 Youssef Beddad, https://github.com/lifof
* 2013 Lee Driscoll, https://github.com/lsdriscoll
* 2013 Stefan Slonevskiy, https://github.com/stefslon
* 2013 Jeremy Morel, https://github.com/jmorel
* 2013 Christoph Hartmann, https://github.com/chris-rock
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 James Makes, https://github.com/dollaruw
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 Steven Spungin, https://github.com/Flamenco
* 2014 Kenneth Glassey, https://github.com/Gavvers
*
* Licensed under the MIT License
*
* Contributor(s):
* siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
* kim3er, mfo, alnorth, Flamenco
*/
/**
* Creates new jsPDF document object instance.
*
* @class
* @param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
* @param unit Measurement unit to be used when coordinates are specified.
* One of "pt" (points), "mm" (Default), "cm", "in"
* @param format One of 'pageFormats' as shown below, default: a4
* @returns {jsPDF}
* @name jsPDF
*/
var jsPDF = function (global) {
'use strict';
var pdfVersion = '1.3',
pageFormats = { // Size in pt of various paper formats
'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94],
'a2': [1190.55, 1683.78], 'a3': [841.89, 1190.55],
'a4': [595.28, 841.89], 'a5': [419.53, 595.28],
'a6': [297.64, 419.53], 'a7': [209.76, 297.64],
'a8': [147.40, 209.76], 'a9': [104.88, 147.40],
'a10': [73.70, 104.88], 'b0': [2834.65, 4008.19],
'b1': [2004.09, 2834.65], 'b2': [1417.32, 2004.09],
'b3': [1000.63, 1417.32], 'b4': [708.66, 1000.63],
'b5': [498.90, 708.66], 'b6': [354.33, 498.90],
'b7': [249.45, 354.33], 'b8': [175.75, 249.45],
'b9': [124.72, 175.75], 'b10': [87.87, 124.72],
'c0': [2599.37, 3676.54], 'c1': [1836.85, 2599.37],
'c2': [1298.27, 1836.85], 'c3': [918.43, 1298.27],
'c4': [649.13, 918.43], 'c5': [459.21, 649.13],
'c6': [323.15, 459.21], 'c7': [229.61, 323.15],
'c8': [161.57, 229.61], 'c9': [113.39, 161.57],
'c10': [79.37, 113.39], 'dl': [311.81, 623.62],
'letter': [612, 792],
'government-letter': [576, 756],
'legal': [612, 1008],
'junior-legal': [576, 360],
'ledger': [1224, 792],
'tabloid': [792, 1224],
'credit-card': [153, 243]
};
/**
* 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
*/
function PubSub(context) {
var topics = {};
this.subscribe = function (topic, callback, once) {
if (typeof callback !== 'function') {
return false;
}
if (!topics.hasOwnProperty(topic)) {
topics[topic] = {};
}
var id = Math.random().toString(35);
topics[topic][id] = [callback, !!once];
return id;
};
this.unsubscribe = function (token) {
for (var topic in topics) {
if (topics[topic][token]) {
delete topics[topic][token];
return true;
}
}
return false;
};
this.publish = function (topic) {
if (topics.hasOwnProperty(topic)) {
var args = Array.prototype.slice.call(arguments, 1),
idr = [];
for (var id in topics[topic]) {
var sub = topics[topic][id];
try {
sub[0].apply(context, args);
} catch (ex) {
if (global.console) {
console.error('jsPDF PubSub Error', ex.message, ex);
}
}
if (sub[1]) idr.push(id);
}
if (idr.length) idr.forEach(this.unsubscribe);
}
};
}
/**
* @constructor
* @private
*/
function jsPDF(orientation, unit, format, compressPdf) {
var options = {};
if ((typeof orientation === 'undefined' ? 'undefined' : _typeof(orientation)) === 'object') {
options = orientation;
orientation = options.orientation;
unit = options.unit || unit;
format = options.format || format;
compressPdf = options.compress || options.compressPdf || compressPdf;
}
// Default options
unit = unit || 'mm';
format = format || 'a4';
orientation = ('' + (orientation || 'P')).toLowerCase();
var format_as_string = ('' + format).toLowerCase(),
compress = !!compressPdf && typeof Uint8Array === 'function',
textColor = options.textColor || '0 g',
drawColor = options.drawColor || '0 G',
activeFontSize = options.fontSize || 16,
lineHeightProportion = options.lineHeight || 1.15,
lineWidth = options.lineWidth || 0.200025,
// 2mm
objectNumber = 2,
// 'n' Current object number
outToPages = !1,
// switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
offsets = [],
// List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.
fonts = {},
// collection of font objects, where key is fontKey - a dynamically created label for a given font.
fontmap = {},
// mapping structure fontName > fontStyle > font key - performance layer. See addFont()
activeFontKey,
// will be string representing the KEY of the font as combination of fontName + fontStyle
k,
// Scale factor
tmp,
page = 0,
currentPage,
pages = [],
pagesContext = [],
// same index as pages and pagedim
pagedim = [],
content = [],
additionalObjects = [],
lineCapID = 0,
lineJoinID = 0,
content_length = 0,
pageWidth,
评论0