(function (global, factory){
typeof exports==='object'&&typeof module!=='undefined' ? factory(exports) :
typeof define==='function'&&define.amd ? define(['exports'], factory) :
(global=global||self, factory(global.jspdf={}));
}(this, (function (exports){ 'use strict';
var globalObject=(function(){
return "undefined"!==typeof window
? window
: "undefined"!==typeof global
? global
: "undefined"!==typeof self
? self
: this;
})();
function consoleLog(){
if(globalObject.console&&typeof globalObject.console.log==="function"){
globalObject.console.log.apply(globalObject.console, arguments);
}}
function consoleWarn(str){
if(globalObject.console){
if(typeof globalObject.console.warn==="function"){
globalObject.console.warn.apply(globalObject.console, arguments);
}else{
consoleLog.call(null, arguments);
}}
}
function consoleError(str){
if(globalObject.console){
if(typeof globalObject.console.error==="function"){
globalObject.console.error.apply(globalObject.console, arguments);
}else{
consoleLog(str);
}}
}
var console={
log: consoleLog,
warn: consoleWarn,
error: consoleError
};
function bom(blob, opts){
if(typeof opts==="undefined") opts={ autoBom: false };
else if(typeof opts!=="object"){
console.warn("Deprecated: Expected third argument to be a object");
opts={ autoBom: !opts };}
if(opts.autoBom &&
/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type
)
){
return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type });
}
return blob;
}
function download(url, name, opts){
var xhr=new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType="blob";
xhr.onload=function(){
saveAs(xhr.response, name, opts);
};
xhr.onerror=function(){
console.error("could not download file");
};
xhr.send();
}
function corsEnabled(url){
var xhr=new XMLHttpRequest();
xhr.open("HEAD", url, false);
try {
xhr.send();
} catch (e){}
return xhr.status >=200&&xhr.status <=299;
}
function click(node){
try {
node.dispatchEvent(new MouseEvent("click"));
} catch (e){
var evt=document.createEvent("MouseEvents");
evt.initMouseEvent("click",
true,
true,
window,
0,
0,
0,
80,
20,
false,
false,
false,
false,
0,
null
);
node.dispatchEvent(evt);
}}
var saveAs =
globalObject.saveAs ||
(typeof window!=="object"||window!==globalObject
? function saveAs(){
}
:
"download" in HTMLAnchorElement.prototype
? function saveAs(blob, name, opts){
var URL=globalObject.URL||globalObject.webkitURL;
var a=document.createElement("a");
name=name||blob.name||"download";
a.download=name;
a.rel="noopener";
if(typeof blob==="string"){
a.href=blob;
if(a.origin!==location.origin){
corsEnabled(a.href)
? download(blob, name, opts)
: click(a, (a.target="_blank"));
}else{
click(a);
}}else{
a.href=URL.createObjectURL(blob);
setTimeout(function(){
URL.revokeObjectURL(a.href);
}, 4e4);
setTimeout(function(){
click(a);
}, 0);
}}
:
"msSaveOrOpenBlob" in navigator
? function saveAs(blob, name, opts){
name=name||blob.name||"download";
if(typeof blob==="string"){
if(corsEnabled(blob)){
download(blob, name, opts);
}else{
var a=document.createElement("a");
a.href=blob;
a.target="_blank";
setTimeout(function(){
click(a);
});
}}else{
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
}}
:
function saveAs(blob, name, opts, popup){
popup=popup||open("", "_blank");
if(popup){
popup.document.title=popup.document.body.innerText =
"downloading...";
}
if(typeof blob==="string") return download(blob, name, opts);
var force=blob.type==="application/octet-stream";
var isSafari =
/constructor/i.test(globalObject.HTMLElement)||globalObject.safari;
var isChromeIOS=/CriOS\/[\d]+/.test(navigator.userAgent);
if((isChromeIOS||(force&&isSafari)) &&
typeof FileReader==="object"
){
var reader=new FileReader();
reader.onloadend=function(){
var url=reader.result;
url=isChromeIOS
? url
: url.replace(/^data:[^;]*;/, "data:attachment/file;");
if(popup) popup.location.href=url;
else location=url;
popup=null;
};
reader.readAsDataURL(blob);
}else{
var URL=globalObject.URL||globalObject.webkitURL;
var url=URL.createObjectURL(blob);
if(popup) popup.location=url;
else location.href=url;
popup=null;
setTimeout(function(){
URL.revokeObjectURL(url);
}, 4e4);
}});
function RGBColor(color_string){
color_string=color_string||"";
this.ok=false;
if(color_string.charAt(0)=="#"){
color_string=color_string.substr(1, 6);
}
color_string=color_string.replace(/ /g, "");
color_string=color_string.toLowerCase();
var channels;
var simple_colors={
aliceblue: "f0f8ff",
antiquewhite: "faebd7",
aqua: "00ffff",
aquamarine: "7fffd4",
azure: "f0ffff",
beige: "f5f5dc",
bisque: "ffe4c4",
black: "000000",
blanchedalmond: "ffebcd",
blue: "0000ff",
blueviolet: "8a2be2",
brown: "a52a2a",
burlywood: "deb887",
cadetblue: "5f9ea0",
chartreuse: "7fff00",
chocolate: "d2691e",
coral: "ff7f50",
cornflowerblue: "6495ed",
cornsilk: "fff8dc",
crimson: "dc143c",
cyan: "00ffff",
darkblue: "00008b",
darkcyan: "008b8b",
darkgoldenrod: "b8860b",
darkgray: "a9a9a9",
darkgreen: "006400",
darkkhaki: "bdb76b",
darkmagenta: "8b008b",
darkolivegreen: "556b2f",
darkorange: "ff8c00",
darkorchid: "9932cc",
darkred: "8b0000",
darksalmon: "e9967a",
darkseagreen: "8fbc8f",
darkslateblue: "483d8b",
darkslategray: "2f4f4f",
darkturquoise: "00ced1",
darkviolet: "9400d3",
deeppink: "ff1493",
deepskyblue: "00bfff",
dimgray: "696969",
dodgerblue: "1e90ff",
feldspar: "d19275",
firebrick: "b22222",
floralwhite: "fffaf0",
forestgreen: "228b22",
fuchsia: "ff00ff",
gainsboro: "dcdcdc",
ghostwhite: "f8f8ff",
gold: "ffd700",
goldenrod: "daa520",
gray: "808080",
green: "008000",
greenyellow: "adff2f",
honeydew: "f0fff0",
hotpink: "ff69b4",
indianred: "cd5c5c",
indigo: "4b0082",
ivory: "fffff0",
khaki: "f0e68c",
lavender: "e6e6fa",
lavenderblush: "fff0f5",
lawngreen: "7cfc00",
lemonchiffon: "fffacd",
lightblue: "add8e6",
lightcoral: "f08080",
lightcyan: "e0ffff",
lightgoldenrodyellow: "fafad2",
lightgrey: "d3d3d3",
lightgreen: "90ee90",
lightpink: "ffb6c1",
lightsalmon: "ffa07a",
lightseagreen: "20b2aa",
lightskyblue: "87cefa",
lightslateblue: "8470ff",
lightslategray: "778899",
lightsteelblue: "b0c4de",
lightyellow: "ffffe0",
lime: "00ff00",
limegreen: "32cd32",
linen: "faf0e6",
magenta: "ff00ff",
maroon: "800000",
mediumaquamarine: "66cdaa",
mediumblue: "0000cd",
mediumorchid: "ba55d3",
mediumpurple: "9370d8",
mediumseagreen: "3cb371",
mediumslateblue: "7b68ee",
mediumspringgreen: "00fa9a",
mediumturquoise: "48d1cc",
mediumvioletred: "c71585",
midnightblue: "191970",
mintcream: "f5fffa",
mistyrose: "ffe4e1",
moccasin: "ffe4b5",
navajowhite: "ffdead",
navy: "000080",
oldlace: "fdf5e6",
olive: "808000",
olivedrab: "6b8e23",
orange: "ffa500",
orangered: "ff4500",
orchid: "da70d6",
palegoldenrod: "eee8aa",
palegreen: "98fb98",
paleturquoise: "afeeee",
palevioletred: "d87093",
papayawhip: "ffefd5",
peachpuff: "ffdab9",
peru: "cd853f",
pink: "ffc0cb",
plum: "dda0dd",
powderblue: "b0e0e6",
purple: "800080",
red: "ff0000",
rosybrown: "bc8f8f",
royalblue: "4169e1",
saddlebrown: "8b4513",
salmon: "fa8072",
sandybrown: "f4a460",
seagreen: "2e8b57",
seashell: "fff5ee",
sienna: "a0522d",
silver: "c0c0c0",
skyblue: "87ceeb",
slateblue: "6a5acd",
slategray: "708090",
snow: "fffafa",
springgreen: "00ff7f",
steelblue: "4682b4",
tan: "d2b48c",
teal: "008080",
thistle: "d8bfd8",
tomato: "ff6347",
turquoise: "40e0d0",
violet: "ee82ee",
violetred: "d02090",
wheat: "f5deb3",
white: "ffffff",
whitesmoke: "f5f5f5",
yellow: "ffff00",
yellowgreen: "9acd32"
};
color_string=simple_colors[color_string]||color_string;
var color_defs=[
{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
example: ["rgb(123, 234, 45)", "rgb(255,234,245)"],
process: function(bits){
return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])];
}},
{
re: /^(\w{2})(\w{2})(\w{2})$/,
example: ["#00ff00", "336699"],
process: function(bits){
return [
parseInt(bits[1], 16),
parseInt(bits[2], 16),
parseInt(bits[3], 16)
];
}},
{
re: /^(\w{1})(\w{1})(\w{1})$/,
example: ["#fb0", "f0f"],
process: function(bits){
return [
parseInt(bits[1] + bits[1], 16),
parseInt(bits[2] + bits[2], 16),
parseInt(bits[3] + bits[3], 16)
];
}}
];
for (var i=0; i < color_defs.length; i++){
var re=color_defs[i].re;
var processor=color_defs[i].process;
var bits=re.exec(color_string);
if(bits){
channels=processor(bits);
this.r=channels[0];
this.g=channels[1];
this.b=channels[2];
this.ok=true;
}}
this.r=this.r < 0||isNaN(this.r) ? 0:this.r > 255 ? 255:this.r;
this.g=this.g < 0||isNaN(this.g) ? 0:this.g > 255 ? 255:this.g;
this.b=this.b < 0||isNaN(this.b) ? 0:this.b > 255 ? 255:this.b;
this.toRGB=function(){
return "rgb(" + this.r + ", " + this.g + ", " + this.b + ")";
};
this.toHex=function(){
var r=this.r.toString(16);
var g=this.g.toString(16);
var b=this.b.toString(16);
if(r.length==1) r="0" + r;
if(g.length==1) g="0" + g;
if(b.length==1) b="0" + b;
return "#" + r + g + b;
};}
var atob, btoa;
(function(){
atob=globalObject.atob;
btoa=globalObject.btoa;
return;
})();
function PubSub(context){
if(typeof context!=="object"){
throw new Error(
"Invalid Context passed to initialize PubSub (jsPDF-module)"
);
}
var topics={};
this.subscribe=function(topic, callback, once){
once=once||false;
if(typeof topic!=="string" ||
typeof callback!=="function" ||
typeof once!=="boolean"
){
throw new Error(
"Invalid arguments passed to PubSub.subscribe (jsPDF-module)"
);
}
if(!topics.hasOwnProperty(topic)){
topics[topic]={};}
var token=Math.random().toString(35);
topics[topic][token]=[callback, !!once];
return token;
};
this.unsubscribe=function(token){
for (var topic in topics){
if(topics[topic][token]){
delete topics[topic][token];
if(Object.keys(topics[topic]).length===0){
delete topics[topic];
}
return true;
}}
return false;
};
this.publish=function(topic){
if(topics.hasOwnProperty(topic)){
var args=Array.prototype.slice.call(arguments, 1),
tokens=[];
for (var token in topics[topic]){
var sub=topics[topic][token];
try {
sub[0].apply(context, args);
} catch (ex){
if(globalObject.console){
console.error("jsPDF PubSub Error", ex.message, ex);
}}
if(sub[1]) tokens.push(token);
}
if(tokens.length) tokens.forEach(this.unsubscribe);
}};
this.getTopics=function(){
return topics;
};}
function GState(parameters){
if(!(this instanceof GState)){
return new GState(parameters);
}
var supported="opacity,stroke-opacity".split(",");
for (var p in parameters){
if(parameters.hasOwnProperty(p)&&supported.indexOf(p) >=0){
this[p]=parameters[p];
}}
this.id="";
this.objectNumber=-1;
}
GState.prototype.equals=function equals(other){
var ignore="id,objectNumber,equals";
var p;
if(!other||typeof other!==typeof this) return false;
var count=0;
for (p in this){
if(ignore.indexOf(p) >=0) continue;
if(this.hasOwnProperty(p)&&!other.hasOwnProperty(p)) return false;
if(this[p]!==other[p]) return false;
count++;
}
for (p in other){
if(other.hasOwnProperty(p)&&ignore.indexOf(p) < 0) count--;
}
return count===0;
};
function Pattern(gState, matrix){
this.gState=gState;
this.matrix=matrix;
this.id="";
this.objectNumber=-1;
}
function ShadingPattern(type, coords, colors, gState, matrix){
if(!(this instanceof ShadingPattern)){
return new ShadingPattern(type, coords, colors, gState, matrix);
}
this.type=type==="axial" ? 2:3;
this.coords=coords;
this.colors=colors;
Pattern.call(this, gState, matrix);
}
function TilingPattern(boundingBox, xStep, yStep, gState, matrix){
if(!(this instanceof TilingPattern)){
return new TilingPattern(boundingBox, xStep, yStep, gState, matrix);
}
this.boundingBox=boundingBox;
this.xStep=xStep;
this.yStep=yStep;
this.stream="";
this.cloneIndex=0;
Pattern.call(this, gState, matrix);
}
function jsPDF(options){
var orientation=typeof arguments[0]==="string" ? arguments[0]:"p";
var unit=arguments[1];
var format=arguments[2];
var compressPdf=arguments[3];
var filters=[];
var userUnit=1.0;
var precision;
var floatPrecision=16;
var defaultPathOperation="S";
options=options||{};
if(typeof options==="object"){
orientation=options.orientation;
unit=options.unit||unit;
format=options.format||format;
compressPdf=options.compress||options.compressPdf||compressPdf;
userUnit =
typeof options.userUnit==="number" ? Math.abs(options.userUnit):1.0;
if(typeof options.precision!=="undefined"){
precision=options.precision;
}
if(typeof options.floatPrecision!=="undefined"){
floatPrecision=options.floatPrecision;
}
defaultPathOperation=options.defaultPathOperation||"S";
}
filters =
options.filters||(compressPdf===true ? ["FlateEncode"]:filters);
unit=unit||"mm";
orientation=("" + (orientation||"P")).toLowerCase();
var putOnlyUsedFonts=options.putOnlyUsedFonts||false;
var usedFonts={};
var API={
internal: {},
__private__: {}};
API.__private__.PubSub=PubSub;
var pdfVersion="1.3";
var getPdfVersion=(API.__private__.getPdfVersion=function(){
return pdfVersion;
});
API.__private__.setPdfVersion=function(value){
pdfVersion=value;
};
var pageFormats={
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.4, 209.76],
a9: [104.88, 147.4],
a10: [73.7, 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.9, 708.66],
b6: [354.33, 498.9],
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]
};
API.__private__.getPageFormats=function(){
return pageFormats;
};
var getPageFormat=(API.__private__.getPageFormat=function(value){
return pageFormats[value];
});
format=format||"a4";
var ApiMode={
COMPAT: "compat",
ADVANCED: "advanced"
};
var apiMode=ApiMode.COMPAT;
function advancedAPI(){
this.saveGraphicsState();
out(
new Matrix(
scaleFactor,
0,
0,
-scaleFactor,
0,
getPageHeight() * scaleFactor
).toString() + " cm"
);
this.setFontSize(this.getFontSize() / scaleFactor);
defaultPathOperation="n";
apiMode=ApiMode.ADVANCED;
}
function compatAPI(){
this.restoreGraphicsState();
defaultPathOperation="S";
apiMode=ApiMode.COMPAT;
}
API.advancedAPI=function(body){
var doSwitch=apiMode===ApiMode.COMPAT;
if(doSwitch){
advancedAPI.call(this);
}
if(typeof body!=="function"){
return this;
}
body(this);
if(doSwitch){
compatAPI.call(this);
}
return this;
};
API.compatAPI=function(body){
var doSwitch=apiMode===ApiMode.ADVANCED;
if(doSwitch){
compatAPI.call(this);
}
if(typeof body!=="function"){
return this;
}
body(this);
if(doSwitch){
advancedAPI.call(this);
}
return this;
};
API.isAdvancedAPI=function(){
return apiMode===ApiMode.ADVANCED;
};
var advancedApiModeTrap=function(methodName){
if(apiMode!==ApiMode.ADVANCED){
throw new Error(
methodName +
" is only available in 'advanced' API mode. " +
"You need to call advancedAPI() first."
);
}};
var roundToPrecision=(API.roundToPrecision=API.__private__.roundToPrecision=function(
number,
parmPrecision
){
var tmpPrecision=precision||parmPrecision;
if(isNaN(number)||isNaN(tmpPrecision)){
throw new Error("Invalid argument passed to jsPDF.roundToPrecision");
}
return number.toFixed(tmpPrecision).replace(/0+$/, "");
});
var hpf;
if(typeof floatPrecision==="number"){
hpf=API.hpf=API.__private__.hpf=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.hpf");
}
return roundToPrecision(number, floatPrecision);
};}else if(floatPrecision==="smart"){
hpf=API.hpf=API.__private__.hpf=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.hpf");
}
if(number > -1&&number < 1){
return roundToPrecision(number, 16);
}else{
return roundToPrecision(number, 5);
}};}else{
hpf=API.hpf=API.__private__.hpf=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.hpf");
}
return roundToPrecision(number, 16);
};}
var f2=(API.f2=API.__private__.f2=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.f2");
}
return roundToPrecision(number, 2);
});
var f3=(API.__private__.f3=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.f3");
}
return roundToPrecision(number, 3);
});
var scale=(API.scale=API.__private__.scale=function(number){
if(isNaN(number)){
throw new Error("Invalid argument passed to jsPDF.scale");
}
if(apiMode===ApiMode.COMPAT){
return number * scaleFactor;
}else if(apiMode===ApiMode.ADVANCED){
return number;
}});
var transformY=function(y){
if(apiMode===ApiMode.COMPAT){
return getPageHeight() - y;
}else if(apiMode===ApiMode.ADVANCED){
return y;
}};
var transformScaleY=function(y){
return scale(transformY(y));
};
API.__private__.setPrecision=API.setPrecision=function(value){
if(typeof parseInt(value, 10)==="number"){
precision=parseInt(value, 10);
}};
var fileId="00000000000000000000000000000000";
var getFileId=(API.__private__.getFileId=function(){
return fileId;
});
var setFileId=(API.__private__.setFileId=function(value){
if(typeof value!=="undefined"&&/^[a-fA-F0-9]{32}$/.test(value)){
fileId=value.toUpperCase();
}else{
fileId=fileId
.split("")
.map(function(){
return "ABCDEF0123456789".charAt(Math.floor(Math.random() * 16));
})
.join("");
}
return fileId;
});
API.setFileId=function(value){
setFileId(value);
return this;
};
API.getFileId=function(){
return getFileId();
};
var creationDate;
var convertDateToPDFDate=(API.__private__.convertDateToPDFDate=function(
parmDate
){
var result="";
var tzoffset=parmDate.getTimezoneOffset(),
tzsign=tzoffset < 0 ? "+":"-",
tzhour=Math.floor(Math.abs(tzoffset / 60)),
tzmin=Math.abs(tzoffset % 60),
timeZoneString=[tzsign, padd2(tzhour), "'", padd2(tzmin), "'"].join("");
result=[
"D:",
parmDate.getFullYear(),
padd2(parmDate.getMonth() + 1),
padd2(parmDate.getDate()),
padd2(parmDate.getHours()),
padd2(parmDate.getMinutes()),
padd2(parmDate.getSeconds()),
timeZoneString
].join("");
return result;
});
var convertPDFDateToDate=(API.__private__.convertPDFDateToDate=function(
parmPDFDate
){
var year=parseInt(parmPDFDate.substr(2, 4), 10);
var month=parseInt(parmPDFDate.substr(6, 2), 10) - 1;
var date=parseInt(parmPDFDate.substr(8, 2), 10);
var hour=parseInt(parmPDFDate.substr(10, 2), 10);
var minutes=parseInt(parmPDFDate.substr(12, 2), 10);
var seconds=parseInt(parmPDFDate.substr(14, 2), 10);
var resultingDate=new Date(year, month, date, hour, minutes, seconds, 0);
return resultingDate;
});
var setCreationDate=(API.__private__.setCreationDate=function(date){
var tmpCreationDateString;
var regexPDFCreationDate=/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/;
if(typeof date==="undefined"){
date=new Date();
}
if(date instanceof Date){
tmpCreationDateString=convertDateToPDFDate(date);
}else if(regexPDFCreationDate.test(date)){
tmpCreationDateString=date;
}else{
throw new Error("Invalid argument passed to jsPDF.setCreationDate");
}
creationDate=tmpCreationDateString;
return creationDate;
});
var getCreationDate=(API.__private__.getCreationDate=function(type){
var result=creationDate;
if(type==="jsDate"){
result=convertPDFDateToDate(creationDate);
}
return result;
});
API.setCreationDate=function(date){
setCreationDate(date);
return this;
};
API.getCreationDate=function(type){
return getCreationDate(type);
};
var padd2=(API.__private__.padd2=function(number){
return ("0" + parseInt(number)).slice(-2);
});
var padd2Hex=(API.__private__.padd2Hex=function(hexString){
hexString=hexString.toString();
return ("00" + hexString).substr(hexString.length);
});
var objectNumber=0; // 'n' Current object number
var offsets=[];
var content=[];
var contentLength=0;
var additionalObjects=[];
var pages=[];
var currentPage;
var hasCustomDestination=false;
var outputDestination=content;
var resetDocument=function(){
objectNumber=0;
contentLength=0;
content=[];
offsets=[];
additionalObjects=[];
rootDictionaryObjId=newObjectDeferred();
resourceDictionaryObjId=newObjectDeferred();
};
API.__private__.setCustomOutputDestination=function(destination){
hasCustomDestination=true;
outputDestination=destination;
};
var setOutputDestination=function(destination){
if(!hasCustomDestination){
outputDestination=destination;
}};
API.__private__.resetCustomOutputDestination=function(){
hasCustomDestination=false;
outputDestination=content;
};
var out=(API.__private__.out=function(string){
string=string.toString();
contentLength +=string.length + 1;
outputDestination.push(string);
return outputDestination;
});
var write=(API.__private__.write=function(value){
return out(
arguments.length===1
? value.toString()
: Array.prototype.join.call(arguments, " ")
);
});
var getArrayBuffer=(API.__private__.getArrayBuffer=function(data){
var len=data.length,
ab=new ArrayBuffer(len),
u8=new Uint8Array(ab);
while (len--) u8[len]=data.charCodeAt(len);
return ab;
});
var standardFonts=[
["Helvetica", "helvetica", "normal", "WinAnsiEncoding"],
["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"],
["Helvetica-Oblique", "helvetica", "italic", "WinAnsiEncoding"],
["Helvetica-BoldOblique", "helvetica", "bolditalic", "WinAnsiEncoding"],
["Courier", "courier", "normal", "WinAnsiEncoding"],
["Courier-Bold", "courier", "bold", "WinAnsiEncoding"],
["Courier-Oblique", "courier", "italic", "WinAnsiEncoding"],
["Courier-BoldOblique", "courier", "bolditalic", "WinAnsiEncoding"],
["Times-Roman", "times", "normal", "WinAnsiEncoding"],
["Times-Bold", "times", "bold", "WinAnsiEncoding"],
["Times-Italic", "times", "italic", "WinAnsiEncoding"],
["Times-BoldItalic", "times", "bolditalic", "WinAnsiEncoding"],
["ZapfDingbats", "zapfdingbats", "normal", null],
["Symbol", "symbol", "normal", null]
];
API.__private__.getStandardFonts=function(){
return standardFonts;
};
var activeFontSize=options.fontSize||16;
API.__private__.setFontSize=API.setFontSize=function(size){
if(apiMode===ApiMode.ADVANCED){
activeFontSize=size / scaleFactor;
}else{
activeFontSize=size;
}
return this;
};
var getFontSize=(API.__private__.getFontSize=API.getFontSize=function(){
if(apiMode===ApiMode.COMPAT){
return activeFontSize;
}else{
return activeFontSize * scaleFactor;
}});
var R2L=options.R2L||false;
API.__private__.setR2L=API.setR2L=function(value){
R2L=value;
return this;
};
API.__private__.getR2L=API.getR2L=function(){
return R2L;
};
var zoomMode;
var setZoomMode=(API.__private__.setZoomMode=function(zoom){
var validZoomModes=[
undefined,
null,
"fullwidth",
"fullheight",
"fullpage",
"original"
];
if(/^\d*\.?\d*%$/.test(zoom)){
zoomMode=zoom;
}else if(!isNaN(zoom)){
zoomMode=parseInt(zoom, 10);
}else if(validZoomModes.indexOf(zoom)!==-1){
zoomMode=zoom;
}else{
throw new Error(
'zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "' +
zoom +
'" is not recognized.'
);
}});
API.__private__.getZoomMode=function(){
return zoomMode;
};
var pageMode;
var setPageMode=(API.__private__.setPageMode=function(pmode){
var validPageModes=[
undefined,
null,
"UseNone",
"UseOutlines",
"UseThumbs",
"FullScreen"
];
if(validPageModes.indexOf(pmode)==-1){
throw new Error(
'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' +
pmode +
'" is not recognized.'
);
}
pageMode=pmode;
});
API.__private__.getPageMode=function(){
return pageMode;
};
var layoutMode;
var setLayoutMode=(API.__private__.setLayoutMode=function(layout){
var validLayoutModes=[
undefined,
null,
"continuous",
"single",
"twoleft",
"tworight",
"two"
];
if(validLayoutModes.indexOf(layout)==-1){
throw new Error(
'Layout mode must be one of continuous, single, twoleft, tworight. "' +
layout +
'" is not recognized.'
);
}
layoutMode=layout;
});
API.__private__.getLayoutMode=function(){
return layoutMode;
};
API.__private__.setDisplayMode=API.setDisplayMode=function(
zoom,
layout,
pmode
){
setZoomMode(zoom);
setLayoutMode(layout);
setPageMode(pmode);
return this;
};
var documentProperties={
title: "",
subject: "",
author: "",
keywords: "",
creator: ""
};
API.__private__.getDocumentProperty=function(key){
if(Object.keys(documentProperties).indexOf(key)===-1){
throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");
}
return documentProperties[key];
};
API.__private__.getDocumentProperties=function(){
return documentProperties;
};
API.__private__.setDocumentProperties=API.setProperties=API.setDocumentProperties=function(
properties
){
for (var property in documentProperties){
if(documentProperties.hasOwnProperty(property)&&properties[property]){
documentProperties[property]=properties[property];
}}
return this;
};
API.__private__.setDocumentProperty=function(key, value){
if(Object.keys(documentProperties).indexOf(key)===-1){
throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");
}
return (documentProperties[key]=value);
};
var fonts={};
var fontmap={};
var activeFontKey;
var fontStateStack=[];
var patterns={};
var patternMap={};
var gStates={};
var gStatesMap={};
var activeGState=null;
var scaleFactor;
var page=0;
var pagesContext=[];
var events=new PubSub(API);
var hotfixes=options.hotfixes||[];
var renderTargets={};
var renderTargetMap={};
var renderTargetStack=[];
var pageX;
var pageY;
var pageMatrix;
var Matrix=function(sx, shy, shx, sy, tx, ty){
if(!(this instanceof Matrix)){
return new Matrix(sx, shy, shx, sy, tx, ty);
}
if(isNaN(sx)) sx=1;
if(isNaN(shy)) shy=0;
if(isNaN(shx)) shx=0;
if(isNaN(sy)) sy=1;
if(isNaN(tx)) tx=0;
if(isNaN(ty)) ty=0;
this._matrix=[sx, shy, shx, sy, tx, ty];
};
Object.defineProperty(Matrix.prototype, "sx", {
get: function(){
return this._matrix[0];
},
set: function(value){
this._matrix[0]=value;
}});
Object.defineProperty(Matrix.prototype, "shy", {
get: function(){
return this._matrix[1];
},
set: function(value){
this._matrix[1]=value;
}});
Object.defineProperty(Matrix.prototype, "shx", {
get: function(){
return this._matrix[2];
},
set: function(value){
this._matrix[2]=value;
}});
Object.defineProperty(Matrix.prototype, "sy", {
get: function(){
return this._matrix[3];
},
set: function(value){
this._matrix[3]=value;
}});
Object.defineProperty(Matrix.prototype, "tx", {
get: function(){
return this._matrix[4];
},
set: function(value){
this._matrix[4]=value;
}});
Object.defineProperty(Matrix.prototype, "ty", {
get: function(){
return this._matrix[5];
},
set: function(value){
this._matrix[5]=value;
}});
Object.defineProperty(Matrix.prototype, "a", {
get: function(){
return this._matrix[0];
},
set: function(value){
this._matrix[0]=value;
}});
Object.defineProperty(Matrix.prototype, "b", {
get: function(){
return this._matrix[1];
},
set: function(value){
this._matrix[1]=value;
}});
Object.defineProperty(Matrix.prototype, "c", {
get: function(){
return this._matrix[2];
},
set: function(value){
this._matrix[2]=value;
}});
Object.defineProperty(Matrix.prototype, "d", {
get: function(){
return this._matrix[3];
},
set: function(value){
this._matrix[3]=value;
}});
Object.defineProperty(Matrix.prototype, "e", {
get: function(){
return this._matrix[4];
},
set: function(value){
this._matrix[4]=value;
}});
Object.defineProperty(Matrix.prototype, "f", {
get: function(){
return this._matrix[5];
},
set: function(value){
this._matrix[5]=value;
}});
Object.defineProperty(Matrix.prototype, "rotation", {
get: function(){
return Math.atan2(this.shx, this.sx);
}});
Object.defineProperty(Matrix.prototype, "scaleX", {
get: function(){
return this.decompose().scale.sx;
}});
Object.defineProperty(Matrix.prototype, "scaleY", {
get: function(){
return this.decompose().scale.sy;
}});
Object.defineProperty(Matrix.prototype, "isIdentity", {
get: function(){
if(this.sx!==1){
return false;
}
if(this.shy!==0){
return false;
}
if(this.shx!==0){
return false;
}
if(this.sy!==1){
return false;
}
if(this.tx!==0){
return false;
}
if(this.ty!==0){
return false;
}
return true;
}});
Matrix.prototype.join=function(separator){
return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty]
.map(hpf)
.join(separator);
};
Matrix.prototype.multiply=function(matrix){
var sx=matrix.sx * this.sx + matrix.shy * this.shx;
var shy=matrix.sx * this.shy + matrix.shy * this.sy;
var shx=matrix.shx * this.sx + matrix.sy * this.shx;
var sy=matrix.shx * this.shy + matrix.sy * this.sy;
var tx=matrix.tx * this.sx + matrix.ty * this.shx + this.tx;
var ty=matrix.tx * this.shy + matrix.ty * this.sy + this.ty;
return new Matrix(sx, shy, shx, sy, tx, ty);
};
Matrix.prototype.decompose=function(){
var a=this.sx;
var b=this.shy;
var c=this.shx;
var d=this.sy;
var e=this.tx;
var f=this.ty;
var scaleX=Math.sqrt(a * a + b * b);
a /=scaleX;
b /=scaleX;
var shear=a * c + b * d;
c -=a * shear;
d -=b * shear;
var scaleY=Math.sqrt(c * c + d * d);
c /=scaleY;
d /=scaleY;
shear /=scaleY;
if(a * d < b * c){
a=-a;
b=-b;
shear=-shear;
scaleX=-scaleX;
}
return {
scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0),
translate: new Matrix(1, 0, 0, 1, e, f),
rotate: new Matrix(a, b, -b, a, 0, 0),
skew: new Matrix(1, 0, shear, 1, 0, 0)
};};
Matrix.prototype.toString=function(parmPrecision){
return this.join(" ");
};
Matrix.prototype.inversed=function(){
var a=this.sx,
b=this.shy,
c=this.shx,
d=this.sy,
e=this.tx,
f=this.ty;
var quot=1 / (a * d - b * c);
var aInv=d * quot;
var bInv=-b * quot;
var cInv=-c * quot;
var dInv=a * quot;
var eInv=-aInv * e - cInv * f;
var fInv=-bInv * e - dInv * f;
return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv);
};
Matrix.prototype.applyToPoint=function(pt){
var x=pt.x * this.sx + pt.y * this.shx + this.tx;
var y=pt.x * this.shy + pt.y * this.sy + this.ty;
return new Point(x, y);
};
Matrix.prototype.applyToRectangle=function(rect){
var pt1=this.applyToPoint(rect);
var pt2=this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h));
return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y);
};
Matrix.prototype.clone=function(){
var sx=this.sx;
var shy=this.shy;
var shx=this.shx;
var sy=this.sy;
var tx=this.tx;
var ty=this.ty;
return new Matrix(sx, shy, shx, sy, tx, ty);
};
API.Matrix=Matrix;
var matrixMult=(API.matrixMult=function(m1, m2){
return m2.multiply(m1);
});
var identityMatrix=new Matrix(1, 0, 0, 1, 0, 0);
API.unitMatrix=API.identityMatrix=identityMatrix;
var addPattern=function(key, pattern){
if(patternMap[key]) return;
var prefix=pattern instanceof ShadingPattern ? "Sh":"P";
var patternKey=prefix + (Object.keys(patterns).length + 1).toString(10);
pattern.id=patternKey;
patternMap[key]=patternKey;
patterns[patternKey]=pattern;
events.publish("addPattern", pattern);
};
API.ShadingPattern=ShadingPattern;
API.TilingPattern=TilingPattern;
API.addShadingPattern=function(key, pattern){
advancedApiModeTrap("addShadingPattern()");
addPattern(key, pattern);
return this;
};
API.beginTilingPattern=function(pattern){
advancedApiModeTrap("beginTilingPattern()");
beginNewRenderTarget(
pattern.boundingBox[0],
pattern.boundingBox[1],
pattern.boundingBox[2] - pattern.boundingBox[0],
pattern.boundingBox[3] - pattern.boundingBox[1],
pattern.matrix
);
};
API.endTilingPattern=function(key, pattern){
advancedApiModeTrap("endTilingPattern()");
pattern.stream=pages[currentPage].join("\n");
addPattern(key, pattern);
events.publish("endTilingPattern", pattern);
renderTargetStack.pop().restore();
};
var newObject=(API.__private__.newObject=function(){
var oid=newObjectDeferred();
newObjectDeferredBegin(oid, true);
return oid;
});
var newObjectDeferred=(API.__private__.newObjectDeferred=function(){
objectNumber++;
offsets[objectNumber]=function(){
return contentLength;
};
return objectNumber;
});
var newObjectDeferredBegin=function(oid, doOutput){
doOutput=typeof doOutput==="boolean" ? doOutput:false;
offsets[oid]=contentLength;
if(doOutput){
out(oid + " 0 obj");
}
return oid;
};
var newAdditionalObject=(API.__private__.newAdditionalObject=function(){
var objId=newObjectDeferred();
var obj={
objId: objId,
content: ""
};
additionalObjects.push(obj);
return obj;
});
var rootDictionaryObjId=newObjectDeferred();
var resourceDictionaryObjId=newObjectDeferred();
var decodeColorString=(API.__private__.decodeColorString=function(color){
var colorEncoded=color.split(" ");
if(colorEncoded.length===2 &&
(colorEncoded[1]==="g"||colorEncoded[1]==="G")
){
var floatVal=parseFloat(colorEncoded[0]);
colorEncoded=[floatVal, floatVal, floatVal, "r"];
}else if(colorEncoded.length===5 &&
(colorEncoded[4]==="k"||colorEncoded[4]==="K")
){
var red=(1.0 - colorEncoded[0]) * (1.0 - colorEncoded[3]);
var green=(1.0 - colorEncoded[1]) * (1.0 - colorEncoded[3]);
var blue=(1.0 - colorEncoded[2]) * (1.0 - colorEncoded[3]);
colorEncoded=[red, green, blue, "r"];
}
var colorAsRGB="#";
for (var i=0; i < 3; i++){
colorAsRGB +=(
"0" + Math.floor(parseFloat(colorEncoded[i]) * 255).toString(16)
).slice(-2);
}
return colorAsRGB;
});
var encodeColorString=(API.__private__.encodeColorString=function(
options
){
var color;
if(typeof options==="string"){
options={
ch1: options
};}
var ch1=options.ch1;
var ch2=options.ch2;
var ch3=options.ch3;
var ch4=options.ch4;
var letterArray =
options.pdfColorType==="draw" ? ["G", "RG", "K"]:["g", "rg", "k"];
if(typeof ch1==="string"&&ch1.charAt(0)!=="#"){
var rgbColor=new RGBColor(ch1);
if(rgbColor.ok){
ch1=rgbColor.toHex();
}else if(!/^\d*\.?\d*$/.test(ch1)){
throw new Error(
'Invalid color "' + ch1 + '" passed to jsPDF.encodeColorString.'
);
}}
if(typeof ch1==="string"&&/^#[0-9A-Fa-f]{3}$/.test(ch1)){
ch1="#" + ch1[1] + ch1[1] + ch1[2] + ch1[2] + ch1[3] + ch1[3];
}
if(typeof ch1==="string"&&/^#[0-9A-Fa-f]{6}$/.test(ch1)){
var hex=parseInt(ch1.substr(1), 16);
ch1=(hex >> 16) & 255;
ch2=(hex >> 8) & 255;
ch3=hex & 255;
}
if(typeof ch2==="undefined" ||
(typeof ch4==="undefined"&&ch1===ch2&&ch2===ch3)
){
if(typeof ch1==="string"){
color=ch1 + " " + letterArray[0];
}else{
switch (options.precision){
case 2:
color=f2(ch1 / 255) + " " + letterArray[0];
break;
case 3:
default:
color=f3(ch1 / 255) + " " + letterArray[0];
}}
}else if(typeof ch4==="undefined"||typeof ch4==="object"){
if(ch4&&!isNaN(ch4.a)){
if(ch4.a===0){
color=["1.", "1.", "1.", letterArray[1]].join(" ");
return color;
}}
if(typeof ch1==="string"){
color=[ch1, ch2, ch3, letterArray[1]].join(" ");
}else{
switch (options.precision){
case 2:
color=[
f2(ch1 / 255),
f2(ch2 / 255),
f2(ch3 / 255),
letterArray[1]
].join(" ");
break;
default:
case 3:
color=[
f3(ch1 / 255),
f3(ch2 / 255),
f3(ch3 / 255),
letterArray[1]
].join(" ");
}}
}else{
if(typeof ch1==="string"){
color=[ch1, ch2, ch3, ch4, letterArray[2]].join(" ");
}else{
switch (options.precision){
case 2:
color=[f2(ch1), f2(ch2), f2(ch3), f2(ch4), letterArray[2]].join(" "
);
break;
case 3:
default:
color=[f3(ch1), f3(ch2), f3(ch3), f3(ch4), letterArray[2]].join(" "
);
}}
}
return color;
});
var getFilters=(API.__private__.getFilters=function(){
return filters;
});
var putStream=(API.__private__.putStream=function(options){
options=options||{};
var data=options.data||"";
var filters=options.filters||getFilters();
var alreadyAppliedFilters=options.alreadyAppliedFilters||[];
var addLength1=options.addLength1||false;
var valueOfLength1=data.length;
var processedData={};
if(filters===true){
filters=["FlateEncode"];
}
var keyValues=options.additionalKeyValues||[];
if(typeof jsPDF.API.processDataByFilters!=="undefined"){
processedData=jsPDF.API.processDataByFilters(data, filters);
}else{
processedData={ data: data, reverseChain: [] };}
var filterAsString =
processedData.reverseChain +
(Array.isArray(alreadyAppliedFilters)
? alreadyAppliedFilters.join(" ")
: alreadyAppliedFilters.toString());
if(processedData.data.length!==0){
keyValues.push({
key: "Length",
value: processedData.data.length
});
if(addLength1===true){
keyValues.push({
key: "Length1",
value: valueOfLength1
});
}}
if(filterAsString.length!=0){
if(filterAsString.split("/").length - 1===1){
keyValues.push({
key: "Filter",
value: filterAsString
});
}else{
keyValues.push({
key: "Filter",
value: "[" + filterAsString + "]"
});
for (var j=0; j < keyValues.length; j +=1){
if(keyValues[j].key==="DecodeParms"){
var decodeParmsArray=[];
for (
var i=0;
i < processedData.reverseChain.split("/").length - 1;
i +=1
){
decodeParmsArray.push("null");
}
decodeParmsArray.push(keyValues[j].value);
keyValues[j].value="[" + decodeParmsArray.join(" ") + "]";
}}
}}
out("<<");
for (var k=0; k < keyValues.length; k++){
out("/" + keyValues[k].key + " " + keyValues[k].value);
}
out(">>");
if(processedData.data.length!==0){
out("stream");
out(processedData.data);
out("endstream");
}});
var putPage=(API.__private__.putPage=function(page){
var pageNumber=page.number;
var data=page.data;
var pageObjectNumber=page.objId;
var pageContentsObjId=page.contentsObjId;
newObjectDeferredBegin(pageObjectNumber, true);
out("<</Type /Page");
out("/Parent " + page.rootDictionaryObjId + " 0 R");
out("/Resources " + page.resourceDictionaryObjId + " 0 R");
out(
"/MediaBox [" +
parseFloat(hpf(page.mediaBox.bottomLeftX)) +
" " +
parseFloat(hpf(page.mediaBox.bottomLeftY)) +
" " +
hpf(page.mediaBox.topRightX) +
" " +
hpf(page.mediaBox.topRightY) +
"]"
);
if(page.cropBox!==null){
out(
"/CropBox [" +
hpf(page.cropBox.bottomLeftX) +
" " +
hpf(page.cropBox.bottomLeftY) +
" " +
hpf(page.cropBox.topRightX) +
" " +
hpf(page.cropBox.topRightY) +
"]"
);
}
if(page.bleedBox!==null){
out(
"/BleedBox [" +
hpf(page.bleedBox.bottomLeftX) +
" " +
hpf(page.bleedBox.bottomLeftY) +
" " +
hpf(page.bleedBox.topRightX) +
" " +
hpf(page.bleedBox.topRightY) +
"]"
);
}
if(page.trimBox!==null){
out(
"/TrimBox [" +
hpf(page.trimBox.bottomLeftX) +
" " +
hpf(page.trimBox.bottomLeftY) +
" " +
hpf(page.trimBox.topRightX) +
" " +
hpf(page.trimBox.topRightY) +
"]"
);
}
if(page.artBox!==null){
out(
"/ArtBox [" +
hpf(page.artBox.bottomLeftX) +
" " +
hpf(page.artBox.bottomLeftY) +
" " +
hpf(page.artBox.topRightX) +
" " +
hpf(page.artBox.topRightY) +
"]"
);
}
if(typeof page.userUnit==="number"&&page.userUnit!==1.0){
out("/UserUnit " + page.userUnit);
}
events.publish("putPage", {
objId: pageObjectNumber,
pageContext: pagesContext[pageNumber],
pageNumber: pageNumber,
page: data
});
out("/Contents " + pageContentsObjId + " 0 R");
out(">>");
out("endobj");
var pageContent=data.join("\n");
if(apiMode===ApiMode.ADVANCED){
pageContent +="\nQ";
}
newObjectDeferredBegin(pageContentsObjId, true);
putStream({
data: pageContent,
filters: getFilters()
});
out("endobj");
return pageObjectNumber;
});
var putPages=(API.__private__.putPages=function(){
var n,
i,
pageObjectNumbers=[];
for (n=1; n <=page; n++){
pagesContext[n].objId=newObjectDeferred();
pagesContext[n].contentsObjId=newObjectDeferred();
}
for (n=1; n <=page; n++){
pageObjectNumbers.push(putPage({
number: n,
data: pages[n],
objId: pagesContext[n].objId,
contentsObjId: pagesContext[n].contentsObjId,
mediaBox: pagesContext[n].mediaBox,
cropBox: pagesContext[n].cropBox,
bleedBox: pagesContext[n].bleedBox,
trimBox: pagesContext[n].trimBox,
artBox: pagesContext[n].artBox,
userUnit: pagesContext[n].userUnit,
rootDictionaryObjId: rootDictionaryObjId,
resourceDictionaryObjId: resourceDictionaryObjId
})
);
}
newObjectDeferredBegin(rootDictionaryObjId, true);
out("<</Type /Pages");
var kids="/Kids [";
for (i=0; i < page; i++){
kids +=pageObjectNumbers[i] + " 0 R ";
}
out(kids + "]");
out("/Count " + page);
out(">>");
out("endobj");
events.publish("postPutPages");
});
var putFont=function(font){
var pdfEscapeWithNeededParanthesis=function(text, flags){
var addParanthesis=text.indexOf(" ")!==-1;
return addParanthesis
? "(" + pdfEscape(text, flags) + ")"
: pdfEscape(text, flags);
};
events.publish("putFont", {
font: font,
out: out,
newObject: newObject,
putStream: putStream,
pdfEscapeWithNeededParanthesis: pdfEscapeWithNeededParanthesis
});
if(font.isAlreadyPutted!==true){
font.objectNumber=newObject();
out("<<");
out("/Type /Font");
out("/BaseFont /" + pdfEscapeWithNeededParanthesis(font.postScriptName));
out("/Subtype /Type1");
if(typeof font.encoding==="string"){
out("/Encoding /" + font.encoding);
}
out("/FirstChar 32");
out("/LastChar 255");
out(">>");
out("endobj");
}};
var putFonts=function(){
for (var fontKey in fonts){
if(fonts.hasOwnProperty(fontKey)){
if(putOnlyUsedFonts===false ||
(putOnlyUsedFonts===true&&usedFonts.hasOwnProperty(fontKey))
){
putFont(fonts[fontKey]);
}}
}};
var putXObject=function(xObject){
xObject.objectNumber=newObject();
var options=[];
options.push({ key: "Type", value: "/XObject" });
options.push({ key: "Subtype", value: "/Form" });
options.push({
key: "BBox",
value:
"[" +
[
hpf(xObject.x),
hpf(xObject.y),
hpf(xObject.x + xObject.width),
hpf(xObject.y + xObject.height)
].join(" ") +
"]"
});
options.push({
key: "Matrix",
value: "[" + xObject.matrix.toString() + "]"
});
var stream=xObject.pages[1].join("\n");
putStream({
data: stream,
additionalKeyValues: options
});
out("endobj");
};
var putXObjects=function(){
for (var xObjectKey in renderTargets){
if(renderTargets.hasOwnProperty(xObjectKey)){
putXObject(renderTargets[xObjectKey]);
}}
};
var interpolateAndEncodeRGBStream=function(colors, numberSamples){
var tValues=[];
var t;
var dT=1.0 / (numberSamples - 1);
for (t=0.0; t < 1.0; t +=dT){
tValues.push(t);
}
tValues.push(1.0);
if(colors[0].offset!=0.0){
var c0={
offset: 0.0,
color: colors[0].color
};
colors.unshift(c0);
}
if(colors[colors.length - 1].offset!=1.0){
var c1={
offset: 1.0,
color: colors[colors.length - 1].color
};
colors.push(c1);
}
var out="";
var index=0;
for (var i=0; i < tValues.length; i++){
t=tValues[i];
while (t > colors[index + 1].offset) index++;
var a=colors[index].offset;
var b=colors[index + 1].offset;
var d=(t - a) / (b - a);
var aColor=colors[index].color;
var bColor=colors[index + 1].color;
out +=
padd2Hex(Math.round((1 - d) * aColor[0] + d * bColor[0]).toString(16)) +
padd2Hex(Math.round((1 - d) * aColor[1] + d * bColor[1]).toString(16)) +
padd2Hex(Math.round((1 - d) * aColor[2] + d * bColor[2]).toString(16));
}
return out.trim();
};
var putShadingPattern=function(pattern, numberSamples){
numberSamples||(numberSamples=21);
var funcObjectNumber=newObject();
var stream=interpolateAndEncodeRGBStream(pattern.colors, numberSamples);
var options=[];
options.push({ key: "FunctionType", value: "0" });
options.push({ key: "Domain", value: "[0.0 1.0]" });
options.push({ key: "Size", value: "[" + numberSamples + "]" });
options.push({ key: "BitsPerSample", value: "8" });
options.push({ key: "Range", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" });
options.push({ key: "Decode", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" });
putStream({
data: stream,
additionalKeyValues: options,
alreadyAppliedFilters: ["/ASCIIHexDecode"]
});
out("endobj");
pattern.objectNumber=newObject();
out("<< /ShadingType " + pattern.type);
out("/ColorSpace /DeviceRGB");
var coords =
"/Coords [" +
hpf(parseFloat(pattern.coords[0])) +
" " +
hpf(parseFloat(pattern.coords[1])) +
" ";
if(pattern.type===2){
coords +=
hpf(parseFloat(pattern.coords[2])) +
" " +
hpf(parseFloat(pattern.coords[3]));
}else{
coords +=
hpf(parseFloat(pattern.coords[2])) +
" " +
hpf(parseFloat(pattern.coords[3])) +
" " +
hpf(parseFloat(pattern.coords[4])) +
" " +
hpf(parseFloat(pattern.coords[5]));
}
coords +="]";
out(coords);
if(pattern.matrix){
out("/Matrix [" + pattern.matrix.toString() + "]");
}
out("/Function " + funcObjectNumber + " 0 R");
out("/Extend [true true]");
out(">>");
out("endobj");
};
var putTilingPattern=function(pattern, deferredResourceDictionaryIds){
var resourcesObjectId=newObjectDeferred();
var patternObjectId=newObject();
deferredResourceDictionaryIds.push({
resourcesOid: resourcesObjectId,
objectOid: patternObjectId
});
pattern.objectNumber=patternObjectId;
var options=[];
options.push({ key: "Type", value: "/Pattern" });
options.push({ key: "PatternType", value: "1" });
options.push({ key: "PaintType", value: "1" });
options.push({ key: "TilingType", value: "1" });
options.push({
key: "BBox",
value: "[" + pattern.boundingBox.map(hpf).join(" ") + "]"
});
options.push({ key: "XStep", value: hpf(pattern.xStep) });
options.push({ key: "YStep", value: hpf(pattern.yStep) });
options.push({ key: "Resources", value: resourcesObjectId + " 0 R" });
if(pattern.matrix){
options.push({
key: "Matrix",
value: "[" + pattern.matrix.toString() + "]"
});
}
putStream({
data: pattern.stream,
additionalKeyValues: options
});
out("endobj");
};
var putPatterns=function(deferredResourceDictionaryIds){
var patternKey;
for (patternKey in patterns){
if(patterns.hasOwnProperty(patternKey)){
if(patterns[patternKey] instanceof ShadingPattern){
putShadingPattern(patterns[patternKey]);
}else if(patterns[patternKey] instanceof TilingPattern){
putTilingPattern(patterns[patternKey], deferredResourceDictionaryIds);
}}
}};
var putGState=function(gState){
gState.objectNumber=newObject();
out("<<");
for (var p in gState){
switch (p){
case "opacity":
out("/ca " + f2(gState[p]));
break;
case "stroke-opacity":
out("/CA " + f2(gState[p]));
break;
}}
out(">>");
out("endobj");
};
var putGStates=function(){
var gStateKey;
for (gStateKey in gStates){
if(gStates.hasOwnProperty(gStateKey)){
putGState(gStates[gStateKey]);
}}
};
var putXobjectDict=function(){
out("/XObject <<");
for (var xObjectKey in renderTargets){
if(renderTargets.hasOwnProperty(xObjectKey) &&
renderTargets[xObjectKey].objectNumber >=0
){
out(
"/" +
xObjectKey +
" " +
renderTargets[xObjectKey].objectNumber +
" 0 R"
);
}}
events.publish("putXobjectDict");
out(">>");
};
var putFontDict=function(){
out("/Font <<");
for (var fontKey in fonts){
if(fonts.hasOwnProperty(fontKey)){
if(putOnlyUsedFonts===false ||
(putOnlyUsedFonts===true&&usedFonts.hasOwnProperty(fontKey))
){
out("/" + fontKey + " " + fonts[fontKey].objectNumber + " 0 R");
}}
}
out(">>");
};
var putShadingPatternDict=function(){
if(Object.keys(patterns).length > 0){
out("/Shading <<");
for (var patternKey in patterns){
if(patterns.hasOwnProperty(patternKey) &&
patterns[patternKey] instanceof ShadingPattern &&
patterns[patternKey].objectNumber >=0
){
out(
"/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R"
);
}}
events.publish("putShadingPatternDict");
out(">>");
}};
var putTilingPatternDict=function(objectOid){
if(Object.keys(patterns).length > 0){
out("/Pattern <<");
for (var patternKey in patterns){
if(patterns.hasOwnProperty(patternKey) &&
patterns[patternKey] instanceof API.TilingPattern &&
patterns[patternKey].objectNumber >=0 &&
patterns[patternKey].objectNumber < objectOid
){
out(
"/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R"
);
}}
events.publish("putTilingPatternDict");
out(">>");
}};
var putGStatesDict=function(){
if(Object.keys(gStates).length > 0){
var gStateKey;
out("/ExtGState <<");
for (gStateKey in gStates){
if(gStates.hasOwnProperty(gStateKey) &&
gStates[gStateKey].objectNumber >=0
){
out("/" + gStateKey + " " + gStates[gStateKey].objectNumber + " 0 R");
}}
events.publish("putGStateDict");
out(">>");
}};
var putResourceDictionary=function(objectIds){
newObjectDeferredBegin(objectIds.resourcesOid, true);
out("<<");
out("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");
putFontDict();
putShadingPatternDict();
putTilingPatternDict(objectIds.objectOid);
putGStatesDict();
putXobjectDict();
out(">>");
out("endobj");
};
var putResources=function(){
var deferredResourceDictionaryIds=[];
putFonts();
putGStates();
putXObjects();
putPatterns(deferredResourceDictionaryIds);
events.publish("putResources");
deferredResourceDictionaryIds.forEach(putResourceDictionary);
putResourceDictionary({
resourcesOid: resourceDictionaryObjId,
objectOid: Number.MAX_SAFE_INTEGER
});
events.publish("postPutResources");
};
var putAdditionalObjects=function(){
events.publish("putAdditionalObjects");
for (var i=0; i < additionalObjects.length; i++){
var obj=additionalObjects[i];
newObjectDeferredBegin(obj.objId, true);
out(obj.content);
out("endobj");
}
events.publish("postPutAdditionalObjects");
};
var addFontToFontDictionary=function(font){
fontmap[font.fontName]=fontmap[font.fontName]||{};
fontmap[font.fontName][font.fontStyle]=font.id;
};
var addFont=function(
postScriptName,
fontName,
fontStyle,
encoding,
isStandardFont
){
var font={
id: "F" + (Object.keys(fonts).length + 1).toString(10),
postScriptName: postScriptName,
fontName: fontName,
fontStyle: fontStyle,
encoding: encoding,
isStandardFont: isStandardFont||false,
metadata: {}};
events.publish("addFont", {
font: font,
instance: this
});
fonts[font.id]=font;
addFontToFontDictionary(font);
return font.id;
};
var addFonts=function(arrayOfFonts){
for (var i=0, l=standardFonts.length; i < l; i++){
var fontKey=addFont.call(this,
arrayOfFonts[i][0],
arrayOfFonts[i][1],
arrayOfFonts[i][2],
standardFonts[i][3],
true
);
if(putOnlyUsedFonts===false){
usedFonts[fontKey]=true;
}
var parts=arrayOfFonts[i][0].split("-");
addFontToFontDictionary({
id: fontKey,
fontName: parts[0],
fontStyle: parts[1]||""
});
}
events.publish("addFonts", {
fonts: fonts,
dictionary: fontmap
});
};
var SAFE=function __safeCall(fn){
fn.foo=function __safeCallWrapper(){
try {
return fn.apply(this, arguments);
} catch (e){
var stack=e.stack||"";
if(~stack.indexOf(" at ")) stack=stack.split(" at ")[1];
var m =
"Error in function " +
stack.split("\n")[0].split("<")[0] +
": " +
e.message;
if(globalObject.console){
globalObject.console.error(m, e);
if(globalObject.alert) alert(m);
}else{
throw new Error(m);
}}
};
fn.foo.bar=fn;
return fn.foo;
};
var to8bitStream=function(text, flags){
var i,
l,
sourceEncoding,
encodingBlock,
outputEncoding,
newtext,
isUnicode,
ch,
bch;
flags=flags||{};
sourceEncoding=flags.sourceEncoding||"Unicode";
outputEncoding=flags.outputEncoding;
if((flags.autoencode||outputEncoding) &&
fonts[activeFontKey].metadata &&
fonts[activeFontKey].metadata[sourceEncoding] &&
fonts[activeFontKey].metadata[sourceEncoding].encoding
){
encodingBlock=fonts[activeFontKey].metadata[sourceEncoding].encoding;
if(!outputEncoding&&fonts[activeFontKey].encoding){
outputEncoding=fonts[activeFontKey].encoding;
}
if(!outputEncoding&&encodingBlock.codePages){
outputEncoding=encodingBlock.codePages[0];
}
if(typeof outputEncoding==="string"){
outputEncoding=encodingBlock[outputEncoding];
}
if(outputEncoding){
isUnicode=false;
newtext=[];
for (i=0, l=text.length; i < l; i++){
ch=outputEncoding[text.charCodeAt(i)];
if(ch){
newtext.push(String.fromCharCode(ch));
}else{
newtext.push(text[i]);
}
if(newtext[i].charCodeAt(0) >> 8){
isUnicode=true;
}}
text=newtext.join("");
}}
i=text.length;
while (isUnicode===undefined&&i!==0){
if(text.charCodeAt(i - 1) >> 8){
isUnicode=true;
}
i--;
}
if(!isUnicode){
return text;
}
newtext=flags.noBOM ? []:[254, 255];
for (i=0, l=text.length; i < l; i++){
ch=text.charCodeAt(i);
bch=ch >> 8;
if(bch >> 8){
throw new Error(
"Character at position " +
i +
" of string '" +
text +
"' exceeds 16bits. Cannot be encoded into UCS-2 BE"
);
}
newtext.push(bch);
newtext.push(ch - (bch << 8));
}
return String.fromCharCode.apply(undefined, newtext);
};
var pdfEscape=(API.__private__.pdfEscape=API.pdfEscape=function(
text,
flags
){
return to8bitStream(text, flags)
.replace(/\\/g, "\\\\")
.replace(/\(/g, "\\(")
.replace(/\)/g, "\\)");
});
var beginPage=(API.__private__.beginPage=function(format){
pages[++page]=[];
pagesContext[page]={
objId: 0,
contentsObjId: 0,
userUnit: Number(userUnit),
artBox: null,
bleedBox: null,
cropBox: null,
trimBox: null,
mediaBox: {
bottomLeftX: 0,
bottomLeftY: 0,
topRightX: Number(format[0]),
topRightY: Number(format[1])
}};
_setPage(page);
setOutputDestination(pages[currentPage]);
});
var _addPage=function(parmFormat, parmOrientation){
var dimensions, width, height;
orientation=parmOrientation||orientation;
if(typeof parmFormat==="string"){
dimensions=getPageFormat(parmFormat.toLowerCase());
if(Array.isArray(dimensions)){
width=dimensions[0];
height=dimensions[1];
}}
if(Array.isArray(parmFormat)){
width=parmFormat[0] * scaleFactor;
height=parmFormat[1] * scaleFactor;
}
if(isNaN(width)){
width=format[0];
height=format[1];
}
if(width > 14400||height > 14400){
console.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"
);
width=Math.min(14400, width);
height=Math.min(14400, height);
}
format=[width, height];
switch (orientation.substr(0, 1)){
case "l":
if(height > width){
format=[height, width];
}
break;
case "p":
if(width > height){
format=[height, width];
}
break;
}
beginPage(format);
setLineWidth(lineWidth);
out(strokeColor);
if(lineCapID!==0){
out(lineCapID + " J");
}
if(lineJoinID!==0){
out(lineJoinID + " j");
}
events.publish("addPage", {
pageNumber: page
});
};
var _deletePage=function(n){
if(n > 0&&n <=page){
pages.splice(n, 1);
pagesContext.splice(n, 1);
page--;
if(currentPage > page){
currentPage=page;
}
this.setPage(currentPage);
}};
var _setPage=function(n){
if(n > 0&&n <=page){
currentPage=n;
}};
var getNumberOfPages=(API.__private__.getNumberOfPages=API.getNumberOfPages=function(){
return pages.length - 1;
});
var getFont=function(fontName, fontStyle, options){
var key=undefined,
fontNameLowerCase;
options=options||{};
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."
);
}}
if(!key&&!options.noFallback){
key=fontmap["times"][fontStyle];
if(key==null){
key=fontmap["times"]["normal"];
}}
return key;
};
var putInfo=(API.__private__.putInfo=function(){
newObject();
out("<<");
out("/Producer (jsPDF " + jsPDF.version + ")");
for (var key in documentProperties){
if(documentProperties.hasOwnProperty(key)&&documentProperties[key]){
out(
"/" +
key.substr(0, 1).toUpperCase() +
key.substr(1) +
" (" +
pdfEscape(documentProperties[key]) +
")"
);
}}
out("/CreationDate (" + creationDate + ")");
out(">>");
out("endobj");
});
var putCatalog=(API.__private__.putCatalog=function(options){
options=options||{};
var tmpRootDictionaryObjId =
options.rootDictionaryObjId||rootDictionaryObjId;
newObject();
out("<<");
out("/Type /Catalog");
out("/Pages " + tmpRootDictionaryObjId + " 0 R");
if(!zoomMode) zoomMode="fullwidth";
switch (zoomMode){
case "fullwidth":
out("/OpenAction [3 0 R /FitH null]");
break;
case "fullheight":
out("/OpenAction [3 0 R /FitV null]");
break;
case "fullpage":
out("/OpenAction [3 0 R /Fit]");
break;
case "original":
out("/OpenAction [3 0 R /XYZ null null 1]");
break;
default:
var pcn="" + zoomMode;
if(pcn.substr(pcn.length - 1)==="%")
zoomMode=parseInt(zoomMode) / 100;
if(typeof zoomMode==="number"){
out("/OpenAction [3 0 R /XYZ null null " + f2(zoomMode) + "]");
}}
if(!layoutMode) layoutMode="continuous";
switch (layoutMode){
case "continuous":
out("/PageLayout /OneColumn");
break;
case "single":
out("/PageLayout /SinglePage");
break;
case "two":
case "twoleft":
out("/PageLayout /TwoColumnLeft");
break;
case "tworight":
out("/PageLayout /TwoColumnRight");
break;
}
if(pageMode){
out("/PageMode /" + pageMode);
}
events.publish("putCatalog");
out(">>");
out("endobj");
});
var putTrailer=(API.__private__.putTrailer=function(){
out("trailer");
out("<<");
out("/Size " + (objectNumber + 1));
out("/Root " + objectNumber + " 0 R");
out("/Info " + (objectNumber - 1) + " 0 R");
out("/ID [ <" + fileId + "> <" + fileId + "> ]");
out(">>");
});
var putHeader=(API.__private__.putHeader=function(){
out("%PDF-" + pdfVersion);
out("%\xBA\xDF\xAC\xE0");
});
var putXRef=(API.__private__.putXRef=function(){
var p="0000000000";
out("xref");
out("0 " + (objectNumber + 1));
out("0000000000 65535 f");
for (var i=1; i <=objectNumber; i++){
var offset=offsets[i];
if(typeof offset==="function"){
out((p + offsets[i]()).slice(-10) + " 00000 n");
}else{
if(typeof offsets[i]!=="undefined"){
out((p + offsets[i]).slice(-10) + " 00000 n");
}else{
out("0000000000 00000 n");
}}
}});
var buildDocument=(API.__private__.buildDocument=function(){
resetDocument();
setOutputDestination(content);
events.publish("buildDocument");
putHeader();
putPages();
putAdditionalObjects();
putResources();
putInfo();
putCatalog();
var offsetOfXRef=contentLength;
putXRef();
putTrailer();
out("startxref");
out("" + offsetOfXRef);
out("%%EOF");
setOutputDestination(pages[currentPage]);
return content.join("\n");
});
var getBlob=(API.__private__.getBlob=function(data){
return new Blob([getArrayBuffer(data)], {
type: "application/pdf"
});
});
var output=(API.output=API.__private__.output=SAFE(function output(
type,
options
){
options=options||{};
if(typeof options==="string"){
options={
filename: options
};}else{
options.filename=options.filename||"generated.pdf";
}
switch (type){
case undefined:
return buildDocument();
case "save":
API.save(options.filename);
break;
case "arraybuffer":
return getArrayBuffer(buildDocument());
case "blob":
return getBlob(buildDocument());
case "bloburi":
case "bloburl":
if(typeof globalObject.URL!=="undefined" &&
typeof globalObject.URL.createObjectURL==="function"
){
return (
(globalObject.URL &&
globalObject.URL.createObjectURL(getBlob(buildDocument()))) ||
void 0
);
}else{
console.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser."
);
}
break;
case "datauristring":
case "dataurlstring":
var dataURI="";
var pdfDocument=buildDocument();
try {
dataURI=btoa(pdfDocument);
} catch (e){
dataURI=btoa(unescape(encodeURIComponent(pdfDocument)));
}
return (
"data:application/pdf;filename=" +
options.filename +
";base64," +
dataURI
);
case "pdfobjectnewwindow":
if(Object.prototype.toString.call(globalObject)==="[object Window]"
){
var pdfObjectUrl =
options.pdfObjectUrl ||
"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js";
var htmlForNewWindow =
"<html>" +
'<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style><body><script src="' +
pdfObjectUrl +
'"></script><script >PDFObject.embed("' +
this.output("dataurlstring") +
'", ' +
JSON.stringify(options) +
");</script></body></html>";
var nW=globalObject.open();
if(nW!==null){
nW.document.write(htmlForNewWindow);
}
return nW;
}else{
throw new Error(
"The option pdfobjectnewwindow just works in a browser-environment."
);
}
case "pdfjsnewwindow":
if(Object.prototype.toString.call(globalObject)==="[object Window]"
){
var pdfJsUrl=options.pdfJsUrl||"examples/PDF.js/web/viewer.html";
var htmlForPDFjsNewWindow =
"<html>" +
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style>" +
'<body><iframe id="pdfViewer" src="' +
pdfJsUrl +
'?file=" width="500px" height="400px" />' +
"</body></html>";
var PDFjsNewWindow=globalObject.open();
if(PDFjsNewWindow!==null){
PDFjsNewWindow.document.write(htmlForPDFjsNewWindow);
var scope=this;
PDFjsNewWindow.document.documentElement.querySelector("#pdfViewer"
).onload=function(){
PDFjsNewWindow.document.documentElement
.querySelector("#pdfViewer")
.contentWindow.PDFViewerApplication.open(scope.output("bloburl")
);
};}
return PDFjsNewWindow;
}else{
throw new Error(
"The option pdfjsnewwindow just works in a browser-environment."
);
}
case "dataurlnewwindow":
if(Object.prototype.toString.call(globalObject)==="[object Window]"
){
var htmlForDataURLNewWindow =
"<html>" +
"<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style>" +
"<body>" +
'<iframe src="' +
this.output("datauristring", options) +
'"></iframe>' +
"</body></html>";
var dataURLNewWindow=globalObject.open();
if(dataURLNewWindow!==null){
dataURLNewWindow.document.write(htmlForDataURLNewWindow);
dataURLNewWindow.document.title=options.filename;
}
if(dataURLNewWindow||typeof safari==="undefined")
return dataURLNewWindow;
}else{
throw new Error(
"The option dataurlnewwindow just works in a browser-environment."
);
}
break;
case "datauri":
case "dataurl":
return (globalObject.document.location.href=this.output("datauristring",
options
));
default:
return null;
}}));
var hasHotfix=function(hotfixName){
return (
Array.isArray(hotfixes)===true&&hotfixes.indexOf(hotfixName) > -1
);
};
switch (unit){
case "pt":
scaleFactor=1;
break;
case "mm":
scaleFactor=72 / 25.4;
break;
case "cm":
scaleFactor=72 / 2.54;
break;
case "in":
scaleFactor=72;
break;
case "px":
if(hasHotfix("px_scaling")==true){
scaleFactor=72 / 96;
}else{
scaleFactor=96 / 72;
}
break;
case "pc":
scaleFactor=12;
break;
case "em":
scaleFactor=12;
break;
case "ex":
scaleFactor=6;
break;
default:
throw new Error("Invalid unit: " + unit);
}
setCreationDate();
setFileId();
var getPageInfo=(API.__private__.getPageInfo=API.getPageInfo=function(
pageNumberOneBased
){
if(isNaN(pageNumberOneBased)||pageNumberOneBased % 1!==0){
throw new Error("Invalid argument passed to jsPDF.getPageInfo");
}
var objId=pagesContext[pageNumberOneBased].objId;
return {
objId: objId,
pageNumber: pageNumberOneBased,
pageContext: pagesContext[pageNumberOneBased]
};});
var getPageInfoByObjId=(API.__private__.getPageInfoByObjId=function(
objId
){
if(isNaN(objId)||objId % 1!==0){
throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");
}
for (var pageNumber in pagesContext){
if(pagesContext[pageNumber].objId===objId){
break;
}}
return getPageInfo(pageNumber);
});
var getCurrentPageInfo=(API.__private__.getCurrentPageInfo=API.getCurrentPageInfo=function(){
return {
objId: pagesContext[currentPage].objId,
pageNumber: currentPage,
pageContext: pagesContext[currentPage]
};});
API.addPage=function(){
_addPage.apply(this, arguments);
return this;
};
API.setPage=function(){
_setPage.apply(this, arguments);
setOutputDestination.call(this, pages[currentPage]);
return this;
};
API.insertPage=function(beforePage){
this.addPage();
this.movePage(currentPage, beforePage);
return this;
};
API.movePage=function(targetPage, beforePage){
var tmpPages, tmpPagesContext;
if(targetPage > beforePage){
tmpPages=pages[targetPage];
tmpPagesContext=pagesContext[targetPage];
for (var i=targetPage; i > beforePage; i--){
pages[i]=pages[i - 1];
pagesContext[i]=pagesContext[i - 1];
}
pages[beforePage]=tmpPages;
pagesContext[beforePage]=tmpPagesContext;
this.setPage(beforePage);
}else if(targetPage < beforePage){
tmpPages=pages[targetPage];
tmpPagesContext=pagesContext[targetPage];
for (var j=targetPage; j < beforePage; j++){
pages[j]=pages[j + 1];
pagesContext[j]=pagesContext[j + 1];
}
pages[beforePage]=tmpPages;
pagesContext[beforePage]=tmpPagesContext;
this.setPage(beforePage);
}
return this;
};
API.deletePage=function(){
_deletePage.apply(this, arguments);
return this;
};
API.__private__.text=API.text=function(text, x, y, options, transform){
options=options||{};
var scope=options.scope||this;
var payload, da, angle, align, charSpace, maxWidth, flags;
if(typeof text==="number" &&
typeof x==="number" &&
(typeof y==="string"||Array.isArray(y))
){
var tmp=y;
y=x;
x=text;
text=tmp;
}
var transformationMatrix;
if(arguments[3] instanceof Matrix===false){
flags=arguments[3];
angle=arguments[4];
align=arguments[5];
if(typeof flags!=="object"||flags===null){
if(typeof angle==="string"){
align=angle;
angle=null;
}
if(typeof flags==="string"){
align=flags;
flags=null;
}
if(typeof flags==="number"){
angle=flags;
flags=null;
}
options={
flags: flags,
angle: angle,
align: align
};}}else{
advancedApiModeTrap(
"The transform parameter of text() with a Matrix value"
);
transformationMatrix=transform;
}
if(isNaN(x)||isNaN(y)||typeof text==="undefined"||text===null){
throw new Error("Invalid arguments passed to jsPDF.text");
}
if(text.length===0){
return scope;
}
var xtra="";
var isHex=false;
var lineHeight =
typeof options.lineHeightFactor==="number"
? options.lineHeightFactor
: lineHeightFactor;
var scaleFactor=scope.internal.scaleFactor;
function ESC(s){
s=s.split("\t").join(Array(options.TabLen||9).join(" "));
return pdfEscape(s, flags);
}
function transformTextToSpecialArray(text){
var sa=text.concat();
var da=[];
var len=sa.length;
var curDa;
while (len--){
curDa=sa.shift();
if(typeof curDa==="string"){
da.push(curDa);
}else{
if(Array.isArray(text) &&
(curDa.length===1 ||
(curDa[1]===undefined&&curDa[2]===undefined))
){
da.push(curDa[0]);
}else{
da.push([curDa[0], curDa[1], curDa[2]]);
}}
}
return da;
}
function processTextByFunction(text, processingFunction){
var result;
if(typeof text==="string"){
result=processingFunction(text)[0];
}else if(Array.isArray(text)){
var sa=text.concat();
var da=[];
var len=sa.length;
var curDa;
var tmpResult;
while (len--){
curDa=sa.shift();
if(typeof curDa==="string"){
da.push(processingFunction(curDa)[0]);
}else if(Array.isArray(curDa)&&typeof curDa[0]==="string"){
tmpResult=processingFunction(curDa[0], curDa[1], curDa[2]);
da.push([tmpResult[0], tmpResult[1], tmpResult[2]]);
}}
result=da;
}
return result;
}
var textIsOfTypeString=false;
var tmpTextIsOfTypeString=true;
if(typeof text==="string"){
textIsOfTypeString=true;
}else if(Array.isArray(text)){
var sa=text.concat();
da=[];
var len=sa.length;
var curDa;
while (len--){
curDa=sa.shift();
if(typeof curDa!=="string" ||
(Array.isArray(curDa)&&typeof curDa[0]!=="string")
){
tmpTextIsOfTypeString=false;
}}
textIsOfTypeString=tmpTextIsOfTypeString;
}
if(textIsOfTypeString===false){
throw new Error(
'Type of text must be string or Array. "' +
text +
'" is not recognized.'
);
}
if(typeof text==="string"){
if(text.match(/[\r?\n]/)){
text=text.split(/\r\n|\r|\n/g);
}else{
text=[text];
}}
var height=activeFontSize / scope.internal.scaleFactor;
var descent=height * (lineHeightFactor - 1);
switch (options.baseline){
case "bottom":
y -=descent;
break;
case "top":
y +=height - descent;
break;
case "hanging":
y +=height - 2 * descent;
break;
case "middle":
y +=height / 2 - descent;
break;
}
maxWidth=options.maxWidth||0;
if(maxWidth > 0){
if(typeof text==="string"){
text=scope.splitTextToSize(text, maxWidth);
}else if(Object.prototype.toString.call(text)==="[object Array]"){
text=scope.splitTextToSize(text.join(" "), maxWidth);
}}
payload={
text: text,
x: x,
y: y,
options: options,
mutex: {
pdfEscape: pdfEscape,
activeFontKey: activeFontKey,
fonts: fonts,
activeFontSize: activeFontSize
}};
events.publish("preProcessText", payload);
text=payload.text;
options=payload.options;
angle=options.angle;
if(transformationMatrix instanceof Matrix===false &&
angle &&
typeof angle==="number"
){
angle *=Math.PI / 180;
if(options.rotationDirection===0){
angle=-angle;
}
if(apiMode===ApiMode.ADVANCED){
angle=-angle;
}
var c=Math.cos(angle);
var s=Math.sin(angle);
transformationMatrix=new Matrix(c, s, -s, c, 0, 0);
}else if(angle&&angle instanceof Matrix){
transformationMatrix=angle;
}
if(apiMode===ApiMode.ADVANCED&&!transformationMatrix){
transformationMatrix=identityMatrix;
}
charSpace=options.charSpace||activeCharSpace;
if(typeof charSpace!=="undefined"){
xtra +=hpf(scale(charSpace)) + " Tc\n";
this.setCharSpace(this.getCharSpace()||0);
}
var lang=options.lang;
var renderingMode=-1;
var parmRenderingMode =
typeof options.renderingMode!=="undefined"
? options.renderingMode
: options.stroke;
var pageContext=scope.internal.getCurrentPageInfo().pageContext;
switch (parmRenderingMode){
case 0:
case false:
case "fill":
renderingMode=0;
break;
case 1:
case true:
case "stroke":
renderingMode=1;
break;
case 2:
case "fillThenStroke":
renderingMode=2;
break;
case 3:
case "invisible":
renderingMode=3;
break;
case 4:
case "fillAndAddForClipping":
renderingMode=4;
break;
case 5:
case "strokeAndAddPathForClipping":
renderingMode=5;
break;
case 6:
case "fillThenStrokeAndAddToPathForClipping":
renderingMode=6;
break;
case 7:
case "addToPathForClipping":
renderingMode=7;
break;
}
var usedRenderingMode =
typeof pageContext.usedRenderingMode!=="undefined"
? pageContext.usedRenderingMode
: -1;
if(renderingMode!==-1){
xtra +=renderingMode + " Tr\n";
}else if(usedRenderingMode!==-1){
xtra +="0 Tr\n";
}
if(renderingMode!==-1){
pageContext.usedRenderingMode=renderingMode;
}
align=options.align||"left";
var leading=activeFontSize * lineHeight;
var pageWidth=scope.internal.pageSize.getWidth();
var activeFont=fonts[activeFontKey];
charSpace=options.charSpace||activeCharSpace;
maxWidth=options.maxWidth||0;
var lineWidths;
flags={};
var wordSpacingPerLine=[];
if(Object.prototype.toString.call(text)==="[object Array]"){
da=transformTextToSpecialArray(text);
var newY;
if(align!=="left"){
lineWidths=da.map(function(v){
return (
(scope.getStringUnitWidth(v, {
font: activeFont,
charSpace: charSpace,
fontSize: activeFontSize,
doKerning: false
}) *
activeFontSize) /
scaleFactor
);
});
}
var prevWidth=0;
var newX;
if(align==="right"){
x -=lineWidths[0];
text=[];
len=da.length;
for (var i=0; i < len; i++){
if(i===0){
newX=getHorizontalCoordinate(x);
newY=getVerticalCoordinate(y);
}else{
newX=scale(prevWidth - lineWidths[i]);
newY=-leading;
}
text.push([da[i], newX, newY]);
prevWidth=lineWidths[i];
}}else if(align==="center"){
x -=lineWidths[0] / 2;
text=[];
len=da.length;
for (var j=0; j < len; j++){
if(j===0){
newX=getHorizontalCoordinate(x);
newY=getVerticalCoordinate(y);
}else{
newX=scale((prevWidth - lineWidths[j]) / 2);
newY=-leading;
}
text.push([da[j], newX, newY]);
prevWidth=lineWidths[j];
}}else if(align==="left"){
text=[];
len=da.length;
for (var h=0; h < len; h++){
text.push(da[h]);
}}else if(align==="justify"){
text=[];
len=da.length;
maxWidth=maxWidth!==0 ? maxWidth:pageWidth;
for (var l=0; l < len; l++){
newY=l===0 ? getVerticalCoordinate(y):-leading;
newX=l===0 ? getHorizontalCoordinate(x):0;
if(l < len - 1){
wordSpacingPerLine.push(hpf(
scale(
(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)
)
)
);
}
text.push([da[l], newX, newY]);
}}else{
throw new Error(
'Unrecognized alignment option, use "left", "center", "right" or "justify".'
);
}}
var doReversing=typeof options.R2L==="boolean" ? options.R2L:R2L;
if(doReversing===true){
text=processTextByFunction(text, function(text, posX, posY){
return [
text
.split("")
.reverse()
.join(""),
posX,
posY
];
});
}
payload={
text: text,
x: x,
y: y,
options: options,
mutex: {
pdfEscape: pdfEscape,
activeFontKey: activeFontKey,
fonts: fonts,
activeFontSize: activeFontSize
}};
events.publish("postProcessText", payload);
text=payload.text;
isHex=payload.mutex.isHex||false;
var activeFontEncoding=fonts[activeFontKey].encoding;
if(activeFontEncoding==="WinAnsiEncoding" ||
activeFontEncoding==="StandardEncoding"
){
text=processTextByFunction(text, function(text, posX, posY){
return [ESC(text), posX, posY];
});
}
da=transformTextToSpecialArray(text);
text=[];
var STRING=0;
var ARRAY=1;
var variant=Array.isArray(da[0]) ? ARRAY:STRING;
var posX;
var posY;
var content;
var wordSpacing="";
var generatePosition=function(
parmPosX,
parmPosY,
parmTransformationMatrix
){
var position="";
if(parmTransformationMatrix instanceof Matrix){
if(typeof options.angle==="number"){
parmTransformationMatrix=matrixMult(
parmTransformationMatrix,
new Matrix(1, 0, 0, 1, parmPosX, parmPosY)
);
}else{
parmTransformationMatrix=matrixMult(
new Matrix(1, 0, 0, 1, parmPosX, parmPosY),
parmTransformationMatrix
);
}
if(apiMode===ApiMode.ADVANCED){
parmTransformationMatrix=matrixMult(
new Matrix(1, 0, 0, -1, 0, 0),
parmTransformationMatrix
);
}
position=parmTransformationMatrix.join(" ") + " Tm\n";
}else{
position=hpf(parmPosX) + " " + hpf(parmPosY) + " Td\n";
}
return position;
};
for (var lineIndex=0; lineIndex < da.length; lineIndex++){
wordSpacing="";
switch (variant){
case ARRAY:
content =
(isHex ? "<":"(") + da[lineIndex][0] + (isHex ? ">":")");
posX=parseFloat(da[lineIndex][1]);
posY=parseFloat(da[lineIndex][2]);
break;
case STRING:
content=(isHex ? "<":"(") + da[lineIndex] + (isHex ? ">":")");
posX=getHorizontalCoordinate(x);
posY=getVerticalCoordinate(y);
break;
}
if(typeof wordSpacingPerLine!=="undefined" &&
typeof wordSpacingPerLine[lineIndex]!=="undefined"
){
wordSpacing=wordSpacingPerLine[lineIndex] + " Tw\n";
}
if(lineIndex===0){
text.push(wordSpacing +
generatePosition(posX, posY, transformationMatrix) +
content
);
}else if(variant===STRING){
text.push(wordSpacing + content);
}else if(variant===ARRAY){
text.push(wordSpacing +
generatePosition(posX, posY, transformationMatrix) +
content
);
}}
text=variant===STRING ? text.join(" Tj\nT* "):text.join(" Tj\n");
text +=" Tj\n";
var result="BT\n/";
result +=activeFontKey + " " + activeFontSize + " Tf\n";
result +=hpf(activeFontSize * lineHeight) + " TL\n";
result +=textColor + "\n";
result +=xtra;
result +=text;
result +="ET";
out(result);
usedFonts[activeFontKey]=true;
return scope;
};
API.__private__.lstext=API.lstext=function(text, x, y, charSpace){
return this.text(text, x, y, {
charSpace: charSpace
});
};
var clip=(API.__private__.clip=API.clip=function(rule){
if("evenodd"===rule){
out("W*");
}else{
out("W");
}
return this;
});
API.clipEvenOdd=function(){
return clip("evenodd");
};
API.__private__.clip_fixed=API.clip_fixed=function(rule){
return API.clip(rule);
};
API.__private__.discardPath=API.discardPath=function(){
out("n");
return this;
};
var isValidStyle=(API.__private__.isValidStyle=function(style){
var validStyleVariants=[
undefined,
null,
"S",
"D",
"F",
"DF",
"FD",
"f",
"f*",
"B",
"B*",
"n"
];
var result=false;
if(validStyleVariants.indexOf(style)!==-1){
result=true;
}
return result;
});
API.__private__.setDefaultPathOperation=API.setDefaultPathOperation=function(
operator
){
if(isValidStyle(operator)){
defaultPathOperation=operator;
}
return this;
};
var getStyle=(API.__private__.getStyle=API.getStyle=function(style){
var op=defaultPathOperation;
switch (style){
case "D":
case "S":
op="S";
break;
case "F":
op="f";
break;
case "FD":
case "DF":
op="B";
break;
case "f":
case "f*":
case "B":
case "B*":
op=style;
break;
}
return op;
});
var close=(API.close=function(){
out("h");
return this;
});
API.stroke=function(){
out("S");
return this;
};
API.fill=function(pattern){
fillWithOptionalPattern("f", pattern);
return this;
};
API.fillEvenOdd=function(pattern){
fillWithOptionalPattern("f*", pattern);
return this;
};
API.fillStroke=function(pattern){
fillWithOptionalPattern("B", pattern);
return this;
};
API.fillStrokeEvenOdd=function(pattern){
fillWithOptionalPattern("B*", pattern);
return this;
};
var fillWithOptionalPattern=function(style, pattern){
if(typeof pattern==="object"){
fillWithPattern(pattern, style);
}else{
out(style);
}};
var putStyle=function(style, patternKey, patternData){
if(style===null ||
(apiMode===ApiMode.ADVANCED&&style===undefined)
){
return;
}
style=getStyle(style);
if(!patternKey){
out(style);
return;
}
if(!patternData){
patternData={ matrix: identityMatrix };}
if(patternData instanceof Matrix){
patternData={ matrix: patternData };}
patternData.key=patternKey;
patternData||(patternData=identityMatrix);
fillWithPattern(patternData, style);
};
function cloneTilingPattern(patternKey, boundingBox, xStep, yStep, matrix){
var clone=new TilingPattern(
boundingBox||this.boundingBox,
xStep||this.xStep,
yStep||this.yStep,
this.gState,
matrix||this.matrix
);
clone.stream=this.stream;
var key=patternKey + "$$" + this.cloneIndex++ + "$$";
addPattern(key, clone);
return clone;
}
var fillWithPattern=function(patternData, style){
var patternId=patternMap[patternData.key];
var pattern=patterns[patternId];
if(pattern instanceof ShadingPattern){
out("q");
out(clipRuleFromStyle(style));
if(pattern.gState){
API.setGState(pattern.gState);
}
out(patternData.matrix.toString() + " cm");
out("/" + patternId + " sh");
out("Q");
}else if(pattern instanceof TilingPattern){
var matrix=new Matrix(1, 0, 0, -1, 0, getPageHeight());
if(patternData.matrix){
matrix=matrix.multiply(patternData.matrix||identityMatrix);
patternId=cloneTilingPattern.call(pattern,
patternData.key,
patternData.boundingBox,
patternData.xStep,
patternData.yStep,
matrix
).id;
}
out("q");
out("/Pattern cs");
out("/" + patternId + " scn");
if(pattern.gState){
API.setGState(pattern.gState);
}
out(style);
out("Q");
}};
var clipRuleFromStyle=function(style){
switch (style){
case "f":
case "F":
return "W n";
case "f*":
return "W* n";
case "B":
return "W S";
case "B*":
return "W* S";
case "S":
return "W S";
case "n":
return "W n";
}};
var moveTo=(API.moveTo=function(x, y){
out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " m");
return this;
});
var lineTo=(API.lineTo=function(x, y){
out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " l");
return this;
});
var curveTo=(API.curveTo=function(x1, y1, x2, y2, x3, y3){
out(
[
hpf(scale(x1)),
hpf(transformScaleY(y1)),
hpf(scale(x2)),
hpf(transformScaleY(y2)),
hpf(scale(x3)),
hpf(transformScaleY(y3)),
"c"
].join(" ")
);
return this;
});
API.__private__.line=API.line=function(x1, y1, x2, y2, style){
if(isNaN(x1) ||
isNaN(y1) ||
isNaN(x2) ||
isNaN(y2) ||
!isValidStyle(style)
){
throw new Error("Invalid arguments passed to jsPDF.line");
}
if(apiMode===ApiMode.COMPAT){
return this.lines([[x2 - x1, y2 - y1]], x1, y1, [1, 1], style||"S");
}else{
return this.lines([[x2 - x1, y2 - y1]], x1, y1, [1, 1]).stroke();
}};
API.__private__.lines=API.lines=function(
lines,
x,
y,
scale,
style,
closed,
patternKey,
patternData
){
var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4, tmp;
if(typeof lines==="number"){
tmp=y;
y=x;
x=lines;
lines=tmp;
}
scale=scale||[1, 1];
closed=closed||false;
if(isNaN(x) ||
isNaN(y) ||
!Array.isArray(lines) ||
!Array.isArray(scale) ||
!isValidStyle(style) ||
typeof closed!=="boolean"
){
throw new Error("Invalid arguments passed to jsPDF.lines");
}
moveTo(x, y);
scalex=scale[0];
scaley=scale[1];
l=lines.length;
x4=x;
y4=y;
for (i=0; i < l; i++){
leg=lines[i];
if(leg.length===2){
x4=leg[0] * scalex + x4;
y4=leg[1] * scaley + y4;
lineTo(x4, y4);
}else{
x2=leg[0] * scalex + x4;
y2=leg[1] * scaley + y4;
x3=leg[2] * scalex + x4;
y3=leg[3] * scaley + y4;
x4=leg[4] * scalex + x4;
y4=leg[5] * scaley + y4;
curveTo(x2, y2, x3, y3, x4, y4);
}}
if(closed){
close();
}
putStyle(style, patternKey, patternData);
return this;
};
API.path=function(lines, style, patternKey, patternData){
for (var i=0; i < lines.length; i++){
var leg=lines[i];
var coords=leg.c;
switch (leg.op){
case "m":
moveTo(coords[0], coords[1]);
break;
case "l":
lineTo(coords[0], coords[1]);
break;
case "c":
curveTo.apply(this, coords);
break;
case "h":
close();
break;
}}
putStyle(style, patternKey, patternData);
return this;
};
API.__private__.rect=API.rect=function(
x,
y,
w,
h,
style,
patternKey,
patternData
){
if(isNaN(x)||isNaN(y)||isNaN(w)||isNaN(h)||!isValidStyle(style)){
throw new Error("Invalid arguments passed to jsPDF.rect");
}
if(apiMode===ApiMode.COMPAT){
h=-h;
}
out(
[
hpf(scale(x)),
hpf(transformScaleY(y)),
hpf(scale(w)),
hpf(scale(h)),
"re"
].join(" ")
);
putStyle(style, patternKey, patternData);
return this;
};
API.__private__.triangle=API.triangle=function(
x1,
y1,
x2,
y2,
x3,
y3,
style,
patternKey,
patternData
){
if(isNaN(x1) ||
isNaN(y1) ||
isNaN(x2) ||
isNaN(y2) ||
isNaN(x3) ||
isNaN(y3) ||
!isValidStyle(style)
){
throw new Error("Invalid arguments passed to jsPDF.triangle");
}
this.lines([
[x2 - x1, y2 - y1],
[x3 - x2, y3 - y2],
[x1 - x3, y1 - y3]
],
x1,
y1,
[1, 1],
style,
true,
patternKey,
patternData
);
return this;
};
API.__private__.roundedRect=API.roundedRect=function(
x,
y,
w,
h,
rx,
ry,
style,
patternKey,
patternData
){
if(isNaN(x) ||
isNaN(y) ||
isNaN(w) ||
isNaN(h) ||
isNaN(rx) ||
isNaN(ry) ||
!isValidStyle(style)
){
throw new Error("Invalid arguments passed to jsPDF.roundedRect");
}
var MyArc=(4 / 3) * (Math.SQRT2 - 1);
rx=Math.min(rx, w * 0.5);
ry=Math.min(ry, h * 0.5);
this.lines([
[w - 2 * rx, 0],
[rx * MyArc, 0, rx, ry - ry * MyArc, rx, ry],
[0, h - 2 * ry],
[0, ry * MyArc, -(rx * MyArc), ry, -rx, ry],
[-w + 2 * rx, 0],
[-(rx * MyArc), 0, -rx, -(ry * MyArc), -rx, -ry],
[0, -h + 2 * ry],
[0, -(ry * MyArc), rx * MyArc, -ry, rx, -ry]
],
x + rx,
y,
[1, 1],
style,
true,
patternKey,
patternData
);
return this;
};
API.__private__.ellipse=API.ellipse=function(
x,
y,
rx,
ry,
style,
patternKey,
patternData
){
if(isNaN(x) ||
isNaN(y) ||
isNaN(rx) ||
isNaN(ry) ||
!isValidStyle(style)
){
throw new Error("Invalid arguments passed to jsPDF.ellipse");
}
var lx=(4 / 3) * (Math.SQRT2 - 1) * rx,
ly=(4 / 3) * (Math.SQRT2 - 1) * ry;
moveTo(x + rx, y);
curveTo(x + rx, y - ly, x + lx, y - ry, x, y - ry);
curveTo(x - lx, y - ry, x - rx, y - ly, x - rx, y);
curveTo(x - rx, y + ly, x - lx, y + ry, x, y + ry);
curveTo(x + lx, y + ry, x + rx, y + ly, x + rx, y);
putStyle(style, patternKey, patternData);
return this;
};
API.__private__.circle=API.circle=function(
x,
y,
r,
style,
patternKey,
patternData
){
if(isNaN(x)||isNaN(y)||isNaN(r)||!isValidStyle(style)){
throw new Error("Invalid arguments passed to jsPDF.circle");
}
return this.ellipse(x, y, r, r, style, patternKey, patternData);
};
API.setFont=function(fontName, fontStyle){
activeFontKey=getFont(fontName, fontStyle, {
disableWarning: false
});
return this;
};
var getFontEntry=(API.__private__.getFont=API.getFont=function(){
return fonts[getFont.apply(API, arguments)];
});
API.setFontStyle=API.setFontType=function(style){
activeFontKey=getFont(undefined, style);
return this;
};
API.__private__.getFontList=API.getFontList=function(){
var list={},
fontName,
fontStyle;
for (fontName in fontmap){
if(fontmap.hasOwnProperty(fontName)){
list[fontName]=[];
for (fontStyle in fontmap[fontName]){
if(fontmap[fontName].hasOwnProperty(fontStyle)){
list[fontName].push(fontStyle);
}}
}}
return list;
};
API.addFont=function(postScriptName, fontName, fontStyle, encoding){
encoding=encoding||"Identity-H";
return addFont.call(this, postScriptName, fontName, fontStyle, encoding);
};
var lineWidth=options.lineWidth||0.200025;
var setLineWidth=(API.__private__.setLineWidth=API.setLineWidth=function(
width
){
out(hpf(scale(width)) + " w");
return this;
});
API.__private__.setLineDash=jsPDF.API.setLineDash=jsPDF.API.setLineDashPattern=function(
dashArray,
dashPhase
){
dashArray=dashArray||[];
dashPhase=dashPhase||0;
if(isNaN(dashPhase)||!Array.isArray(dashArray)){
throw new Error("Invalid arguments passed to jsPDF.setLineDash");
}
dashArray=dashArray
.map(function(x){
return hpf(scale(x));
})
.join(" ");
dashPhase=hpf(scale(dashPhase));
out("[" + dashArray + "] " + dashPhase + " d");
return this;
};
var lineHeightFactor;
var getLineHeight=(API.__private__.getLineHeight=API.getLineHeight=function(){
return activeFontSize * lineHeightFactor;
});
API.__private__.getLineHeight=API.getLineHeight=function(){
return activeFontSize * lineHeightFactor;
};
var setLineHeightFactor=(API.__private__.setLineHeightFactor=API.setLineHeightFactor=function(
value
){
value=value||1.15;
if(typeof value==="number"){
lineHeightFactor=value;
}
return this;
});
var getLineHeightFactor=(API.__private__.getLineHeightFactor=API.getLineHeightFactor=function(){
return lineHeightFactor;
});
setLineHeightFactor(options.lineHeight);
var getHorizontalCoordinate=(API.__private__.getHorizontalCoordinate=function(
value
){
return scale(value);
});
var getVerticalCoordinate=(API.__private__.getVerticalCoordinate=function(
value
){
if(apiMode===ApiMode.ADVANCED){
return value;
}else{
var pageHeight =
pagesContext[currentPage].mediaBox.topRightY -
pagesContext[currentPage].mediaBox.bottomLeftY;
return pageHeight - scale(value);
}});
var getHorizontalCoordinateString=(API.__private__.getHorizontalCoordinateString=API.getHorizontalCoordinateString=function(
value
){
return hpf(getHorizontalCoordinate(value));
});
var getVerticalCoordinateString=(API.__private__.getVerticalCoordinateString=API.getVerticalCoordinateString=function(
value
){
return hpf(getVerticalCoordinate(value));
});
var strokeColor=options.strokeColor||"0 G";
API.__private__.getStrokeColor=API.getDrawColor=function(){
return decodeColorString(strokeColor);
};
API.__private__.setStrokeColor=API.setDrawColor=function(
ch1,
ch2,
ch3,
ch4
){
var options={
ch1: ch1,
ch2: ch2,
ch3: ch3,
ch4: ch4,
pdfColorType: "draw",
precision: 2
};
strokeColor=encodeColorString(options);
out(strokeColor);
return this;
};
var fillColor=options.fillColor||"0 g";
API.__private__.getFillColor=API.getFillColor=function(){
return decodeColorString(fillColor);
};
API.__private__.setFillColor=API.setFillColor=function(
ch1,
ch2,
ch3,
ch4
){
var options={
ch1: ch1,
ch2: ch2,
ch3: ch3,
ch4: ch4,
pdfColorType: "fill",
precision: 2
};
fillColor=encodeColorString(options);
out(fillColor);
return this;
};
var textColor=options.textColor||"0 g";
var getTextColor=(API.__private__.getTextColor=API.getTextColor=function(){
return decodeColorString(textColor);
});
API.__private__.setTextColor=API.setTextColor=function(
ch1,
ch2,
ch3,
ch4
){
var options={
ch1: ch1,
ch2: ch2,
ch3: ch3,
ch4: ch4,
pdfColorType: "text",
precision: 3
};
textColor=encodeColorString(options);
return this;
};
var activeCharSpace=options.charSpace;
var getCharSpace=(API.__private__.getCharSpace=API.getCharSpace=function(){
return parseFloat(activeCharSpace||0);
});
API.__private__.setCharSpace=API.setCharSpace=function(charSpace){
if(isNaN(charSpace)){
throw new Error("Invalid argument passed to jsPDF.setCharSpace");
}
activeCharSpace=charSpace;
return this;
};
var lineCapID=0;
API.CapJoinStyles={
0: 0,
butt: 0,
but: 0,
miter: 0,
1: 1,
round: 1,
rounded: 1,
circle: 1,
2: 2,
projecting: 2,
project: 2,
square: 2,
bevel: 2
};
API.__private__.setLineCap=API.setLineCap=function(style){
var id=API.CapJoinStyles[style];
if(id===undefined){
throw new Error(
"Line cap style of '" +
style +
"' is not recognized. See or extend .CapJoinStyles property for valid styles"
);
}
lineCapID=id;
out(id + " J");
return this;
};
var lineJoinID=0;
API.__private__.setLineJoin=API.setLineJoin=function(style){
var id=API.CapJoinStyles[style];
if(id===undefined){
throw new Error(
"Line join style of '" +
style +
"' is not recognized. See or extend .CapJoinStyles property for valid styles"
);
}
lineJoinID=id;
out(id + " j");
return this;
};
API.__private__.setLineMiterLimit=API.__private__.setMiterLimit=API.setLineMiterLimit=API.setMiterLimit=function(
length
){
length=length||0;
if(isNaN(length)){
throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");
}
out(hpf(scale(length)) + " M");
return this;
};
API.GState=GState;
API.setGState=function(gState){
if(typeof gState==="string"){
gState=gStates[gStatesMap[gState]];
}else{
gState=addGState(null, gState);
}
if(!gState.equals(activeGState)){
out("/" + gState.id + " gs");
activeGState=gState;
}};
var addGState=function(key, gState){
if(key&&gStatesMap[key]) return;
var duplicate=false;
for (var s in gStates){
if(gStates.hasOwnProperty(s)){
if(gStates[s].equals(gState)){
duplicate=true;
break;
}}
}
if(duplicate){
gState=gStates[s];
}else{
var gStateKey="GS" + (Object.keys(gStates).length + 1).toString(10);
gStates[gStateKey]=gState;
gState.id=gStateKey;
}
key&&(gStatesMap[key]=gState.id);
events.publish("addGState", gState);
return gState;
};
API.addGState=function(key, gState){
addGState(key, gState);
return this;
};
API.saveGraphicsState=function(){
out("q");
fontStateStack.push({
key: activeFontKey,
size: activeFontSize,
color: textColor
});
return this;
};
API.restoreGraphicsState=function(){
out("Q");
var fontState=fontStateStack.pop();
activeFontKey=fontState.key;
activeFontSize=fontState.size;
textColor=fontState.color;
activeGState=null;
return this;
};
API.setCurrentTransformationMatrix=function(matrix){
out(matrix.toString() + " cm");
return this;
};
API.comment=function(text){
out("#" + text);
return this;
};
var Point=function(x, y){
var _x=x||0;
Object.defineProperty(this, "x", {
enumerable: true,
get: function(){
return _x;
},
set: function(value){
if(!isNaN(value)){
_x=parseFloat(value);
}}
});
var _y=y||0;
Object.defineProperty(this, "y", {
enumerable: true,
get: function(){
return _y;
},
set: function(value){
if(!isNaN(value)){
_y=parseFloat(value);
}}
});
var _type="pt";
Object.defineProperty(this, "type", {
enumerable: true,
get: function(){
return _type;
},
set: function(value){
_type=value.toString();
}});
return this;
};
var Rectangle=function(x, y, w, h){
Point.call(this, x, y);
this.type="rect";
var _w=w||0;
Object.defineProperty(this, "w", {
enumerable: true,
get: function(){
return _w;
},
set: function(value){
if(!isNaN(value)){
_w=parseFloat(value);
}}
});
var _h=h||0;
Object.defineProperty(this, "h", {
enumerable: true,
get: function(){
return _h;
},
set: function(value){
if(!isNaN(value)){
_h=parseFloat(value);
}}
});
return this;
};
var RenderTarget=function(){
this.page=page;
this.currentPage=currentPage;
this.pages=pages.slice(0);
this.pagesContext=pagesContext.slice(0);
this.x=pageX;
this.y=pageY;
this.matrix=pageMatrix;
this.width=getPageWidth(currentPage);
this.height=getPageHeight(currentPage);
this.outputDestination=outputDestination;
this.id="";
this.objectNumber=-1;
};
RenderTarget.prototype.restore=function(){
page=this.page;
currentPage=this.currentPage;
pagesContext=this.pagesContext;
pages=this.pages;
pageX=this.x;
pageY=this.y;
pageMatrix=this.matrix;
setPageWidth(currentPage, this.width);
setPageHeight(currentPage, this.height);
outputDestination=this.outputDestination;
};
var beginNewRenderTarget=function(x, y, width, height, matrix){
renderTargetStack.push(new RenderTarget());
page=currentPage=0;
pages=[];
pageX=x;
pageY=y;
pageMatrix=matrix;
beginPage([width, height]);
};
var endFormObject=function(key){
if(renderTargetMap[key]) return;
var newXObject=new RenderTarget();
var xObjectId="Xo" + (Object.keys(renderTargets).length + 1).toString(10);
newXObject.id=xObjectId;
renderTargetMap[key]=xObjectId;
renderTargets[xObjectId]=newXObject;
events.publish("addFormObject", newXObject);
renderTargetStack.pop().restore();
};
API.beginFormObject=function(x, y, width, height, matrix){
beginNewRenderTarget(x, y, width, height, matrix);
return this;
};
API.endFormObject=function(key){
endFormObject(key);
return this;
};
API.doFormObject=function(key, matrix){
var xObject=renderTargets[renderTargetMap[key]];
out("q");
out(matrix.toString() + " cm");
out("/" + xObject.id + " Do");
out("Q");
return this;
};
API.getFormObject=function(key){
var xObject=renderTargets[renderTargetMap[key]];
return {
x: xObject.x,
y: xObject.y,
width: xObject.width,
height: xObject.height,
matrix: xObject.matrix
};};
API.save=function(filename, options){
filename=filename||"generated.pdf";
options=options||{};
options.returnPromise=options.returnPromise||false;
if(options.returnPromise===false){
saveAs(getBlob(buildDocument()), filename);
if(typeof saveAs.unload==="function"){
if(globalObject.setTimeout){
setTimeout(saveAs.unload, 911);
}}
return this;
}else{
return new Promise(function(resolve, reject){
try {
var result=saveAs(getBlob(buildDocument()), filename);
if(typeof saveAs.unload==="function"){
if(globalObject.setTimeout){
setTimeout(saveAs.unload, 911);
}}
resolve(result);
} catch (e){
reject(e.message);
}});
}};
for (var plugin in jsPDF.API){
if(jsPDF.API.hasOwnProperty(plugin)){
if(plugin==="events"&&jsPDF.API.events.length){
(function(events, newEvents){
var eventname, handler_and_args, i;
for (i=newEvents.length - 1; i!==-1; i--){
eventname=newEvents[i][0];
handler_and_args=newEvents[i][1];
events.subscribe.apply(events,
[eventname].concat(typeof handler_and_args==="function"
? [handler_and_args]
: handler_and_args
)
);
}})(events, jsPDF.API.events);
}else{
API[plugin]=jsPDF.API[plugin];
}}
}
var getPageWidth=(API.getPageWidth=function(pageNumber){
pageNumber=pageNumber||currentPage;
return (
(pagesContext[pageNumber].mediaBox.topRightX -
pagesContext[pageNumber].mediaBox.bottomLeftX) /
scaleFactor
);
});
var setPageWidth=(API.setPageWidth=function(pageNumber, value){
pagesContext[pageNumber].mediaBox.topRightX =
value * scaleFactor + pagesContext[pageNumber].mediaBox.bottomLeftX;
});
var getPageHeight=(API.getPageHeight=function(pageNumber){
pageNumber=pageNumber||currentPage;
return (
(pagesContext[pageNumber].mediaBox.topRightY -
pagesContext[pageNumber].mediaBox.bottomLeftY) /
scaleFactor
);
});
var setPageHeight=(API.setPageHeight=function(pageNumber, value){
pagesContext[pageNumber].mediaBox.topRightY =
value * scaleFactor + pagesContext[pageNumber].mediaBox.bottomLeftY;
});
API.internal={
pdfEscape: pdfEscape,
getStyle: getStyle,
getFont: getFontEntry,
getFontSize: getFontSize,
getCharSpace: getCharSpace,
getTextColor: getTextColor,
getLineHeight: getLineHeight,
getLineHeightFactor: getLineHeightFactor,
write: write,
getHorizontalCoordinate: getHorizontalCoordinate,
getVerticalCoordinate: getVerticalCoordinate,
getCoordinateString: getHorizontalCoordinateString,
getVerticalCoordinateString: getVerticalCoordinateString,
collections: {},
newObject: newObject,
newAdditionalObject: newAdditionalObject,
newObjectDeferred: newObjectDeferred,
newObjectDeferredBegin: newObjectDeferredBegin,
getFilters: getFilters,
putStream: putStream,
events: events,
scaleFactor: scaleFactor,
pageSize: {
getWidth: function(){
return getPageWidth(currentPage);
},
setWidth: function(value){
setPageWidth(currentPage, value);
},
getHeight: function(){
return getPageHeight(currentPage);
},
setHeight: function(value){
setPageHeight(currentPage, value);
}},
output: output,
getNumberOfPages: getNumberOfPages,
pages: pages,
out: out,
f2: f2,
f3: f3,
getPageInfo: getPageInfo,
getPageInfoByObjId: getPageInfoByObjId,
getCurrentPageInfo: getCurrentPageInfo,
getPDFVersion: getPdfVersion,
Point: Point,
Rectangle: Rectangle,
Matrix: Matrix,
hasHotfix: hasHotfix
};
Object.defineProperty(API.internal.pageSize, "width", {
get: function(){
return getPageWidth(currentPage);
},
set: function(value){
setPageWidth(currentPage, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(API.internal.pageSize, "height", {
get: function(){
return getPageHeight(currentPage);
},
set: function(value){
setPageHeight(currentPage, value);
},
enumerable: true,
configurable: true
});
addFonts.call(API, standardFonts);
activeFontKey="F1";
_addPage(format, orientation);
events.publish("initialized");
return API;
}
/**
* jsPDF.API is a STATIC property of jsPDF class.
* jsPDF.API is an object you can add methods and properties to.
* The methods / properties you add will show up in new jsPDF objects.
*
* One property is prepopulated. It is the 'events' Object. Plugin authors can add topics,
* callbacks to this object. These will be reassigned to all new instances of jsPDF.
*
* @static
* @public
* @memberof jsPDF#
* @name API
*
* @example
* jsPDF.API.mymethod=function(){
*   // 'this' will be ref to internal API object. see jsPDF source
*   // , so you can refer to built-in methods like so:
*
*
* }
* var pdfdoc=new jsPDF()
* pdfdoc.mymethod()
*/
jsPDF.API={
events: []
};
jsPDF.version="1.5.3";
var jsPDFAPI=jsPDF.API;
var scope;
var scaleFactor=1;
var pdfEscape=function(value){
return value
.replace(/\\/g, "\\\\")
.replace(/\(/g, "\\(")
.replace(/\)/g, "\\)");
};
var pdfUnescape=function(value){
return value
.replace(/\\\\/g, "\\")
.replace(/\\\(/g, "(")
.replace(/\\\)/g, ")");
};
var f2=function(number){
return number.toFixed(2);
};
var f5=function(number){
return number.toFixed(5);
};
jsPDFAPI.__acroform__={};
var inherit=function(child, parent){
child.prototype=Object.create(parent.prototype);
child.prototype.constructor=child;
};
var scale=function(x){
return x * scaleFactor;
};
var createFormXObject=function(formObject){
var xobj=new AcroFormXObject();
var height=AcroFormAppearance.internal.getHeight(formObject)||0;
var width=AcroFormAppearance.internal.getWidth(formObject)||0;
xobj.BBox=[0, 0, Number(f2(width)), Number(f2(height))];
return xobj;
};
var setBit=(jsPDFAPI.__acroform__.setBit=function(number, bitPosition){
number=number||0;
bitPosition=bitPosition||0;
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.setBit"
);
}
var bitMask=1 << bitPosition;
number |=bitMask;
return number;
});
var clearBit=(jsPDFAPI.__acroform__.clearBit=function(number, bitPosition){
number=number||0;
bitPosition=bitPosition||0;
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.clearBit"
);
}
var bitMask=1 << bitPosition;
number &=~bitMask;
return number;
});
var getBit=(jsPDFAPI.__acroform__.getBit=function(number, bitPosition){
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.getBit"
);
}
return (number & (1 << bitPosition))===0 ? 0:1;
});
var getBitForPdf=(jsPDFAPI.__acroform__.getBitForPdf=function(
number,
bitPosition
){
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf"
);
}
return getBit(number, bitPosition - 1);
});
var setBitForPdf=(jsPDFAPI.__acroform__.setBitForPdf=function(
number,
bitPosition
){
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf"
);
}
return setBit(number, bitPosition - 1);
});
var clearBitForPdf=(jsPDFAPI.__acroform__.clearBitForPdf=function(
number,
bitPosition
){
if(isNaN(number)||isNaN(bitPosition)){
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf"
);
}
return clearBit(number, bitPosition - 1);
});
var calculateCoordinates=(jsPDFAPI.__acroform__.calculateCoordinates=function(
args
){
var getHorizontalCoordinate=this.internal.getHorizontalCoordinate;
var getVerticalCoordinate=this.internal.getVerticalCoordinate;
var x=args[0];
var y=args[1];
var w=args[2];
var h=args[3];
var coordinates={};
coordinates.lowerLeft_X=getHorizontalCoordinate(x)||0;
coordinates.lowerLeft_Y=getVerticalCoordinate(y + h)||0;
coordinates.upperRight_X=getHorizontalCoordinate(x + w)||0;
coordinates.upperRight_Y=getVerticalCoordinate(y)||0;
return [
Number(f2(coordinates.lowerLeft_X)),
Number(f2(coordinates.lowerLeft_Y)),
Number(f2(coordinates.upperRight_X)),
Number(f2(coordinates.upperRight_Y))
];
});
var calculateAppearanceStream=function(formObject){
if(formObject.appearanceStreamContent){
return formObject.appearanceStreamContent;
}
if(!formObject.V&&!formObject.DV){
return;
}
var stream=[];
var text=formObject.V||formObject.DV;
var calcRes=calculateX(formObject, text);
var fontKey=scope.internal.getFont(formObject.fontName,
formObject.fontStyle
).id;
stream.push("/Tx BMC");
stream.push("q");
stream.push("BT");
stream.push(scope.__private__.encodeColorString(formObject.color));
stream.push("/" + fontKey + " " + f2(calcRes.fontSize) + " Tf");
stream.push("1 0 0 1 0 0 Tm");
stream.push(calcRes.text);
stream.push("ET");
stream.push("Q");
stream.push("EMC");
var appearanceStreamContent=new createFormXObject(formObject);
appearanceStreamContent.stream=stream.join("\n");
return appearanceStreamContent;
};
var calculateX=function(formObject, text){
var maxFontSize =
formObject.fontSize===0 ? formObject.maxFontSize:formObject.fontSize;
var returnValue={
text: "",
fontSize: ""
};
text=text.substr(0, 1)=="(" ? text.substr(1):text;
text =
text.substr(text.length - 1)==")"
? text.substr(0, text.length - 1)
: text;
var textSplit=text.split(" ");
var fontSize=maxFontSize;
var lineSpacing=2;
var borderPadding=2;
var height=AcroFormAppearance.internal.getHeight(formObject)||0;
height=height < 0 ? -height:height;
var width=AcroFormAppearance.internal.getWidth(formObject)||0;
width=width < 0 ? -width:width;
var isSmallerThanWidth=function(i, lastLine, fontSize){
if(i + 1 < textSplit.length){
var tmp=lastLine + " " + textSplit[i + 1];
var TextWidth=calculateFontSpace(tmp, formObject, fontSize).width;
var FieldWidth=width - 2 * borderPadding;
return TextWidth <=FieldWidth;
}else{
return false;
}};
fontSize++;
FontSize: while (fontSize > 0){
text="";
fontSize--;
var textHeight=calculateFontSpace("3", formObject, fontSize).height;
var startY=formObject.multiline
? height - fontSize
: (height - textHeight) / 2;
startY +=lineSpacing;
var startX;
var lastY=startY;
var firstWordInLine=0,
lastWordInLine=0;
var lastLength;
if(fontSize <=0){
fontSize=12;
text="(...) Tj\n";
text +=
"% Width of Text: " +
calculateFontSpace(text, formObject, fontSize).width +
", FieldWidth:" +
width +
"\n";
break;
}
var lastLine="";
var lineCount=0;
Line: for (var i in textSplit){
if(textSplit.hasOwnProperty(i)){
lastLine +=textSplit[i] + " ";
lastLine =
lastLine.substr(lastLine.length - 1)==" "
? lastLine.substr(0, lastLine.length - 1)
: lastLine;
var key=parseInt(i);
var nextLineIsSmaller=isSmallerThanWidth(key, lastLine, fontSize);
var isLastWord=i >=textSplit.length - 1;
if(nextLineIsSmaller&&!isLastWord){
lastLine +=" ";
continue;
}else if(!nextLineIsSmaller&&!isLastWord){
if(!formObject.multiline){
continue FontSize;
}else{
if((textHeight + lineSpacing) * (lineCount + 2) + lineSpacing >
height
){
continue FontSize;
}
lastWordInLine=key;
}}else if(isLastWord){
lastWordInLine=key;
}else{
if(formObject.multiline &&
(textHeight + lineSpacing) * (lineCount + 2) + lineSpacing > height
){
continue FontSize;
}}
var line="";
for (var x=firstWordInLine; x <=lastWordInLine; x++){
line +=textSplit[x] + " ";
}
line =
line.substr(line.length - 1)==" "
? line.substr(0, line.length - 1)
: line;
lastLength=calculateFontSpace(line, formObject, fontSize).width;
switch (formObject.textAlign){
case "right":
startX=width - lastLength - borderPadding;
break;
case "center":
startX=(width - lastLength) / 2;
break;
case "left":
default:
startX=borderPadding;
break;
}
text +=f2(startX) + " " + f2(lastY) + " Td\n";
text +="(" + pdfEscape(line) + ") Tj\n";
text +=-f2(startX) + " 0 Td\n";
lastY=-(fontSize + lineSpacing);
lastLength=0;
firstWordInLine=lastWordInLine + 1;
lineCount++;
lastLine="";
continue Line;
}}
break;
}
returnValue.text=text;
returnValue.fontSize=fontSize;
return returnValue;
};
var calculateFontSpace=function(text, formObject, fontSize){
var font=scope.internal.getFont(formObject.fontName, formObject.fontStyle);
var width =
scope.getStringUnitWidth(text, {
font: font,
fontSize: parseFloat(fontSize),
charSpace: 0
}) * parseFloat(fontSize);
var height =
scope.getStringUnitWidth("3", {
font: font,
fontSize: parseFloat(fontSize),
charSpace: 0
}) *
parseFloat(fontSize) *
1.5;
return { height: height, width: width };};
var acroformPluginTemplate={
fields: [],
xForms: [],
acroFormDictionaryRoot: null,
printedOut: false,
internal: null,
isInitialized: false
};
var annotReferenceCallback=function(){
scope.internal.acroformPlugin.acroFormDictionaryRoot.objId=undefined;
var fields=scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields;
for (var i in fields){
if(fields.hasOwnProperty(i)){
var formObject=fields[i];
formObject.objId=undefined;
if(formObject.hasAnnotation){
createAnnotationReference.call(scope, formObject);
}}
}};
var putForm=function(formObject){
if(scope.internal.acroformPlugin.printedOut){
scope.internal.acroformPlugin.printedOut=false;
scope.internal.acroformPlugin.acroFormDictionaryRoot=null;
}
if(!scope.internal.acroformPlugin.acroFormDictionaryRoot){
initializeAcroForm.call(scope);
}
scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(formObject);
};
var createAnnotationReference=function(object){
var options={
type: "reference",
object: object
};
var findEntry=function(entry){
return entry.type===options.type&&entry.object===options.object;
};
if(scope.internal
.getPageInfo(object.page)
.pageContext.annotations.find(findEntry)===undefined
){
scope.internal
.getPageInfo(object.page)
.pageContext.annotations.push(options);
}};
var putCatalogCallback=function(){
if(typeof scope.internal.acroformPlugin.acroFormDictionaryRoot!="undefined"
){
scope.internal.write("/AcroForm " +
scope.internal.acroformPlugin.acroFormDictionaryRoot.objId +
" " +
0 +
" R"
);
}else{
throw new Error("putCatalogCallback: Root missing.");
}};
var AcroFormDictionaryCallback=function(){
scope.internal.events.unsubscribe(scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID
);
delete scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID;
scope.internal.acroformPlugin.printedOut=true;
};
var createFieldCallback=function(fieldArray){
var standardFields = !fieldArray;
if(!fieldArray){
scope.internal.newObjectDeferredBegin(scope.internal.acroformPlugin.acroFormDictionaryRoot.objId,
true
);
scope.internal.acroformPlugin.acroFormDictionaryRoot.putStream();
}
fieldArray =
fieldArray||scope.internal.acroformPlugin.acroFormDictionaryRoot.Kids;
for (var i in fieldArray){
if(fieldArray.hasOwnProperty(i)){
var fieldObject=fieldArray[i];
var keyValueList=[];
var oldRect=fieldObject.Rect;
if(fieldObject.Rect){
fieldObject.Rect=calculateCoordinates.call(this, fieldObject.Rect);
}
scope.internal.newObjectDeferredBegin(fieldObject.objId, true);
fieldObject.DA=AcroFormAppearance.createDefaultAppearanceStream(fieldObject
);
if(typeof fieldObject==="object" &&
typeof fieldObject.getKeyValueListForStream==="function"
){
keyValueList=fieldObject.getKeyValueListForStream();
}
fieldObject.Rect=oldRect;
if(fieldObject.hasAppearanceStream &&
!fieldObject.appearanceStreamContent
){
var appearance=calculateAppearanceStream.call(this, fieldObject);
keyValueList.push({ key: "AP", value: "<</N " + appearance + ">>" });
scope.internal.acroformPlugin.xForms.push(appearance);
}
if(fieldObject.appearanceStreamContent){
var appearanceStreamString="";
for (var k in fieldObject.appearanceStreamContent){
if(fieldObject.appearanceStreamContent.hasOwnProperty(k)){
var value=fieldObject.appearanceStreamContent[k];
appearanceStreamString +="/" + k + " ";
appearanceStreamString +="<<";
if(Object.keys(value).length >=1||Array.isArray(value)){
for (var i in value){
if(value.hasOwnProperty(i)){
var obj=value[i];
if(typeof obj==="function"){
obj=obj.call(this, fieldObject);
}
appearanceStreamString +="/" + i + " " + obj + " ";
if(!(scope.internal.acroformPlugin.xForms.indexOf(obj) >=0))
scope.internal.acroformPlugin.xForms.push(obj);
}}
}else{
obj=value;
if(typeof obj==="function"){
obj=obj.call(this, fieldObject);
}
appearanceStreamString +="/" + i + " " + obj;
if(!(scope.internal.acroformPlugin.xForms.indexOf(obj) >=0))
scope.internal.acroformPlugin.xForms.push(obj);
}
appearanceStreamString +=">>";
}}
keyValueList.push({
key: "AP",
value: "<<\n" + appearanceStreamString + ">>"
});
}
scope.internal.putStream({ additionalKeyValues: keyValueList });
scope.internal.out("endobj");
}}
if(standardFields){
createXFormObjectCallback.call(this, scope.internal.acroformPlugin.xForms);
}};
var createXFormObjectCallback=function(fieldArray){
for (var i in fieldArray){
if(fieldArray.hasOwnProperty(i)){
var key=i;
var fieldObject=fieldArray[i];
scope.internal.newObjectDeferredBegin(fieldObject&&fieldObject.objId,
true
);
if(typeof fieldObject==="object" &&
typeof fieldObject.putStream==="function"
){
fieldObject.putStream();
}
delete fieldArray[key];
}}
};
var initializeAcroForm=function(){
if(this.internal!==undefined &&
(this.internal.acroformPlugin===undefined ||
this.internal.acroformPlugin.isInitialized===false)
){
scope=this;
AcroFormField.FieldNum=0;
this.internal.acroformPlugin=JSON.parse(JSON.stringify(acroformPluginTemplate)
);
if(this.internal.acroformPlugin.acroFormDictionaryRoot){
throw new Error("Exception while creating AcroformDictionary");
}
scaleFactor=scope.internal.scaleFactor;
scope.internal.acroformPlugin.acroFormDictionaryRoot=new AcroFormDictionary();
scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID=scope.internal.events.subscribe("postPutResources",
AcroFormDictionaryCallback
);
scope.internal.events.subscribe("buildDocument", annotReferenceCallback);
scope.internal.events.subscribe("putCatalog", putCatalogCallback);
scope.internal.events.subscribe("postPutPages", createFieldCallback);
scope.internal.acroformPlugin.isInitialized=true;
}};
var arrayToPdfArray=(jsPDFAPI.__acroform__.arrayToPdfArray=function(array){
if(Array.isArray(array)){
var content="[";
for (var i=0; i < array.length; i++){
if(i!==0){
content +=" ";
}
switch (typeof array[i]){
case "boolean":
case "number":
case "object":
content +=array[i].toString();
break;
case "string":
if(array[i].substr(0, 1)!=="/"){
content +="(" + pdfEscape(array[i].toString()) + ")";
}else{
content +=array[i].toString();
}
break;
}}
content +="]";
return content;
}
throw new Error(
"Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray"
);
});
function getMatches(string, regex, index){
index||(index=1);
var matches=[];
var match;
while ((match=regex.exec(string))){
matches.push(match[index]);
}
return matches;
}
var pdfArrayToStringArray=function(array){
var result=[];
if(typeof array==="string"){
result=getMatches(array, /\((.*?)\)/g);
}
return result;
};
var toPdfString=function(string){
string=string||"";
string.toString();
string="(" + pdfEscape(string) + ")";
return string;
};
var AcroFormPDFObject=function(){
var _objId;
Object.defineProperty(this, "objId", {
configurable: true,
get: function(){
if(!_objId){
_objId=scope.internal.newObjectDeferred();
}
return _objId;
},
set: function(value){
_objId=value;
}});
};
AcroFormPDFObject.prototype.toString=function(){
return this.objId + " 0 R";
};
AcroFormPDFObject.prototype.putStream=function(){
var keyValueList=this.getKeyValueListForStream();
scope.internal.putStream({
data: this.stream,
additionalKeyValues: keyValueList
});
scope.internal.out("endobj");
};
AcroFormPDFObject.prototype.getKeyValueListForStream=function(){
var createKeyValueListFromFieldObject=function(fieldObject){
var keyValueList=[];
var keys=Object.getOwnPropertyNames(fieldObject).filter(function(key){
return (
key!="content" &&
key!="appearanceStreamContent" &&
key.substring(0, 1)!="_"
);
});
for (var i in keys){
if(Object.getOwnPropertyDescriptor(fieldObject, keys[i]).configurable===false
){
var key=keys[i];
var value=fieldObject[key];
if(value){
if(Array.isArray(value)){
keyValueList.push({ key: key, value: arrayToPdfArray(value) });
}else if(value instanceof AcroFormPDFObject){
keyValueList.push({ key: key, value: value.objId + " 0 R" });
}else if(typeof value!=="function"){
keyValueList.push({ key: key, value: value });
}}
}}
return keyValueList;
};
return createKeyValueListFromFieldObject(this);
};
var AcroFormXObject=function(){
AcroFormPDFObject.call(this);
Object.defineProperty(this, "Type", {
value: "/XObject",
configurable: false,
writeable: true
});
Object.defineProperty(this, "Subtype", {
value: "/Form",
configurable: false,
writeable: true
});
Object.defineProperty(this, "FormType", {
value: 1,
configurable: false,
writeable: true
});
var _BBox=[];
Object.defineProperty(this, "BBox", {
configurable: false,
writeable: true,
get: function(){
return _BBox;
},
set: function(value){
_BBox=value;
}});
Object.defineProperty(this, "Resources", {
value: "2 0 R",
configurable: false,
writeable: true
});
var _stream;
Object.defineProperty(this, "stream", {
enumerable: false,
configurable: true,
set: function(value){
_stream=value.trim();
},
get: function(){
if(_stream){
return _stream;
}else{
return null;
}}
});
};
inherit(AcroFormXObject, AcroFormPDFObject);
var AcroFormDictionary=function(){
AcroFormPDFObject.call(this);
var _Kids=[];
Object.defineProperty(this, "Kids", {
enumerable: false,
configurable: true,
get: function(){
if(_Kids.length > 0){
return _Kids;
}else{
return undefined;
}}
});
Object.defineProperty(this, "Fields", {
enumerable: false,
configurable: false,
get: function(){
return _Kids;
}});
var _DA;
Object.defineProperty(this, "DA", {
enumerable: false,
configurable: false,
get: function(){
if(!_DA){
return undefined;
}
return "(" + _DA + ")";
},
set: function(value){
_DA=value;
}});
};
inherit(AcroFormDictionary, AcroFormPDFObject);
var AcroFormField=function(){
AcroFormPDFObject.call(this);
var _F=4;
Object.defineProperty(this, "F", {
enumerable: false,
configurable: false,
get: function(){
return _F;
},
set: function(value){
if(!isNaN(value)){
_F=value;
}else{
throw new Error(
'Invalid value "' + value + '" for attribute F supplied.'
);
}}
});
Object.defineProperty(this, "showWhenPrinted", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(_F, 3));
},
set: function(value){
if(Boolean(value)===true){
this.F=setBitForPdf(_F, 3);
}else{
this.F=clearBitForPdf(_F, 3);
}}
});
var _Ff=0;
Object.defineProperty(this, "Ff", {
enumerable: false,
configurable: false,
get: function(){
return _Ff;
},
set: function(value){
if(!isNaN(value)){
_Ff=value;
}else{
throw new Error(
'Invalid value "' + value + '" for attribute Ff supplied.'
);
}}
});
var _Rect=[];
Object.defineProperty(this, "Rect", {
enumerable: false,
configurable: false,
get: function(){
if(_Rect.length===0){
return undefined;
}
return _Rect;
},
set: function(value){
if(typeof value!=="undefined"){
_Rect=value;
}else{
_Rect=[];
}}
});
Object.defineProperty(this, "x", {
enumerable: true,
configurable: true,
get: function(){
if(!_Rect||isNaN(_Rect[0])){
return 0;
}
return _Rect[0];
},
set: function(value){
_Rect[0]=value;
}});
Object.defineProperty(this, "y", {
enumerable: true,
configurable: true,
get: function(){
if(!_Rect||isNaN(_Rect[1])){
return 0;
}
return _Rect[1];
},
set: function(value){
_Rect[1]=value;
}});
Object.defineProperty(this, "width", {
enumerable: true,
configurable: true,
get: function(){
if(!_Rect||isNaN(_Rect[2])){
return 0;
}
return _Rect[2];
},
set: function(value){
_Rect[2]=value;
}});
Object.defineProperty(this, "height", {
enumerable: true,
configurable: true,
get: function(){
if(!_Rect||isNaN(_Rect[3])){
return 0;
}
return _Rect[3];
},
set: function(value){
_Rect[3]=value;
}});
var _FT="";
Object.defineProperty(this, "FT", {
enumerable: true,
configurable: false,
get: function(){
return _FT;
},
set: function(value){
switch (value){
case "/Btn":
case "/Tx":
case "/Ch":
case "/Sig":
_FT=value;
break;
default:
throw new Error(
'Invalid value "' + value + '" for attribute FT supplied.'
);
}}
});
var _T=null;
Object.defineProperty(this, "T", {
enumerable: true,
configurable: false,
get: function(){
if(!_T||_T.length < 1){
if(this instanceof AcroFormChildClass){
return undefined;
}
_T="FieldObject" + AcroFormField.FieldNum++;
}
return "(" + pdfEscape(_T) + ")";
},
set: function(value){
_T=value.toString();
}});
Object.defineProperty(this, "fieldName", {
configurable: true,
enumerable: true,
get: function(){
return _T;
},
set: function(value){
_T=value;
}});
var _fontName="helvetica";
Object.defineProperty(this, "fontName", {
enumerable: true,
configurable: true,
get: function(){
return _fontName;
},
set: function(value){
_fontName=value;
}});
var _fontStyle="normal";
Object.defineProperty(this, "fontStyle", {
enumerable: true,
configurable: true,
get: function(){
return _fontStyle;
},
set: function(value){
_fontStyle=value;
}});
var _fontSize=0;
Object.defineProperty(this, "fontSize", {
enumerable: true,
configurable: true,
get: function(){
return _fontSize;
},
set: function(value){
_fontSize=value;
}});
var _maxFontSize=undefined;
Object.defineProperty(this, "maxFontSize", {
enumerable: true,
configurable: true,
get: function(){
if(_maxFontSize===undefined){
return 50 / scaleFactor;
}else{
return _maxFontSize;
}},
set: function(value){
_maxFontSize=value;
}});
var _color="black";
Object.defineProperty(this, "color", {
enumerable: true,
configurable: true,
get: function(){
return _color;
},
set: function(value){
_color=value;
}});
var _DA="/F1 0 Tf 0 g";
Object.defineProperty(this, "DA", {
enumerable: true,
configurable: false,
get: function(){
if(!_DA ||
this instanceof AcroFormChildClass ||
this instanceof AcroFormTextField
){
return undefined;
}
return toPdfString(_DA);
},
set: function(value){
value=value.toString();
_DA=value;
}});
var _DV=null;
Object.defineProperty(this, "DV", {
enumerable: false,
configurable: false,
get: function(){
if(!_DV){
return undefined;
}
if(this instanceof AcroFormButton===false){
return toPdfString(_DV);
}
return _DV;
},
set: function(value){
value=value.toString();
if(this instanceof AcroFormButton===false){
if(value.substr(0, 1)==="("){
_DV=pdfUnescape(value.substr(1, value.length - 2));
}else{
_DV=pdfUnescape(value);
}}else{
_DV=value;
}}
});
Object.defineProperty(this, "defaultValue", {
enumerable: true,
configurable: true,
get: function(){
if(this instanceof AcroFormButton===true){
return pdfUnescape(_DV.substr(1, _DV.length - 1));
}else{
return _DV;
}},
set: function(value){
value=value.toString();
if(this instanceof AcroFormButton===true){
_DV="/" + value;
}else{
_DV=value;
}}
});
var _V=null;
Object.defineProperty(this, "V", {
enumerable: false,
configurable: false,
get: function(){
if(!_V){
return undefined;
}
if(this instanceof AcroFormButton===false){
return toPdfString(_V);
}
return _V;
},
set: function(value){
value=value.toString();
if(this instanceof AcroFormButton===false){
if(value.substr(0, 1)==="("){
_V=pdfUnescape(value.substr(1, value.length - 2));
}else{
_V=pdfUnescape(value);
}}else{
_V=value;
}}
});
Object.defineProperty(this, "value", {
enumerable: true,
configurable: true,
get: function(){
if(this instanceof AcroFormButton===true){
return pdfUnescape(_V.substr(1, _V.length - 1));
}else{
return _V;
}},
set: function(value){
value=value.toString();
if(this instanceof AcroFormButton===true){
_V="/" + value;
}else{
_V=value;
}}
});
Object.defineProperty(this, "hasAnnotation", {
enumerable: true,
configurable: true,
get: function(){
return this.Rect;
}});
Object.defineProperty(this, "Type", {
enumerable: true,
configurable: false,
get: function(){
return this.hasAnnotation ? "/Annot":null;
}});
Object.defineProperty(this, "Subtype", {
enumerable: true,
configurable: false,
get: function(){
return this.hasAnnotation ? "/Widget":null;
}});
var _hasAppearanceStream=false;
Object.defineProperty(this, "hasAppearanceStream", {
enumerable: true,
configurable: true,
writeable: true,
get: function(){
return _hasAppearanceStream;
},
set: function(value){
value=Boolean(value);
_hasAppearanceStream=value;
}});
var _page;
Object.defineProperty(this, "page", {
enumerable: true,
configurable: true,
writeable: true,
get: function(){
if(!_page){
return undefined;
}
return _page;
},
set: function(value){
_page=value;
}});
Object.defineProperty(this, "readOnly", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 1));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 1);
}else{
this.Ff=clearBitForPdf(this.Ff, 1);
}}
});
Object.defineProperty(this, "required", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 2));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 2);
}else{
this.Ff=clearBitForPdf(this.Ff, 2);
}}
});
Object.defineProperty(this, "noExport", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 3));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 3);
}else{
this.Ff=clearBitForPdf(this.Ff, 3);
}}
});
var _Q=null;
Object.defineProperty(this, "Q", {
enumerable: true,
configurable: false,
get: function(){
if(_Q===null){
return undefined;
}
return _Q;
},
set: function(value){
if([0, 1, 2].indexOf(value)!==-1){
_Q=value;
}else{
throw new Error(
'Invalid value "' + value + '" for attribute Q supplied.'
);
}}
});
Object.defineProperty(this, "textAlign", {
get: function(){
var result;
switch (_Q){
case 0:
default:
result="left";
break;
case 1:
result="center";
break;
case 2:
result="right";
break;
}
return result;
},
configurable: true,
enumerable: true,
set: function(value){
switch (value){
case "right":
case 2:
_Q=2;
break;
case "center":
case 1:
_Q=1;
break;
case "left":
case 0:
default:
_Q=0;
}}
});
};
inherit(AcroFormField, AcroFormPDFObject);
var AcroFormChoiceField=function(){
AcroFormField.call(this);
this.FT="/Ch";
this.V="()";
this.fontName="zapfdingbats";
var _TI=0;
Object.defineProperty(this, "TI", {
enumerable: true,
configurable: false,
get: function(){
return _TI;
},
set: function(value){
_TI=value;
}});
Object.defineProperty(this, "topIndex", {
enumerable: true,
configurable: true,
get: function(){
return _TI;
},
set: function(value){
_TI=value;
}});
var _Opt=[];
Object.defineProperty(this, "Opt", {
enumerable: true,
configurable: false,
get: function(){
return arrayToPdfArray(_Opt);
},
set: function(value){
_Opt=pdfArrayToStringArray(value);
}});
this.getOptions=function(){
return _Opt;
};
this.setOptions=function(value){
_Opt=value;
if(this.sort){
_Opt.sort();
}};
this.addOption=function(value){
value=value||"";
value=value.toString();
_Opt.push(value);
if(this.sort){
_Opt.sort();
}};
this.removeOption=function(value, allEntries){
allEntries=allEntries||false;
value=value||"";
value=value.toString();
while (_Opt.indexOf(value)!==-1){
_Opt.splice(_Opt.indexOf(value), 1);
if(allEntries===false){
break;
}}
};
Object.defineProperty(this, "combo", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 18));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 18);
}else{
this.Ff=clearBitForPdf(this.Ff, 18);
}}
});
Object.defineProperty(this, "edit", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 19));
},
set: function(value){
if(this.combo===true){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 19);
}else{
this.Ff=clearBitForPdf(this.Ff, 19);
}}
}});
Object.defineProperty(this, "sort", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 20));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 20);
_Opt.sort();
}else{
this.Ff=clearBitForPdf(this.Ff, 20);
}}
});
Object.defineProperty(this, "multiSelect", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 22));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 22);
}else{
this.Ff=clearBitForPdf(this.Ff, 22);
}}
});
Object.defineProperty(this, "doNotSpellCheck", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 23));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 23);
}else{
this.Ff=clearBitForPdf(this.Ff, 23);
}}
});
Object.defineProperty(this, "commitOnSelChange", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 27));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 27);
}else{
this.Ff=clearBitForPdf(this.Ff, 27);
}}
});
this.hasAppearanceStream=false;
};
inherit(AcroFormChoiceField, AcroFormField);
var AcroFormListBox=function(){
AcroFormChoiceField.call(this);
this.fontName="helvetica";
this.combo=false;
};
inherit(AcroFormListBox, AcroFormChoiceField);
var AcroFormComboBox=function(){
AcroFormListBox.call(this);
this.combo=true;
};
inherit(AcroFormComboBox, AcroFormListBox);
var AcroFormEditBox=function(){
AcroFormComboBox.call(this);
this.edit=true;
};
inherit(AcroFormEditBox, AcroFormComboBox);
var AcroFormButton=function(){
AcroFormField.call(this);
this.FT="/Btn";
Object.defineProperty(this, "noToggleToOff", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 15));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 15);
}else{
this.Ff=clearBitForPdf(this.Ff, 15);
}}
});
Object.defineProperty(this, "radio", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 16));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 16);
}else{
this.Ff=clearBitForPdf(this.Ff, 16);
}}
});
Object.defineProperty(this, "pushButton", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 17));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 17);
}else{
this.Ff=clearBitForPdf(this.Ff, 17);
}}
});
Object.defineProperty(this, "radioIsUnison", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 26));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 26);
}else{
this.Ff=clearBitForPdf(this.Ff, 26);
}}
});
var _MK={};
Object.defineProperty(this, "MK", {
enumerable: false,
configurable: false,
get: function(){
if(Object.keys(_MK).length!==0){
var result=[];
result.push("<<");
var key;
for (key in _MK){
result.push("/" + key + " (" + _MK[key] + ")");
}
result.push(">>");
return result.join("\n");
}
return undefined;
},
set: function(value){
if(typeof value==="object"){
_MK=value;
}}
});
Object.defineProperty(this, "caption", {
enumerable: true,
configurable: true,
get: function(){
return _MK.CA||"";
},
set: function(value){
if(typeof value==="string"){
_MK.CA=value;
}}
});
var _AS;
Object.defineProperty(this, "AS", {
enumerable: false,
configurable: false,
get: function(){
return _AS;
},
set: function(value){
_AS=value;
}});
Object.defineProperty(this, "appearanceState", {
enumerable: true,
configurable: true,
get: function(){
return _AS.substr(1, _AS.length - 1);
},
set: function(value){
_AS="/" + value;
}});
};
inherit(AcroFormButton, AcroFormField);
var AcroFormPushButton=function(){
AcroFormButton.call(this);
this.pushButton=true;
};
inherit(AcroFormPushButton, AcroFormButton);
var AcroFormRadioButton=function(){
AcroFormButton.call(this);
this.radio=true;
this.pushButton=false;
var _Kids=[];
Object.defineProperty(this, "Kids", {
enumerable: true,
configurable: false,
get: function(){
return _Kids;
},
set: function(value){
if(typeof value!=="undefined"){
_Kids=value;
}else{
_Kids=[];
}}
});
};
inherit(AcroFormRadioButton, AcroFormButton);
var AcroFormChildClass=function(){
AcroFormField.call(this);
var _parent;
Object.defineProperty(this, "Parent", {
enumerable: false,
configurable: false,
get: function(){
return _parent;
},
set: function(value){
_parent=value;
}});
var _optionName;
Object.defineProperty(this, "optionName", {
enumerable: false,
configurable: true,
get: function(){
return _optionName;
},
set: function(value){
_optionName=value;
}});
var _MK={};
Object.defineProperty(this, "MK", {
enumerable: false,
configurable: false,
get: function(){
var result=[];
result.push("<<");
var key;
for (key in _MK){
result.push("/" + key + " (" + _MK[key] + ")");
}
result.push(">>");
return result.join("\n");
},
set: function(value){
if(typeof value==="object"){
_MK=value;
}}
});
Object.defineProperty(this, "caption", {
enumerable: true,
configurable: true,
get: function(){
return _MK.CA||"";
},
set: function(value){
if(typeof value==="string"){
_MK.CA=value;
}}
});
var _AS;
Object.defineProperty(this, "AS", {
enumerable: false,
configurable: false,
get: function(){
return _AS;
},
set: function(value){
_AS=value;
}});
Object.defineProperty(this, "appearanceState", {
enumerable: true,
configurable: true,
get: function(){
return _AS.substr(1, _AS.length - 1);
},
set: function(value){
_AS="/" + value;
}});
this.caption="l";
this.appearanceState="Off";
this._AppearanceType=AcroFormAppearance.RadioButton.Circle;
this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName
);
};
inherit(AcroFormChildClass, AcroFormField);
AcroFormRadioButton.prototype.setAppearance=function(appearance){
if(!("createAppearanceStream" in appearance&&"getCA" in appearance)){
throw new Error(
"Couldn't assign Appearance to RadioButton. Appearance was Invalid!"
);
}
for (var objId in this.Kids){
if(this.Kids.hasOwnProperty(objId)){
var child=this.Kids[objId];
child.appearanceStreamContent=appearance.createAppearanceStream(child.optionName
);
child.caption=appearance.getCA();
}}
};
AcroFormRadioButton.prototype.createOption=function(name){
var child=new AcroFormChildClass();
child.Parent=this;
child.optionName=name;
this.Kids.push(child);
addField.call(this, child);
return child;
};
var AcroFormCheckBox=function(){
AcroFormButton.call(this);
this.fontName="zapfdingbats";
this.caption="3";
this.appearanceState="On";
this.value="On";
this.textAlign="center";
this.appearanceStreamContent=AcroFormAppearance.CheckBox.createAppearanceStream();
};
inherit(AcroFormCheckBox, AcroFormButton);
var AcroFormTextField=function(){
AcroFormField.call(this);
this.FT="/Tx";
Object.defineProperty(this, "multiline", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 13));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 13);
}else{
this.Ff=clearBitForPdf(this.Ff, 13);
}}
});
Object.defineProperty(this, "fileSelect", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 21));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 21);
}else{
this.Ff=clearBitForPdf(this.Ff, 21);
}}
});
Object.defineProperty(this, "doNotSpellCheck", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 23));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 23);
}else{
this.Ff=clearBitForPdf(this.Ff, 23);
}}
});
Object.defineProperty(this, "doNotScroll", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 24));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 24);
}else{
this.Ff=clearBitForPdf(this.Ff, 24);
}}
});
Object.defineProperty(this, "comb", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 25));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 25);
}else{
this.Ff=clearBitForPdf(this.Ff, 25);
}}
});
Object.defineProperty(this, "richText", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 26));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 26);
}else{
this.Ff=clearBitForPdf(this.Ff, 26);
}}
});
var _MaxLen=null;
Object.defineProperty(this, "MaxLen", {
enumerable: true,
configurable: false,
get: function(){
return _MaxLen;
},
set: function(value){
_MaxLen=value;
}});
Object.defineProperty(this, "maxLength", {
enumerable: true,
configurable: true,
get: function(){
return _MaxLen;
},
set: function(value){
if(Number.isInteger(value)){
_MaxLen=value;
}}
});
Object.defineProperty(this, "hasAppearanceStream", {
enumerable: true,
configurable: true,
get: function(){
return this.V||this.DV;
}});
};
inherit(AcroFormTextField, AcroFormField);
var AcroFormPasswordField=function(){
AcroFormTextField.call(this);
Object.defineProperty(this, "password", {
enumerable: true,
configurable: true,
get: function(){
return Boolean(getBitForPdf(this.Ff, 14));
},
set: function(value){
if(Boolean(value)===true){
this.Ff=setBitForPdf(this.Ff, 14);
}else{
this.Ff=clearBitForPdf(this.Ff, 14);
}}
});
this.password=true;
};
inherit(AcroFormPasswordField, AcroFormTextField);
var AcroFormAppearance={
CheckBox: {
createAppearanceStream: function(){
var appearance={
N: {
On: AcroFormAppearance.CheckBox.YesNormal
},
D: {
On: AcroFormAppearance.CheckBox.YesPushDown,
Off: AcroFormAppearance.CheckBox.OffPushDown
}};
return appearance;
},
YesPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
var fontKey=scope.internal.getFont(formObject.fontName,
formObject.fontStyle
).id;
var encodedColor=scope.__private__.encodeColorString(formObject.color);
var calcRes=calculateX(formObject, formObject.caption);
stream.push("0.749023 g");
stream.push("0 0 " +
f2(AcroFormAppearance.internal.getWidth(formObject)) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject)) +
" re"
);
stream.push("f");
stream.push("BMC");
stream.push("q");
stream.push("0 0 1 rg");
stream.push("/" + fontKey + " " + f2(calcRes.fontSize) + " Tf " + encodedColor
);
stream.push("BT");
stream.push(calcRes.text);
stream.push("ET");
stream.push("Q");
stream.push("EMC");
xobj.stream=stream.join("\n");
return xobj;
},
YesNormal: function(formObject){
var xobj=new createFormXObject(formObject);
var fontKey=scope.internal.getFont(formObject.fontName,
formObject.fontStyle
).id;
var encodedColor=scope.__private__.encodeColorString(formObject.color);
var stream=[];
var height=AcroFormAppearance.internal.getHeight(formObject);
var width=AcroFormAppearance.internal.getWidth(formObject);
var calcRes=calculateX(formObject, formObject.caption);
stream.push("1 g");
stream.push("0 0 " + f2(width) + " " + f2(height) + " re");
stream.push("f");
stream.push("q");
stream.push("0 0 1 rg");
stream.push("0 0 " + f2(width - 1) + " " + f2(height - 1) + " re");
stream.push("W");
stream.push("n");
stream.push("0 g");
stream.push("BT");
stream.push("/" + fontKey + " " + f2(calcRes.fontSize) + " Tf " + encodedColor
);
stream.push(calcRes.text);
stream.push("ET");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
},
OffPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
stream.push("0.749023 g");
stream.push("0 0 " +
f2(AcroFormAppearance.internal.getWidth(formObject)) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject)) +
" re"
);
stream.push("f");
xobj.stream=stream.join("\n");
return xobj;
}},
RadioButton: {
Circle: {
createAppearanceStream: function(name){
var appearanceStreamContent={
D: {
Off: AcroFormAppearance.RadioButton.Circle.OffPushDown
},
N: {}};
appearanceStreamContent.N[name] =
AcroFormAppearance.RadioButton.Circle.YesNormal;
appearanceStreamContent.D[name] =
AcroFormAppearance.RadioButton.Circle.YesPushDown;
return appearanceStreamContent;
},
getCA: function(){
return "l";
},
YesNormal: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
var DotRadius =
AcroFormAppearance.internal.getWidth(formObject) <=
AcroFormAppearance.internal.getHeight(formObject)
? AcroFormAppearance.internal.getWidth(formObject) / 4
: AcroFormAppearance.internal.getHeight(formObject) / 4;
DotRadius=Number((DotRadius * 0.9).toFixed(5));
var c=AcroFormAppearance.internal.Bezier_C;
var DotRadiusBezier=Number((DotRadius * c).toFixed(5));
stream.push("q");
stream.push("1 0 0 1 " +
f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +
" " +
f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +
" cm"
);
stream.push(DotRadius + " 0 m");
stream.push(DotRadius +
" " +
DotRadiusBezier +
" " +
DotRadiusBezier +
" " +
DotRadius +
" 0 " +
DotRadius +
" c"
);
stream.push("-" +
DotRadiusBezier +
" " +
DotRadius +
" -" +
DotRadius +
" " +
DotRadiusBezier +
" -" +
DotRadius +
" 0 c"
);
stream.push("-" +
DotRadius +
" -" +
DotRadiusBezier +
" -" +
DotRadiusBezier +
" -" +
DotRadius +
" 0 -" +
DotRadius +
" c"
);
stream.push(DotRadiusBezier +
" -" +
DotRadius +
" " +
DotRadius +
" -" +
DotRadiusBezier +
" " +
DotRadius +
" 0 c"
);
stream.push("f");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
},
YesPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
var DotRadius =
AcroFormAppearance.internal.getWidth(formObject) <=
AcroFormAppearance.internal.getHeight(formObject)
? AcroFormAppearance.internal.getWidth(formObject) / 4
: AcroFormAppearance.internal.getHeight(formObject) / 4;
var DotRadius=Number((DotRadius * 0.9).toFixed(5));
var k=Number((DotRadius * 2).toFixed(5));
var kc=Number((k * AcroFormAppearance.internal.Bezier_C).toFixed(5));
var dc=Number(
(DotRadius * AcroFormAppearance.internal.Bezier_C).toFixed(5)
);
stream.push("0.749023 g");
stream.push("q");
stream.push("1 0 0 1 " +
f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +
" " +
f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +
" cm"
);
stream.push(k + " 0 m");
stream.push(k + " " + kc + " " + kc + " " + k + " 0 " + k + " c");
stream.push("-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c"
);
stream.push("-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c"
);
stream.push(kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c");
stream.push("f");
stream.push("Q");
stream.push("0 g");
stream.push("q");
stream.push("1 0 0 1 " +
f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +
" " +
f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +
" cm"
);
stream.push(DotRadius + " 0 m");
stream.push("" +
DotRadius +
" " +
dc +
" " +
dc +
" " +
DotRadius +
" 0 " +
DotRadius +
" c"
);
stream.push("-" +
dc +
" " +
DotRadius +
" -" +
DotRadius +
" " +
dc +
" -" +
DotRadius +
" 0 c"
);
stream.push("-" +
DotRadius +
" -" +
dc +
" -" +
dc +
" -" +
DotRadius +
" 0 -" +
DotRadius +
" c"
);
stream.push(dc +
" -" +
DotRadius +
" " +
DotRadius +
" -" +
dc +
" " +
DotRadius +
" 0 c"
);
stream.push("f");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
},
OffPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
var DotRadius =
AcroFormAppearance.internal.getWidth(formObject) <=
AcroFormAppearance.internal.getHeight(formObject)
? AcroFormAppearance.internal.getWidth(formObject) / 4
: AcroFormAppearance.internal.getHeight(formObject) / 4;
DotRadius=Number((DotRadius * 0.9).toFixed(5));
var k=Number((DotRadius * 2).toFixed(5));
var kc=Number((k * AcroFormAppearance.internal.Bezier_C).toFixed(5));
stream.push("0.749023 g");
stream.push("q");
stream.push("1 0 0 1 " +
f5(AcroFormAppearance.internal.getWidth(formObject) / 2) +
" " +
f5(AcroFormAppearance.internal.getHeight(formObject) / 2) +
" cm"
);
stream.push(k + " 0 m");
stream.push(k + " " + kc + " " + kc + " " + k + " 0 " + k + " c");
stream.push("-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c"
);
stream.push("-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c"
);
stream.push(kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c");
stream.push("f");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
}},
Cross: {
createAppearanceStream: function(name){
var appearanceStreamContent={
D: {
Off: AcroFormAppearance.RadioButton.Cross.OffPushDown
},
N: {}};
appearanceStreamContent.N[name] =
AcroFormAppearance.RadioButton.Cross.YesNormal;
appearanceStreamContent.D[name] =
AcroFormAppearance.RadioButton.Cross.YesPushDown;
return appearanceStreamContent;
},
getCA: function(){
return "8";
},
YesNormal: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
var cross=AcroFormAppearance.internal.calculateCross(formObject);
stream.push("q");
stream.push("1 1 " +
f2(AcroFormAppearance.internal.getWidth(formObject) - 2) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject) - 2) +
" re"
);
stream.push("W");
stream.push("n");
stream.push(f2(cross.x1.x) + " " + f2(cross.x1.y) + " m");
stream.push(f2(cross.x2.x) + " " + f2(cross.x2.y) + " l");
stream.push(f2(cross.x4.x) + " " + f2(cross.x4.y) + " m");
stream.push(f2(cross.x3.x) + " " + f2(cross.x3.y) + " l");
stream.push("s");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
},
YesPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var cross=AcroFormAppearance.internal.calculateCross(formObject);
var stream=[];
stream.push("0.749023 g");
stream.push("0 0 " +
f2(AcroFormAppearance.internal.getWidth(formObject)) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject)) +
" re"
);
stream.push("f");
stream.push("q");
stream.push("1 1 " +
f2(AcroFormAppearance.internal.getWidth(formObject) - 2) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject) - 2) +
" re"
);
stream.push("W");
stream.push("n");
stream.push(f2(cross.x1.x) + " " + f2(cross.x1.y) + " m");
stream.push(f2(cross.x2.x) + " " + f2(cross.x2.y) + " l");
stream.push(f2(cross.x4.x) + " " + f2(cross.x4.y) + " m");
stream.push(f2(cross.x3.x) + " " + f2(cross.x3.y) + " l");
stream.push("s");
stream.push("Q");
xobj.stream=stream.join("\n");
return xobj;
},
OffPushDown: function(formObject){
var xobj=new createFormXObject(formObject);
var stream=[];
stream.push("0.749023 g");
stream.push("0 0 " +
f2(AcroFormAppearance.internal.getWidth(formObject)) +
" " +
f2(AcroFormAppearance.internal.getHeight(formObject)) +
" re"
);
stream.push("f");
xobj.stream=stream.join("\n");
return xobj;
}}
},
createDefaultAppearanceStream: function(formObject){
var fontKey=scope.internal.getFont(formObject.fontName,
formObject.fontStyle
).id;
var encodedColor=scope.__private__.encodeColorString(formObject.color);
var fontSize=formObject.fontSize;
var result="/" + fontKey + " " + fontSize + " Tf " + encodedColor;
return result;
}};
AcroFormAppearance.internal={
Bezier_C: 0.551915024494,
calculateCross: function(formObject){
var width=AcroFormAppearance.internal.getWidth(formObject);
var height=AcroFormAppearance.internal.getHeight(formObject);
var a=Math.min(width, height);
var cross={
x1: {
x: (width - a) / 2,
y: (height - a) / 2 + a
},
x2: {
x: (width - a) / 2 + a,
y: (height - a) / 2 
},
x3: {
x: (width - a) / 2,
y: (height - a) / 2 
},
x4: {
x: (width - a) / 2 + a,
y: (height - a) / 2 + a
}};
return cross;
}};
AcroFormAppearance.internal.getWidth=function(formObject){
var result=0;
if(typeof formObject==="object"){
result=scale(formObject.Rect[2]);
}
return result;
};
AcroFormAppearance.internal.getHeight=function(formObject){
var result=0;
if(typeof formObject==="object"){
result=scale(formObject.Rect[3]);
}
return result;
};
var addField=(jsPDFAPI.addField=function(fieldObject){
initializeAcroForm.call(this);
if(fieldObject instanceof AcroFormField){
putForm.call(this, fieldObject);
}else{
throw new Error("Invalid argument passed to jsPDF.addField.");
}
fieldObject.page=scope.internal.getCurrentPageInfo().pageNumber;
return this;
});
jsPDFAPI.addButton=function(button){
if(button instanceof AcroFormButton===false){
throw new Error("Invalid argument passed to jsPDF.addButton.");
}
return addField.call(this, button);
};
jsPDFAPI.addTextField=function(textField){
if(textField instanceof AcroFormTextField===false){
throw new Error("Invalid argument passed to jsPDF.addTextField.");
}
return addField.call(this, textField);
};
jsPDFAPI.addChoiceField=function(choiceField){
if(choiceField instanceof AcroFormChoiceField===false){
throw new Error("Invalid argument passed to jsPDF.addChoiceField.");
}
return addField.call(this, choiceField);
};
jsPDFAPI.AcroFormChoiceField=AcroFormChoiceField;
jsPDFAPI.AcroFormListBox=AcroFormListBox;
jsPDFAPI.AcroFormComboBox=AcroFormComboBox;
jsPDFAPI.AcroFormEditBox=AcroFormEditBox;
jsPDFAPI.AcroFormButton=AcroFormButton;
jsPDFAPI.AcroFormPushButton=AcroFormPushButton;
jsPDFAPI.AcroFormRadioButton=AcroFormRadioButton;
jsPDFAPI.AcroFormCheckBox=AcroFormCheckBox;
jsPDFAPI.AcroFormTextField=AcroFormTextField;
jsPDFAPI.AcroFormPasswordField=AcroFormPasswordField;
jsPDFAPI.AcroFormAppearance=AcroFormAppearance;
jsPDFAPI.AcroForm={
ChoiceField: AcroFormChoiceField,
ListBox: AcroFormListBox,
ComboBox: AcroFormComboBox,
EditBox: AcroFormEditBox,
Button: AcroFormButton,
PushButton: AcroFormPushButton,
RadioButton: AcroFormRadioButton,
CheckBox: AcroFormCheckBox,
TextField: AcroFormTextField,
PasswordField: AcroFormPasswordField,
Appearance: AcroFormAppearance
};
jsPDF.AcroForm={
ChoiceField: AcroFormChoiceField,
ListBox: AcroFormListBox,
ComboBox: AcroFormComboBox,
EditBox: AcroFormEditBox,
Button: AcroFormButton,
PushButton: AcroFormPushButton,
RadioButton: AcroFormRadioButton,
CheckBox: AcroFormCheckBox,
TextField: AcroFormTextField,
PasswordField: AcroFormPasswordField,
Appearance: AcroFormAppearance
};
var AcroForm=jsPDF.AcroForm;
(function(jsPDFAPI){
var namespace="addImage_";
jsPDFAPI.__addimage__={};
var UNKNOWN="UNKNOWN";
var imageFileTypeHeaders={
PNG: [[0x89, 0x50, 0x4e, 0x47]],
TIFF: [
[0x4d, 0x4d, 0x00, 0x2a],
[0x49, 0x49, 0x2a, 0x00]
],
JPEG: [
[
0xff,
0xd8,
0xff,
0xe0,
undefined,
undefined,
0x4a,
0x46,
0x49,
0x46,
0x00
],
[
0xff,
0xd8,
0xff,
0xe1,
undefined,
undefined,
0x45,
0x78,
0x69,
0x66,
0x00,
0x00
],
[0xff, 0xd8, 0xff, 0xdb],
[0xff, 0xd8, 0xff, 0xee]
],
JPEG2000: [[0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20]],
GIF87a: [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61]],
GIF89a: [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61]],
WEBP: [
[
0x52,
0x49,
0x46,
0x46,
undefined,
undefined,
undefined,
undefined,
0x57,
0x45,
0x42,
0x50
]
],
BMP: [
[0x42, 0x4d],
[0x42, 0x41],
[0x43, 0x49],
[0x43, 0x50],
[0x49, 0x43],
[0x50, 0x54]
]
};
var getImageFileTypeByImageData=(jsPDFAPI.__addimage__.getImageFileTypeByImageData=function(
imageData,
fallbackFormat
){
fallbackFormat=fallbackFormat||UNKNOWN;
var i;
var j;
var result=UNKNOWN;
var headerSchemata;
var compareResult;
var fileType;
if(isArrayBufferView(imageData)){
for (fileType in imageFileTypeHeaders){
headerSchemata=imageFileTypeHeaders[fileType];
for (i=0; i < headerSchemata.length; i +=1){
compareResult=true;
for (j=0; j < headerSchemata[i].length; j +=1){
if(headerSchemata[i][j]===undefined){
continue;
}
if(headerSchemata[i][j]!==imageData[j]){
compareResult=false;
break;
}}
if(compareResult===true){
result=fileType;
break;
}}
}}else{
for (fileType in imageFileTypeHeaders){
headerSchemata=imageFileTypeHeaders[fileType];
for (i=0; i < headerSchemata.length; i +=1){
compareResult=true;
for (j=0; j < headerSchemata[i].length; j +=1){
if(headerSchemata[i][j]===undefined){
continue;
}
if(headerSchemata[i][j]!==imageData.charCodeAt(j)){
compareResult=false;
break;
}}
if(compareResult===true){
result=fileType;
break;
}}
}}
if(result===UNKNOWN&&fallbackFormat!==UNKNOWN){
result=fallbackFormat;
}
return result;
});
var putImage=function(image){
var out=this.internal.write;
var putStream=this.internal.putStream;
var getFilters=this.internal.getFilters;
var filter=getFilters();
while (filter.indexOf("FlateEncode")!==-1){
filter.splice(filter.indexOf("FlateEncode"), 1);
}
image.objectId=this.internal.newObject();
var additionalKeyValues=[];
additionalKeyValues.push({ key: "Type", value: "/XObject" });
additionalKeyValues.push({ key: "Subtype", value: "/Image" });
additionalKeyValues.push({ key: "Width", value: image.width });
additionalKeyValues.push({ key: "Height", value: image.height });
if(image.colorSpace===color_spaces.INDEXED){
additionalKeyValues.push({
key: "ColorSpace",
value:
"[/Indexed /DeviceRGB " +
(image.palette.length / 3 - 1) +
" " +
("sMask" in image&&typeof image.sMask!=="undefined"
? image.objectId + 2
: image.objectId + 1) +
" 0 R]"
});
}else{
additionalKeyValues.push({
key: "ColorSpace",
value: "/" + image.colorSpace
});
if(image.colorSpace===color_spaces.DEVICE_CMYK){
additionalKeyValues.push({ key: "Decode", value: "[1 0 1 0 1 0 1 0]" });
}}
additionalKeyValues.push({
key: "BitsPerComponent",
value: image.bitsPerComponent
});
if("decodeParameters" in image &&
typeof image.decodeParameters!=="undefined"
){
additionalKeyValues.push({
key: "DecodeParms",
value: "<<" + image.decodeParameters + ">>"
});
}
if("transparency" in image&&Array.isArray(image.transparency)){
var transparency="",
i=0,
len=image.transparency.length;
for (; i < len; i++)
transparency +=
image.transparency[i] + " " + image.transparency[i] + " ";
additionalKeyValues.push({
key: "Mask",
value: "[" + transparency + "]"
});
}
if(typeof image.sMask!=="undefined"){
additionalKeyValues.push({
key: "SMask",
value: image.objectId + 1 + " 0 R"
});
}
var alreadyAppliedFilters =
typeof image.filter!=="undefined" ? ["/" + image.filter]:undefined;
putStream({
data: image.data,
additionalKeyValues: additionalKeyValues,
alreadyAppliedFilters: alreadyAppliedFilters
});
out("endobj");
if("sMask" in image&&typeof image.sMask!=="undefined"){
var decodeParameters =
"/Predictor " +
image.predictor +
" /Colors 1 /BitsPerComponent " +
image.bitsPerComponent +
" /Columns " +
image.width;
var sMask={
width: image.width,
height: image.height,
colorSpace: "DeviceGray",
bitsPerComponent: image.bitsPerComponent,
decodeParameters: decodeParameters,
data: image.sMask
};
if("filter" in image){
sMask.filter=image.filter;
}
putImage.call(this, sMask);
}
if(image.colorSpace===color_spaces.INDEXED){
this.internal.newObject();
putStream({
data: arrayBufferToBinaryString(new Uint8Array(image.palette))
});
out("endobj");
}};
var putResourcesCallback=function(){
var images=this.internal.collections[namespace + "images"];
for (var i in images){
putImage.call(this, images[i]);
}};
var putXObjectsDictCallback=function(){
var images=this.internal.collections[namespace + "images"],
out=this.internal.write,
image;
for (var i in images){
image=images[i];
out("/I" + image.index, image.objectId, "0", "R");
}};
var checkCompressValue=function(value){
if(value&&typeof value==="string") value=value.toUpperCase();
return value in jsPDFAPI.image_compression ? value:image_compression.NONE;
};
var initialize=function(){
if(!this.internal.collections[namespace + "images"]){
this.internal.collections[namespace + "images"]={};
this.internal.events.subscribe("putResources", putResourcesCallback);
this.internal.events.subscribe("putXobjectDict", putXObjectsDictCallback);
}};
var getImages=function(){
var images=this.internal.collections[namespace + "images"];
initialize.call(this);
return images;
};
var getImageIndex=function(){
return Object.keys(this.internal.collections[namespace + "images"]).length;
};
var notDefined=function(value){
return typeof value==="undefined"||value===null||value.length===0;
};
var generateAliasFromImageData=function(imageData){
if(typeof imageData==="string"||isArrayBufferView(imageData)){
return sHashCode(imageData);
}
return null;
};
var isImageTypeSupported=function(type){
return typeof jsPDFAPI["process" + type.toUpperCase()]==="function";
};
var isDOMElement=function(object){
return typeof object==="object"&&object.nodeType===1;
};
var getImageDataFromElement=function(element, format){
if(element.nodeName==="IMG"&&element.hasAttribute("src")){
var src="" + element.getAttribute("src");
if(src.indexOf("data:image/")===0){
return atob(
unescape(src)
.split("base64,")
.pop()
);
}
var tmpImageData=jsPDFAPI.loadFile(src, true);
if(tmpImageData!==undefined){
return tmpImageData;
}}
if(element.nodeName==="CANVAS"){
var mimeType;
switch (format){
case "PNG":
mimeType="image/png";
break;
case "WEBP":
mimeType="image/webp";
break;
case "JPEG":
case "JPG":
default:
mimeType="image/jpeg";
break;
}
return atob(
element
.toDataURL(mimeType, 1.0)
.split("base64,")
.pop()
);
}};
var checkImagesForAlias=function(alias){
var images=this.internal.collections[namespace + "images"];
if(images){
for (var e in images){
if(alias===images[e].alias){
return images[e];
}}
}};
var determineWidthAndHeight=function(width, height, image){
if(!width&&!height){
width=-96;
height=-96;
}
if(width < 0){
width=(-1 * image.width * 72) / width / this.internal.scaleFactor;
}
if(height < 0){
height=(-1 * image.height * 72) / height / this.internal.scaleFactor;
}
if(width===0){
width=(height * image.width) / image.height;
}
if(height===0){
height=(width * image.height) / image.width;
}
return [width, height];
};
var writeImageToPDF=function(x, y, width, height, image, rotation){
var dims=determineWidthAndHeight.call(this, width, height, image),
coord=this.internal.getCoordinateString,
vcoord=this.internal.getVerticalCoordinateString;
var images=getImages.call(this);
width=dims[0];
height=dims[1];
images[image.index]=image;
if(rotation){
rotation *=Math.PI / 180;
var c=Math.cos(rotation);
var s=Math.sin(rotation);
var f4=function(number){
return number.toFixed(4);
};
var rotationTransformationMatrix=[
f4(c),
f4(s),
f4(s * -1),
f4(c),
0,
0,
"cm"
];
}
this.internal.write("q");
if(rotation){
this.internal.write([1, "0", "0", 1, coord(x), vcoord(y + height), "cm"].join(" ")
);
this.internal.write(rotationTransformationMatrix.join(" "));
this.internal.write([coord(width), "0", "0", coord(height), "0", "0", "cm"].join(" ")
);
}else{
this.internal.write([
coord(width),
"0",
"0",
coord(height),
coord(x),
vcoord(y + height),
"cm"
].join(" ")
);
}
if(this.isAdvancedAPI()){
this.internal.write([1, 0, 0, -1, 0, 0, "cm"].join(" "));
}
this.internal.write("/I" + image.index + " Do");
this.internal.write("Q");
};
var color_spaces=(jsPDFAPI.color_spaces={
DEVICE_RGB: "DeviceRGB",
DEVICE_GRAY: "DeviceGray",
DEVICE_CMYK: "DeviceCMYK",
CAL_GREY: "CalGray",
CAL_RGB: "CalRGB",
LAB: "Lab",
ICC_BASED: "ICCBased",
INDEXED: "Indexed",
PATTERN: "Pattern",
SEPARATION: "Separation",
DEVICE_N: "DeviceN"
});
jsPDFAPI.decode={
DCT_DECODE: "DCTDecode",
FLATE_DECODE: "FlateDecode",
LZW_DECODE: "LZWDecode",
JPX_DECODE: "JPXDecode",
JBIG2_DECODE: "JBIG2Decode",
ASCII85_DECODE: "ASCII85Decode",
ASCII_HEX_DECODE: "ASCIIHexDecode",
RUN_LENGTH_DECODE: "RunLengthDecode",
CCITT_FAX_DECODE: "CCITTFaxDecode"
};
var image_compression=(jsPDFAPI.image_compression={
NONE: "NONE",
FAST: "FAST",
MEDIUM: "MEDIUM",
SLOW: "SLOW"
});
var sHashCode=(jsPDFAPI.__addimage__.sHashCode=function(data){
var hash=0,
i,
len;
if(typeof data==="string"){
len=data.length;
for (i=0; i < len; i++){
hash=(hash << 5) - hash + data.charCodeAt(i);
hash |=0;
}}else if(isArrayBufferView(data)){
len=data.byteLength / 2;
for (i=0; i < len; i++){
hash=(hash << 5) - hash + data[i];
hash |=0;
}}
return hash;
});
var validateStringAsBase64=(jsPDFAPI.__addimage__.validateStringAsBase64=function(
possibleBase64String
){
possibleBase64String=possibleBase64String||"";
possibleBase64String.toString().trim();
var result=true;
if(possibleBase64String.length===0){
result=false;
}
if(possibleBase64String.length % 4!==0){
result=false;
}
if(/^[A-Za-z0-9+/]+$/.test(possibleBase64String.substr(0, possibleBase64String.length - 2)
)===false
){
result=false;
}
if(/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(possibleBase64String.substr(-2)
)===false
){
result=false;
}
return result;
});
var extractImageFromDataUrl=(jsPDFAPI.__addimage__.extractImageFromDataUrl=function(
dataUrl
){
dataUrl=dataUrl||"";
var dataUrlParts=dataUrl.split("base64,");
var result=null;
if(dataUrlParts.length===2){
var extractedInfo=/^data:(\w*\/\w*);*(charset=[\w=-]*)*;*$/.exec(dataUrlParts[0]
);
if(Array.isArray(extractedInfo)){
result={
mimeType: extractedInfo[1],
charset: extractedInfo[2],
data: dataUrlParts[1]
};}}
return result;
});
var supportsArrayBuffer=(jsPDFAPI.__addimage__.supportsArrayBuffer=function(){
return (
typeof ArrayBuffer!=="undefined"&&typeof Uint8Array!=="undefined"
);
});
jsPDFAPI.__addimage__.isArrayBuffer=function(object){
return supportsArrayBuffer()&&object instanceof ArrayBuffer;
};
var isArrayBufferView=(jsPDFAPI.__addimage__.isArrayBufferView=function(
object
){
return (
supportsArrayBuffer() &&
typeof Uint32Array!=="undefined" &&
(object instanceof Int8Array ||
object instanceof Uint8Array ||
(typeof Uint8ClampedArray!=="undefined" &&
object instanceof Uint8ClampedArray) ||
object instanceof Int16Array ||
object instanceof Uint16Array ||
object instanceof Int32Array ||
object instanceof Uint32Array ||
object instanceof Float32Array ||
object instanceof Float64Array)
);
});
var binaryStringToUint8Array=(jsPDFAPI.__addimage__.binaryStringToUint8Array=function(
binary_string
){
var len=binary_string.length;
var bytes=new Uint8Array(len);
for (var i=0; i < len; i++){
bytes[i]=binary_string.charCodeAt(i);
}
return bytes;
});
var arrayBufferToBinaryString=(jsPDFAPI.__addimage__.arrayBufferToBinaryString=function(
buffer
){
try {
return atob(btoa(String.fromCharCode.apply(null, buffer)));
} catch (e){
if(typeof Uint8Array!=="undefined" &&
typeof Uint8Array.prototype.reduce!=="undefined"
){
return new Uint8Array(buffer)
.reduce(function(data, byte){
return data.push(String.fromCharCode(byte)), data;
}, [])
.join("");
}}
});
jsPDFAPI.addImage=function(){
var imageData, format, x, y, w, h, alias, compression, rotation;
imageData=arguments[0];
if(typeof arguments[1]==="number"){
format=UNKNOWN;
x=arguments[1];
y=arguments[2];
w=arguments[3];
h=arguments[4];
alias=arguments[5];
compression=arguments[6];
rotation=arguments[7];
}else{
format=arguments[1];
x=arguments[2];
y=arguments[3];
w=arguments[4];
h=arguments[5];
alias=arguments[6];
compression=arguments[7];
rotation=arguments[8];
}
if(typeof imageData==="object" &&
!isDOMElement(imageData) &&
"imageData" in imageData
){
var options=imageData;
imageData=options.imageData;
format=options.format||format||UNKNOWN;
x=options.x||x || 0;
y=options.y||y || 0;
w=options.w||options.width||w;
h=options.h||options.height||h;
alias=options.alias||alias;
compression=options.compression||compression;
rotation=options.rotation||options.angle||rotation;
}
var filter=this.internal.getFilters();
if(compression===undefined&&filter.indexOf("FlateEncode")!==-1){
compression="SLOW";
}
if(isNaN(x)||isNaN(y)){
throw new Error("Invalid coordinates passed to jsPDF.addImage");
}
initialize.call(this);
var image=processImageData.call(this,
imageData,
format,
alias,
compression
);
writeImageToPDF.call(this, x, y, w, h, image, rotation);
return this;
};
var processImageData=function(imageData, format, alias, compression){
var result, dataAsBinaryString;
if(typeof imageData==="string" &&
getImageFileTypeByImageData(imageData)===UNKNOWN
){
imageData=unescape(imageData);
var tmpImageData=convertBase64ToBinaryString(imageData, false);
if(tmpImageData!==""){
imageData=tmpImageData;
}else{
tmpImageData=jsPDFAPI.loadFile(imageData, true);
if(tmpImageData!==undefined){
imageData=tmpImageData;
}}
}
if(isDOMElement(imageData)){
imageData=getImageDataFromElement(imageData, format);
}
format=getImageFileTypeByImageData(imageData, format);
if(!isImageTypeSupported(format)){
throw new Error(
"addImage does not support files of type '" +
format +
"', please ensure that a plugin for '" +
format +
"' support is added."
);
}
if(notDefined(alias)){
alias=generateAliasFromImageData(imageData);
}
result=checkImagesForAlias.call(this, alias);
if(!result){
if(supportsArrayBuffer()){
if(!(imageData instanceof Uint8Array)){
dataAsBinaryString=imageData;
imageData=binaryStringToUint8Array(imageData);
}}
result=this["process" + format.toUpperCase()](
imageData,
getImageIndex.call(this),
alias,
checkCompressValue(compression),
dataAsBinaryString
);
}
if(!result){
throw new Error("An unknown error occurred whilst processing the image.");
}
return result;
};
var convertBase64ToBinaryString=(jsPDFAPI.__addimage__.convertBase64ToBinaryString=function(
stringData,
throwError
){
throwError=typeof throwError==="boolean" ? throwError:true;
var base64Info;
var imageData="";
var rawData;
if(typeof stringData==="string"){
base64Info=extractImageFromDataUrl(stringData);
rawData=base64Info!==null ? base64Info.data:stringData;
try {
imageData=atob(rawData);
} catch (e){
if(throwError){
if(!validateStringAsBase64(rawData)){
throw new Error(
"Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString "
);
}else{
throw new Error(
"atob-Error in jsPDF.convertBase64ToBinaryString " + e.message
);
}}
}}
return imageData;
});
jsPDFAPI.getImageProperties=function(imageData){
var image;
var tmpImageData="";
var format;
if(isDOMElement(imageData)){
imageData=getImageDataFromElement(imageData);
}
if(typeof imageData==="string" &&
getImageFileTypeByImageData(imageData)===UNKNOWN
){
tmpImageData=convertBase64ToBinaryString(imageData, false);
if(tmpImageData===""){
tmpImageData=jsPDFAPI.loadFile(imageData)||"";
}
imageData=tmpImageData;
}
format=getImageFileTypeByImageData(imageData);
if(!isImageTypeSupported(format)){
throw new Error(
"addImage does not support files of type '" +
format +
"', please ensure that a plugin for '" +
format +
"' support is added."
);
}
if(supportsArrayBuffer()&&!(imageData instanceof Uint8Array)){
imageData=binaryStringToUint8Array(imageData);
}
image=this["process" + format.toUpperCase()](imageData);
if(!image){
throw new Error("An unknown error occurred whilst processing the image");
}
image.fileType=format;
return image;
};})(jsPDF.API);
(function(jsPDFAPI){
var notEmpty=function(obj){
if(typeof obj!="undefined"){
if(obj!=""){
return true;
}}
};
jsPDF.API.events.push([
"addPage",
function(addPageData){
var pageInfo=this.internal.getPageInfo(addPageData.pageNumber);
pageInfo.pageContext.annotations=[];
}
]);
jsPDFAPI.events.push([
"putPage",
function(putPageData){
var getHorizontalCoordinateString=this.internal.getCoordinateString;
var getVerticalCoordinateString=this.internal
.getVerticalCoordinateString;
var pageInfo=this.internal.getPageInfoByObjId(putPageData.objId);
var pageAnnos=putPageData.pageContext.annotations;
var anno, rect, line;
var found=false;
for (var a=0; a < pageAnnos.length&&!found; a++){
anno=pageAnnos[a];
switch (anno.type){
case "link":
if(notEmpty(anno.options.url) ||
notEmpty(anno.options.pageNumber)
){
found=true;
}
break;
case "reference":
case "text":
case "freetext":
found=true;
break;
}}
if(found==false){
return;
}
this.internal.write("/Annots [");
for (var i=0; i < pageAnnos.length; i++){
anno=pageAnnos[i];
switch (anno.type){
case "reference":
this.internal.write(" " + anno.object.objId + " 0 R ");
break;
case "text":
var objText=this.internal.newAdditionalObject();
var objPopup=this.internal.newAdditionalObject();
var title=anno.title||"Note";
rect =
"/Rect [" +
getHorizontalCoordinateString(anno.bounds.x) +
" " +
getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +
" " +
getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w) +
" " +
getVerticalCoordinateString(anno.bounds.y) +
"] ";
line =
"<</Type /Annot /Subtype /" +
"Text" +
" " +
rect +
"/Contents (" +
anno.contents +
")";
line +=" /Popup " + objPopup.objId + " 0 R";
line +=" /P " + pageInfo.objId + " 0 R";
line +=" /T (" + title + ") >>";
objText.content=line;
var parent=objText.objId + " 0 R";
var popoff=30;
rect =
"/Rect [" +
getHorizontalCoordinateString(anno.bounds.x + popoff) +
" " +
getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +
" " +
getHorizontalCoordinateString(
anno.bounds.x + anno.bounds.w + popoff
) +
" " +
getVerticalCoordinateString(anno.bounds.y) +
"] ";
line =
"<</Type /Annot /Subtype /" +
"Popup" +
" " +
rect +
" /Parent " +
parent;
if(anno.open){
line +=" /Open true";
}
line +=" >>";
objPopup.content=line;
this.internal.write(objText.objId, "0 R", objPopup.objId, "0 R");
break;
case "freetext":
rect =
"/Rect [" +
getHorizontalCoordinateString(anno.bounds.x) +
" " +
getVerticalCoordinateString(anno.bounds.y) +
" " +
getHorizontalCoordinateString(anno.bounds.x + anno.bounds.w) +
" " +
getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +
"] ";
var color=anno.color||"#000000";
line =
"<</Type /Annot /Subtype /" +
"FreeText" +
" " +
rect +
"/Contents (" +
anno.contents +
")";
line +=
" /DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#" +
color +
")";
line +=" /Border [0 0 0]";
line +=" >>";
this.internal.write(line);
break;
case "link":
if(anno.options.name){
var loc=this.annotations._nameMap[anno.options.name];
anno.options.pageNumber=loc.page;
anno.options.top=loc.y;
}else{
if(!anno.options.top){
anno.options.top=0;
}}
rect =
"/Rect [" +
getHorizontalCoordinateString(anno.x) +
" " +
getVerticalCoordinateString(anno.y) +
" " +
getHorizontalCoordinateString(anno.x + anno.w) +
" " +
getVerticalCoordinateString(anno.y + anno.h) +
"] ";
line="";
if(anno.options.url){
line =
"<</Type /Annot /Subtype /Link " +
rect +
"/Border [0 0 0] /A <</S /URI /URI (" +
anno.options.url +
") >>";
}else if(anno.options.pageNumber){
var info=this.internal.getPageInfo(anno.options.pageNumber);
line =
"<</Type /Annot /Subtype /Link " +
rect +
"/Border [0 0 0] /Dest [" +
info.objId +
" 0 R";
anno.options.magFactor=anno.options.magFactor||"XYZ";
switch (anno.options.magFactor){
case "Fit":
line +=" /Fit]";
break;
case "FitH":
line +=" /FitH " + anno.options.top + "]";
break;
case "FitV":
anno.options.left=anno.options.left||0;
line +=" /FitV " + anno.options.left + "]";
break;
case "XYZ":
default:
var top=getVerticalCoordinateString(anno.options.top);
anno.options.left=anno.options.left||0;
if(typeof anno.options.zoom==="undefined"){
anno.options.zoom=0;
}
line +=
" /XYZ " +
anno.options.left +
" " +
top +
" " +
anno.options.zoom +
"]";
break;
}}
if(line!=""){
line +=" >>";
this.internal.write(line);
}
break;
}}
this.internal.write("]");
}
]);
jsPDFAPI.createAnnotation=function(options){
var pageInfo=this.internal.getCurrentPageInfo();
switch (options.type){
case "link":
this.link(options.bounds.x,
options.bounds.y,
options.bounds.w,
options.bounds.h,
options
);
break;
case "text":
case "freetext":
pageInfo.pageContext.annotations.push(options);
break;
}};
jsPDFAPI.link=function(x, y, w, h, options){
var pageInfo=this.internal.getCurrentPageInfo();
pageInfo.pageContext.annotations.push({
x: x,
y: y,
w: w,
h: h,
options: options,
type: "link"
});
};
jsPDFAPI.textWithLink=function(text, x, y, options){
var width=this.getTextWidth(text);
var height=this.internal.getLineHeight() / this.internal.scaleFactor;
this.text(text, x, y, options);
y +=height * 0.2;
this.link(x, y - height, width, height, options);
return width;
};
jsPDFAPI.getTextWidth=function(text){
var fontSize=this.internal.getFontSize();
var txtWidth =
(this.getStringUnitWidth(text) * fontSize) / this.internal.scaleFactor;
return txtWidth;
};
return this;
})(jsPDF.API);
(function(jsPDFAPI){
var arabicSubstitionA={
0x0621: [0xfe80],
0x0622: [0xfe81, 0xfe82],
0x0623: [0xfe83, 0xfe84],
0x0624: [0xfe85, 0xfe86],
0x0625: [0xfe87, 0xfe88],
0x0626: [0xfe89, 0xfe8a, 0xfe8b, 0xfe8c],
0x0627: [0xfe8d, 0xfe8e],
0x0628: [0xfe8f, 0xfe90, 0xfe91, 0xfe92],
0x0629: [0xfe93, 0xfe94],
0x062a: [0xfe95, 0xfe96, 0xfe97, 0xfe98],
0x062b: [0xfe99, 0xfe9a, 0xfe9b, 0xfe9c],
0x062c: [0xfe9d, 0xfe9e, 0xfe9f, 0xfea0],
0x062d: [0xfea1, 0xfea2, 0xfea3, 0xfea4],
0x062e: [0xfea5, 0xfea6, 0xfea7, 0xfea8],
0x062f: [0xfea9, 0xfeaa],
0x0630: [0xfeab, 0xfeac],
0x0631: [0xfead, 0xfeae],
0x0632: [0xfeaf, 0xfeb0],
0x0633: [0xfeb1, 0xfeb2, 0xfeb3, 0xfeb4],
0x0634: [0xfeb5, 0xfeb6, 0xfeb7, 0xfeb8],
0x0635: [0xfeb9, 0xfeba, 0xfebb, 0xfebc],
0x0636: [0xfebd, 0xfebe, 0xfebf, 0xfec0],
0x0637: [0xfec1, 0xfec2, 0xfec3, 0xfec4],
0x0638: [0xfec5, 0xfec6, 0xfec7, 0xfec8],
0x0639: [0xfec9, 0xfeca, 0xfecb, 0xfecc],
0x063a: [0xfecd, 0xfece, 0xfecf, 0xfed0],
0x0641: [0xfed1, 0xfed2, 0xfed3, 0xfed4],
0x0642: [0xfed5, 0xfed6, 0xfed7, 0xfed8],
0x0643: [0xfed9, 0xfeda, 0xfedb, 0xfedc],
0x0644: [0xfedd, 0xfede, 0xfedf, 0xfee0],
0x0645: [0xfee1, 0xfee2, 0xfee3, 0xfee4],
0x0646: [0xfee5, 0xfee6, 0xfee7, 0xfee8],
0x0647: [0xfee9, 0xfeea, 0xfeeb, 0xfeec],
0x0648: [0xfeed, 0xfeee],
0x0649: [0xfeef, 0xfef0, 64488, 64489],
0x064a: [0xfef1, 0xfef2, 0xfef3, 0xfef4],
0x0671: [0xfb50, 0xfb51],
0x0677: [0xfbdd],
0x0679: [0xfb66, 0xfb67, 0xfb68, 0xfb69],
0x067a: [0xfb5e, 0xfb5f, 0xfb60, 0xfb61],
0x067b: [0xfb52, 0xfb53, 0xfb54, 0xfb55],
0x067e: [0xfb56, 0xfb57, 0xfb58, 0xfb59],
0x067f: [0xfb62, 0xfb63, 0xfb64, 0xfb65],
0x0680: [0xfb5a, 0xfb5b, 0xfb5c, 0xfb5d],
0x0683: [0xfb76, 0xfb77, 0xfb78, 0xfb79],
0x0684: [0xfb72, 0xfb73, 0xfb74, 0xfb75],
0x0686: [0xfb7a, 0xfb7b, 0xfb7c, 0xfb7d],
0x0687: [0xfb7e, 0xfb7f, 0xfb80, 0xfb81],
0x0688: [0xfb88, 0xfb89],
0x068c: [0xfb84, 0xfb85],
0x068d: [0xfb82, 0xfb83],
0x068e: [0xfb86, 0xfb87],
0x0691: [0xfb8c, 0xfb8d],
0x0698: [0xfb8a, 0xfb8b],
0x06a4: [0xfb6a, 0xfb6b, 0xfb6c, 0xfb6d],
0x06a6: [0xfb6e, 0xfb6f, 0xfb70, 0xfb71],
0x06a9: [0xfb8e, 0xfb8f, 0xfb90, 0xfb91],
0x06ad: [0xfbd3, 0xfbd4, 0xfbd5, 0xfbd6],
0x06af: [0xfb92, 0xfb93, 0xfb94, 0xfb95],
0x06b1: [0xfb9a, 0xfb9b, 0xfb9c, 0xfb9d],
0x06b3: [0xfb96, 0xfb97, 0xfb98, 0xfb99],
0x06ba: [0xfb9e, 0xfb9f],
0x06bb: [0xfba0, 0xfba1, 0xfba2, 0xfba3],
0x06be: [0xfbaa, 0xfbab, 0xfbac, 0xfbad],
0x06c0: [0xfba4, 0xfba5],
0x06c1: [0xfba6, 0xfba7, 0xfba8, 0xfba9],
0x06c5: [0xfbe0, 0xfbe1],
0x06c6: [0xfbd9, 0xfbda],
0x06c7: [0xfbd7, 0xfbd8],
0x06c8: [0xfbdb, 0xfbdc],
0x06c9: [0xfbe2, 0xfbe3],
0x06cb: [0xfbde, 0xfbdf],
0x06cc: [0xfbfc, 0xfbfd, 0xfbfe, 0xfbff],
0x06d0: [0xfbe4, 0xfbe5, 0xfbe6, 0xfbe7],
0x06d2: [0xfbae, 0xfbaf],
0x06d3: [0xfbb0, 0xfbb1]
};
var ligatures={
0xfedf: {
0xfe82: 0xfef5,
0xfe84: 0xfef7,
0xfe88: 0xfef9,
0xfe8e: 0xfefb
},
0xfee0: {
0xfe82: 0xfef6,
0xfe84: 0xfef8,
0xfe88: 0xfefa,
0xfe8e: 0xfefc
},
0xfe8d: { 0xfedf: { 0xfee0: { 0xfeea: 0xfdf2 }} },
0x0651: {
0x064c: 0xfc5e,
0x064d: 0xfc5f,
0x064e: 0xfc60,
0x064f: 0xfc61,
0x0650: 0xfc62 
}};
var arabic_diacritics={
1612: 64606,
1613: 64607,
1614: 64608,
1615: 64609,
1616: 64610 
};
var alfletter=[1570, 1571, 1573, 1575];
var noChangeInForm=-1;
var isolatedForm=0;
var finalForm=1;
var initialForm=2;
var medialForm=3;
jsPDFAPI.__arabicParser__={};
var isInArabicSubstitutionA=(jsPDFAPI.__arabicParser__.isInArabicSubstitutionA=function(
letter
){
return typeof arabicSubstitionA[letter.charCodeAt(0)]!=="undefined";
});
var isArabicLetter=(jsPDFAPI.__arabicParser__.isArabicLetter=function(
letter
){
return (
typeof letter==="string" &&
/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(letter
)
);
});
var isArabicEndLetter=(jsPDFAPI.__arabicParser__.isArabicEndLetter=function(
letter
){
return (
isArabicLetter(letter) &&
isInArabicSubstitutionA(letter) &&
arabicSubstitionA[letter.charCodeAt(0)].length <=2
);
});
var isArabicAlfLetter=(jsPDFAPI.__arabicParser__.isArabicAlfLetter=function(
letter
){
return (
isArabicLetter(letter)&&alfletter.indexOf(letter.charCodeAt(0)) >=0
);
});
jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm=function(letter){
return (
isArabicLetter(letter) &&
isInArabicSubstitutionA(letter) &&
arabicSubstitionA[letter.charCodeAt(0)].length >=1
);
};
var arabicLetterHasFinalForm=(jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm=function(
letter
){
return (
isArabicLetter(letter) &&
isInArabicSubstitutionA(letter) &&
arabicSubstitionA[letter.charCodeAt(0)].length >=2
);
});
jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm=function(letter){
return (
isArabicLetter(letter) &&
isInArabicSubstitutionA(letter) &&
arabicSubstitionA[letter.charCodeAt(0)].length >=3
);
};
var arabicLetterHasMedialForm=(jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm=function(
letter
){
return (
isArabicLetter(letter) &&
isInArabicSubstitutionA(letter) &&
arabicSubstitionA[letter.charCodeAt(0)].length==4
);
});
var resolveLigatures=(jsPDFAPI.__arabicParser__.resolveLigatures=function(
letters
){
var i=0;
var tmpLigatures=ligatures;
var result="";
var effectedLetters=0;
for (i=0; i < letters.length; i +=1){
if(typeof tmpLigatures[letters.charCodeAt(i)]!=="undefined"){
effectedLetters++;
tmpLigatures=tmpLigatures[letters.charCodeAt(i)];
if(typeof tmpLigatures==="number"){
result +=String.fromCharCode(tmpLigatures);
tmpLigatures=ligatures;
effectedLetters=0;
}
if(i===letters.length - 1){
tmpLigatures=ligatures;
result +=letters.charAt(i - (effectedLetters - 1));
i=i - (effectedLetters - 1);
effectedLetters=0;
}}else{
tmpLigatures=ligatures;
result +=letters.charAt(i - effectedLetters);
i=i - effectedLetters;
effectedLetters=0;
}}
return result;
});
jsPDFAPI.__arabicParser__.isArabicDiacritic=function(letter){
return (
letter!==undefined &&
arabic_diacritics[letter.charCodeAt(0)]!==undefined
);
};
var getCorrectForm=(jsPDFAPI.__arabicParser__.getCorrectForm=function(
currentChar,
beforeChar,
nextChar
){
if(!isArabicLetter(currentChar)){
return -1;
}
if(isInArabicSubstitutionA(currentChar)===false){
return noChangeInForm;
}
if(!arabicLetterHasFinalForm(currentChar) ||
(!isArabicLetter(beforeChar)&&!isArabicLetter(nextChar)) ||
(!isArabicLetter(nextChar)&&isArabicEndLetter(beforeChar)) ||
(isArabicEndLetter(currentChar)&&!isArabicLetter(beforeChar)) ||
(isArabicEndLetter(currentChar)&&isArabicAlfLetter(beforeChar)) ||
(isArabicEndLetter(currentChar)&&isArabicEndLetter(beforeChar))
){
return isolatedForm;
}
if(arabicLetterHasMedialForm(currentChar) &&
isArabicLetter(beforeChar) &&
!isArabicEndLetter(beforeChar) &&
isArabicLetter(nextChar) &&
arabicLetterHasFinalForm(nextChar)
){
return medialForm;
}
if(isArabicEndLetter(currentChar)||!isArabicLetter(nextChar)){
return finalForm;
}
return initialForm;
});
var parseArabic=function(text){
text=text||"";
var result="";
var i=0;
var j=0;
var position=0;
var currentLetter="";
var prevLetter="";
var nextLetter="";
var words=text.split("\\s+");
var newWords=[];
for (i=0; i < words.length; i +=1){
newWords.push("");
for (j=0; j < words[i].length; j +=1){
currentLetter=words[i][j];
prevLetter=words[i][j - 1];
nextLetter=words[i][j + 1];
if(isArabicLetter(currentLetter)){
position=getCorrectForm(currentLetter, prevLetter, nextLetter);
if(position!==-1){
newWords[i] +=String.fromCharCode(arabicSubstitionA[currentLetter.charCodeAt(0)][position]
);
}else{
newWords[i] +=currentLetter;
}}else{
newWords[i] +=currentLetter;
}}
newWords[i]=resolveLigatures(newWords[i]);
}
result=newWords.join(" ");
return result;
};
var processArabic=(jsPDFAPI.__arabicParser__.processArabic=jsPDFAPI.processArabic=function(){
var text =
typeof arguments[0]==="string" ? arguments[0]:arguments[0].text;
var tmpText=[];
var result;
if(Array.isArray(text)){
var i=0;
tmpText=[];
for (i=0; i < text.length; i +=1){
if(Array.isArray(text[i])){
tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]);
}else{
tmpText.push([parseArabic(text[i])]);
}}
result=tmpText;
}else{
result=parseArabic(text);
}
if(typeof arguments[0]==="string"){
return result;
}else{
arguments[0].text=result;
return arguments[0];
}});
jsPDFAPI.events.push(["preProcessText", processArabic]);
})(jsPDF.API);
(function(jsPDFAPI){
jsPDFAPI.autoPrint=function(options){
var refAutoPrintTag;
options=options||{};
options.variant=options.variant||"non-conform";
switch (options.variant){
case "javascript":
this.addJS("print({});");
break;
case "non-conform":
default:
this.internal.events.subscribe("postPutResources", function(){
refAutoPrintTag=this.internal.newObject();
this.internal.out("<<");
this.internal.out("/S /Named");
this.internal.out("/Type /Action");
this.internal.out("/N /Print");
this.internal.out(">>");
this.internal.out("endobj");
});
this.internal.events.subscribe("putCatalog", function(){
this.internal.out("/OpenAction " + refAutoPrintTag + " 0 R");
});
break;
}
return this;
};})(jsPDF.API);
(function(jsPDFAPI){
var Canvas=function(){
var jsPdfInstance=undefined;
Object.defineProperty(this, "pdf", {
get: function(){
return jsPdfInstance;
},
set: function(value){
jsPdfInstance=value;
}});
var _width=150;
Object.defineProperty(this, "width", {
get: function(){
return _width;
},
set: function(value){
if(isNaN(value)||Number.isInteger(value)===false||value < 0){
_width=150;
}else{
_width=value;
}
if(this.getContext("2d").pageWrapXEnabled){
this.getContext("2d").pageWrapX=_width + 1;
}}
});
var _height=300;
Object.defineProperty(this, "height", {
get: function(){
return _height;
},
set: function(value){
if(isNaN(value)||Number.isInteger(value)===false||value < 0){
_height=300;
}else{
_height=value;
}
if(this.getContext("2d").pageWrapYEnabled){
this.getContext("2d").pageWrapY=_height + 1;
}}
});
var _childNodes=[];
Object.defineProperty(this, "childNodes", {
get: function(){
return _childNodes;
},
set: function(value){
_childNodes=value;
}});
var _style={};
Object.defineProperty(this, "style", {
get: function(){
return _style;
},
set: function(value){
_style=value;
}});
Object.defineProperty(this, "parentNode", {});
};
Canvas.prototype.getContext=function(contextType, contextAttributes){
contextType=contextType||"2d";
var key;
if(contextType!=="2d"){
return null;
}
for (key in contextAttributes){
if(this.pdf.context2d.hasOwnProperty(key)){
this.pdf.context2d[key]=contextAttributes[key];
}}
this.pdf.context2d._canvas=this;
return this.pdf.context2d;
};
Canvas.prototype.toDataURL=function(){
throw new Error("toDataURL is not implemented.");
};
jsPDFAPI.events.push([
"initialized",
function(){
this.canvas=new Canvas();
this.canvas.pdf=this;
}
]);
return this;
})(jsPDF.API);
(function(jsPDFAPI){
var NO_MARGINS={ left: 0, top: 0, bottom: 0, right: 0 };
var px2pt=(0.264583 * 72) / 25.4;
var printingHeaderRow=false;
var _initialize=function(){
if(typeof this.internal.__cell__==="undefined"){
this.internal.__cell__={};
this.internal.__cell__.padding=3;
this.internal.__cell__.headerFunction=undefined;
this.internal.__cell__.margins=Object.assign({}, NO_MARGINS);
this.internal.__cell__.margins.width=this.getPageWidth();
_reset.call(this);
}};
var _reset=function(){
this.internal.__cell__.lastCell=new Cell();
this.internal.__cell__.pages=1;
};
var Cell=function(){
var _x=arguments[0];
Object.defineProperty(this, "x", {
enumerable: true,
get: function(){
return _x;
},
set: function(value){
_x=value;
}});
var _y=arguments[1];
Object.defineProperty(this, "y", {
enumerable: true,
get: function(){
return _y;
},
set: function(value){
_y=value;
}});
var _width=arguments[2];
Object.defineProperty(this, "width", {
enumerable: true,
get: function(){
return _width;
},
set: function(value){
_width=value;
}});
var _height=arguments[3];
Object.defineProperty(this, "height", {
enumerable: true,
get: function(){
return _height;
},
set: function(value){
_height=value;
}});
var _text=arguments[4];
Object.defineProperty(this, "text", {
enumerable: true,
get: function(){
return _text;
},
set: function(value){
_text=value;
}});
var _lineNumber=arguments[5];
Object.defineProperty(this, "lineNumber", {
enumerable: true,
get: function(){
return _lineNumber;
},
set: function(value){
_lineNumber=value;
}});
var _align=arguments[6];
Object.defineProperty(this, "align", {
enumerable: true,
get: function(){
return _align;
},
set: function(value){
_align=value;
}});
return this;
};
Cell.prototype.clone=function(){
return new Cell(
this.x,
this.y,
this.width,
this.height,
this.text,
this.lineNumber,
this.align
);
};
Cell.prototype.toArray=function(){
return [
this.x,
this.y,
this.width,
this.height,
this.text,
this.lineNumber,
this.align
];
};
jsPDFAPI.setHeaderFunction=function(func){
_initialize.call(this);
this.internal.__cell__.headerFunction =
typeof func==="function" ? func:undefined;
return this;
};
jsPDFAPI.getTextDimensions=function(text, options){
_initialize.call(this);
options=options||{};
var fontSize=options.fontSize||this.getFontSize();
var font=options.font||this.getFont();
var scaleFactor=options.scaleFactor||this.internal.scaleFactor;
var width=0;
var amountOfLines=0;
var height=0;
var tempWidth=0;
if(!Array.isArray(text)&&typeof text!=="string"){
throw new Error(
"getTextDimensions expects text-parameter to be of type String or an Array of Strings."
);
}
text=Array.isArray(text) ? text:[text];
for (var i=0; i < text.length; i++){
tempWidth=this.getStringUnitWidth(text[i], { font: font }) * fontSize;
if(width < tempWidth){
width=tempWidth;
}
if(width!==0){
amountOfLines=text.length;
}}
width=width / scaleFactor;
height=Math.max((amountOfLines * fontSize * this.getLineHeightFactor() -
fontSize * (this.getLineHeightFactor() - 1)) /
scaleFactor,
0
);
return { w: width, h: height };};
jsPDFAPI.cellAddPage=function(){
_initialize.call(this);
this.addPage();
var margins=this.internal.__cell__.margins||NO_MARGINS;
this.internal.__cell__.lastCell=new Cell(
margins.left,
margins.top,
undefined,
undefined
);
this.internal.__cell__.pages +=1;
return this;
};
jsPDFAPI.cellInitialize=function(){
_initialize.call(this);
_reset.call(this);
};
var cell=(jsPDFAPI.cell=function(){
var currentCell;
if(arguments[0] instanceof Cell){
currentCell=arguments[0];
}else{
currentCell=new Cell(
arguments[0],
arguments[1],
arguments[2],
arguments[3],
arguments[4],
arguments[5]
);
}
_initialize.call(this);
var lastCell=this.internal.__cell__.lastCell;
var padding=this.internal.__cell__.padding;
var margins=this.internal.__cell__.margins||NO_MARGINS;
var tableHeaderRow=this.internal.__cell__.tableHeaderRow;
var printHeaders=this.internal.__cell__.printHeaders;
if(typeof lastCell.lineNumber!=="undefined"){
if(lastCell.lineNumber===currentCell.lineNumber){
currentCell.x=(lastCell.x||0) + (lastCell.width||0);
currentCell.y=lastCell.y||0;
}else{
if(lastCell.y + lastCell.height + currentCell.height + margins.bottom >
this.getPageHeight()
){
this.cellAddPage();
currentCell.y=margins.top;
if(printHeaders&&tableHeaderRow){
this.printHeaderRow(currentCell.lineNumber, true);
currentCell.y +=tableHeaderRow[0].height;
}}else{
currentCell.y=lastCell.y + lastCell.height||currentCell.y;
}}
}
if(typeof currentCell.text[0]!=="undefined"){
this.rect(currentCell.x,
currentCell.y,
currentCell.width,
currentCell.height,
printingHeaderRow===true ? "FD":undefined
);
if(currentCell.align==="right"){
this.text(currentCell.text,
currentCell.x + currentCell.width - padding,
currentCell.y + padding,
{ align: "right", baseline: "top" }
);
}else if(currentCell.align==="center"){
this.text(currentCell.text,
currentCell.x + currentCell.width / 2,
currentCell.y + padding,
{
align: "center",
baseline: "top",
maxWidth: currentCell.width - padding - padding
}
);
}else{
this.text(currentCell.text,
currentCell.x + padding,
currentCell.y + padding,
{
align: "left",
baseline: "top",
maxWidth: currentCell.width - padding - padding
}
);
}}
this.internal.__cell__.lastCell=currentCell;
return this;
});
jsPDFAPI.table=function(x, y, data, headers, config){
_initialize.call(this);
if(!data){
throw new Error("No data for PDF table.");
}
config=config||{};
var headerNames=[],
headerLabels=[],
headerAligns=[],
i,
columnMatrix={},
columnWidths={},
column,
columnMinWidths=[],
j,
tableHeaderConfigs=[],
autoSize=config.autoSize||false,
printHeaders=config.printHeaders===false ? false:true,
fontSize =
config.css&&typeof config.css["font-size"]!=="undefined"
? config.css["font-size"] * 16
: config.fontSize||12,
margins =
config.margins ||
Object.assign({ width: this.getPageWidth() }, NO_MARGINS),
padding=typeof config.padding==="number" ? config.padding:3,
headerBackgroundColor=config.headerBackgroundColor||"#c8c8c8";
_reset.call(this);
this.internal.__cell__.printHeaders=printHeaders;
this.internal.__cell__.margins=margins;
this.internal.__cell__.table_font_size=fontSize;
this.internal.__cell__.padding=padding;
this.internal.__cell__.headerBackgroundColor=headerBackgroundColor;
this.setFontSize(fontSize);
if(headers===undefined||headers===null){
headerNames=Object.keys(data[0]);
headerLabels=headerNames;
headerAligns=headerNames.map(function(){
return "left";
});
}else if(Array.isArray(headers)&&typeof headers[0]==="object"){
headerNames=headers.map(function(header){
return header.name;
});
headerLabels=headers.map(function(header){
return header.prompt||header.name||"";
});
headerAligns=headerNames.map(function(header){
return header.align||"left";
});
for (i=0; i < headers.length; i +=1){
columnWidths[headers[i].name]=headers[i].width * px2pt;
}}else if(Array.isArray(headers)&&typeof headers[0]==="string"){
headerNames=headers;
headerLabels=headerNames;
headerAligns=headerNames.map(function(){
return "left";
});
}
if(autoSize){
var headerName;
for (i=0; i < headerNames.length; i +=1){
headerName=headerNames[i];
columnMatrix[headerName]=data.map(function(rec){
return rec[headerName];
});
this.setFontStyle("bold");
columnMinWidths.push(this.getTextDimensions(headerLabels[i], {
fontSize: this.internal.__cell__.table_font_size,
scaleFactor: this.internal.scaleFactor
}).w
);
column=columnMatrix[headerName];
this.setFontStyle("normal");
for (j=0; j < column.length; j +=1){
columnMinWidths.push(this.getTextDimensions(column[j], {
fontSize: this.internal.__cell__.table_font_size,
scaleFactor: this.internal.scaleFactor
}).w
);
}
columnWidths[headerName] =
Math.max.apply(null, columnMinWidths) + padding + padding;
columnMinWidths=[];
}}
if(printHeaders){
var row={};
for (i=0; i < headerNames.length; i +=1){
row[headerNames[i]]={};
row[headerNames[i]].text=headerLabels[i];
row[headerNames[i]].align=headerAligns[i];
}
var rowHeight=calculateLineHeight.call(this, row, columnWidths);
tableHeaderConfigs=headerNames.map(function(value){
return new Cell(
x,
y,
columnWidths[value],
rowHeight,
row[value].text,
undefined,
row[value].align
);
});
this.setTableHeaderRow(tableHeaderConfigs);
this.printHeaderRow(1, false);
}
var align=headers.reduce(function(pv, cv){
pv[cv.name]=cv.align;
return pv;
}, {});
for (i=0; i < data.length; i +=1){
var lineHeight=calculateLineHeight.call(this, data[i], columnWidths);
for (j=0; j < headerNames.length; j +=1){
cell.call(this,
new Cell(
x,
y,
columnWidths[headerNames[j]],
lineHeight,
data[i][headerNames[j]],
i + 2,
align[headerNames[j]]
)
);
}}
this.internal.__cell__.table_x=x;
this.internal.__cell__.table_y=y;
return this;
};
var calculateLineHeight=function calculateLineHeight(model, columnWidths){
var padding=this.internal.__cell__.padding;
var fontSize=this.internal.__cell__.table_font_size;
var scaleFactor=this.internal.scaleFactor;
return Object.keys(model)
.map(function(key){
return [key, model[key]];
})
.map(function(item){
var key=item[0];
var value=item[1];
return typeof value==="object" ? [key, value.text]:[key, value];
})
.map(function(item){
var key=item[0];
var value=item[1];
return this.splitTextToSize(value,
columnWidths[key] - padding - padding
);
}, this)
.map(function(value){
return (
(this.getLineHeightFactor() * value.length * fontSize) / scaleFactor +
padding +
padding
);
}, this)
.reduce(function(pv, cv){
return Math.max(pv, cv);
}, 0);
};
jsPDFAPI.setTableHeaderRow=function(config){
_initialize.call(this);
this.internal.__cell__.tableHeaderRow=config;
};
jsPDFAPI.printHeaderRow=function(lineNumber, new_page){
_initialize.call(this);
if(!this.internal.__cell__.tableHeaderRow){
throw new Error("Property tableHeaderRow does not exist.");
}
var tableHeaderCell;
printingHeaderRow=true;
if(typeof this.internal.__cell__.headerFunction==="function"){
var position=this.internal.__cell__.headerFunction(this,
this.internal.__cell__.pages
);
this.internal.__cell__.lastCell=new Cell(
position[0],
position[1],
position[2],
position[3],
undefined,
-1
);
}
this.setFontStyle("bold");
var tempHeaderConf=[];
for (var i=0; i < this.internal.__cell__.tableHeaderRow.length; i +=1){
tableHeaderCell=this.internal.__cell__.tableHeaderRow[i].clone();
if(new_page){
tableHeaderCell.y=this.internal.__cell__.margins.top||0;
tempHeaderConf.push(tableHeaderCell);
}
tableHeaderCell.lineNumber=lineNumber;
this.setFillColor(this.internal.__cell__.headerBackgroundColor);
cell.call(this, tableHeaderCell);
}
if(tempHeaderConf.length > 0){
this.setTableHeaderRow(tempHeaderConf);
}
this.setFontStyle("normal");
printingHeaderRow=false;
};})(jsPDF.API);
(function(jsPDFAPI){
var ContextLayer=function(ctx){
ctx=ctx||{};
this.isStrokeTransparent=ctx.isStrokeTransparent||false;
this.strokeOpacity=ctx.strokeOpacity||1;
this.strokeStyle=ctx.strokeStyle||"#000000";
this.fillStyle=ctx.fillStyle||"#000000";
this.isFillTransparent=ctx.isFillTransparent||false;
this.fillOpacity=ctx.fillOpacity||1;
this.font=ctx.font||"10px sans-serif";
this.textBaseline=ctx.textBaseline||"alphabetic";
this.textAlign=ctx.textAlign||"left";
this.lineWidth=ctx.lineWidth||1;
this.lineJoin=ctx.lineJoin||"miter";
this.lineCap=ctx.lineCap||"butt";
this.path=ctx.path||[];
this.transform =
typeof ctx.transform!=="undefined"
? ctx.transform.clone()
: new Matrix();
this.globalCompositeOperation=ctx.globalCompositeOperation||"normal";
this.globalAlpha=ctx.globalAlpha||1.0;
this.clip_path=ctx.clip_path||[];
this.currentPoint=ctx.currentPoint||new Point();
this.miterLimit=ctx.miterLimit||10.0;
this.lastPoint=ctx.lastPoint||new Point();
this.ignoreClearRect =
typeof ctx.ignoreClearRect==="boolean" ? ctx.ignoreClearRect:true;
return this;
};
var f2,
getHorizontalCoordinateString,
getVerticalCoordinateString,
getHorizontalCoordinate,
getVerticalCoordinate,
Point,
Rectangle,
Matrix,
_ctx;
jsPDFAPI.events.push([
"initialized",
function(){
this.context2d=new Context2D(this);
f2=this.internal.f2;
getHorizontalCoordinateString=this.internal.getCoordinateString;
getVerticalCoordinateString=this.internal.getVerticalCoordinateString;
getHorizontalCoordinate=this.internal.getHorizontalCoordinate;
getVerticalCoordinate=this.internal.getVerticalCoordinate;
Point=this.internal.Point;
Rectangle=this.internal.Rectangle;
Matrix=this.internal.Matrix;
_ctx=new ContextLayer();
}
]);
var Context2D=function(pdf){
Object.defineProperty(this, "canvas", {
get: function(){
return { parentNode: false, style: false };}});
var _pdf=pdf;
Object.defineProperty(this, "pdf", {
get: function(){
return _pdf;
}});
var _pageWrapXEnabled=false;
Object.defineProperty(this, "pageWrapXEnabled", {
get: function(){
return _pageWrapXEnabled;
},
set: function(value){
_pageWrapXEnabled=Boolean(value);
}});
var _pageWrapYEnabled=false;
Object.defineProperty(this, "pageWrapYEnabled", {
get: function(){
return _pageWrapYEnabled;
},
set: function(value){
_pageWrapYEnabled=Boolean(value);
}});
var _posX=0;
Object.defineProperty(this, "posX", {
get: function(){
return _posX;
},
set: function(value){
if(!isNaN(value)){
_posX=value;
}}
});
var _posY=0;
Object.defineProperty(this, "posY", {
get: function(){
return _posY;
},
set: function(value){
if(!isNaN(value)){
_posY=value;
}}
});
var _autoPaging=false;
Object.defineProperty(this, "autoPaging", {
get: function(){
return _autoPaging;
},
set: function(value){
_autoPaging=Boolean(value);
}});
var lastBreak=0;
Object.defineProperty(this, "lastBreak", {
get: function(){
return lastBreak;
},
set: function(value){
lastBreak=value;
}});
var pageBreaks=[];
Object.defineProperty(this, "pageBreaks", {
get: function(){
return pageBreaks;
},
set: function(value){
pageBreaks=value;
}});
Object.defineProperty(this, "ctx", {
get: function(){
return _ctx;
},
set: function(value){
if(value instanceof ContextLayer){
_ctx=value;
}}
});
Object.defineProperty(this, "path", {
get: function(){
return _ctx.path;
},
set: function(value){
_ctx.path=value;
}});
var _ctxStack=[];
Object.defineProperty(this, "ctxStack", {
get: function(){
return _ctxStack;
},
set: function(value){
_ctxStack=value;
}});
Object.defineProperty(this, "fillStyle", {
get: function(){
return this.ctx.fillStyle;
},
set: function(value){
var rgba;
rgba=getRGBA(value);
this.ctx.fillStyle=rgba.style;
this.ctx.isFillTransparent=rgba.a===0;
this.ctx.fillOpacity=rgba.a;
this.pdf.setFillColor(rgba.r, rgba.g, rgba.b, { a: rgba.a });
this.pdf.setTextColor(rgba.r, rgba.g, rgba.b, { a: rgba.a });
}});
Object.defineProperty(this, "strokeStyle", {
get: function(){
return this.ctx.strokeStyle;
},
set: function(value){
var rgba=getRGBA(value);
this.ctx.strokeStyle=rgba.style;
this.ctx.isStrokeTransparent=rgba.a===0;
this.ctx.strokeOpacity=rgba.a;
if(rgba.a===0){
this.pdf.setDrawColor(255, 255, 255);
}else if(rgba.a===1){
this.pdf.setDrawColor(rgba.r, rgba.g, rgba.b);
}else{
this.pdf.setDrawColor(rgba.r, rgba.g, rgba.b);
}}
});
Object.defineProperty(this, "lineCap", {
get: function(){
return this.ctx.lineCap;
},
set: function(value){
if(["butt", "round", "square"].indexOf(value)!==-1){
this.ctx.lineCap=value;
this.pdf.setLineCap(value);
}}
});
Object.defineProperty(this, "lineWidth", {
get: function(){
return this.ctx.lineWidth;
},
set: function(value){
if(!isNaN(value)){
this.ctx.lineWidth=value;
this.pdf.setLineWidth(value);
}}
});
Object.defineProperty(this, "lineJoin", {
get: function(){
return this.ctx.lineJoin;
},
set: function(value){
if(["bevel", "round", "miter"].indexOf(value)!==-1){
this.ctx.lineJoin=value;
this.pdf.setLineJoin(value);
}}
});
Object.defineProperty(this, "miterLimit", {
get: function(){
return this.ctx.miterLimit;
},
set: function(value){
if(!isNaN(value)){
this.ctx.miterLimit=value;
this.pdf.setMiterLimit(value);
}}
});
Object.defineProperty(this, "textBaseline", {
get: function(){
return this.ctx.textBaseline;
},
set: function(value){
this.ctx.textBaseline=value;
}});
Object.defineProperty(this, "textAlign", {
get: function(){
return this.ctx.textAlign;
},
set: function(value){
if(["right", "end", "center", "left", "start"].indexOf(value)!==-1){
this.ctx.textAlign=value;
}}
});
Object.defineProperty(this, "font", {
get: function(){
return this.ctx.font;
},
set: function(value){
this.ctx.font=value;
var rx, matches;
rx=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z]+?)\s*$/i;
matches=rx.exec(value);
if(matches!==null){
var fontStyle=matches[1];
var fontVariant=matches[2];
var fontWeight=matches[3];
var fontSize=matches[4];
var lineHeight=matches[5];
var fontFamily=matches[6];
}else{
return;
}
var rxFontSize=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i;
var fontSizeUnit=rxFontSize.exec(fontSize)[2];
if("px"===fontSizeUnit){
fontSize=Math.floor(parseFloat(fontSize) * this.pdf.internal.scaleFactor);
}else if("em"===fontSizeUnit){
fontSize=Math.floor(parseFloat(fontSize) * this.pdf.getFontSize());
}else{
fontSize=Math.floor(parseFloat(fontSize) * this.pdf.internal.scaleFactor);
}
this.pdf.setFontSize(fontSize);
var style="";
if(fontWeight==="bold" ||
parseInt(fontWeight, 10) >=700 ||
fontStyle==="bold"
){
style="bold";
}
if(fontStyle==="italic"){
style +="italic";
}
if(style.length===0){
style="normal";
}
var jsPdfFontName="";
var parts=fontFamily
.toLowerCase()
.replace(/"|'/g, "")
.split(/\s*,\s*/);
var fallbackFonts={
arial: "Helvetica",
verdana: "Helvetica",
helvetica: "Helvetica",
"sans-serif": "Helvetica",
fixed: "Courier",
monospace: "Courier",
terminal: "Courier",
courier: "Courier",
times: "Times",
cursive: "Times",
fantasy: "Times",
serif: "Times"
};
for (var i=0; i < parts.length; i++){
if(this.pdf.internal.getFont(parts[i], style, {
noFallback: true,
disableWarning: true
})!==undefined
){
jsPdfFontName=parts[i];
break;
}else if(style==="bolditalic" &&
this.pdf.internal.getFont(parts[i], "bold", {
noFallback: true,
disableWarning: true
})!==undefined
){
jsPdfFontName=parts[i];
style="bold";
}else if(this.pdf.internal.getFont(parts[i], "normal", {
noFallback: true,
disableWarning: true
})!==undefined
){
jsPdfFontName=parts[i];
style="normal";
break;
}}
if(jsPdfFontName===""){
for (var j=0; j < parts.length; j++){
if(fallbackFonts[parts[j]]){
jsPdfFontName=fallbackFonts[parts[j]];
break;
}}
}
jsPdfFontName=jsPdfFontName==="" ? "Times":jsPdfFontName;
this.pdf.setFont(jsPdfFontName, style);
}});
Object.defineProperty(this, "globalCompositeOperation", {
get: function(){
return this.ctx.globalCompositeOperation;
},
set: function(value){
this.ctx.globalCompositeOperation=value;
}});
Object.defineProperty(this, "globalAlpha", {
get: function(){
return this.ctx.globalAlpha;
},
set: function(value){
this.ctx.globalAlpha=value;
}});
Object.defineProperty(this, "ignoreClearRect", {
get: function(){
return this.ctx.ignoreClearRect;
},
set: function(value){
this.ctx.ignoreClearRect=Boolean(value);
}});
};
Context2D.prototype.fill=function(){
pathPreProcess.call(this, "fill", false);
};
Context2D.prototype.stroke=function(){
pathPreProcess.call(this, "stroke", false);
};
Context2D.prototype.beginPath=function(){
this.path=[
{
type: "begin"
}
];
};
Context2D.prototype.moveTo=function(x, y){
if(isNaN(x)||isNaN(y)){
console.error("jsPDF.context2d.moveTo: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.moveTo");
}
var pt=this.ctx.transform.applyToPoint(new Point(x, y));
this.path.push({
type: "mt",
x: pt.x,
y: pt.y
});
this.ctx.lastPoint=new Point(x, y);
};
Context2D.prototype.closePath=function(){
var pathBegin=new Point(0, 0);
var i=0;
for (i=this.path.length - 1; i!==-1; i--){
if(this.path[i].type==="begin"){
if(typeof this.path[i + 1]==="object" &&
typeof this.path[i + 1].x==="number"
){
pathBegin=new Point(this.path[i + 1].x, this.path[i + 1].y);
this.path.push({
type: "lt",
x: pathBegin.x,
y: pathBegin.y
});
break;
}}
}
if(typeof this.path[i + 2]==="object" &&
typeof this.path[i + 2].x==="number"
){
this.path.push(JSON.parse(JSON.stringify(this.path[i + 2])));
}
this.path.push({
type: "close"
});
this.ctx.lastPoint=new Point(pathBegin.x, pathBegin.y);
};
Context2D.prototype.lineTo=function(x, y){
if(isNaN(x)||isNaN(y)){
console.error("jsPDF.context2d.lineTo: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.lineTo");
}
var pt=this.ctx.transform.applyToPoint(new Point(x, y));
this.path.push({
type: "lt",
x: pt.x,
y: pt.y
});
this.ctx.lastPoint=new Point(pt.x, pt.y);
};
Context2D.prototype.clip=function(){
this.ctx.clip_path=JSON.parse(JSON.stringify(this.path));
pathPreProcess.call(this, null, true);
};
Context2D.prototype.quadraticCurveTo=function(cpx, cpy, x, y){
if(isNaN(x)||isNaN(y)||isNaN(cpx)||isNaN(cpy)){
console.error("jsPDF.context2d.quadraticCurveTo: Invalid arguments",
arguments
);
throw new Error(
"Invalid arguments passed to jsPDF.context2d.quadraticCurveTo"
);
}
var pt0=this.ctx.transform.applyToPoint(new Point(x, y));
var pt1=this.ctx.transform.applyToPoint(new Point(cpx, cpy));
this.path.push({
type: "qct",
x1: pt1.x,
y1: pt1.y,
x: pt0.x,
y: pt0.y
});
this.ctx.lastPoint=new Point(pt0.x, pt0.y);
};
Context2D.prototype.bezierCurveTo=function(cp1x, cp1y, cp2x, cp2y, x, y){
if(isNaN(x) ||
isNaN(y) ||
isNaN(cp1x) ||
isNaN(cp1y) ||
isNaN(cp2x) ||
isNaN(cp2y)
){
console.error("jsPDF.context2d.bezierCurveTo: Invalid arguments",
arguments
);
throw new Error(
"Invalid arguments passed to jsPDF.context2d.bezierCurveTo"
);
}
var pt0=this.ctx.transform.applyToPoint(new Point(x, y));
var pt1=this.ctx.transform.applyToPoint(new Point(cp1x, cp1y));
var pt2=this.ctx.transform.applyToPoint(new Point(cp2x, cp2y));
this.path.push({
type: "bct",
x1: pt1.x,
y1: pt1.y,
x2: pt2.x,
y2: pt2.y,
x: pt0.x,
y: pt0.y
});
this.ctx.lastPoint=new Point(pt0.x, pt0.y);
};
Context2D.prototype.arc=function(
x,
y,
radius,
startAngle,
endAngle,
counterclockwise
){
if(isNaN(x) ||
isNaN(y) ||
isNaN(radius) ||
isNaN(startAngle) ||
isNaN(endAngle)
){
console.error("jsPDF.context2d.arc: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.arc");
}
counterclockwise=Boolean(counterclockwise);
if(!this.ctx.transform.isIdentity){
var xpt=this.ctx.transform.applyToPoint(new Point(x, y));
x=xpt.x;
y=xpt.y;
var x_radPt=this.ctx.transform.applyToPoint(new Point(0, radius));
var x_radPt0=this.ctx.transform.applyToPoint(new Point(0, 0));
radius=Math.sqrt(Math.pow(x_radPt.x - x_radPt0.x, 2) +
Math.pow(x_radPt.y - x_radPt0.y, 2)
);
}
if(Math.abs(endAngle - startAngle) >=2 * Math.PI){
startAngle=0;
endAngle=2 * Math.PI;
}
this.path.push({
type: "arc",
x: x,
y: y,
radius: radius,
startAngle: startAngle,
endAngle: endAngle,
counterclockwise: counterclockwise
});
};
Context2D.prototype.arcTo=function(x1, y1, x2, y2, radius){
throw new Error("arcTo not implemented.");
};
Context2D.prototype.rect=function(x, y, w, h){
if(isNaN(x)||isNaN(y)||isNaN(w)||isNaN(h)){
console.error("jsPDF.context2d.rect: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.rect");
}
this.moveTo(x, y);
this.lineTo(x + w, y);
this.lineTo(x + w, y + h);
this.lineTo(x, y + h);
this.lineTo(x, y);
this.lineTo(x + w, y);
this.lineTo(x, y);
};
Context2D.prototype.fillRect=function(x, y, w, h){
if(isNaN(x)||isNaN(y)||isNaN(w)||isNaN(h)){
console.error("jsPDF.context2d.fillRect: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.fillRect");
}
if(isFillTransparent.call(this)){
return;
}
var tmp={};
if(this.lineCap!=="butt"){
tmp.lineCap=this.lineCap;
this.lineCap="butt";
}
if(this.lineJoin!=="miter"){
tmp.lineJoin=this.lineJoin;
this.lineJoin="miter";
}
this.beginPath();
this.rect(x, y, w, h);
this.fill();
if(tmp.hasOwnProperty("lineCap")){
this.lineCap=tmp.lineCap;
}
if(tmp.hasOwnProperty("lineJoin")){
this.lineJoin=tmp.lineJoin;
}};
Context2D.prototype.strokeRect=function strokeRect(x, y, w, h){
if(isNaN(x)||isNaN(y)||isNaN(w)||isNaN(h)){
console.error("jsPDF.context2d.strokeRect: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");
}
if(isStrokeTransparent.call(this)){
return;
}
this.beginPath();
this.rect(x, y, w, h);
this.stroke();
};
Context2D.prototype.clearRect=function(x, y, w, h){
if(isNaN(x)||isNaN(y)||isNaN(w)||isNaN(h)){
console.error("jsPDF.context2d.clearRect: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.clearRect");
}
if(this.ignoreClearRect){
return;
}
this.fillStyle="#ffffff";
this.fillRect(x, y, w, h);
};
Context2D.prototype.save=function(doStackPush){
doStackPush=typeof doStackPush==="boolean" ? doStackPush:true;
var tmpPageNumber=this.pdf.internal.getCurrentPageInfo().pageNumber;
for (var i=0; i < this.pdf.internal.getNumberOfPages(); i++){
this.pdf.setPage(i + 1);
this.pdf.internal.out("q");
}
this.pdf.setPage(tmpPageNumber);
if(doStackPush){
this.ctx.fontSize=this.pdf.internal.getFontSize();
var ctx=new ContextLayer(this.ctx);
this.ctxStack.push(this.ctx);
this.ctx=ctx;
}};
Context2D.prototype.restore=function(doStackPop){
doStackPop=typeof doStackPop==="boolean" ? doStackPop:true;
var tmpPageNumber=this.pdf.internal.getCurrentPageInfo().pageNumber;
for (var i=0; i < this.pdf.internal.getNumberOfPages(); i++){
this.pdf.setPage(i + 1);
this.pdf.internal.out("Q");
}
this.pdf.setPage(tmpPageNumber);
if(doStackPop&&this.ctxStack.length!==0){
this.ctx=this.ctxStack.pop();
this.fillStyle=this.ctx.fillStyle;
this.strokeStyle=this.ctx.strokeStyle;
this.font=this.ctx.font;
this.lineCap=this.ctx.lineCap;
this.lineWidth=this.ctx.lineWidth;
this.lineJoin=this.ctx.lineJoin;
}};
Context2D.prototype.toDataURL=function(){
throw new Error("toDataUrl not implemented.");
};
var getRGBA=function(style){
var rxRgb=/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
var rxRgba=/rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/;
var rxTransparent=/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/;
var r, g, b, a;
if(style.isCanvasGradient===true){
style=style.getColor();
}
if(!style){
return { r: 0, g: 0, b: 0, a: 0, style: style };}
if(rxTransparent.test(style)){
r=0;
g=0;
b=0;
a=0;
}else{
var matches=rxRgb.exec(style);
if(matches!==null){
r=parseInt(matches[1]);
g=parseInt(matches[2]);
b=parseInt(matches[3]);
a=1;
}else{
matches=rxRgba.exec(style);
if(matches!==null){
r=parseInt(matches[1]);
g=parseInt(matches[2]);
b=parseInt(matches[3]);
a=parseFloat(matches[4]);
}else{
a=1;
if(typeof style==="string"&&style.charAt(0)!=="#"){
var rgbColor=new RGBColor(style);
if(rgbColor.ok){
style=rgbColor.toHex();
}else{
style="#000000";
}}
if(style.length===4){
r=style.substring(1, 2);
r +=r;
g=style.substring(2, 3);
g +=g;
b=style.substring(3, 4);
b +=b;
}else{
r=style.substring(1, 3);
g=style.substring(3, 5);
b=style.substring(5, 7);
}
r=parseInt(r, 16);
g=parseInt(g, 16);
b=parseInt(b, 16);
}}
}
return { r: r, g: g, b: b, a: a, style: style };};
var isFillTransparent=function(){
return this.ctx.isFillTransparent||this.globalAlpha==0;
};
var isStrokeTransparent=function(){
return Boolean(this.ctx.isStrokeTransparent||this.globalAlpha==0);
};
Context2D.prototype.fillText=function(text, x, y, maxWidth){
if(isNaN(x)||isNaN(y)||typeof text!=="string"){
console.error("jsPDF.context2d.fillText: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.fillText");
}
maxWidth=isNaN(maxWidth) ? undefined:maxWidth;
if(isFillTransparent.call(this)){
return;
}
y=getBaseline.call(this, y);
var degs=rad2deg(this.ctx.transform.rotation);
var scale=this.ctx.transform.scaleX;
putText.call(this, {
text: text,
x: x,
y: y,
scale: scale,
angle: degs,
align: this.textAlign,
maxWidth: maxWidth
});
};
Context2D.prototype.strokeText=function(text, x, y, maxWidth){
if(isNaN(x)||isNaN(y)||typeof text!=="string"){
console.error("jsPDF.context2d.strokeText: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.strokeText");
}
if(isStrokeTransparent.call(this)){
return;
}
maxWidth=isNaN(maxWidth) ? undefined:maxWidth;
y=getBaseline.call(this, y);
var degs=rad2deg(this.ctx.transform.rotation);
var scale=this.ctx.transform.scaleX;
putText.call(this, {
text: text,
x: x,
y: y,
scale: scale,
renderingMode: "stroke",
angle: degs,
align: this.textAlign,
maxWidth: maxWidth
});
};
Context2D.prototype.measureText=function(text){
if(typeof text!=="string"){
console.error("jsPDF.context2d.measureText: Invalid arguments",
arguments
);
throw new Error(
"Invalid arguments passed to jsPDF.context2d.measureText"
);
}
var pdf=this.pdf;
var k=this.pdf.internal.scaleFactor;
var fontSize=pdf.internal.getFontSize();
var txtWidth =
(pdf.getStringUnitWidth(text) * fontSize) / pdf.internal.scaleFactor;
txtWidth *=Math.round(((k * 96) / 72) * 10000) / 10000;
var TextMetrics=function(options){
options=options||{};
var _width=options.width||0;
Object.defineProperty(this, "width", {
get: function(){
return _width;
}});
return this;
};
return new TextMetrics({ width: txtWidth });
};
Context2D.prototype.scale=function(scalewidth, scaleheight){
if(isNaN(scalewidth)||isNaN(scaleheight)){
console.error("jsPDF.context2d.scale: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.scale");
}
var matrix=new Matrix(scalewidth, 0.0, 0.0, scaleheight, 0.0, 0.0);
this.ctx.transform=this.ctx.transform.multiply(matrix);
};
Context2D.prototype.rotate=function(angle){
if(isNaN(angle)){
console.error("jsPDF.context2d.rotate: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.rotate");
}
var matrix=new Matrix(
Math.cos(angle),
Math.sin(angle),
-Math.sin(angle),
Math.cos(angle),
0.0,
0.0
);
this.ctx.transform=this.ctx.transform.multiply(matrix);
};
Context2D.prototype.translate=function(x, y){
if(isNaN(x)||isNaN(y)){
console.error("jsPDF.context2d.translate: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.translate");
}
var matrix=new Matrix(1.0, 0.0, 0.0, 1.0, x, y);
this.ctx.transform=this.ctx.transform.multiply(matrix);
};
Context2D.prototype.transform=function(a, b, c, d, e, f){
if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||isNaN(e)||isNaN(f)){
console.error("jsPDF.context2d.transform: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.transform");
}
var matrix=new Matrix(a, b, c, d, e, f);
this.ctx.transform=this.ctx.transform.multiply(matrix);
};
Context2D.prototype.setTransform=function(a, b, c, d, e, f){
a=isNaN(a) ? 1:a;
b=isNaN(b) ? 0:b;
c=isNaN(c) ? 0:c;
d=isNaN(d) ? 1:d;
e=isNaN(e) ? 0:e;
f=isNaN(f) ? 0:f;
this.ctx.transform=new Matrix(a, b, c, d, e, f);
};
Context2D.prototype.drawImage=function(
img,
sx,
sy,
swidth,
sheight,
x,
y,
width,
height
){
var imageProperties=this.pdf.getImageProperties(img);
var factorX=1;
var factorY=1;
var clipFactorX=1;
var clipFactorY=1;
if(typeof swidth!=="undefined"&&typeof width!=="undefined"){
clipFactorX=width / swidth;
clipFactorY=height / sheight;
factorX=((imageProperties.width / swidth) * width) / swidth;
factorY=((imageProperties.height / sheight) * height) / sheight;
}
if(typeof x==="undefined"){
x=sx;
y=sy;
sx=0;
sy=0;
}
if(typeof swidth!=="undefined"&&typeof width==="undefined"){
width=swidth;
height=sheight;
}
if(typeof swidth==="undefined"&&typeof width==="undefined"){
width=imageProperties.width;
height=imageProperties.height;
}
var decomposedTransformationMatrix=this.ctx.transform.decompose();
var angle=rad2deg(decomposedTransformationMatrix.rotate.shx);
var matrix=new Matrix();
matrix=matrix.multiply(decomposedTransformationMatrix.translate);
matrix=matrix.multiply(decomposedTransformationMatrix.skew);
matrix=matrix.multiply(decomposedTransformationMatrix.scale);
var xRect=matrix.applyToRectangle(new Rectangle(
x - sx * clipFactorX,
y - sy * clipFactorY,
swidth * factorX,
sheight * factorY
)
);
var pageArray=getPagesByPath.call(this, xRect);
var pages=[];
for (var ii=0; ii < pageArray.length; ii +=1){
if(pages.indexOf(pageArray[ii])===-1){
pages.push(pageArray[ii]);
}}
sortPages(pages);
var clipPath;
if(this.autoPaging){
var min=pages[0];
var max=pages[pages.length - 1];
for (var i=min; i < max + 1; i++){
this.pdf.setPage(i);
if(this.ctx.clip_path.length!==0){
var tmpPaths=this.path;
clipPath=JSON.parse(JSON.stringify(this.ctx.clip_path));
this.path=pathPositionRedo(
clipPath,
this.posX,
-1 * this.pdf.internal.pageSize.height * (i - 1) + this.posY
);
drawPaths.call(this, "fill", true);
this.path=tmpPaths;
}
var tmpRect=JSON.parse(JSON.stringify(xRect));
tmpRect=pathPositionRedo(
[tmpRect],
this.posX,
-1 * this.pdf.internal.pageSize.height * (i - 1) + this.posY
)[0];
this.pdf.addImage(img,
"JPEG",
tmpRect.x,
tmpRect.y,
tmpRect.w,
tmpRect.h,
null,
null,
angle
);
}}else{
this.pdf.addImage(img,
"JPEG",
xRect.x,
xRect.y,
xRect.w,
xRect.h,
null,
null,
angle
);
}};
var getPagesByPath=function(path, pageWrapX, pageWrapY){
var result=[];
pageWrapX=pageWrapX||this.pdf.internal.pageSize.width;
pageWrapY=pageWrapY||this.pdf.internal.pageSize.height;
switch (path.type){
default:
case "mt":
case "lt":
result.push(Math.floor((path.y + this.posY) / pageWrapY) + 1);
break;
case "arc":
result.push(Math.floor((path.y + this.posY - path.radius) / pageWrapY) + 1
);
result.push(Math.floor((path.y + this.posY + path.radius) / pageWrapY) + 1
);
break;
case "qct":
var rectOfQuadraticCurve=getQuadraticCurveBoundary(
this.ctx.lastPoint.x,
this.ctx.lastPoint.y,
path.x1,
path.y1,
path.x,
path.y
);
result.push(Math.floor(rectOfQuadraticCurve.y / pageWrapY) + 1);
result.push(Math.floor((rectOfQuadraticCurve.y + rectOfQuadraticCurve.h) / pageWrapY
) + 1
);
break;
case "bct":
var rectOfBezierCurve=getBezierCurveBoundary(
this.ctx.lastPoint.x,
this.ctx.lastPoint.y,
path.x1,
path.y1,
path.x2,
path.y2,
path.x,
path.y
);
result.push(Math.floor(rectOfBezierCurve.y / pageWrapY) + 1);
result.push(Math.floor((rectOfBezierCurve.y + rectOfBezierCurve.h) / pageWrapY) +
1
);
break;
case "rect":
result.push(Math.floor((path.y + this.posY) / pageWrapY) + 1);
result.push(Math.floor((path.y + path.h + this.posY) / pageWrapY) + 1);
}
for (var i=0; i < result.length; i +=1){
while (this.pdf.internal.getNumberOfPages() < result[i]){
addPage.call(this);
}}
return result;
};
var addPage=function(){
var fillStyle=this.fillStyle;
var strokeStyle=this.strokeStyle;
var font=this.font;
var lineCap=this.lineCap;
var lineWidth=this.lineWidth;
var lineJoin=this.lineJoin;
this.pdf.addPage();
this.fillStyle=fillStyle;
this.strokeStyle=strokeStyle;
this.font=font;
this.lineCap=lineCap;
this.lineWidth=lineWidth;
this.lineJoin=lineJoin;
};
var pathPositionRedo=function(paths, x, y){
for (var i=0; i < paths.length; i++){
switch (paths[i].type){
case "bct":
paths[i].x2 +=x;
paths[i].y2 +=y;
case "qct":
paths[i].x1 +=x;
paths[i].y1 +=y;
case "mt":
case "lt":
case "arc":
default:
paths[i].x +=x;
paths[i].y +=y;
}}
return paths;
};
var sortPages=function(pages){
return pages.sort(function(a, b){
return a - b;
});
};
var pathPreProcess=function(rule, isClip){
var fillStyle=this.fillStyle;
var strokeStyle=this.strokeStyle;
var lineCap=this.lineCap;
var oldLineWidth=this.lineWidth;
var lineWidth=oldLineWidth * this.ctx.transform.scaleX;
var lineJoin=this.lineJoin;
var origPath=JSON.parse(JSON.stringify(this.path));
var xPath=JSON.parse(JSON.stringify(this.path));
var clipPath;
var tmpPath;
var pages=[];
for (var i=0; i < xPath.length; i++){
if(typeof xPath[i].x!=="undefined"){
var page=getPagesByPath.call(this, xPath[i]);
for (var ii=0; ii < page.length; ii +=1){
if(pages.indexOf(page[ii])===-1){
pages.push(page[ii]);
}}
}}
for (var j=0; j < pages.length; j++){
while (this.pdf.internal.getNumberOfPages() < pages[j]){
addPage.call(this);
}}
sortPages(pages);
if(this.autoPaging){
var min=pages[0];
var max=pages[pages.length - 1];
for (var k=min; k < max + 1; k++){
this.pdf.setPage(k);
this.fillStyle=fillStyle;
this.strokeStyle=strokeStyle;
this.lineCap=lineCap;
this.lineWidth=lineWidth;
this.lineJoin=lineJoin;
if(this.ctx.clip_path.length!==0){
var tmpPaths=this.path;
clipPath=JSON.parse(JSON.stringify(this.ctx.clip_path));
this.path=pathPositionRedo(
clipPath,
this.posX,
-1 * this.pdf.internal.pageSize.height * (k - 1) + this.posY
);
drawPaths.call(this, rule, true);
this.path=tmpPaths;
}
tmpPath=JSON.parse(JSON.stringify(origPath));
this.path=pathPositionRedo(
tmpPath,
this.posX,
-1 * this.pdf.internal.pageSize.height * (k - 1) + this.posY
);
if(isClip===false||k===0){
drawPaths.call(this, rule, isClip);
}
this.lineWidth=oldLineWidth;
}}else{
this.lineWidth=lineWidth;
drawPaths.call(this, rule, isClip);
this.lineWidth=oldLineWidth;
}
this.path=origPath;
};
var drawPaths=function(rule, isClip){
if(rule==="stroke"&&!isClip&&isStrokeTransparent.call(this)){
return;
}
if(rule!=="stroke"&&!isClip&&isFillTransparent.call(this)){
return;
}
var moves=[];
var delta;
var xPath=this.path;
for (var i=0; i < xPath.length; i++){
var pt=xPath[i];
switch (pt.type){
case "begin":
moves.push({
begin: true
});
break;
case "close":
moves.push({
close: true
});
break;
case "mt":
moves.push({
start: pt,
deltas: [],
abs: []
});
break;
case "lt":
var iii=moves.length;
if(!isNaN(xPath[i - 1].x)){
delta=[pt.x - xPath[i - 1].x, pt.y - xPath[i - 1].y];
if(iii > 0){
for (iii; iii >=0; iii--){
if(moves[iii - 1].close!==true &&
moves[iii - 1].begin!==true
){
moves[iii - 1].deltas.push(delta);
moves[iii - 1].abs.push(pt);
break;
}}
}}
break;
case "bct":
delta=[
pt.x1 - xPath[i - 1].x,
pt.y1 - xPath[i - 1].y,
pt.x2 - xPath[i - 1].x,
pt.y2 - xPath[i - 1].y,
pt.x - xPath[i - 1].x,
pt.y - xPath[i - 1].y
];
moves[moves.length - 1].deltas.push(delta);
break;
case "qct":
var x1=xPath[i - 1].x + (2.0 / 3.0) * (pt.x1 - xPath[i - 1].x);
var y1=xPath[i - 1].y + (2.0 / 3.0) * (pt.y1 - xPath[i - 1].y);
var x2=pt.x + (2.0 / 3.0) * (pt.x1 - pt.x);
var y2=pt.y + (2.0 / 3.0) * (pt.y1 - pt.y);
var x3=pt.x;
var y3=pt.y;
delta=[
x1 - xPath[i - 1].x,
y1 - xPath[i - 1].y,
x2 - xPath[i - 1].x,
y2 - xPath[i - 1].y,
x3 - xPath[i - 1].x,
y3 - xPath[i - 1].y
];
moves[moves.length - 1].deltas.push(delta);
break;
case "arc":
moves.push({
deltas: [],
abs: [],
arc: true
});
if(Array.isArray(moves[moves.length - 1].abs)){
moves[moves.length - 1].abs.push(pt);
}
break;
}}
var style;
if(!isClip){
if(rule==="stroke"){
style="stroke";
}else{
style="fill";
}}else{
style=null;
}
for (var k=0; k < moves.length; k++){
if(moves[k].arc){
var arcs=moves[k].abs;
for (var ii=0; ii < arcs.length; ii++){
var arc=arcs[ii];
if(arc.type==="arc"){
drawArc.call(this,
arc.x,
arc.y,
arc.radius,
arc.startAngle,
arc.endAngle,
arc.counterclockwise,
undefined,
isClip
);
}else{
drawLine.call(this, arc.x, arc.y);
}}
putStyle.call(this, style);
this.pdf.internal.out("h");
}
if(!moves[k].arc){
if(moves[k].close!==true&&moves[k].begin!==true){
var x=moves[k].start.x;
var y=moves[k].start.y;
drawLines.call(this, moves[k].deltas, x, y);
}}
}
if(style){
putStyle.call(this, style);
}
if(isClip){
doClip.call(this);
}};
var getBaseline=function(y){
var height =
this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor;
var descent=height * (this.pdf.internal.getLineHeightFactor() - 1);
switch (this.ctx.textBaseline){
case "bottom":
return y - descent;
case "top":
return y + height - descent;
case "hanging":
return y + height - 2 * descent;
case "middle":
return y + height / 2 - descent;
case "ideographic":
return y;
case "alphabetic":
default:
return y;
}};
Context2D.prototype.createLinearGradient=function createLinearGradient(){
var canvasGradient=function canvasGradient(){};
canvasGradient.colorStops=[];
canvasGradient.addColorStop=function(offset, color){
this.colorStops.push([offset, color]);
};
canvasGradient.getColor=function(){
if(this.colorStops.length===0){
return "#000000";
}
return this.colorStops[0][1];
};
canvasGradient.isCanvasGradient=true;
return canvasGradient;
};
Context2D.prototype.createPattern=function createPattern(){
return this.createLinearGradient();
};
Context2D.prototype.createRadialGradient=function createRadialGradient(){
return this.createLinearGradient();
};
var drawArc=function(x, y, r, a1, a2, counterclockwise, style, isClip){
var curves=createArc.call(this, r, a1, a2, counterclockwise);
for (var i=0; i < curves.length; i++){
var curve=curves[i];
if(i===0){
doMove.call(this, curve.x1 + x, curve.y1 + y);
}
drawCurve.call(this,
x,
y,
curve.x2,
curve.y2,
curve.x3,
curve.y3,
curve.x4,
curve.y4
);
}
if(!isClip){
putStyle.call(this, style);
}else{
doClip.call(this);
}};
var putStyle=function(style){
switch (style){
case "stroke":
this.pdf.internal.out("S");
break;
case "fill":
this.pdf.internal.out("f");
break;
}};
var doClip=function(){
this.pdf.clip();
this.pdf.discardPath();
};
var doMove=function(x, y){
this.pdf.internal.out(getHorizontalCoordinateString(x) +
" " +
getVerticalCoordinateString(y) +
" m"
);
};
var putText=function(options){
var textAlign;
switch (options.align){
case "right":
case "end":
textAlign="right";
break;
case "center":
textAlign="center";
break;
case "left":
case "start":
default:
textAlign="left";
break;
}
var pt=this.ctx.transform.applyToPoint(new Point(options.x, options.y));
var decomposedTransformationMatrix=this.ctx.transform.decompose();
var matrix=new Matrix();
matrix=matrix.multiply(decomposedTransformationMatrix.translate);
matrix=matrix.multiply(decomposedTransformationMatrix.skew);
matrix=matrix.multiply(decomposedTransformationMatrix.scale);
var textDimensions=this.pdf.getTextDimensions(options.text);
var textRect=this.ctx.transform.applyToRectangle(new Rectangle(options.x, options.y, textDimensions.w, textDimensions.h)
);
var textXRect=matrix.applyToRectangle(new Rectangle(
options.x,
options.y - textDimensions.h,
textDimensions.w,
textDimensions.h
)
);
var pageArray=getPagesByPath.call(this, textXRect);
var pages=[];
for (var ii=0; ii < pageArray.length; ii +=1){
if(pages.indexOf(pageArray[ii])===-1){
pages.push(pageArray[ii]);
}}
sortPages(pages);
var clipPath, oldSize, oldLineWidth;
if(this.autoPaging===true){
var min=pages[0];
var max=pages[pages.length - 1];
for (var i=min; i < max + 1; i++){
this.pdf.setPage(i);
if(this.ctx.clip_path.length!==0){
var tmpPaths=this.path;
clipPath=JSON.parse(JSON.stringify(this.ctx.clip_path));
this.path=pathPositionRedo(
clipPath,
this.posX,
-1 * this.pdf.internal.pageSize.height * (i - 1) + this.posY
);
drawPaths.call(this, "fill", true);
this.path=tmpPaths;
}
var tmpRect=JSON.parse(JSON.stringify(textRect));
tmpRect=pathPositionRedo(
[tmpRect],
this.posX,
-1 * this.pdf.internal.pageSize.height * (i - 1) + this.posY
)[0];
if(options.scale >=0.01){
oldSize=this.pdf.internal.getFontSize();
this.pdf.setFontSize(oldSize * options.scale);
oldLineWidth=this.lineWidth;
this.lineWidth=oldLineWidth * options.scale;
}
this.pdf.text(options.text, tmpRect.x, tmpRect.y, {
angle: options.angle,
align: textAlign,
renderingMode: options.renderingMode,
maxWidth: options.maxWidth
});
if(options.scale >=0.01){
this.pdf.setFontSize(oldSize);
this.lineWidth=oldLineWidth;
}}
}else{
if(options.scale >=0.01){
oldSize=this.pdf.internal.getFontSize();
this.pdf.setFontSize(oldSize * options.scale);
oldLineWidth=this.lineWidth;
this.lineWidth=oldLineWidth * options.scale;
}
this.pdf.text(options.text, pt.x + this.posX, pt.y + this.posY, {
angle: options.angle,
align: textAlign,
renderingMode: options.renderingMode,
maxWidth: options.maxWidth
});
if(options.scale >=0.01){
this.pdf.setFontSize(oldSize);
this.lineWidth=oldLineWidth;
}}
};
var drawLine=function(x, y, prevX, prevY){
prevX=prevX||0;
prevY=prevY||0;
this.pdf.internal.out(getHorizontalCoordinateString(x + prevX) +
" " +
getVerticalCoordinateString(y + prevY) +
" l"
);
};
var drawLines=function(lines, x, y){
return this.pdf.lines(lines, x, y, null, null);
};
var drawCurve=function(x, y, x1, y1, x2, y2, x3, y3){
this.pdf.internal.out([
f2(getHorizontalCoordinate(x1 + x)),
f2(getVerticalCoordinate(y1 + y)),
f2(getHorizontalCoordinate(x2 + x)),
f2(getVerticalCoordinate(y2 + y)),
f2(getHorizontalCoordinate(x3 + x)),
f2(getVerticalCoordinate(y3 + y)),
"c"
].join(" ")
);
};
var createArc=function(radius, startAngle, endAngle, anticlockwise){
var EPSILON=0.00001;
var twoPi=Math.PI * 2;
var halfPi=Math.PI / 2.0;
while (startAngle > endAngle){
startAngle=startAngle - twoPi;
}
var totalAngle=Math.abs(endAngle - startAngle);
if(totalAngle < twoPi){
if(anticlockwise){
totalAngle=twoPi - totalAngle;
}}
var curves=[];
var sgn=anticlockwise ? -1:+1;
var a1=startAngle;
for (; totalAngle > EPSILON;){
var remain=sgn * Math.min(totalAngle, halfPi);
var a2=a1 + remain;
curves.push(createSmallArc.call(this, radius, a1, a2));
totalAngle -=Math.abs(a2 - a1);
a1=a2;
}
return curves;
};
var createSmallArc=function(r, a1, a2){
var a=(a2 - a1) / 2.0;
var x4=r * Math.cos(a);
var y4=r * Math.sin(a);
var x1=x4;
var y1=-y4;
var q1=x1 * x1 + y1 * y1;
var q2=q1 + x1 * x4 + y1 * y4;
var k2=((4 / 3) * (Math.sqrt(2 * q1 * q2) - q2)) / (x1 * y4 - y1 * x4);
var x2=x1 - k2 * y1;
var y2=y1 + k2 * x1;
var x3=x2;
var y3=-y2;
var ar=a + a1;
var cos_ar=Math.cos(ar);
var sin_ar=Math.sin(ar);
return {
x1: r * Math.cos(a1),
y1: r * Math.sin(a1),
x2: x2 * cos_ar - y2 * sin_ar,
y2: x2 * sin_ar + y2 * cos_ar,
x3: x3 * cos_ar - y3 * sin_ar,
y3: x3 * sin_ar + y3 * cos_ar,
x4: r * Math.cos(a2),
y4: r * Math.sin(a2)
};};
var rad2deg=function(value){
return (value * 180) / Math.PI;
};
var getQuadraticCurveBoundary=function(sx, sy, cpx, cpy, ex, ey){
var midX1=sx + (cpx - sx) * 0.5;
var midY1=sy + (cpy - sy) * 0.5;
var midX2=ex + (cpx - ex) * 0.5;
var midY2=ey + (cpy - ey) * 0.5;
var resultX1=Math.min(sx, ex, midX1, midX2);
var resultX2=Math.max(sx, ex, midX1, midX2);
var resultY1=Math.min(sy, ey, midY1, midY2);
var resultY2=Math.max(sy, ey, midY1, midY2);
return new Rectangle(
resultX1,
resultY1,
resultX2 - resultX1,
resultY2 - resultY1
);
};
var getBezierCurveBoundary=function(ax, ay, bx, by, cx, cy, dx, dy){
var tobx=bx - ax;
var toby=by - ay;
var tocx=cx - bx;
var tocy=cy - by;
var todx=dx - cx;
var tody=dy - cy;
var precision=40;
var d,
i,
px,
py,
qx,
qy,
rx,
ry,
tx,
ty,
sx,
sy,
x,
y,
minx,
miny,
maxx,
maxy,
toqx,
toqy,
torx,
tory,
totx,
toty;
for (i=0; i < precision + 1; i++){
d=i / precision;
px=ax + d * tobx;
py=ay + d * toby;
qx=bx + d * tocx;
qy=by + d * tocy;
rx=cx + d * todx;
ry=cy + d * tody;
toqx=qx - px;
toqy=qy - py;
torx=rx - qx;
tory=ry - qy;
sx=px + d * toqx;
sy=py + d * toqy;
tx=qx + d * torx;
ty=qy + d * tory;
totx=tx - sx;
toty=ty - sy;
x=sx + d * totx;
y=sy + d * toty;
if(i==0){
minx=x;
miny=y;
maxx=x;
maxy=y;
}else{
minx=Math.min(minx, x);
miny=Math.min(miny, y);
maxx=Math.max(maxx, x);
maxy=Math.max(maxy, y);
}}
return new Rectangle(
Math.round(minx),
Math.round(miny),
Math.round(maxx - minx),
Math.round(maxy - miny)
);
};})(jsPDF.API);
var MAX_BITS=15;
var D_CODES=30;
var BL_CODES=19;
var LENGTH_CODES=29;
var LITERALS=256;
var L_CODES=LITERALS + 1 + LENGTH_CODES;
var HEAP_SIZE=2 * L_CODES + 1;
var END_BLOCK=256;
var MAX_BL_BITS=7;
var REP_3_6=16;
var REPZ_3_10=17;
var REPZ_11_138=18;
var Buf_size=8 * 2;
var Z_DEFAULT_COMPRESSION=-1;
var Z_FILTERED=1;
var Z_HUFFMAN_ONLY=2;
var Z_DEFAULT_STRATEGY=0;
var Z_NO_FLUSH=0;
var Z_PARTIAL_FLUSH=1;
var Z_FULL_FLUSH=3;
var Z_FINISH=4;
var Z_OK=0;
var Z_STREAM_END=1;
var Z_NEED_DICT=2;
var Z_STREAM_ERROR=-2;
var Z_DATA_ERROR=-3;
var Z_BUF_ERROR=-5;
var _dist_code=[
0,
1,
2,
3,
4,
4,
5,
5,
6,
6,
6,
6,
7,
7,
7,
7,
8,
8,
8,
8,
8,
8,
8,
8,
9,
9,
9,
9,
9,
9,
9,
9,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
10,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
0,
0,
16,
17,
18,
18,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
22,
22,
22,
22,
22,
22,
22,
22,
23,
23,
23,
23,
23,
23,
23,
23,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
28,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29
];
function Tree(){
var that=this;
function gen_bitlen(s){
var tree=that.dyn_tree;
var stree=that.stat_desc.static_tree;
var extra=that.stat_desc.extra_bits;
var base=that.stat_desc.extra_base;
var max_length=that.stat_desc.max_length;
var h;
var n, m;
var bits;
var xbits;
var f;
var overflow=0;
for (bits=0; bits <=MAX_BITS; bits++) s.bl_count[bits]=0;
tree[s.heap[s.heap_max] * 2 + 1]=0;
for (h=s.heap_max + 1; h < HEAP_SIZE; h++){
n=s.heap[h];
bits=tree[tree[n * 2 + 1] * 2 + 1] + 1;
if(bits > max_length){
bits=max_length;
overflow++;
}
tree[n * 2 + 1]=bits;
if(n > that.max_code) continue;
s.bl_count[bits]++;
xbits=0;
if(n >=base) xbits=extra[n - base];
f=tree[n * 2];
s.opt_len +=f * (bits + xbits);
if(stree) s.static_len +=f * (stree[n * 2 + 1] + xbits);
}
if(overflow===0) return;
do {
bits=max_length - 1;
while (s.bl_count[bits]===0) bits--;
s.bl_count[bits]--;
s.bl_count[bits + 1] +=2;
s.bl_count[max_length]--;
overflow -=2;
} while (overflow > 0);
for (bits=max_length; bits!==0; bits--){
n=s.bl_count[bits];
while (n!==0){
m=s.heap[--h];
if(m > that.max_code) continue;
if(tree[m * 2 + 1]!==bits){
s.opt_len +=(bits - tree[m * 2 + 1]) * tree[m * 2];
tree[m * 2 + 1]=bits;
}
n--;
}}
}
function bi_reverse(
code,
len
){
var res=0;
do {
res |=code & 1;
code >>>=1;
res <<=1;
} while (--len > 0);
return res >>> 1;
}
function gen_codes(
tree,
max_code,
bl_count
){
var next_code=[];
var code=0;
var bits;
var n;
var len;
for (bits=1; bits <=MAX_BITS; bits++){
next_code[bits]=code=(code + bl_count[bits - 1]) << 1;
}
for (n=0; n <=max_code; n++){
len=tree[n * 2 + 1];
if(len===0) continue;
tree[n * 2]=bi_reverse(next_code[len]++, len);
}}
that.build_tree=function(s){
var tree=that.dyn_tree;
var stree=that.stat_desc.static_tree;
var elems=that.stat_desc.elems;
var n, m;
var max_code=-1;
var node;
s.heap_len=0;
s.heap_max=HEAP_SIZE;
for (n=0; n < elems; n++){
if(tree[n * 2]!==0){
s.heap[++s.heap_len]=max_code=n;
s.depth[n]=0;
}else{
tree[n * 2 + 1]=0;
}}
while (s.heap_len < 2){
node=s.heap[++s.heap_len]=max_code < 2 ? ++max_code:0;
tree[node * 2]=1;
s.depth[node]=0;
s.opt_len--;
if(stree) s.static_len -=stree[node * 2 + 1];
}
that.max_code=max_code;
for (n=Math.floor(s.heap_len / 2); n >=1; n--) s.pqdownheap(tree, n);
node=elems;
do {
n=s.heap[1];
s.heap[1]=s.heap[s.heap_len--];
s.pqdownheap(tree, 1);
m=s.heap[1];
s.heap[--s.heap_max]=n;
s.heap[--s.heap_max]=m;
tree[node * 2]=tree[n * 2] + tree[m * 2];
s.depth[node]=Math.max(s.depth[n], s.depth[m]) + 1;
tree[n * 2 + 1]=tree[m * 2 + 1]=node;
s.heap[1]=node++;
s.pqdownheap(tree, 1);
} while (s.heap_len >=2);
s.heap[--s.heap_max]=s.heap[1];
gen_bitlen(s);
gen_codes(tree, that.max_code, s.bl_count);
};}
Tree._length_code=[
0,
1,
2,
3,
4,
5,
6,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
12,
12,
13,
13,
13,
13,
14,
14,
14,
14,
15,
15,
15,
15,
16,
16,
16,
16,
16,
16,
16,
16,
17,
17,
17,
17,
17,
17,
17,
17,
18,
18,
18,
18,
18,
18,
18,
18,
19,
19,
19,
19,
19,
19,
19,
19,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
26,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
27,
28
];
Tree.base_length=[
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
12,
14,
16,
20,
24,
28,
32,
40,
48,
56,
64,
80,
96,
112,
128,
160,
192,
224,
0
];
Tree.base_dist=[
0,
1,
2,
3,
4,
6,
8,
12,
16,
24,
32,
48,
64,
96,
128,
192,
256,
384,
512,
768,
1024,
1536,
2048,
3072,
4096,
6144,
8192,
12288,
16384,
24576
];
Tree.d_code=function(dist){
return dist < 256 ? _dist_code[dist]:_dist_code[256 + (dist >>> 7)];
};
Tree.extra_lbits=[
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
4,
4,
4,
4,
5,
5,
5,
5,
0
];
Tree.extra_dbits=[
0,
0,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
5,
5,
6,
6,
7,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
13,
13
];
Tree.extra_blbits=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
Tree.bl_order=[
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
];
function StaticTree(static_tree, extra_bits, extra_base, elems, max_length){
var that=this;
that.static_tree=static_tree;
that.extra_bits=extra_bits;
that.extra_base=extra_base;
that.elems=elems;
that.max_length=max_length;
}
StaticTree.static_ltree=[
12,
8,
140,
8,
76,
8,
204,
8,
44,
8,
172,
8,
108,
8,
236,
8,
28,
8,
156,
8,
92,
8,
220,
8,
60,
8,
188,
8,
124,
8,
252,
8,
2,
8,
130,
8,
66,
8,
194,
8,
34,
8,
162,
8,
98,
8,
226,
8,
18,
8,
146,
8,
82,
8,
210,
8,
50,
8,
178,
8,
114,
8,
242,
8,
10,
8,
138,
8,
74,
8,
202,
8,
42,
8,
170,
8,
106,
8,
234,
8,
26,
8,
154,
8,
90,
8,
218,
8,
58,
8,
186,
8,
122,
8,
250,
8,
6,
8,
134,
8,
70,
8,
198,
8,
38,
8,
166,
8,
102,
8,
230,
8,
22,
8,
150,
8,
86,
8,
214,
8,
54,
8,
182,
8,
118,
8,
246,
8,
14,
8,
142,
8,
78,
8,
206,
8,
46,
8,
174,
8,
110,
8,
238,
8,
30,
8,
158,
8,
94,
8,
222,
8,
62,
8,
190,
8,
126,
8,
254,
8,
1,
8,
129,
8,
65,
8,
193,
8,
33,
8,
161,
8,
97,
8,
225,
8,
17,
8,
145,
8,
81,
8,
209,
8,
49,
8,
177,
8,
113,
8,
241,
8,
9,
8,
137,
8,
73,
8,
201,
8,
41,
8,
169,
8,
105,
8,
233,
8,
25,
8,
153,
8,
89,
8,
217,
8,
57,
8,
185,
8,
121,
8,
249,
8,
5,
8,
133,
8,
69,
8,
197,
8,
37,
8,
165,
8,
101,
8,
229,
8,
21,
8,
149,
8,
85,
8,
213,
8,
53,
8,
181,
8,
117,
8,
245,
8,
13,
8,
141,
8,
77,
8,
205,
8,
45,
8,
173,
8,
109,
8,
237,
8,
29,
8,
157,
8,
93,
8,
221,
8,
61,
8,
189,
8,
125,
8,
253,
8,
19,
9,
275,
9,
147,
9,
403,
9,
83,
9,
339,
9,
211,
9,
467,
9,
51,
9,
307,
9,
179,
9,
435,
9,
115,
9,
371,
9,
243,
9,
499,
9,
11,
9,
267,
9,
139,
9,
395,
9,
75,
9,
331,
9,
203,
9,
459,
9,
43,
9,
299,
9,
171,
9,
427,
9,
107,
9,
363,
9,
235,
9,
491,
9,
27,
9,
283,
9,
155,
9,
411,
9,
91,
9,
347,
9,
219,
9,
475,
9,
59,
9,
315,
9,
187,
9,
443,
9,
123,
9,
379,
9,
251,
9,
507,
9,
7,
9,
263,
9,
135,
9,
391,
9,
71,
9,
327,
9,
199,
9,
455,
9,
39,
9,
295,
9,
167,
9,
423,
9,
103,
9,
359,
9,
231,
9,
487,
9,
23,
9,
279,
9,
151,
9,
407,
9,
87,
9,
343,
9,
215,
9,
471,
9,
55,
9,
311,
9,
183,
9,
439,
9,
119,
9,
375,
9,
247,
9,
503,
9,
15,
9,
271,
9,
143,
9,
399,
9,
79,
9,
335,
9,
207,
9,
463,
9,
47,
9,
303,
9,
175,
9,
431,
9,
111,
9,
367,
9,
239,
9,
495,
9,
31,
9,
287,
9,
159,
9,
415,
9,
95,
9,
351,
9,
223,
9,
479,
9,
63,
9,
319,
9,
191,
9,
447,
9,
127,
9,
383,
9,
255,
9,
511,
9,
0,
7,
64,
7,
32,
7,
96,
7,
16,
7,
80,
7,
48,
7,
112,
7,
8,
7,
72,
7,
40,
7,
104,
7,
24,
7,
88,
7,
56,
7,
120,
7,
4,
7,
68,
7,
36,
7,
100,
7,
20,
7,
84,
7,
52,
7,
116,
7,
3,
8,
131,
8,
67,
8,
195,
8,
35,
8,
163,
8,
99,
8,
227,
8
];
StaticTree.static_dtree=[
0,
5,
16,
5,
8,
5,
24,
5,
4,
5,
20,
5,
12,
5,
28,
5,
2,
5,
18,
5,
10,
5,
26,
5,
6,
5,
22,
5,
14,
5,
30,
5,
1,
5,
17,
5,
9,
5,
25,
5,
5,
5,
21,
5,
13,
5,
29,
5,
3,
5,
19,
5,
11,
5,
27,
5,
7,
5,
23,
5
];
StaticTree.static_l_desc=new StaticTree(
StaticTree.static_ltree,
Tree.extra_lbits,
LITERALS + 1,
L_CODES,
MAX_BITS
);
StaticTree.static_d_desc=new StaticTree(
StaticTree.static_dtree,
Tree.extra_dbits,
0,
D_CODES,
MAX_BITS
);
StaticTree.static_bl_desc=new StaticTree(
null,
Tree.extra_blbits,
0,
BL_CODES,
MAX_BL_BITS
);
var MAX_MEM_LEVEL=9;
var DEF_MEM_LEVEL=8;
function Config(good_length, max_lazy, nice_length, max_chain, func){
var that=this;
that.good_length=good_length;
that.max_lazy=max_lazy;
that.nice_length=nice_length;
that.max_chain=max_chain;
that.func=func;
}
var STORED=0;
var FAST=1;
var SLOW=2;
var config_table=[
new Config(0, 0, 0, 0, STORED),
new Config(4, 4, 8, 4, FAST),
new Config(4, 5, 16, 8, FAST),
new Config(4, 6, 32, 32, FAST),
new Config(4, 4, 16, 16, SLOW),
new Config(8, 16, 32, 32, SLOW),
new Config(8, 16, 128, 128, SLOW),
new Config(8, 32, 128, 256, SLOW),
new Config(32, 128, 258, 1024, SLOW),
new Config(32, 258, 258, 4096, SLOW)
];
var z_errmsg=[
"need dictionary",
"stream end",
"",
"",
"stream error",
"data error",
"",
"buffer error",
"",
""
];
var NeedMore=0;
var BlockDone=1;
var FinishStarted=2;
var FinishDone=3;
var PRESET_DICT=0x20;
var INIT_STATE=42;
var BUSY_STATE=113;
var FINISH_STATE=666;
var Z_DEFLATED=8;
var STORED_BLOCK=0;
var STATIC_TREES=1;
var DYN_TREES=2;
var MIN_MATCH=3;
var MAX_MATCH=258;
var MIN_LOOKAHEAD=MAX_MATCH + MIN_MATCH + 1;
function smaller(tree, n, m, depth){
var tn2=tree[n * 2];
var tm2=tree[m * 2];
return tn2 < tm2||(tn2===tm2&&depth[n] <=depth[m]);
}
function Deflate(){
var that=this;
var strm;
var status;
var pending_buf_size;
var last_flush;
var w_size;
var w_bits;
var w_mask;
var window;
var window_size;
var prev;
var head;
var ins_h;
var hash_size;
var hash_bits;
var hash_mask;
var hash_shift;
var block_start;
var match_length;
var prev_match;
var match_available;
var strstart;
var match_start;
var lookahead;
var prev_length;
var max_chain_length;
var max_lazy_match;
var level;
var strategy;
var good_match;
var nice_match;
var dyn_ltree;
var dyn_dtree;
var bl_tree;
var l_desc=new Tree();
var d_desc=new Tree();
var bl_desc=new Tree();
that.depth=[];
var l_buf; // index for literals or lengths */
var lit_bufsize;
var last_lit;
var d_buf;
var matches;
var last_eob_len;
var bi_buf;
var bi_valid;
that.bl_count=[];
that.heap=[];
dyn_ltree=[];
dyn_dtree=[];
bl_tree=[];
function lm_init(){
var i;
window_size=2 * w_size;
head[hash_size - 1]=0;
for (i=0; i < hash_size - 1; i++){
head[i]=0;
}
max_lazy_match=config_table[level].max_lazy;
good_match=config_table[level].good_length;
nice_match=config_table[level].nice_length;
max_chain_length=config_table[level].max_chain;
strstart=0;
block_start=0;
lookahead=0;
match_length=prev_length=MIN_MATCH - 1;
match_available=0;
ins_h=0;
}
function init_block(){
var i;
for (i=0; i < L_CODES; i++) dyn_ltree[i * 2]=0;
for (i=0; i < D_CODES; i++) dyn_dtree[i * 2]=0;
for (i=0; i < BL_CODES; i++) bl_tree[i * 2]=0;
dyn_ltree[END_BLOCK * 2]=1;
that.opt_len=that.static_len=0;
last_lit=matches=0;
}
function tr_init(){
l_desc.dyn_tree=dyn_ltree;
l_desc.stat_desc=StaticTree.static_l_desc;
d_desc.dyn_tree=dyn_dtree;
d_desc.stat_desc=StaticTree.static_d_desc;
bl_desc.dyn_tree=bl_tree;
bl_desc.stat_desc=StaticTree.static_bl_desc;
bi_buf=0;
bi_valid=0;
last_eob_len=8;
init_block();
}
that.pqdownheap=function(
tree,
k
){
var heap=that.heap;
var v=heap[k];
var j=k << 1;
while (j <=that.heap_len){
if(j < that.heap_len &&
smaller(tree, heap[j + 1], heap[j], that.depth)
){
j++;
}
if(smaller(tree, v, heap[j], that.depth)) break;
heap[k]=heap[j];
k=j;
j <<=1;
}
heap[k]=v;
};
function scan_tree(
tree,
max_code
){
var n;
var prevlen=-1;
var curlen;
var nextlen=tree[0 * 2 + 1];
var count=0;
var max_count=7;
var min_count=4;
if(nextlen===0){
max_count=138;
min_count=3;
}
tree[(max_code + 1) * 2 + 1]=0xffff;
for (n=0; n <=max_code; n++){
curlen=nextlen;
nextlen=tree[(n + 1) * 2 + 1];
if(++count < max_count&&curlen===nextlen){
continue;
}else if(count < min_count){
bl_tree[curlen * 2] +=count;
}else if(curlen!==0){
if(curlen!==prevlen) bl_tree[curlen * 2]++;
bl_tree[REP_3_6 * 2]++;
}else if(count <=10){
bl_tree[REPZ_3_10 * 2]++;
}else{
bl_tree[REPZ_11_138 * 2]++;
}
count=0;
prevlen=curlen;
if(nextlen===0){
max_count=138;
min_count=3;
}else if(curlen===nextlen){
max_count=6;
min_count=3;
}else{
max_count=7;
min_count=4;
}}
}
function build_bl_tree(){
var max_blindex;
scan_tree(dyn_ltree, l_desc.max_code);
scan_tree(dyn_dtree, d_desc.max_code);
bl_desc.build_tree(that);
for (max_blindex=BL_CODES - 1; max_blindex >=3; max_blindex--){
if(bl_tree[Tree.bl_order[max_blindex] * 2 + 1]!==0) break;
}
that.opt_len +=3 * (max_blindex + 1) + 5 + 5 + 4;
return max_blindex;
}
function put_byte(p){
that.pending_buf[that.pending++]=p;
}
function put_short(w){
put_byte(w & 0xff);
put_byte((w >>> 8) & 0xff);
}
function putShortMSB(b){
put_byte((b >> 8) & 0xff);
put_byte(b & 0xff & 0xff);
}
function send_bits(value, length){
var val,
len=length;
if(bi_valid > Buf_size - len){
val=value;
bi_buf |=(val << bi_valid) & 0xffff;
put_short(bi_buf);
bi_buf=val >>> (Buf_size - bi_valid);
bi_valid +=len - Buf_size;
}else{
bi_buf |=(value << bi_valid) & 0xffff;
bi_valid +=len;
}}
function send_code(c, tree){
var c2=c * 2;
send_bits(tree[c2] & 0xffff, tree[c2 + 1] & 0xffff);
}
function send_tree(
tree,
max_code
){
var n;
var prevlen=-1;
var curlen;
var nextlen=tree[0 * 2 + 1];
var count=0;
var max_count=7;
var min_count=4;
if(nextlen===0){
max_count=138;
min_count=3;
}
for (n=0; n <=max_code; n++){
curlen=nextlen;
nextlen=tree[(n + 1) * 2 + 1];
if(++count < max_count&&curlen===nextlen){
continue;
}else if(count < min_count){
do {
send_code(curlen, bl_tree);
} while (--count!==0);
}else if(curlen!==0){
if(curlen!==prevlen){
send_code(curlen, bl_tree);
count--;
}
send_code(REP_3_6, bl_tree);
send_bits(count - 3, 2);
}else if(count <=10){
send_code(REPZ_3_10, bl_tree);
send_bits(count - 3, 3);
}else{
send_code(REPZ_11_138, bl_tree);
send_bits(count - 11, 7);
}
count=0;
prevlen=curlen;
if(nextlen===0){
max_count=138;
min_count=3;
}else if(curlen===nextlen){
max_count=6;
min_count=3;
}else{
max_count=7;
min_count=4;
}}
}
function send_all_trees(lcodes, dcodes, blcodes){
var rank;
send_bits(lcodes - 257, 5);
send_bits(dcodes - 1, 5);
send_bits(blcodes - 4, 4);
for (rank=0; rank < blcodes; rank++){
send_bits(bl_tree[Tree.bl_order[rank] * 2 + 1], 3);
}
send_tree(dyn_ltree, lcodes - 1);
send_tree(dyn_dtree, dcodes - 1);
}
function bi_flush(){
if(bi_valid===16){
put_short(bi_buf);
bi_buf=0;
bi_valid=0;
}else if(bi_valid >=8){
put_byte(bi_buf & 0xff);
bi_buf >>>=8;
bi_valid -=8;
}}
function _tr_align(){
send_bits(STATIC_TREES << 1, 3);
send_code(END_BLOCK, StaticTree.static_ltree);
bi_flush();
if(1 + last_eob_len + 10 - bi_valid < 9){
send_bits(STATIC_TREES << 1, 3);
send_code(END_BLOCK, StaticTree.static_ltree);
bi_flush();
}
last_eob_len=7;
}
function _tr_tally(
dist,
lc
){
var out_length, in_length, dcode;
that.pending_buf[d_buf + last_lit * 2]=(dist >>> 8) & 0xff;
that.pending_buf[d_buf + last_lit * 2 + 1]=dist & 0xff;
that.pending_buf[l_buf + last_lit]=lc & 0xff;
last_lit++;
if(dist===0){
dyn_ltree[lc * 2]++;
}else{
matches++;
dist--;
dyn_ltree[(Tree._length_code[lc] + LITERALS + 1) * 2]++;
dyn_dtree[Tree.d_code(dist) * 2]++;
}
if((last_lit & 0x1fff)===0&&level > 2){
out_length=last_lit * 8;
in_length=strstart - block_start;
for (dcode=0; dcode < D_CODES; dcode++){
out_length +=dyn_dtree[dcode * 2] * (5 + Tree.extra_dbits[dcode]);
}
out_length >>>=3;
if(matches < Math.floor(last_lit / 2) &&
out_length < Math.floor(in_length / 2)
)
return true;
}
return last_lit===lit_bufsize - 1;
}
function compress_block(ltree, dtree){
var dist;
var lc;
var lx=0;
var code;
var extra;
if(last_lit!==0){
do {
dist =
((that.pending_buf[d_buf + lx * 2] << 8) & 0xff00) |
(that.pending_buf[d_buf + lx * 2 + 1] & 0xff);
lc=that.pending_buf[l_buf + lx] & 0xff;
lx++;
if(dist===0){
send_code(lc, ltree);
}else{
code=Tree._length_code[lc];
send_code(code + LITERALS + 1, ltree);
extra=Tree.extra_lbits[code];
if(extra!==0){
lc -=Tree.base_length[code];
send_bits(lc, extra);
}
dist--;
code=Tree.d_code(dist);
send_code(code, dtree);
extra=Tree.extra_dbits[code];
if(extra!==0){
dist -=Tree.base_dist[code];
send_bits(dist, extra);
}}
} while (lx < last_lit);
}
send_code(END_BLOCK, ltree);
last_eob_len=ltree[END_BLOCK * 2 + 1];
}
function bi_windup(){
if(bi_valid > 8){
put_short(bi_buf);
}else if(bi_valid > 0){
put_byte(bi_buf & 0xff);
}
bi_buf=0;
bi_valid=0;
}
function copy_block(
buf,
len,
header
){
bi_windup();
last_eob_len=8;
if(header){
put_short(len);
put_short(~len);
}
that.pending_buf.set(window.subarray(buf, buf + len), that.pending);
that.pending +=len;
}
function _tr_stored_block(
buf,
stored_len,
eof
){
send_bits((STORED_BLOCK << 1) + (eof ? 1:0), 3);
copy_block(buf, stored_len, true);
}
function _tr_flush_block(
buf,
stored_len,
eof
){
var opt_lenb, static_lenb;
var max_blindex=0;
if(level > 0){
l_desc.build_tree(that);
d_desc.build_tree(that);
max_blindex=build_bl_tree();
opt_lenb=(that.opt_len + 3 + 7) >>> 3;
static_lenb=(that.static_len + 3 + 7) >>> 3;
if(static_lenb <=opt_lenb) opt_lenb=static_lenb;
}else{
opt_lenb=static_lenb=stored_len + 5;
}
if(stored_len + 4 <=opt_lenb&&buf!==-1){
_tr_stored_block(buf, stored_len, eof);
}else if(static_lenb===opt_lenb){
send_bits((STATIC_TREES << 1) + (eof ? 1:0), 3);
compress_block(StaticTree.static_ltree, StaticTree.static_dtree);
}else{
send_bits((DYN_TREES << 1) + (eof ? 1:0), 3);
send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, max_blindex + 1);
compress_block(dyn_ltree, dyn_dtree);
}
init_block();
if(eof){
bi_windup();
}}
function flush_block_only(eof){
_tr_flush_block(
block_start >=0 ? block_start:-1,
strstart - block_start,
eof
);
block_start=strstart;
strm.flush_pending();
}
function fill_window(){
var n, m;
var p;
var more;
do {
more=window_size - lookahead - strstart;
if(more===0&&strstart===0&&lookahead===0){
more=w_size;
}else if(more===-1){
more--;
}else if(strstart >=w_size + w_size - MIN_LOOKAHEAD){
window.set(window.subarray(w_size, w_size + w_size), 0);
match_start -=w_size;
strstart -=w_size;
block_start -=w_size;
n=hash_size;
p=n;
do {
m=head[--p] & 0xffff;
head[p]=m >=w_size ? m - w_size:0;
} while (--n!==0);
n=w_size;
p=n;
do {
m=prev[--p] & 0xffff;
prev[p]=m >=w_size ? m - w_size:0;
} while (--n!==0);
more +=w_size;
}
if(strm.avail_in===0) return;
n=strm.read_buf(window, strstart + lookahead, more);
lookahead +=n;
if(lookahead >=MIN_MATCH){
ins_h=window[strstart] & 0xff;
ins_h =
((ins_h << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask;
}} while (lookahead < MIN_LOOKAHEAD&&strm.avail_in!==0);
}
function deflate_stored(flush){
var max_block_size=0xffff;
var max_start;
if(max_block_size > pending_buf_size - 5){
max_block_size=pending_buf_size - 5;
}
while (true){
if(lookahead <=1){
fill_window();
if(lookahead===0&&flush===Z_NO_FLUSH) return NeedMore;
if(lookahead===0) break;
}
strstart +=lookahead;
lookahead=0;
max_start=block_start + max_block_size;
if(strstart===0||strstart >=max_start){
lookahead=strstart - max_start;
strstart=max_start;
flush_block_only(false);
if(strm.avail_out===0) return NeedMore;
}
if(strstart - block_start >=w_size - MIN_LOOKAHEAD){
flush_block_only(false);
if(strm.avail_out===0) return NeedMore;
}}
flush_block_only(flush===Z_FINISH);
if(strm.avail_out===0)
return flush===Z_FINISH ? FinishStarted:NeedMore;
return flush===Z_FINISH ? FinishDone:BlockDone;
}
function longest_match(cur_match){
var chain_length=max_chain_length;
var scan=strstart;
var match;
var len;
var best_len=prev_length;
var limit =
strstart > w_size - MIN_LOOKAHEAD
? strstart - (w_size - MIN_LOOKAHEAD)
: 0;
var _nice_match=nice_match;
var wmask=w_mask;
var strend=strstart + MAX_MATCH;
var scan_end1=window[scan + best_len - 1];
var scan_end=window[scan + best_len];
if(prev_length >=good_match){
chain_length >>=2;
}
if(_nice_match > lookahead) _nice_match=lookahead;
do {
match=cur_match;
if(window[match + best_len]!==scan_end ||
window[match + best_len - 1]!==scan_end1 ||
window[match]!==window[scan] ||
window[++match]!==window[scan + 1]
)
continue;
scan +=2;
match++;
do {} while (
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
window[++scan]===window[++match] &&
scan < strend
);
len=MAX_MATCH - (strend - scan);
scan=strend - MAX_MATCH;
if(len > best_len){
match_start=cur_match;
best_len=len;
if(len >=_nice_match) break;
scan_end1=window[scan + best_len - 1];
scan_end=window[scan + best_len];
}} while (
(cur_match=prev[cur_match & wmask] & 0xffff) > limit &&
--chain_length!==0
);
if(best_len <=lookahead) return best_len;
return lookahead;
}
function deflate_fast(flush){
var hash_head=0;
var bflush;
while (true){
if(lookahead < MIN_LOOKAHEAD){
fill_window();
if(lookahead < MIN_LOOKAHEAD&&flush===Z_NO_FLUSH){
return NeedMore;
}
if(lookahead===0) break;
}
if(lookahead >=MIN_MATCH){
ins_h =
((ins_h << hash_shift) ^
(window[strstart + (MIN_MATCH - 1)] & 0xff)) &
hash_mask;
hash_head=head[ins_h] & 0xffff;
prev[strstart & w_mask]=head[ins_h];
head[ins_h]=strstart;
}
if(hash_head!==0 &&
((strstart - hash_head) & 0xffff) <=w_size - MIN_LOOKAHEAD
){
if(strategy!==Z_HUFFMAN_ONLY){
match_length=longest_match(hash_head);
}}
if(match_length >=MIN_MATCH){
bflush=_tr_tally(strstart - match_start, match_length - MIN_MATCH);
lookahead -=match_length;
if(match_length <=max_lazy_match&&lookahead >=MIN_MATCH){
match_length--;
do {
strstart++;
ins_h =
((ins_h << hash_shift) ^
(window[strstart + (MIN_MATCH - 1)] & 0xff)) &
hash_mask;
hash_head=head[ins_h] & 0xffff;
prev[strstart & w_mask]=head[ins_h];
head[ins_h]=strstart;
} while (--match_length!==0);
strstart++;
}else{
strstart +=match_length;
match_length=0;
ins_h=window[strstart] & 0xff;
ins_h =
((ins_h << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask;
}}else{
bflush=_tr_tally(0, window[strstart] & 0xff);
lookahead--;
strstart++;
}
if(bflush){
flush_block_only(false);
if(strm.avail_out===0) return NeedMore;
}}
flush_block_only(flush===Z_FINISH);
if(strm.avail_out===0){
if(flush===Z_FINISH) return FinishStarted;
else return NeedMore;
}
return flush===Z_FINISH ? FinishDone:BlockDone;
}
function deflate_slow(flush){
var hash_head=0;
var bflush;
var max_insert;
while (true){
if(lookahead < MIN_LOOKAHEAD){
fill_window();
if(lookahead < MIN_LOOKAHEAD&&flush===Z_NO_FLUSH){
return NeedMore;
}
if(lookahead===0) break;
}
if(lookahead >=MIN_MATCH){
ins_h =
((ins_h << hash_shift) ^
(window[strstart + (MIN_MATCH - 1)] & 0xff)) &
hash_mask;
hash_head=head[ins_h] & 0xffff;
prev[strstart & w_mask]=head[ins_h];
head[ins_h]=strstart;
}
prev_length=match_length;
prev_match=match_start;
match_length=MIN_MATCH - 1;
if(hash_head!==0 &&
prev_length < max_lazy_match &&
((strstart - hash_head) & 0xffff) <=w_size - MIN_LOOKAHEAD
){
if(strategy!==Z_HUFFMAN_ONLY){
match_length=longest_match(hash_head);
}
if(match_length <=5 &&
(strategy===Z_FILTERED ||
(match_length===MIN_MATCH&&strstart - match_start > 4096))
){
match_length=MIN_MATCH - 1;
}}
if(prev_length >=MIN_MATCH&&match_length <=prev_length){
max_insert=strstart + lookahead - MIN_MATCH;
bflush=_tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH);
lookahead -=prev_length - 1;
prev_length -=2;
do {
if(++strstart <=max_insert){
ins_h =
((ins_h << hash_shift) ^
(window[strstart + (MIN_MATCH - 1)] & 0xff)) &
hash_mask;
hash_head=head[ins_h] & 0xffff;
prev[strstart & w_mask]=head[ins_h];
head[ins_h]=strstart;
}} while (--prev_length!==0);
match_available=0;
match_length=MIN_MATCH - 1;
strstart++;
if(bflush){
flush_block_only(false);
if(strm.avail_out===0) return NeedMore;
}}else if(match_available!==0){
bflush=_tr_tally(0, window[strstart - 1] & 0xff);
if(bflush){
flush_block_only(false);
}
strstart++;
lookahead--;
if(strm.avail_out===0) return NeedMore;
}else{
match_available=1;
strstart++;
lookahead--;
}}
if(match_available!==0){
bflush=_tr_tally(0, window[strstart - 1] & 0xff);
match_available=0;
}
flush_block_only(flush===Z_FINISH);
if(strm.avail_out===0){
if(flush===Z_FINISH) return FinishStarted;
else return NeedMore;
}
return flush===Z_FINISH ? FinishDone:BlockDone;
}
function deflateReset(strm){
strm.total_in=strm.total_out=0;
strm.msg=null;
that.pending=0;
that.pending_out=0;
status=BUSY_STATE;
last_flush=Z_NO_FLUSH;
tr_init();
lm_init();
return Z_OK;
}
that.deflateInit=function(
strm,
_level,
bits,
_method,
memLevel,
_strategy
){
if(!_method) _method=Z_DEFLATED;
if(!memLevel) memLevel=DEF_MEM_LEVEL;
if(!_strategy) _strategy=Z_DEFAULT_STRATEGY;
strm.msg=null;
if(_level===Z_DEFAULT_COMPRESSION) _level=6;
if(memLevel < 1 ||
memLevel > MAX_MEM_LEVEL ||
_method!==Z_DEFLATED ||
bits < 9 ||
bits > 15 ||
_level < 0 ||
_level > 9 ||
_strategy < 0 ||
_strategy > Z_HUFFMAN_ONLY
){
return Z_STREAM_ERROR;
}
strm.dstate=that;
w_bits=bits;
w_size=1 << w_bits;
w_mask=w_size - 1;
hash_bits=memLevel + 7;
hash_size=1 << hash_bits;
hash_mask=hash_size - 1;
hash_shift=Math.floor((hash_bits + MIN_MATCH - 1) / MIN_MATCH);
window=new Uint8Array(w_size * 2);
prev=[];
head=[];
lit_bufsize=1 << (memLevel + 6);
that.pending_buf=new Uint8Array(lit_bufsize * 4);
pending_buf_size=lit_bufsize * 4;
d_buf=Math.floor(lit_bufsize / 2);
l_buf=(1 + 2) * lit_bufsize;
level=_level;
strategy=_strategy;
return deflateReset(strm);
};
that.deflateEnd=function(){
if(status!==INIT_STATE &&
status!==BUSY_STATE &&
status!==FINISH_STATE
){
return Z_STREAM_ERROR;
}
that.pending_buf=null;
head=null;
prev=null;
window=null;
that.dstate=null;
return status===BUSY_STATE ? Z_DATA_ERROR:Z_OK;
};
that.deflateParams=function(strm, _level, _strategy){
var err=Z_OK;
if(_level===Z_DEFAULT_COMPRESSION){
_level=6;
}
if(_level < 0 ||
_level > 9 ||
_strategy < 0 ||
_strategy > Z_HUFFMAN_ONLY
){
return Z_STREAM_ERROR;
}
if(config_table[level].func!==config_table[_level].func &&
strm.total_in!==0
){
err=strm.deflate(Z_PARTIAL_FLUSH);
}
if(level!==_level){
level=_level;
max_lazy_match=config_table[level].max_lazy;
good_match=config_table[level].good_length;
nice_match=config_table[level].nice_length;
max_chain_length=config_table[level].max_chain;
}
strategy=_strategy;
return err;
};
that.deflateSetDictionary=function(strm, dictionary, dictLength){
var length=dictLength;
var n,
index=0;
if(!dictionary||status!==INIT_STATE) return Z_STREAM_ERROR;
if(length < MIN_MATCH) return Z_OK;
if(length > w_size - MIN_LOOKAHEAD){
length=w_size - MIN_LOOKAHEAD;
index=dictLength - length;
}
window.set(dictionary.subarray(index, index + length), 0);
strstart=length;
block_start=length;
ins_h=window[0] & 0xff;
ins_h=((ins_h << hash_shift) ^ (window[1] & 0xff)) & hash_mask;
for (n=0; n <=length - MIN_MATCH; n++){
ins_h =
((ins_h << hash_shift) ^ (window[n + (MIN_MATCH - 1)] & 0xff)) &
hash_mask;
prev[n & w_mask]=head[ins_h];
head[ins_h]=n;
}
return Z_OK;
};
that.deflate=function(_strm, flush){
var i, header, level_flags, old_flush, bstate;
if(flush > Z_FINISH||flush < 0){
return Z_STREAM_ERROR;
}
if(!_strm.next_out ||
(!_strm.next_in&&_strm.avail_in!==0) ||
(status===FINISH_STATE&&flush!==Z_FINISH)
){
_strm.msg=z_errmsg[Z_NEED_DICT - Z_STREAM_ERROR];
return Z_STREAM_ERROR;
}
if(_strm.avail_out===0){
_strm.msg=z_errmsg[Z_NEED_DICT - Z_BUF_ERROR];
return Z_BUF_ERROR;
}
strm=_strm;
old_flush=last_flush;
last_flush=flush;
if(status===INIT_STATE){
header=(Z_DEFLATED + ((w_bits - 8) << 4)) << 8;
level_flags=((level - 1) & 0xff) >> 1;
if(level_flags > 3) level_flags=3;
header |=level_flags << 6;
if(strstart!==0) header |=PRESET_DICT;
header +=31 - (header % 31);
status=BUSY_STATE;
putShortMSB(header);
}
if(that.pending!==0){
strm.flush_pending();
if(strm.avail_out===0){
last_flush=-1;
return Z_OK;
}}else if(strm.avail_in===0 &&
flush <=old_flush &&
flush!==Z_FINISH
){
strm.msg=z_errmsg[Z_NEED_DICT - Z_BUF_ERROR];
return Z_BUF_ERROR;
}
if(status===FINISH_STATE&&strm.avail_in!==0){
_strm.msg=z_errmsg[Z_NEED_DICT - Z_BUF_ERROR];
return Z_BUF_ERROR;
}
if(strm.avail_in!==0 ||
lookahead!==0 ||
(flush!==Z_NO_FLUSH&&status!==FINISH_STATE)
){
bstate=-1;
switch (config_table[level].func){
case STORED:
bstate=deflate_stored(flush);
break;
case FAST:
bstate=deflate_fast(flush);
break;
case SLOW:
bstate=deflate_slow(flush);
break;
}
if(bstate===FinishStarted||bstate===FinishDone){
status=FINISH_STATE;
}
if(bstate===NeedMore||bstate===FinishStarted){
if(strm.avail_out===0){
last_flush=-1;
}
return Z_OK;
}
if(bstate===BlockDone){
if(flush===Z_PARTIAL_FLUSH){
_tr_align();
}else{
_tr_stored_block(0, 0, false);
if(flush===Z_FULL_FLUSH){
for (i=0; i < hash_size ; i++)
head[i]=0;
}}
strm.flush_pending();
if(strm.avail_out===0){
last_flush=-1;
return Z_OK;
}}
}
if(flush!==Z_FINISH) return Z_OK;
return Z_STREAM_END;
};}
function ZStream(){
var that=this;
that.next_in_index=0;
that.next_out_index=0;
that.avail_in=0;
that.total_in=0;
that.avail_out=0;
that.total_out=0;
}
ZStream.prototype={
deflateInit: function(level, bits){
var that=this;
that.dstate=new Deflate();
if(!bits) bits=MAX_BITS;
return that.dstate.deflateInit(that, level, bits);
},
deflate: function(flush){
var that=this;
if(!that.dstate){
return Z_STREAM_ERROR;
}
return that.dstate.deflate(that, flush);
},
deflateEnd: function(){
var that=this;
if(!that.dstate) return Z_STREAM_ERROR;
var ret=that.dstate.deflateEnd();
that.dstate=null;
return ret;
},
deflateParams: function(level, strategy){
var that=this;
if(!that.dstate) return Z_STREAM_ERROR;
return that.dstate.deflateParams(that, level, strategy);
},
deflateSetDictionary: function(dictionary, dictLength){
var that=this;
if(!that.dstate) return Z_STREAM_ERROR;
return that.dstate.deflateSetDictionary(that, dictionary, dictLength);
},
read_buf: function(buf, start, size){
var that=this;
var len=that.avail_in;
if(len > size) len=size;
if(len===0) return 0;
that.avail_in -=len;
buf.set(that.next_in.subarray(that.next_in_index, that.next_in_index + len),
start
);
that.next_in_index +=len;
that.total_in +=len;
return len;
},
flush_pending: function(){
var that=this;
var len=that.dstate.pending;
if(len > that.avail_out) len=that.avail_out;
if(len===0) return;
that.next_out.set(that.dstate.pending_buf.subarray(that.dstate.pending_out,
that.dstate.pending_out + len
),
that.next_out_index
);
that.next_out_index +=len;
that.dstate.pending_out +=len;
that.total_out +=len;
that.avail_out -=len;
that.dstate.pending -=len;
if(that.dstate.pending===0){
that.dstate.pending_out=0;
}}
};
function Deflater(options){
var that=this;
var z=new ZStream();
var bufsize=512;
var flush=Z_NO_FLUSH;
var buf=new Uint8Array(bufsize);
var level=options ? options.level:Z_DEFAULT_COMPRESSION;
if(typeof level==="undefined") level=Z_DEFAULT_COMPRESSION;
z.deflateInit(level);
z.next_out=buf;
that.append=function(data, onprogress){
var err,
buffers=[],
lastIndex=0,
bufferIndex=0,
bufferSize=0,
array;
if(!data.length) return;
z.next_in_index=0;
z.next_in=data;
z.avail_in=data.length;
do {
z.next_out_index=0;
z.avail_out=bufsize;
err=z.deflate(flush);
if(err!==Z_OK) throw new Error("deflating: " + z.msg);
if(z.next_out_index)
if(z.next_out_index===bufsize) buffers.push(new Uint8Array(buf));
else buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index)));
bufferSize +=z.next_out_index;
if(onprogress&&z.next_in_index > 0&&z.next_in_index!==lastIndex){
onprogress(z.next_in_index);
lastIndex=z.next_in_index;
}} while (z.avail_in > 0||z.avail_out===0);
array=new Uint8Array(bufferSize);
buffers.forEach(function(chunk){
array.set(chunk, bufferIndex);
bufferIndex +=chunk.length;
});
return array;
};
that.flush=function(){
var err,
buffers=[],
bufferIndex=0,
bufferSize=0,
array;
do {
z.next_out_index=0;
z.avail_out=bufsize;
err=z.deflate(Z_FINISH);
if(err!==Z_STREAM_END&&err!==Z_OK)
throw new Error("deflating: " + z.msg);
if(bufsize - z.avail_out > 0)
buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index)));
bufferSize +=z.next_out_index;
} while (z.avail_in > 0||z.avail_out===0);
z.deflateEnd();
array=new Uint8Array(bufferSize);
buffers.forEach(function(chunk){
array.set(chunk, bufferIndex);
bufferIndex +=chunk.length;
});
return array;
};}
(function(jsPDFAPI){
var ASCII85Encode=function(a){
var b, c, d, e, f, g, h, i, j, k;
for (
!/[^\x00-\xFF]/.test(a),
b="\x00\x00\x00\x00".slice(a.length % 4||4),
a +=b,
c=[],
d=0,
e=a.length;
e > d;
d +=4
)
(f =
(a.charCodeAt(d) << 24) +
(a.charCodeAt(d + 1) << 16) +
(a.charCodeAt(d + 2) << 8) +
a.charCodeAt(d + 3)),
0!==f
? ((k=f % 85),
(f=(f - k) / 85),
(j=f % 85),
(f=(f - j) / 85),
(i=f % 85),
(f=(f - i) / 85),
(h=f % 85),
(f=(f - h) / 85),
(g=f % 85),
c.push(g + 33, h + 33, i + 33, j + 33, k + 33))
: c.push(122);
return (
(function(a, b){
for (var c=b; c > 0; c--) a.pop();
})(c, b.length),
String.fromCharCode.apply(String, c) + "~>"
);
};
var ASCII85Decode=function(a){
var c,
d,
e,
f,
g,
h=String,
l="length",
w=255,
x="charCodeAt",
y="slice",
z="replace";
for (
"~>"===a[y](-2),
a=a[y](0, -2)
[z](/\s/g, "")
[z]("z", "!!!!!"),
c="uuuuu"[y](a[l] % 5||5),
a +=c,
e=[],
f=0,
g=a[l];
g > f;
f +=5
)
(d =
52200625 * (a[x](f) - 33) +
614125 * (a[x](f + 1) - 33) +
7225 * (a[x](f + 2) - 33) +
85 * (a[x](f + 3) - 33) +
(a[x](f + 4) - 33)),
e.push(w & (d >> 24), w & (d >> 16), w & (d >> 8), w & d);
return (
(function(a, b){
for (var c=b; c > 0; c--) a.pop();
})(e, c[l]),
h.fromCharCode.apply(h, e)
);
};
var ASCIIHexEncode=function(value){
return (
value
.split("")
.map(function(value){
return ("0" + value.charCodeAt().toString(16)).slice(-2);
})
.join("") + ">"
);
};
var ASCIIHexDecode=function(value){
var regexCheckIfHex=new RegExp(/^([0-9A-Fa-f]{2})+$/);
value=value.replace(/\s/g, "");
if(value.indexOf(">")!==-1){
value=value.substr(0, value.indexOf(">"));
}
if(value.length % 2){
value +="0";
}
if(regexCheckIfHex.test(value)===false){
return "";
}
var result="";
for (var i=0; i < value.length; i +=2){
result +=String.fromCharCode("0x" + (value[i] + value[i + 1]));
}
return result;
};
var appendBuffer=function(buffer1, buffer2){
var combinedBuffer=new Uint8Array(
buffer1.byteLength + buffer2.byteLength
);
combinedBuffer.set(new Uint8Array(buffer1), 0);
combinedBuffer.set(new Uint8Array(buffer2), buffer1.byteLength);
return combinedBuffer;
};
var FlateEncode=function(data){
var arr=[];
var i=data.length;
var adler32;
var deflater;
while (i--){
arr[i]=data.charCodeAt(i);
}
adler32=jsPDFAPI.adler32cs.from(data);
deflater=new Deflater(6);
data=deflater.append(new Uint8Array(arr));
data=appendBuffer(data, deflater.flush());
arr=new Uint8Array(data.byteLength + 6);
arr.set(new Uint8Array([120, 156]));
arr.set(data, 2);
arr.set(new Uint8Array([
adler32 & 0xff,
(adler32 >> 8) & 0xff,
(adler32 >> 16) & 0xff,
(adler32 >> 24) & 0xff
]),
data.byteLength + 2
);
data=arr.reduce(function(data, byte){
return data + String.fromCharCode(byte);
}, "");
return data;
};
jsPDFAPI.processDataByFilters=function(origData, filterChain){
var i=0;
var data=origData||"";
var reverseChain=[];
filterChain=filterChain||[];
if(typeof filterChain==="string"){
filterChain=[filterChain];
}
for (i=0; i < filterChain.length; i +=1){
switch (filterChain[i]){
case "ASCII85Decode":
case "/ASCII85Decode":
data=ASCII85Decode(data);
reverseChain.push("/ASCII85Encode");
break;
case "ASCII85Encode":
case "/ASCII85Encode":
data=ASCII85Encode(data);
reverseChain.push("/ASCII85Decode");
break;
case "ASCIIHexDecode":
case "/ASCIIHexDecode":
data=ASCIIHexDecode(data);
reverseChain.push("/ASCIIHexEncode");
break;
case "ASCIIHexEncode":
case "/ASCIIHexEncode":
data=ASCIIHexEncode(data);
reverseChain.push("/ASCIIHexDecode");
break;
case "FlateEncode":
case "/FlateEncode":
data=FlateEncode(data);
reverseChain.push("/FlateDecode");
break;
default:
throw new Error(
'The filter: "' + filterChain[i] + '" is not implemented'
);
}}
return { data: data, reverseChain: reverseChain.reverse().join(" ") };};
})(jsPDF.API);
(function(jsPDFAPI){
jsPDFAPI.loadFile=function(url, sync, callback){
return browserRequest(url, sync, callback);
};
jsPDFAPI.loadImageFile=jsPDFAPI.loadFile;
function browserRequest(url, sync, callback){
sync=sync===false ? false:true;
callback=typeof callback==="function" ? callback:function(){};
var result=undefined;
var xhr=function(url, sync, callback){
var request=new XMLHttpRequest();
var i=0;
var sanitizeUnicode=function(data){
var dataLength=data.length;
var charArray=[];
var StringFromCharCode=String.fromCharCode;
for (i=0; i < dataLength; i +=1){
charArray.push(StringFromCharCode(data.charCodeAt(i) & 0xff));
}
return charArray.join("");
};
request.open("GET", url, !sync);
request.overrideMimeType("text/plain; charset=x-user-defined");
if(sync===false){
request.onload=function(){
if(request.status===200){
callback(sanitizeUnicode(this.responseText));
}else{
callback(undefined);
}};}
request.send(null);
if(sync&&request.status===200){
return sanitizeUnicode(request.responseText);
}};
try {
result=xhr(url, sync, callback);
} catch (e){}
return result;
}})(jsPDF.API);
function loadOptionalLibrary(name, globalName){
globalName=globalName||name;
if(globalObject[globalName]){
return Promise.resolve(globalObject[globalName]);
}
if(typeof exports==="object"&&typeof module!=="undefined"){
return new Promise(function(resolve, reject){
try {
resolve(require(name));
} catch (e){
reject(e);
}});
}
if(typeof define==="function"&&define.amd){
return new Promise(function(resolve, reject){
try {
require([name], resolve);
} catch (e){
reject(e);
}});
}
return Promise.reject(new Error("Could not load " + name));
}
(function(jsPDFAPI){
function loadHtml2Canvas(){
return loadOptionalLibrary("html2canvas").catch(function(e){
return Promise.reject(new Error("Could not load html2canvas: " + e));
});
}
function loadDomPurify(){
return loadOptionalLibrary("dompurify", "DOMPurify").catch(function(e){
return Promise.reject(new Error("Could not load dompurify: " + e));
});
}
var objType=function(obj){
var type=typeof obj;
if(type==="undefined") return "undefined";
else if(type==="string"||obj instanceof String) return "string";
else if(type==="number"||obj instanceof Number) return "number";
else if(type==="function"||obj instanceof Function) return "function";
else if(!!obj&&obj.constructor===Array) return "array";
else if(obj&&obj.nodeType===1) return "element";
else if(type==="object") return "object";
else return "unknown";
};
var createElement=function(tagName, opt){
var el=document.createElement(tagName);
if(opt.className) el.className=opt.className;
if(opt.innerHTML&&opt.dompurify){
el.innerHTML=opt.dompurify.sanitize(opt.innerHTML);
}
for (var key in opt.style){
el.style[key]=opt.style[key];
}
return el;
};
var cloneNode=function(node, javascriptEnabled){
var clone =
node.nodeType===3
? document.createTextNode(node.nodeValue)
: node.cloneNode(false);
for (var child=node.firstChild; child; child=child.nextSibling){
if(javascriptEnabled===true ||
child.nodeType!==1 ||
child.nodeName!=="SCRIPT"
){
clone.appendChild(cloneNode(child, javascriptEnabled));
}}
if(node.nodeType===1){
if(node.nodeName==="CANVAS"){
clone.width=node.width;
clone.height=node.height;
clone.getContext("2d").drawImage(node, 0, 0);
}else if(node.nodeName==="TEXTAREA"||node.nodeName==="SELECT"){
clone.value=node.value;
}
clone.addEventListener("load",
function(){
clone.scrollTop=node.scrollTop;
clone.scrollLeft=node.scrollLeft;
},
true
);
}
return clone;
};
var Worker=function Worker(opt){
var root=Object.assign(Worker.convert(Promise.resolve()),
JSON.parse(JSON.stringify(Worker.template))
);
var self=Worker.convert(Promise.resolve(), root);
self=self.setProgress(1, Worker, 1, [Worker]);
self=self.set(opt);
return self;
};
Worker.prototype=Object.create(Promise.prototype);
Worker.prototype.constructor=Worker;
Worker.convert=function convert(promise, inherit){
promise.__proto__=inherit||Worker.prototype;
return promise;
};
Worker.template={
prop: {
src: null,
container: null,
overlay: null,
canvas: null,
img: null,
pdf: null,
pageSize: null,
callback: function(){}},
progress: {
val: 0,
state: null,
n: 0,
stack: []
},
opt: {
filename: "file.pdf",
margin: [0, 0, 0, 0],
enableLinks: true,
x: 0,
y: 0,
html2canvas: {},
jsPDF: {},
backgroundColor: "transparent"
}};
Worker.prototype.from=function from(src, type){
function getType(src){
switch (objType(src)){
case "string":
return "string";
case "element":
return src.nodeName.toLowerCase==="canvas" ? "canvas":"element";
default:
return "unknown";
}}
return this.then(function from_main(){
type=type||getType(src);
switch (type){
case "string":
return this.then(loadDomPurify).then(function(dompurify){
return this.set({
src: createElement("div", {
innerHTML: src,
dompurify: dompurify
})
});
});
case "element":
return this.set({ src: src });
case "canvas":
return this.set({ canvas: src });
case "img":
return this.set({ img: src });
default:
return this.error("Unknown source type.");
}});
};
Worker.prototype.to=function to(target){
switch (target){
case "container":
return this.toContainer();
case "canvas":
return this.toCanvas();
case "img":
return this.toImg();
case "pdf":
return this.toPdf();
default:
return this.error("Invalid target.");
}};
Worker.prototype.toContainer=function toContainer(){
var prereqs=[
function checkSrc(){
return (
this.prop.src||this.error("Cannot duplicate - no source HTML.")
);
},
function checkPageSize(){
return this.prop.pageSize||this.setPageSize();
}
];
return this.thenList(prereqs).then(function toContainer_main(){
var overlayCSS={
position: "fixed",
overflow: "hidden",
zIndex: 1000,
left: "-100000px",
right: 0,
bottom: 0,
top: 0
};
var containerCSS={
position: "relative",
display: "inline-block",
width:
Math.max(this.prop.src.clientWidth,
this.prop.src.scrollWidth,
this.prop.src.offsetWidth
) + "px",
left: 0,
right: 0,
top: 0,
margin: "auto",
backgroundColor: this.opt.backgroundColor
};
var source=cloneNode(
this.prop.src,
this.opt.html2canvas.javascriptEnabled
);
if(source.tagName==="BODY"){
containerCSS.height =
Math.max(document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight
) + "px";
}
this.prop.overlay=createElement("div", {
className: "html2pdf__overlay",
style: overlayCSS
});
this.prop.container=createElement("div", {
className: "html2pdf__container",
style: containerCSS
});
this.prop.container.appendChild(source);
this.prop.container.firstChild.appendChild(createElement("div", {
style: {
clear: "both",
border: "0 none transparent",
margin: 0,
padding: 0,
height: 0
}})
);
this.prop.container.style.float="none";
this.prop.overlay.appendChild(this.prop.container);
document.body.appendChild(this.prop.overlay);
this.prop.container.firstChild.style.position="relative";
this.prop.container.height =
Math.max(this.prop.container.firstChild.clientHeight,
this.prop.container.firstChild.scrollHeight,
this.prop.container.firstChild.offsetHeight
) + "px";
});
};
Worker.prototype.toCanvas=function toCanvas(){
var prereqs=[
function checkContainer(){
return (
document.body.contains(this.prop.container)||this.toContainer()
);
}
];
return this.thenList(prereqs)
.then(loadHtml2Canvas)
.then(function toCanvas_main(html2canvas){
var options=Object.assign({}, this.opt.html2canvas);
delete options.onrendered;
return html2canvas(this.prop.container, options);
})
.then(function toCanvas_post(canvas){
var onRendered=this.opt.html2canvas.onrendered||function(){};
onRendered(canvas);
this.prop.canvas=canvas;
document.body.removeChild(this.prop.overlay);
});
};
Worker.prototype.toContext2d=function toContext2d(){
var prereqs=[
function checkContainer(){
return (
document.body.contains(this.prop.container)||this.toContainer()
);
}
];
return this.thenList(prereqs)
.then(loadHtml2Canvas)
.then(function toContext2d_main(html2canvas){
var pdf=this.opt.jsPDF;
var options=Object.assign({
async: true,
allowTaint: true,
scale: 1,
scrollX: this.opt.scrollX||0,
scrollY: this.opt.scrollY||0,
backgroundColor: "#ffffff",
imageTimeout: 15000,
logging: true,
proxy: null,
removeContainer: true,
foreignObjectRendering: false,
useCORS: false
},
this.opt.html2canvas
);
delete options.onrendered;
pdf.context2d.autoPaging=true;
pdf.context2d.posX=this.opt.x;
pdf.context2d.posY=this.opt.y;
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;
return html2canvas(this.prop.container, options);
})
.then(function toContext2d_post(canvas){
var onRendered=this.opt.html2canvas.onrendered||function(){};
onRendered(canvas);
this.prop.canvas=canvas;
document.body.removeChild(this.prop.overlay);
});
};
Worker.prototype.toImg=function toImg(){
var prereqs=[
function checkCanvas(){
return this.prop.canvas||this.toCanvas();
}
];
return this.thenList(prereqs).then(function toImg_main(){
var imgData=this.prop.canvas.toDataURL("image/" + this.opt.image.type,
this.opt.image.quality
);
this.prop.img=document.createElement("img");
this.prop.img.src=imgData;
});
};
Worker.prototype.toPdf=function toPdf(){
var prereqs=[
function checkContext2d(){
return this.toContext2d();
}
];
return this.thenList(prereqs).then(function toPdf_main(){
this.prop.pdf=this.prop.pdf||this.opt.jsPDF;
});
};
Worker.prototype.output=function output(type, options, src){
src=src||"pdf";
if(src.toLowerCase()==="img"||src.toLowerCase()==="image"){
return this.outputImg(type, options);
}else{
return this.outputPdf(type, options);
}};
Worker.prototype.outputPdf=function outputPdf(type, options){
var prereqs=[
function checkPdf(){
return this.prop.pdf||this.toPdf();
}
];
return this.thenList(prereqs).then(function outputPdf_main(){
return this.prop.pdf.output(type, options);
});
};
Worker.prototype.outputImg=function outputImg(type){
var prereqs=[
function checkImg(){
return this.prop.img||this.toImg();
}
];
return this.thenList(prereqs).then(function outputImg_main(){
switch (type){
case undefined:
case "img":
return this.prop.img;
case "datauristring":
case "dataurlstring":
return this.prop.img.src;
case "datauri":
case "dataurl":
return (document.location.href=this.prop.img.src);
default:
throw 'Image output type "' + type + '" is not supported.';
}});
};
Worker.prototype.save=function save(filename){
var prereqs=[
function checkPdf(){
return this.prop.pdf||this.toPdf();
}
];
return this.thenList(prereqs)
.set(filename ? { filename: filename }:null)
.then(function save_main(){
this.prop.pdf.save(this.opt.filename);
});
};
Worker.prototype.doCallback=function doCallback(){
var prereqs=[
function checkPdf(){
return this.prop.pdf||this.toPdf();
}
];
return this.thenList(prereqs).then(function doCallback_main(){
this.prop.callback(this.prop.pdf);
});
};
Worker.prototype.set=function set(opt){
if(objType(opt)!=="object"){
return this;
}
var fns=Object.keys(opt||{}).map(function(key){
if(key in Worker.template.prop){
return function set_prop(){
this.prop[key]=opt[key];
};}else{
switch (key){
case "margin":
return this.setMargin.bind(this, opt.margin);
case "jsPDF":
return function set_jsPDF(){
this.opt.jsPDF=opt.jsPDF;
return this.setPageSize();
};
case "pageSize":
return this.setPageSize.bind(this, opt.pageSize);
default:
return function set_opt(){
this.opt[key]=opt[key];
};}}
}, this);
return this.then(function set_main(){
return this.thenList(fns);
});
};
Worker.prototype.get=function get(key, cbk){
return this.then(function get_main(){
var val=key in Worker.template.prop ? this.prop[key]:this.opt[key];
return cbk ? cbk(val):val;
});
};
Worker.prototype.setMargin=function setMargin(margin){
return this.then(function setMargin_main(){
switch (objType(margin)){
case "number":
margin=[margin, margin, margin, margin];
case "array":
if(margin.length===2){
margin=[margin[0], margin[1], margin[0], margin[1]];
}
if(margin.length===4){
break;
}
default:
return this.error("Invalid margin array.");
}
this.opt.margin=margin;
}).then(this.setPageSize);
};
Worker.prototype.setPageSize=function setPageSize(pageSize){
function toPx(val, k){
return Math.floor(((val * k) / 72) * 96);
}
return this.then(function setPageSize_main(){
pageSize=pageSize||jsPDF.getPageSize(this.opt.jsPDF);
if(!pageSize.hasOwnProperty("inner")){
pageSize.inner={
width: pageSize.width - this.opt.margin[1] - this.opt.margin[3],
height: pageSize.height - this.opt.margin[0] - this.opt.margin[2]
};
pageSize.inner.px={
width: toPx(pageSize.inner.width, pageSize.k),
height: toPx(pageSize.inner.height, pageSize.k)
};
pageSize.inner.ratio=pageSize.inner.height / pageSize.inner.width;
}
this.prop.pageSize=pageSize;
});
};
Worker.prototype.setProgress=function setProgress(val, state, n, stack){
if(val!=null) this.progress.val=val;
if(state!=null) this.progress.state=state;
if(n!=null) this.progress.n=n;
if(stack!=null) this.progress.stack=stack;
this.progress.ratio=this.progress.val / this.progress.state;
return this;
};
Worker.prototype.updateProgress=function updateProgress(
val,
state,
n,
stack
){
return this.setProgress(val ? this.progress.val + val:null,
state ? state:null,
n ? this.progress.n + n:null,
stack ? this.progress.stack.concat(stack):null
);
};
Worker.prototype.then=function then(onFulfilled, onRejected){
var self=this;
return this.thenCore(onFulfilled, onRejected, function then_main(
onFulfilled,
onRejected
){
self.updateProgress(null, null, 1, [onFulfilled]);
return Promise.prototype.then
.call(this, function then_pre(val){
self.updateProgress(null, onFulfilled);
return val;
})
.then(onFulfilled, onRejected)
.then(function then_post(val){
self.updateProgress(1);
return val;
});
});
};
Worker.prototype.thenCore=function thenCore(
onFulfilled,
onRejected,
thenBase
){
thenBase=thenBase||Promise.prototype.then;
var self=this;
if(onFulfilled){
onFulfilled=onFulfilled.bind(self);
}
if(onRejected){
onRejected=onRejected.bind(self);
}
var isNative =
Promise.toString().indexOf("[native code]")!==-1 &&
Promise.name==="Promise";
var selfPromise=isNative
? self
: Worker.convert(Object.assign({}, self), Promise.prototype);
var returnVal=thenBase.call(selfPromise, onFulfilled, onRejected);
return Worker.convert(returnVal, self.__proto__);
};
Worker.prototype.thenExternal=function thenExternal(
onFulfilled,
onRejected
){
return Promise.prototype.then.call(this, onFulfilled, onRejected);
};
Worker.prototype.thenList=function thenList(fns){
var self=this;
fns.forEach(function thenList_forEach(fn){
self=self.thenCore(fn);
});
return self;
};
Worker.prototype["catch"]=function(onRejected){
if(onRejected){
onRejected=onRejected.bind(this);
}
var returnVal=Promise.prototype["catch"].call(this, onRejected);
return Worker.convert(returnVal, this);
};
Worker.prototype.catchExternal=function catchExternal(onRejected){
return Promise.prototype["catch"].call(this, onRejected);
};
Worker.prototype.error=function error(msg){
return this.then(function error_main(){
throw new Error(msg);
});
};
Worker.prototype.using=Worker.prototype.set;
Worker.prototype.saveAs=Worker.prototype.save;
Worker.prototype.export=Worker.prototype.output;
Worker.prototype.run=Worker.prototype.then;
jsPDF.getPageSize=function(orientation, unit, format){
if(typeof orientation==="object"){
var options=orientation;
orientation=options.orientation;
unit=options.unit||unit;
format=options.format||format;
}
unit=unit||"mm";
format=format||"a4";
orientation=("" + (orientation||"P")).toLowerCase();
var format_as_string=("" + format).toLowerCase();
var pageFormats={
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.4, 209.76],
a9: [104.88, 147.4],
a10: [73.7, 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.9, 708.66],
b6: [354.33, 498.9],
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]
};
var k;
switch (unit){
case "pt":
k=1;
break;
case "mm":
k=72 / 25.4;
break;
case "cm":
k=72 / 2.54;
break;
case "in":
k=72;
break;
case "px":
k=72 / 96;
break;
case "pc":
k=12;
break;
case "em":
k=12;
break;
case "ex":
k=6;
break;
default:
throw "Invalid unit: " + unit;
}
var pageHeight=0;
var pageWidth=0;
if(pageFormats.hasOwnProperty(format_as_string)){
pageHeight=pageFormats[format_as_string][1] / k;
pageWidth=pageFormats[format_as_string][0] / k;
}else{
try {
pageHeight=format[1];
pageWidth=format[0];
} catch (err){
throw new Error("Invalid format: " + format);
}}
var tmp;
if(orientation==="p"||orientation==="portrait"){
orientation="p";
if(pageWidth > pageHeight){
tmp=pageWidth;
pageWidth=pageHeight;
pageHeight=tmp;
}}else if(orientation==="l"||orientation==="landscape"){
orientation="l";
if(pageHeight > pageWidth){
tmp=pageWidth;
pageWidth=pageHeight;
pageHeight=tmp;
}}else{
throw "Invalid orientation: " + orientation;
}
var info={
width: pageWidth,
height: pageHeight,
unit: unit,
k: k,
orientation: orientation
};
return info;
};
jsPDFAPI.html=function(src, options){
options=options||{};
options.callback=options.callback||function(){};
options.html2canvas=options.html2canvas||{};
options.html2canvas.canvas=options.html2canvas.canvas||this.canvas;
options.jsPDF=options.jsPDF||this;
var worker=new Worker(options);
if(!options.worker){
return worker.from(src).doCallback();
}else{
return worker;
}};})(jsPDF.API);
(function(jsPDFAPI){
var jsNamesObj, jsJsObj, text;
jsPDFAPI.addJS=function(javascript){
text=javascript;
this.internal.events.subscribe("postPutResources", function(){
jsNamesObj=this.internal.newObject();
this.internal.out("<<");
this.internal.out("/Names [(EmbeddedJS) " + (jsNamesObj + 1) + " 0 R]");
this.internal.out(">>");
this.internal.out("endobj");
jsJsObj=this.internal.newObject();
this.internal.out("<<");
this.internal.out("/S /JavaScript");
this.internal.out("/JS (" + text + ")");
this.internal.out(">>");
this.internal.out("endobj");
});
this.internal.events.subscribe("putCatalog", function(){
if(jsNamesObj!==undefined&&jsJsObj!==undefined){
this.internal.out("/Names <</JavaScript " + jsNamesObj + " 0 R>>");
}});
return this;
};})(jsPDF.API);
(function(jsPDFAPI){
var namesOid;
jsPDFAPI.events.push([
"postPutResources",
function(){
var pdf=this;
var rx=/^(\d+) 0 obj$/;
if(this.outline.root.children.length > 0){
var lines=pdf.outline.render().split(/\r\n/);
for (var i=0; i < lines.length; i++){
var line=lines[i];
var m=rx.exec(line);
if(m!=null){
var oid=m[1];
pdf.internal.newObjectDeferredBegin(oid, false);
}
pdf.internal.write(line);
}}
if(this.outline.createNamedDestinations){
var totalPages=this.internal.pages.length;
var dests=[];
for (var i=0; i < totalPages; i++){
var id=pdf.internal.newObject();
dests.push(id);
var info=pdf.internal.getPageInfo(i + 1);
pdf.internal.write("<< /D[" + info.objId + " 0 R /XYZ null null null]>> endobj"
);
}
var names2Oid=pdf.internal.newObject();
pdf.internal.write("<< /Names [ ");
for (var i=0; i < dests.length; i++){
pdf.internal.write("(page_" + (i + 1) + ")" + dests[i] + " 0 R");
}
pdf.internal.write(" ] >>", "endobj");
namesOid=pdf.internal.newObject();
pdf.internal.write("<< /Dests " + names2Oid + " 0 R");
pdf.internal.write(">>", "endobj");
}}
]);
jsPDFAPI.events.push([
"putCatalog",
function(){
var pdf=this;
if(pdf.outline.root.children.length > 0){
pdf.internal.write("/Outlines",
this.outline.makeRef(this.outline.root)
);
if(this.outline.createNamedDestinations){
pdf.internal.write("/Names " + namesOid + " 0 R");
}}
}
]);
jsPDFAPI.events.push([
"initialized",
function(){
var pdf=this;
pdf.outline={
createNamedDestinations: false,
root: {
children: []
}};
pdf.outline.add=function(parent, title, options){
var item={
title: title,
options: options,
children: []
};
if(parent==null){
parent=this.root;
}
parent.children.push(item);
return item;
};
pdf.outline.render=function(){
this.ctx={};
this.ctx.val="";
this.ctx.pdf=pdf;
this.genIds_r(this.root);
this.renderRoot(this.root);
this.renderItems(this.root);
return this.ctx.val;
};
pdf.outline.genIds_r=function(node){
node.id=pdf.internal.newObjectDeferred();
for (var i=0; i < node.children.length; i++){
this.genIds_r(node.children[i]);
}};
pdf.outline.renderRoot=function(node){
this.objStart(node);
this.line("/Type /Outlines");
if(node.children.length > 0){
this.line("/First " + this.makeRef(node.children[0]));
this.line("/Last " + this.makeRef(node.children[node.children.length - 1])
);
}
this.line("/Count " +
this.count_r({
count: 0
},
node
)
);
this.objEnd();
};
pdf.outline.renderItems=function(node){
var getVerticalCoordinateString=this.ctx.pdf.internal
.getVerticalCoordinateString;
for (var i=0; i < node.children.length; i++){
var item=node.children[i];
this.objStart(item);
this.line("/Title " + this.makeString(item.title));
this.line("/Parent " + this.makeRef(node));
if(i > 0){
this.line("/Prev " + this.makeRef(node.children[i - 1]));
}
if(i < node.children.length - 1){
this.line("/Next " + this.makeRef(node.children[i + 1]));
}
if(item.children.length > 0){
this.line("/First " + this.makeRef(item.children[0]));
this.line("/Last " + this.makeRef(item.children[item.children.length - 1])
);
}
var count=(this.count=this.count_r({
count: 0
},
item
));
if(count > 0){
this.line("/Count " + count);
}
if(item.options){
if(item.options.pageNumber){
var info=pdf.internal.getPageInfo(item.options.pageNumber);
this.line("/Dest " +
"[" +
info.objId +
" 0 R /XYZ 0 " +
getVerticalCoordinateString(0) +
" 0]"
);
}}
this.objEnd();
}
for (var z=0; z < node.children.length; z++){
this.renderItems(node.children[z]);
}};
pdf.outline.line=function(text){
this.ctx.val +=text + "\r\n";
};
pdf.outline.makeRef=function(node){
return node.id + " 0 R";
};
pdf.outline.makeString=function(val){
return "(" + pdf.internal.pdfEscape(val) + ")";
};
pdf.outline.objStart=function(node){
this.ctx.val +="\r\n" + node.id + " 0 obj" + "\r\n<<\r\n";
};
pdf.outline.objEnd=function(){
this.ctx.val +=">> \r\n" + "endobj" + "\r\n";
};
pdf.outline.count_r=function(ctx, node){
for (var i=0; i < node.children.length; i++){
ctx.count++;
this.count_r(ctx, node.children[i]);
}
return ctx.count;
};}
]);
return this;
})(jsPDF.API);
(function(jsPDFAPI){
var markers=[0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7];
var getJpegInfo=function(imgData){
var width, height, numcomponents;
var blockLength=imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5);
var len=imgData.length;
var result={ width: 0, height: 0, numcomponents: 1 };
for (var i=4; i < len; i +=2){
i +=blockLength;
if(markers.indexOf(imgData.charCodeAt(i + 1))!==-1){
height=imgData.charCodeAt(i + 5) * 256 + imgData.charCodeAt(i + 6);
width=imgData.charCodeAt(i + 7) * 256 + imgData.charCodeAt(i + 8);
numcomponents=imgData.charCodeAt(i + 9);
result={ width: width, height: height, numcomponents: numcomponents };
break;
}else{
blockLength =
imgData.charCodeAt(i + 2) * 256 + imgData.charCodeAt(i + 3);
}}
return result;
};
jsPDFAPI.processJPEG=function(
data,
index,
alias,
compression,
dataAsBinaryString,
colorSpace
){
var filter=this.decode.DCT_DECODE,
bpc=8,
dims,
result=null;
if(typeof data==="string" ||
this.__addimage__.isArrayBuffer(data) ||
this.__addimage__.isArrayBufferView(data)
){
data=dataAsBinaryString||data;
data=this.__addimage__.isArrayBuffer(data)
? new Uint8Array(data)
: data;
data=this.__addimage__.isArrayBufferView(data)
? this.__addimage__.arrayBufferToBinaryString(data)
: data;
dims=getJpegInfo(data);
switch (dims.numcomponents){
case 1:
colorSpace=this.color_spaces.DEVICE_GRAY;
break;
case 4:
colorSpace=this.color_spaces.DEVICE_CMYK;
break;
case 3:
colorSpace=this.color_spaces.DEVICE_RGB;
break;
}
result={
data: data,
width: dims.width,
height: dims.height,
colorSpace: colorSpace,
bitsPerComponent: bpc,
filter: filter,
index: index,
alias: alias
};}
return result;
};})(jsPDF.API);
var DecodeStream=(function(){
function constructor(){
this.pos=0;
this.bufferLength=0;
this.eof=false;
this.buffer=null;
}
constructor.prototype={
ensureBuffer: function decodestream_ensureBuffer(requested){
var buffer=this.buffer;
var current=buffer ? buffer.byteLength:0;
if(requested < current) return buffer;
var size=512;
while (size < requested) size <<=1;
var buffer2=new Uint8Array(size);
for (var i=0; i < current; ++i) buffer2[i]=buffer[i];
return (this.buffer=buffer2);
},
getByte: function decodestream_getByte(){
var pos=this.pos;
while (this.bufferLength <=pos){
if(this.eof) return null;
this.readBlock();
}
return this.buffer[this.pos++];
},
getBytes: function decodestream_getBytes(length){
var pos=this.pos;
if(length){
this.ensureBuffer(pos + length);
var end=pos + length;
while (!this.eof&&this.bufferLength < end) this.readBlock();
var bufEnd=this.bufferLength;
if(end > bufEnd) end=bufEnd;
}else{
while (!this.eof) this.readBlock();
var end=this.bufferLength;
}
this.pos=end;
return this.buffer.subarray(pos, end);
},
lookChar: function decodestream_lookChar(){
var pos=this.pos;
while (this.bufferLength <=pos){
if(this.eof) return null;
this.readBlock();
}
return String.fromCharCode(this.buffer[this.pos]);
},
getChar: function decodestream_getChar(){
var pos=this.pos;
while (this.bufferLength <=pos){
if(this.eof) return null;
this.readBlock();
}
return String.fromCharCode(this.buffer[this.pos++]);
},
makeSubStream: function decodestream_makeSubstream(start, length, dict){
var end=start + length;
while (this.bufferLength <=end&&!this.eof) this.readBlock();
return new Stream(this.buffer, start, length, dict);
},
skip: function decodestream_skip(n){
if(!n) n=1;
this.pos +=n;
},
reset: function decodestream_reset(){
this.pos=0;
}};
return constructor;
})();
var globalObject$1 =
(typeof self!=="undefined"&&self) ||
(typeof window!=="undefined"&&window) ||
(typeof global!=="undefined"&&global) ||
Function('return typeof this==="object"&&this.content')() ||
Function("return this")();
var FlateStream=(globalObject$1.FlateStream=(function(){
if(typeof Uint32Array==="undefined"){
return undefined;
}
var codeLenCodeMap=new Uint32Array([
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
]);
var lengthDecode=new Uint32Array([
0x00003,
0x00004,
0x00005,
0x00006,
0x00007,
0x00008,
0x00009,
0x0000a,
0x1000b,
0x1000d,
0x1000f,
0x10011,
0x20013,
0x20017,
0x2001b,
0x2001f,
0x30023,
0x3002b,
0x30033,
0x3003b,
0x40043,
0x40053,
0x40063,
0x40073,
0x50083,
0x500a3,
0x500c3,
0x500e3,
0x00102,
0x00102,
0x00102
]);
var distDecode=new Uint32Array([
0x00001,
0x00002,
0x00003,
0x00004,
0x10005,
0x10007,
0x20009,
0x2000d,
0x30011,
0x30019,
0x40021,
0x40031,
0x50041,
0x50061,
0x60081,
0x600c1,
0x70101,
0x70181,
0x80201,
0x80301,
0x90401,
0x90601,
0xa0801,
0xa0c01,
0xb1001,
0xb1801,
0xc2001,
0xc3001,
0xd4001,
0xd6001
]);
var fixedLitCodeTab=[
new Uint32Array([
0x70100,
0x80050,
0x80010,
0x80118,
0x70110,
0x80070,
0x80030,
0x900c0,
0x70108,
0x80060,
0x80020,
0x900a0,
0x80000,
0x80080,
0x80040,
0x900e0,
0x70104,
0x80058,
0x80018,
0x90090,
0x70114,
0x80078,
0x80038,
0x900d0,
0x7010c,
0x80068,
0x80028,
0x900b0,
0x80008,
0x80088,
0x80048,
0x900f0,
0x70102,
0x80054,
0x80014,
0x8011c,
0x70112,
0x80074,
0x80034,
0x900c8,
0x7010a,
0x80064,
0x80024,
0x900a8,
0x80004,
0x80084,
0x80044,
0x900e8,
0x70106,
0x8005c,
0x8001c,
0x90098,
0x70116,
0x8007c,
0x8003c,
0x900d8,
0x7010e,
0x8006c,
0x8002c,
0x900b8,
0x8000c,
0x8008c,
0x8004c,
0x900f8,
0x70101,
0x80052,
0x80012,
0x8011a,
0x70111,
0x80072,
0x80032,
0x900c4,
0x70109,
0x80062,
0x80022,
0x900a4,
0x80002,
0x80082,
0x80042,
0x900e4,
0x70105,
0x8005a,
0x8001a,
0x90094,
0x70115,
0x8007a,
0x8003a,
0x900d4,
0x7010d,
0x8006a,
0x8002a,
0x900b4,
0x8000a,
0x8008a,
0x8004a,
0x900f4,
0x70103,
0x80056,
0x80016,
0x8011e,
0x70113,
0x80076,
0x80036,
0x900cc,
0x7010b,
0x80066,
0x80026,
0x900ac,
0x80006,
0x80086,
0x80046,
0x900ec,
0x70107,
0x8005e,
0x8001e,
0x9009c,
0x70117,
0x8007e,
0x8003e,
0x900dc,
0x7010f,
0x8006e,
0x8002e,
0x900bc,
0x8000e,
0x8008e,
0x8004e,
0x900fc,
0x70100,
0x80051,
0x80011,
0x80119,
0x70110,
0x80071,
0x80031,
0x900c2,
0x70108,
0x80061,
0x80021,
0x900a2,
0x80001,
0x80081,
0x80041,
0x900e2,
0x70104,
0x80059,
0x80019,
0x90092,
0x70114,
0x80079,
0x80039,
0x900d2,
0x7010c,
0x80069,
0x80029,
0x900b2,
0x80009,
0x80089,
0x80049,
0x900f2,
0x70102,
0x80055,
0x80015,
0x8011d,
0x70112,
0x80075,
0x80035,
0x900ca,
0x7010a,
0x80065,
0x80025,
0x900aa,
0x80005,
0x80085,
0x80045,
0x900ea,
0x70106,
0x8005d,
0x8001d,
0x9009a,
0x70116,
0x8007d,
0x8003d,
0x900da,
0x7010e,
0x8006d,
0x8002d,
0x900ba,
0x8000d,
0x8008d,
0x8004d,
0x900fa,
0x70101,
0x80053,
0x80013,
0x8011b,
0x70111,
0x80073,
0x80033,
0x900c6,
0x70109,
0x80063,
0x80023,
0x900a6,
0x80003,
0x80083,
0x80043,
0x900e6,
0x70105,
0x8005b,
0x8001b,
0x90096,
0x70115,
0x8007b,
0x8003b,
0x900d6,
0x7010d,
0x8006b,
0x8002b,
0x900b6,
0x8000b,
0x8008b,
0x8004b,
0x900f6,
0x70103,
0x80057,
0x80017,
0x8011f,
0x70113,
0x80077,
0x80037,
0x900ce,
0x7010b,
0x80067,
0x80027,
0x900ae,
0x80007,
0x80087,
0x80047,
0x900ee,
0x70107,
0x8005f,
0x8001f,
0x9009e,
0x70117,
0x8007f,
0x8003f,
0x900de,
0x7010f,
0x8006f,
0x8002f,
0x900be,
0x8000f,
0x8008f,
0x8004f,
0x900fe,
0x70100,
0x80050,
0x80010,
0x80118,
0x70110,
0x80070,
0x80030,
0x900c1,
0x70108,
0x80060,
0x80020,
0x900a1,
0x80000,
0x80080,
0x80040,
0x900e1,
0x70104,
0x80058,
0x80018,
0x90091,
0x70114,
0x80078,
0x80038,
0x900d1,
0x7010c,
0x80068,
0x80028,
0x900b1,
0x80008,
0x80088,
0x80048,
0x900f1,
0x70102,
0x80054,
0x80014,
0x8011c,
0x70112,
0x80074,
0x80034,
0x900c9,
0x7010a,
0x80064,
0x80024,
0x900a9,
0x80004,
0x80084,
0x80044,
0x900e9,
0x70106,
0x8005c,
0x8001c,
0x90099,
0x70116,
0x8007c,
0x8003c,
0x900d9,
0x7010e,
0x8006c,
0x8002c,
0x900b9,
0x8000c,
0x8008c,
0x8004c,
0x900f9,
0x70101,
0x80052,
0x80012,
0x8011a,
0x70111,
0x80072,
0x80032,
0x900c5,
0x70109,
0x80062,
0x80022,
0x900a5,
0x80002,
0x80082,
0x80042,
0x900e5,
0x70105,
0x8005a,
0x8001a,
0x90095,
0x70115,
0x8007a,
0x8003a,
0x900d5,
0x7010d,
0x8006a,
0x8002a,
0x900b5,
0x8000a,
0x8008a,
0x8004a,
0x900f5,
0x70103,
0x80056,
0x80016,
0x8011e,
0x70113,
0x80076,
0x80036,
0x900cd,
0x7010b,
0x80066,
0x80026,
0x900ad,
0x80006,
0x80086,
0x80046,
0x900ed,
0x70107,
0x8005e,
0x8001e,
0x9009d,
0x70117,
0x8007e,
0x8003e,
0x900dd,
0x7010f,
0x8006e,
0x8002e,
0x900bd,
0x8000e,
0x8008e,
0x8004e,
0x900fd,
0x70100,
0x80051,
0x80011,
0x80119,
0x70110,
0x80071,
0x80031,
0x900c3,
0x70108,
0x80061,
0x80021,
0x900a3,
0x80001,
0x80081,
0x80041,
0x900e3,
0x70104,
0x80059,
0x80019,
0x90093,
0x70114,
0x80079,
0x80039,
0x900d3,
0x7010c,
0x80069,
0x80029,
0x900b3,
0x80009,
0x80089,
0x80049,
0x900f3,
0x70102,
0x80055,
0x80015,
0x8011d,
0x70112,
0x80075,
0x80035,
0x900cb,
0x7010a,
0x80065,
0x80025,
0x900ab,
0x80005,
0x80085,
0x80045,
0x900eb,
0x70106,
0x8005d,
0x8001d,
0x9009b,
0x70116,
0x8007d,
0x8003d,
0x900db,
0x7010e,
0x8006d,
0x8002d,
0x900bb,
0x8000d,
0x8008d,
0x8004d,
0x900fb,
0x70101,
0x80053,
0x80013,
0x8011b,
0x70111,
0x80073,
0x80033,
0x900c7,
0x70109,
0x80063,
0x80023,
0x900a7,
0x80003,
0x80083,
0x80043,
0x900e7,
0x70105,
0x8005b,
0x8001b,
0x90097,
0x70115,
0x8007b,
0x8003b,
0x900d7,
0x7010d,
0x8006b,
0x8002b,
0x900b7,
0x8000b,
0x8008b,
0x8004b,
0x900f7,
0x70103,
0x80057,
0x80017,
0x8011f,
0x70113,
0x80077,
0x80037,
0x900cf,
0x7010b,
0x80067,
0x80027,
0x900af,
0x80007,
0x80087,
0x80047,
0x900ef,
0x70107,
0x8005f,
0x8001f,
0x9009f,
0x70117,
0x8007f,
0x8003f,
0x900df,
0x7010f,
0x8006f,
0x8002f,
0x900bf,
0x8000f,
0x8008f,
0x8004f,
0x900ff
]),
9
];
var fixedDistCodeTab=[
new Uint32Array([
0x50000,
0x50010,
0x50008,
0x50018,
0x50004,
0x50014,
0x5000c,
0x5001c,
0x50002,
0x50012,
0x5000a,
0x5001a,
0x50006,
0x50016,
0x5000e,
0x00000,
0x50001,
0x50011,
0x50009,
0x50019,
0x50005,
0x50015,
0x5000d,
0x5001d,
0x50003,
0x50013,
0x5000b,
0x5001b,
0x50007,
0x50017,
0x5000f,
0x00000
]),
5
];
function error(e){
throw new Error(e);
}
function constructor(bytes){
var bytesPos=0;
var cmf=bytes[bytesPos++];
var flg=bytes[bytesPos++];
if(cmf==-1||flg==-1) error("Invalid header in flate stream");
if((cmf & 0x0f)!=0x08)
error("Unknown compression method in flate stream");
if(((cmf << 8) + flg) % 31!=0) error("Bad FCHECK in flate stream");
if(flg & 0x20) error("FDICT bit set in flate stream");
this.bytes=bytes;
this.bytesPos=bytesPos;
this.codeSize=0;
this.codeBuf=0;
DecodeStream.call(this);
}
constructor.prototype=Object.create(DecodeStream.prototype);
constructor.prototype.getBits=function(bits){
var codeSize=this.codeSize;
var codeBuf=this.codeBuf;
var bytes=this.bytes;
var bytesPos=this.bytesPos;
var b;
while (codeSize < bits){
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad encoding in flate stream");
codeBuf |=b << codeSize;
codeSize +=8;
}
b=codeBuf & ((1 << bits) - 1);
this.codeBuf=codeBuf >> bits;
this.codeSize=codeSize -=bits;
this.bytesPos=bytesPos;
return b;
};
constructor.prototype.getCode=function(table){
var codes=table[0];
var maxLen=table[1];
var codeSize=this.codeSize;
var codeBuf=this.codeBuf;
var bytes=this.bytes;
var bytesPos=this.bytesPos;
while (codeSize < maxLen){
var b;
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad encoding in flate stream");
codeBuf |=b << codeSize;
codeSize +=8;
}
var code=codes[codeBuf & ((1 << maxLen) - 1)];
var codeLen=code >> 16;
var codeVal=code & 0xffff;
if(codeSize==0||codeSize < codeLen||codeLen==0)
error("Bad encoding in flate stream");
this.codeBuf=codeBuf >> codeLen;
this.codeSize=codeSize - codeLen;
this.bytesPos=bytesPos;
return codeVal;
};
constructor.prototype.generateHuffmanTable=function(lengths){
var n=lengths.length;
var maxLen=0;
for (var i=0; i < n; ++i){
if(lengths[i] > maxLen) maxLen=lengths[i];
}
var size=1 << maxLen;
var codes=new Uint32Array(size);
for (
var len=1, code=0, skip=2;
len <=maxLen;
++len, code <<=1, skip <<=1
){
for (var val=0; val < n; ++val){
if(lengths[val]==len){
var code2=0;
var t=code;
for (var i=0; i < len; ++i){
code2=(code2 << 1) | (t & 1);
t >>=1;
}
for (var i=code2; i < size; i +=skip) codes[i]=(len << 16) | val;
++code;
}}
}
return [codes, maxLen];
};
constructor.prototype.readBlock=function(){
function repeat(stream, array, len, offset, what){
var repeat=stream.getBits(len) + offset;
while (repeat-- > 0) array[i++]=what;
}
var hdr=this.getBits(3);
if(hdr & 1) this.eof=true;
hdr >>=1;
if(hdr==0){
var bytes=this.bytes;
var bytesPos=this.bytesPos;
var b;
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad block header in flate stream");
var blockLen=b;
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad block header in flate stream");
blockLen |=b << 8;
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad block header in flate stream");
var check=b;
if(typeof (b=bytes[bytesPos++])=="undefined")
error("Bad block header in flate stream");
check |=b << 8;
if(check!=(~blockLen & 0xffff))
error("Bad uncompressed block length in flate stream");
this.codeBuf=0;
this.codeSize=0;
var bufferLength=this.bufferLength;
var buffer=this.ensureBuffer(bufferLength + blockLen);
var end=bufferLength + blockLen;
this.bufferLength=end;
for (var n=bufferLength; n < end; ++n){
if(typeof (b=bytes[bytesPos++])=="undefined"){
this.eof=true;
break;
}
buffer[n]=b;
}
this.bytesPos=bytesPos;
return;
}
var litCodeTable;
var distCodeTable;
if(hdr==1){
litCodeTable=fixedLitCodeTab;
distCodeTable=fixedDistCodeTab;
}else if(hdr==2){
var numLitCodes=this.getBits(5) + 257;
var numDistCodes=this.getBits(5) + 1;
var numCodeLenCodes=this.getBits(4) + 4;
var codeLenCodeLengths=Array(codeLenCodeMap.length);
var i=0;
while (i < numCodeLenCodes)
codeLenCodeLengths[codeLenCodeMap[i++]]=this.getBits(3);
var codeLenCodeTab=this.generateHuffmanTable(codeLenCodeLengths);
var len=0;
var i=0;
var codes=numLitCodes + numDistCodes;
var codeLengths=new Array(codes);
while (i < codes){
var code=this.getCode(codeLenCodeTab);
if(code==16){
repeat(this, codeLengths, 2, 3, len);
}else if(code==17){
repeat(this, codeLengths, 3, 3, (len=0));
}else if(code==18){
repeat(this, codeLengths, 7, 11, (len=0));
}else{
codeLengths[i++]=len=code;
}}
litCodeTable=this.generateHuffmanTable(codeLengths.slice(0, numLitCodes)
);
distCodeTable=this.generateHuffmanTable(codeLengths.slice(numLitCodes, codes)
);
}else{
error("Unknown block type in flate stream");
}
var buffer=this.buffer;
var limit=buffer ? buffer.length:0;
var pos=this.bufferLength;
while (true){
var code1=this.getCode(litCodeTable);
if(code1 < 256){
if(pos + 1 >=limit){
buffer=this.ensureBuffer(pos + 1);
limit=buffer.length;
}
buffer[pos++]=code1;
continue;
}
if(code1==256){
this.bufferLength=pos;
return;
}
code1 -=257;
code1=lengthDecode[code1];
var code2=code1 >> 16;
if(code2 > 0) code2=this.getBits(code2);
var len=(code1 & 0xffff) + code2;
code1=this.getCode(distCodeTable);
code1=distDecode[code1];
code2=code1 >> 16;
if(code2 > 0) code2=this.getBits(code2);
var dist=(code1 & 0xffff) + code2;
if(pos + len >=limit){
buffer=this.ensureBuffer(pos + len);
limit=buffer.length;
}
for (var k=0; k < len; ++k, ++pos) buffer[pos]=buffer[pos - dist];
}};
return constructor;
})());
var PNG=(function(){
var APNG_BLEND_OP_SOURCE,
APNG_DISPOSE_OP_BACKGROUND,
APNG_DISPOSE_OP_PREVIOUS,
makeImage,
scratchCanvas,
scratchCtx;
APNG_DISPOSE_OP_BACKGROUND=1;
APNG_DISPOSE_OP_PREVIOUS=2;
APNG_BLEND_OP_SOURCE=0;
function PNG(data){
var chunkSize,
colors,
palLen,
delayDen,
delayNum,
frame,
i,
index,
key,
section,
palShort,
text,
_i,
_j,
_ref;
this.data=data;
this.pos=8;
this.palette=[];
this.imgData=[];
this.transparency={};
this.animation=null;
this.text={};
frame=null;
while (true){
chunkSize=this.readUInt32();
section=function(){
var _i, _results;
_results=[];
for (i=_i=0; _i < 4; i=++_i){
_results.push(String.fromCharCode(this.data[this.pos++]));
}
return _results;
}
.call(this)
.join("");
switch (section){
case "IHDR":
this.width=this.readUInt32();
this.height=this.readUInt32();
this.bits=this.data[this.pos++];
this.colorType=this.data[this.pos++];
this.compressionMethod=this.data[this.pos++];
this.filterMethod=this.data[this.pos++];
this.interlaceMethod=this.data[this.pos++];
break;
case "acTL":
this.animation={
numFrames: this.readUInt32(),
numPlays: this.readUInt32()||Infinity,
frames: []
};
break;
case "PLTE":
this.palette=this.read(chunkSize);
break;
case "fcTL":
if(frame){
this.animation.frames.push(frame);
}
this.pos +=4;
frame={
width: this.readUInt32(),
height: this.readUInt32(),
xOffset: this.readUInt32(),
yOffset: this.readUInt32()
};
delayNum=this.readUInt16();
delayDen=this.readUInt16()||100;
frame.delay=(1000 * delayNum) / delayDen;
frame.disposeOp=this.data[this.pos++];
frame.blendOp=this.data[this.pos++];
frame.data=[];
break;
case "IDAT":
case "fdAT":
if(section==="fdAT"){
this.pos +=4;
chunkSize -=4;
}
data=(frame!=null ? frame.data:void 0)||this.imgData;
for (
i=_i=0;
0 <=chunkSize ? _i < chunkSize:_i > chunkSize;
i=0 <=chunkSize ? ++_i:--_i
){
data.push(this.data[this.pos++]);
}
break;
case "tRNS":
this.transparency={};
switch (this.colorType){
case 3:
palLen=this.palette.length / 3;
this.transparency.indexed=this.read(chunkSize);
if(this.transparency.indexed.length > palLen)
throw new Error("More transparent colors than palette size");
palShort=palLen - this.transparency.indexed.length;
if(palShort > 0){
for (
i=_j=0;
0 <=palShort ? _j < palShort:_j > palShort;
i=0 <=palShort ? ++_j:--_j
){
this.transparency.indexed.push(255);
}}
break;
case 0:
this.transparency.grayscale=this.read(chunkSize)[0];
break;
case 2:
this.transparency.rgb=this.read(chunkSize);
}
break;
case "tEXt":
text=this.read(chunkSize);
index=text.indexOf(0);
key=String.fromCharCode.apply(String, text.slice(0, index));
this.text[key]=String.fromCharCode.apply(String,
text.slice(index + 1)
);
break;
case "IEND":
if(frame){
this.animation.frames.push(frame);
}
this.colors=function(){
switch (this.colorType){
case 0:
case 3:
case 4:
return 1;
case 2:
case 6:
return 3;
}}.call(this);
this.hasAlphaChannel=(_ref=this.colorType)===4||_ref===6;
colors=this.colors + (this.hasAlphaChannel ? 1:0);
this.pixelBitlength=this.bits * colors;
this.colorSpace=function(){
switch (this.colors){
case 1:
return "DeviceGray";
case 3:
return "DeviceRGB";
}}.call(this);
this.imgData=new Uint8Array(this.imgData);
return;
default:
this.pos +=chunkSize;
}
this.pos +=4;
if(this.pos > this.data.length){
throw new Error("Incomplete or corrupt PNG file");
}}
}
PNG.prototype.read=function(bytes){
var i, _i, _results;
_results=[];
for (
i=_i=0;
0 <=bytes ? _i < bytes:_i > bytes;
i=0 <=bytes ? ++_i:--_i
){
_results.push(this.data[this.pos++]);
}
return _results;
};
PNG.prototype.readUInt32=function(){
var b1, b2, b3, b4;
b1=this.data[this.pos++] << 24;
b2=this.data[this.pos++] << 16;
b3=this.data[this.pos++] << 8;
b4=this.data[this.pos++];
return b1 | b2 | b3 | b4;
};
PNG.prototype.readUInt16=function(){
var b1, b2;
b1=this.data[this.pos++] << 8;
b2=this.data[this.pos++];
return b1 | b2;
};
PNG.prototype.decodePixels=function(data){
var pixelBytes=this.pixelBitlength / 8;
var fullPixels=new Uint8Array(this.width * this.height * pixelBytes);
var pos=0;
var _this=this;
if(data==null){
data=this.imgData;
}
if(data.length===0){
return new Uint8Array(0);
}
data=new FlateStream(data);
data=data.getBytes();
function pass(x0, y0, dx, dy){
var abyte,
c,
col,
i,
left,
length,
p,
pa,
paeth,
pb,
pc,
pixels,
row,
scanlineLength,
upper,
upperLeft,
_i,
_j,
_k,
_l,
_m;
var w=Math.ceil((_this.width - x0) / dx),
h=Math.ceil((_this.height - y0) / dy);
var isFull=_this.width==w&&_this.height==h;
scanlineLength=pixelBytes * w;
pixels=isFull ? fullPixels:new Uint8Array(scanlineLength * h);
length=data.length;
row=0;
c=0;
while (row < h&&pos < length){
switch (data[pos++]){
case 0:
for (i=_i=0; _i < scanlineLength; i=_i +=1){
pixels[c++]=data[pos++];
}
break;
case 1:
for (i=_j=0; _j < scanlineLength; i=_j +=1){
abyte=data[pos++];
left=i < pixelBytes ? 0:pixels[c - pixelBytes];
pixels[c++]=(abyte + left) % 256;
}
break;
case 2:
for (i=_k=0; _k < scanlineLength; i=_k +=1){
abyte=data[pos++];
col=(i - (i % pixelBytes)) / pixelBytes;
upper =
row &&
pixels[
(row - 1) * scanlineLength +
col * pixelBytes +
(i % pixelBytes)
];
pixels[c++]=(upper + abyte) % 256;
}
break;
case 3:
for (i=_l=0; _l < scanlineLength; i=_l +=1){
abyte=data[pos++];
col=(i - (i % pixelBytes)) / pixelBytes;
left=i < pixelBytes ? 0:pixels[c - pixelBytes];
upper =
row &&
pixels[
(row - 1) * scanlineLength +
col * pixelBytes +
(i % pixelBytes)
];
pixels[c++]=(abyte + Math.floor((left + upper) / 2)) % 256;
}
break;
case 4:
for (i=_m=0; _m < scanlineLength; i=_m +=1){
abyte=data[pos++];
col=(i - (i % pixelBytes)) / pixelBytes;
left=i < pixelBytes ? 0:pixels[c - pixelBytes];
if(row===0){
upper=upperLeft=0;
}else{
upper =
pixels[
(row - 1) * scanlineLength +
col * pixelBytes +
(i % pixelBytes)
];
upperLeft =
col &&
pixels[
(row - 1) * scanlineLength +
(col - 1) * pixelBytes +
(i % pixelBytes)
];
}
p=left + upper - upperLeft;
pa=Math.abs(p - left);
pb=Math.abs(p - upper);
pc=Math.abs(p - upperLeft);
if(pa <=pb&&pa <=pc){
paeth=left;
}else if(pb <=pc){
paeth=upper;
}else{
paeth=upperLeft;
}
pixels[c++]=(abyte + paeth) % 256;
}
break;
default:
throw new Error("Invalid filter algorithm: " + data[pos - 1]);
}
if(!isFull){
var fullPos=((y0 + row * dy) * _this.width + x0) * pixelBytes;
var partPos=row * scanlineLength;
for (i=0; i < w; i +=1){
for (var j=0; j < pixelBytes; j +=1)
fullPixels[fullPos++]=pixels[partPos++];
fullPos +=(dx - 1) * pixelBytes;
}}
row++;
}}
if(_this.interlaceMethod==1){
pass(0, 0, 8, 8);
pass(4, 0, 8, 8);
pass(0, 4, 4, 8);
pass(2, 0, 4, 4);
pass(0, 2, 2, 4);
pass(1, 0, 2, 2);
pass(0, 1, 1, 2);
}else{
pass(0, 0, 1, 1);
}
return fullPixels;
};
PNG.prototype.decodePalette=function(){
var c, i, length, palette, pos, ret, transparency, _i, _ref, _ref1;
palette=this.palette;
transparency=this.transparency.indexed||[];
ret=new Uint8Array((transparency.length||0) + palette.length);
pos=0;
length=palette.length;
c=0;
for (i=_i=0, _ref=length; _i < _ref; i=_i +=3){
ret[pos++]=palette[i];
ret[pos++]=palette[i + 1];
ret[pos++]=palette[i + 2];
ret[pos++]=(_ref1=transparency[c++])!=null ? _ref1:255;
}
return ret;
};
PNG.prototype.copyToImageData=function(imageData, pixels){
var alpha, colors, data, i, input, j, k, length, palette, v, _ref;
colors=this.colors;
palette=null;
alpha=this.hasAlphaChannel;
if(this.palette.length){
palette =
(_ref=this._decodedPalette)!=null
? _ref
: (this._decodedPalette=this.decodePalette());
colors=4;
alpha=true;
}
data=imageData.data||imageData;
length=data.length;
input=palette||pixels;
i=j = 0;
if(colors===1){
while (i < length){
k=palette ? pixels[i / 4] * 4:j;
v=input[k++];
data[i++]=v;
data[i++]=v;
data[i++]=v;
data[i++]=alpha ? input[k++]:255;
j=k;
}}else{
while (i < length){
k=palette ? pixels[i / 4] * 4:j;
data[i++]=input[k++];
data[i++]=input[k++];
data[i++]=input[k++];
data[i++]=alpha ? input[k++]:255;
j=k;
}}
};
PNG.prototype.decode=function(){
var ret;
ret=new Uint8Array(this.width * this.height * 4);
this.copyToImageData(ret, this.decodePixels());
return ret;
};
var hasBrowserCanvas=function(){
if(Object.prototype.toString.call(globalObject)==="[object Window]"){
try {
scratchCanvas=globalObject.document.createElement("canvas");
scratchCtx=scratchCanvas.getContext("2d");
} catch (e){
return false;
}
return true;
}
return false;
};
hasBrowserCanvas();
makeImage=function(imageData){
if(hasBrowserCanvas()===true){
var img;
scratchCtx.width=imageData.width;
scratchCtx.height=imageData.height;
scratchCtx.clearRect(0, 0, imageData.width, imageData.height);
scratchCtx.putImageData(imageData, 0, 0);
img=new Image();
img.src=scratchCanvas.toDataURL();
return img;
}
throw new Error("This method requires a Browser with Canvas-capability.");
};
PNG.prototype.decodeFrames=function(ctx){
var frame, i, imageData, pixels, _i, _len, _ref, _results;
if(!this.animation){
return;
}
_ref=this.animation.frames;
_results=[];
for (i=_i=0, _len=_ref.length; _i < _len; i=++_i){
frame=_ref[i];
imageData=ctx.createImageData(frame.width, frame.height);
pixels=this.decodePixels(new Uint8Array(frame.data));
this.copyToImageData(imageData, pixels);
frame.imageData=imageData;
_results.push((frame.image=makeImage(imageData)));
}
return _results;
};
PNG.prototype.renderFrame=function(ctx, number){
var frame, frames, prev;
frames=this.animation.frames;
frame=frames[number];
prev=frames[number - 1];
if(number===0){
ctx.clearRect(0, 0, this.width, this.height);
}
if((prev!=null ? prev.disposeOp:void 0)===APNG_DISPOSE_OP_BACKGROUND
){
ctx.clearRect(prev.xOffset, prev.yOffset, prev.width, prev.height);
}else if((prev!=null ? prev.disposeOp:void 0)===APNG_DISPOSE_OP_PREVIOUS
){
ctx.putImageData(prev.imageData, prev.xOffset, prev.yOffset);
}
if(frame.blendOp===APNG_BLEND_OP_SOURCE){
ctx.clearRect(frame.xOffset, frame.yOffset, frame.width, frame.height);
}
return ctx.drawImage(frame.image, frame.xOffset, frame.yOffset);
};
PNG.prototype.animate=function(ctx){
var doFrame,
frameNumber,
frames,
numFrames,
numPlays,
_ref,
_this=this;
frameNumber=0;
(_ref=this.animation),
(numFrames=_ref.numFrames),
(frames=_ref.frames),
(numPlays=_ref.numPlays);
return (doFrame=function(){
var f, frame;
f=frameNumber++ % numFrames;
frame=frames[f];
_this.renderFrame(ctx, f);
if(numFrames > 1&&frameNumber / numFrames < numPlays){
return (_this.animation._timeout=setTimeout(doFrame, frame.delay));
}})();
};
PNG.prototype.stopAnimation=function(){
var _ref;
return clearTimeout(
(_ref=this.animation)!=null ? _ref._timeout:void 0
);
};
PNG.prototype.render=function(canvas){
var ctx, data;
if(canvas._png){
canvas._png.stopAnimation();
}
canvas._png=this;
canvas.width=this.width;
canvas.height=this.height;
ctx=canvas.getContext("2d");
if(this.animation){
this.decodeFrames(ctx);
return this.animate(ctx);
}else{
data=ctx.createImageData(this.width, this.height);
this.copyToImageData(data, this.decodePixels());
return ctx.putImageData(data, 0, 0);
}};
return PNG;
})();
(function(jsPDFAPI){
var canCompress=function(value){
return value!==jsPDFAPI.image_compression.NONE&&hasCompressionJS();
};
var hasCompressionJS=function(){
return typeof Deflater==="function";
};
var compressBytes=function(bytes, lineLength, colorsPerPixel, compression){
var level=5;
var filter_method=filterUp;
switch (compression){
case jsPDFAPI.image_compression.FAST:
level=3;
filter_method=filterSub;
break;
case jsPDFAPI.image_compression.MEDIUM:
level=6;
filter_method=filterAverage;
break;
case jsPDFAPI.image_compression.SLOW:
level=9;
filter_method=filterPaeth;
break;
}
bytes=applyPngFilterMethod(
bytes,
lineLength,
colorsPerPixel,
filter_method
);
var header=new Uint8Array(createZlibHeader(level));
var checksum=jsPDF.API.adler32cs.fromBuffer(bytes.buffer);
var deflate=new Deflater(level);
var a=deflate.append(bytes);
var cBytes=deflate.flush();
var len=header.length + a.length + cBytes.length;
var cmpd=new Uint8Array(len + 4);
cmpd.set(header);
cmpd.set(a, header.length);
cmpd.set(cBytes, header.length + a.length);
cmpd[len++]=(checksum >>> 24) & 0xff;
cmpd[len++]=(checksum >>> 16) & 0xff;
cmpd[len++]=(checksum >>> 8) & 0xff;
cmpd[len++]=checksum & 0xff;
return jsPDFAPI.__addimage__.arrayBufferToBinaryString(cmpd);
};
var createZlibHeader=function(level){
var hdr=30720;
var flevel=Math.min(3, ((level - 1) & 0xff) >> 1);
hdr |=flevel << 6;
hdr |=0;
hdr +=31 - (hdr % 31);
return [120, hdr & 0xff & 0xff];
};
var applyPngFilterMethod=function(
bytes,
lineLength,
colorsPerPixel,
filter_method
){
var lines=bytes.length / lineLength,
result=new Uint8Array(bytes.length + lines),
filter_methods=getFilterMethods(),
line,
prevLine,
offset;
for (var i=0; i < lines; i +=1){
offset=i * lineLength;
line=bytes.subarray(offset, offset + lineLength);
if(filter_method){
result.set(filter_method(line, colorsPerPixel, prevLine), offset + i);
}else{
var len=filter_methods.length,
results=[];
for (var j; j < len; j +=1){
results[j]=filter_methods[j](line, colorsPerPixel, prevLine);
}
var ind=getIndexOfSmallestSum(results.concat());
result.set(results[ind], offset + i);
}
prevLine=line;
}
return result;
};
var filterNone=function(line){
var result=Array.apply([], line);
result.unshift(0);
return result;
};
var filterSub=function(line, colorsPerPixel){
var result=[],
len=line.length,
left;
result[0]=1;
for (var i=0; i < len; i +=1){
left=line[i - colorsPerPixel]||0;
result[i + 1]=(line[i] - left + 0x0100) & 0xff;
}
return result;
};
var filterUp=function(line, colorsPerPixel, prevLine){
var result=[],
len=line.length,
up;
result[0]=2;
for (var i=0; i < len; i +=1){
up=(prevLine&&prevLine[i])||0;
result[i + 1]=(line[i] - up + 0x0100) & 0xff;
}
return result;
};
var filterAverage=function(line, colorsPerPixel, prevLine){
var result=[],
len=line.length,
left,
up;
result[0]=3;
for (var i=0; i < len; i +=1){
left=line[i - colorsPerPixel]||0;
up=(prevLine&&prevLine[i])||0;
result[i + 1]=(line[i] + 0x0100 - ((left + up) >>> 1)) & 0xff;
}
return result;
};
var filterPaeth=function(line, colorsPerPixel, prevLine){
var result=[],
len=line.length,
left,
up,
upLeft,
paeth;
result[0]=4;
for (var i=0; i < len; i +=1){
left=line[i - colorsPerPixel]||0;
up=(prevLine&&prevLine[i])||0;
upLeft=(prevLine&&prevLine[i - colorsPerPixel])||0;
paeth=paethPredictor(left, up, upLeft);
result[i + 1]=(line[i] - paeth + 0x0100) & 0xff;
}
return result;
};
var paethPredictor=function(left, up, upLeft){
if(left===up&&up===upLeft){
return left;
}
var pLeft=Math.abs(up - upLeft),
pUp=Math.abs(left - upLeft),
pUpLeft=Math.abs(left + up - upLeft - upLeft);
return pLeft <=pUp&&pLeft <=pUpLeft
? left
: pUp <=pUpLeft
? up
: upLeft;
};
var getFilterMethods=function(){
return [filterNone, filterSub, filterUp, filterAverage, filterPaeth];
};
var getIndexOfSmallestSum=function(arrays){
var sum=arrays.map(function(value){
return value.reduce(function(pv, cv){
return pv + Math.abs(cv);
}, 0);
});
return sum.indexOf(Math.min.apply(null, sum));
};
var getPredictorFromCompression=function(compression){
var predictor;
switch (compression){
case jsPDFAPI.image_compression.FAST:
predictor=11;
break;
case jsPDFAPI.image_compression.MEDIUM:
predictor=13;
break;
case jsPDFAPI.image_compression.SLOW:
predictor=14;
break;
default:
predictor=12;
break;
}
return predictor;
};
jsPDFAPI.processPNG=function(imageData, index, alias, compression){
var colorSpace,
filter=this.decode.FLATE_DECODE,
bitsPerComponent,
image,
decodeParameters="",
trns,
colors,
pal,
smask,
pixels,
len,
alphaData,
imgData,
hasColors,
pixel,
i,
n;
if(this.__addimage__.isArrayBuffer(imageData))
imageData=new Uint8Array(imageData);
if(this.__addimage__.isArrayBufferView(imageData)){
image=new PNG(imageData);
imageData=image.imgData;
bitsPerComponent=image.bits;
colorSpace=image.colorSpace;
colors=image.colors;
if([4, 6].indexOf(image.colorType)!==-1){
if(image.bits===8){
pixels =
image.pixelBitlength==32
? new Uint32Array(image.decodePixels().buffer)
: image.pixelBitlength==16
? new Uint16Array(image.decodePixels().buffer)
: new Uint8Array(image.decodePixels().buffer);
len=pixels.length;
imgData=new Uint8Array(len * image.colors);
alphaData=new Uint8Array(len);
var pDiff=image.pixelBitlength - image.bits;
i=0;
n=0;
var pbl;
for (; i < len; i++){
pixel=pixels[i];
pbl=0;
while (pbl < pDiff){
imgData[n++]=(pixel >>> pbl) & 0xff;
pbl=pbl + image.bits;
}
alphaData[i]=(pixel >>> pbl) & 0xff;
}}
if(image.bits===16){
pixels=new Uint32Array(image.decodePixels().buffer);
len=pixels.length;
imgData=new Uint8Array(
len * (32 / image.pixelBitlength) * image.colors
);
alphaData=new Uint8Array(len * (32 / image.pixelBitlength));
hasColors=image.colors > 1;
i=0;
n=0;
var a=0;
while (i < len){
pixel=pixels[i++];
imgData[n++]=(pixel >>> 0) & 0xff;
if(hasColors){
imgData[n++]=(pixel >>> 16) & 0xff;
pixel=pixels[i++];
imgData[n++]=(pixel >>> 0) & 0xff;
}
alphaData[a++]=(pixel >>> 16) & 0xff;
}
bitsPerComponent=8;
}
if(canCompress(compression)){
imageData=compressBytes(
imgData,
image.width * image.colors,
image.colors,
compression
);
smask=compressBytes(alphaData, image.width, 1, compression);
}else{
imageData=imgData;
smask=alphaData;
filter=undefined;
}}
if(image.colorType===3){
colorSpace=this.color_spaces.INDEXED;
pal=image.palette;
if(image.transparency.indexed){
var trans=image.transparency.indexed;
var total=0;
i=0;
len=trans.length;
for (; i < len; ++i){
total +=trans[i];
}
total=total / 255;
if(total===len - 1&&trans.indexOf(0)!==-1){
trns=[trans.indexOf(0)];
}else if(total!==len){
pixels=image.decodePixels();
alphaData=new Uint8Array(pixels.length);
i=0;
len=pixels.length;
for (; i < len; i++){
alphaData[i]=trans[pixels[i]];
}
smask=compressBytes(alphaData, image.width, 1);
}}
}
var predictor=getPredictorFromCompression(compression);
if(filter===this.decode.FLATE_DECODE){
decodeParameters="/Predictor " + predictor + " ";
}
decodeParameters +=
"/Colors " +
colors +
" /BitsPerComponent " +
bitsPerComponent +
" /Columns " +
image.width;
if(this.__addimage__.isArrayBuffer(imageData) ||
this.__addimage__.isArrayBufferView(imageData)
){
imageData=this.__addimage__.arrayBufferToBinaryString(imageData);
}
if((smask&&this.__addimage__.isArrayBuffer(smask)) ||
this.__addimage__.isArrayBufferView(smask)
){
smask=this.__addimage__.arrayBufferToBinaryString(smask);
}
return {
alias: alias,
data: imageData,
index: index,
filter: filter,
decodeParameters: decodeParameters,
transparency: trns,
palette: pal,
sMask: smask,
predictor: predictor,
width: image.width,
height: image.height,
bitsPerComponent: bitsPerComponent,
colorSpace: colorSpace
};}};})(jsPDF.API);
function GifReader(buf){
var p=0;
if(buf[p++]!==0x47 ||
buf[p++]!==0x49 ||
buf[p++]!==0x46 ||
buf[p++]!==0x38 ||
((buf[p++] + 1) & 0xfd)!==0x38 ||
buf[p++]!==0x61
){
throw new Error("Invalid GIF 87a/89a header.");
}
var width=buf[p++] | (buf[p++] << 8);
var height=buf[p++] | (buf[p++] << 8);
var pf0=buf[p++];
var global_palette_flag=pf0 >> 7;
var num_global_colors_pow2=pf0 & 0x7;
var num_global_colors=1 << (num_global_colors_pow2 + 1);
var background=buf[p++];
buf[p++];
var global_palette_offset=null;
var global_palette_size=null;
if(global_palette_flag){
global_palette_offset=p;
global_palette_size=num_global_colors;
p +=num_global_colors * 3;
}
var no_eof=true;
var frames=[];
var delay=0;
var transparent_index=null;
var disposal=0;
var loop_count=null;
this.width=width;
this.height=height;
while (no_eof&&p < buf.length){
switch (buf[p++]){
case 0x21:
switch (buf[p++]){
case 0xff:
if(buf[p]!==0x0b ||
(buf[p + 1]==0x4e &&
buf[p + 2]==0x45 &&
buf[p + 3]==0x54 &&
buf[p + 4]==0x53 &&
buf[p + 5]==0x43 &&
buf[p + 6]==0x41 &&
buf[p + 7]==0x50 &&
buf[p + 8]==0x45 &&
buf[p + 9]==0x32 &&
buf[p + 10]==0x2e &&
buf[p + 11]==0x30 &&
buf[p + 12]==0x03 &&
buf[p + 13]==0x01 &&
buf[p + 16]==0)
){
p +=14;
loop_count=buf[p++] | (buf[p++] << 8);
p++;
}else{
p +=12;
while (true){
var block_size=buf[p++];
if(!(block_size >=0)) throw Error("Invalid block size");
if(block_size===0) break;
p +=block_size;
}}
break;
case 0xf9:
if(buf[p++]!==0x4||buf[p + 4]!==0)
throw new Error("Invalid graphics extension block.");
var pf1=buf[p++];
delay=buf[p++] | (buf[p++] << 8);
transparent_index=buf[p++];
if((pf1 & 1)===0) transparent_index=null;
disposal=(pf1 >> 2) & 0x7;
p++;
break;
case 0xfe:
while (true){
var block_size=buf[p++];
if(!(block_size >=0)) throw Error("Invalid block size");
if(block_size===0) break;
p +=block_size;
}
break;
default:
throw new Error(
"Unknown graphic control label: 0x" + buf[p - 1].toString(16)
);
}
break;
case 0x2c:
var x=buf[p++] | (buf[p++] << 8);
var y=buf[p++] | (buf[p++] << 8);
var w=buf[p++] | (buf[p++] << 8);
var h=buf[p++] | (buf[p++] << 8);
var pf2=buf[p++];
var local_palette_flag=pf2 >> 7;
var interlace_flag=(pf2 >> 6) & 1;
var num_local_colors_pow2=pf2 & 0x7;
var num_local_colors=1 << (num_local_colors_pow2 + 1);
var palette_offset=global_palette_offset;
var palette_size=global_palette_size;
var has_local_palette=false;
if(local_palette_flag){
var has_local_palette=true;
palette_offset=p;
palette_size=num_local_colors;
p +=num_local_colors * 3;
}
var data_offset=p;
p++;
while (true){
var block_size=buf[p++];
if(!(block_size >=0)) throw Error("Invalid block size");
if(block_size===0) break;
p +=block_size;
}
frames.push({
x: x,
y: y,
width: w,
height: h,
has_local_palette: has_local_palette,
palette_offset: palette_offset,
palette_size: palette_size,
data_offset: data_offset,
data_length: p - data_offset,
transparent_index: transparent_index,
interlaced: !!interlace_flag,
delay: delay,
disposal: disposal
});
break;
case 0x3b:
no_eof=false;
break;
default:
throw new Error("Unknown gif block: 0x" + buf[p - 1].toString(16));
}}
this.numFrames=function(){
return frames.length;
};
this.loopCount=function(){
return loop_count;
};
this.frameInfo=function(frame_num){
if(frame_num < 0||frame_num >=frames.length)
throw new Error("Frame index out of range.");
return frames[frame_num];
};
this.decodeAndBlitFrameBGRA=function(frame_num, pixels){
var frame=this.frameInfo(frame_num);
var num_pixels=frame.width * frame.height;
var index_stream=new Uint8Array(num_pixels);
GifReaderLZWOutputIndexStream(
buf,
frame.data_offset,
index_stream,
num_pixels
);
var palette_offset=frame.palette_offset;
var trans=frame.transparent_index;
if(trans===null) trans=256;
var framewidth=frame.width;
var framestride=width - framewidth;
var xleft=framewidth;
var opbeg=(frame.y * width + frame.x) * 4;
var opend=((frame.y + frame.height) * width + frame.x) * 4;
var op=opbeg;
var scanstride=framestride * 4;
if(frame.interlaced===true){
scanstride +=width * 4 * 7;
}
var interlaceskip=8;
for (var i=0, il=index_stream.length; i < il; ++i){
var index=index_stream[i];
if(xleft===0){
op +=scanstride;
xleft=framewidth;
if(op >=opend){
scanstride=framestride * 4 + width * 4 * (interlaceskip - 1);
op=opbeg + (framewidth + framestride) * (interlaceskip << 1);
interlaceskip >>=1;
}}
if(index===trans){
op +=4;
}else{
var r=buf[palette_offset + index * 3];
var g=buf[palette_offset + index * 3 + 1];
var b=buf[palette_offset + index * 3 + 2];
pixels[op++]=b;
pixels[op++]=g;
pixels[op++]=r;
pixels[op++]=255;
}
--xleft;
}};
this.decodeAndBlitFrameRGBA=function(frame_num, pixels){
var frame=this.frameInfo(frame_num);
var num_pixels=frame.width * frame.height;
var index_stream=new Uint8Array(num_pixels);
GifReaderLZWOutputIndexStream(
buf,
frame.data_offset,
index_stream,
num_pixels
);
var palette_offset=frame.palette_offset;
var trans=frame.transparent_index;
if(trans===null) trans=256;
var framewidth=frame.width;
var framestride=width - framewidth;
var xleft=framewidth;
var opbeg=(frame.y * width + frame.x) * 4;
var opend=((frame.y + frame.height) * width + frame.x) * 4;
var op=opbeg;
var scanstride=framestride * 4;
if(frame.interlaced===true){
scanstride +=width * 4 * 7;
}
var interlaceskip=8;
for (var i=0, il=index_stream.length; i < il; ++i){
var index=index_stream[i];
if(xleft===0){
op +=scanstride;
xleft=framewidth;
if(op >=opend){
scanstride=framestride * 4 + width * 4 * (interlaceskip - 1);
op=opbeg + (framewidth + framestride) * (interlaceskip << 1);
interlaceskip >>=1;
}}
if(index===trans){
op +=4;
}else{
var r=buf[palette_offset + index * 3];
var g=buf[palette_offset + index * 3 + 1];
var b=buf[palette_offset + index * 3 + 2];
pixels[op++]=r;
pixels[op++]=g;
pixels[op++]=b;
pixels[op++]=255;
}
--xleft;
}};}
function GifReaderLZWOutputIndexStream(code_stream, p, output, output_length){
var min_code_size=code_stream[p++];
var clear_code=1 << min_code_size;
var eoi_code=clear_code + 1;
var next_code=eoi_code + 1;
var cur_code_size=min_code_size + 1;
var code_mask=(1 << cur_code_size) - 1;
var cur_shift=0;
var cur=0;
var op=0;
var subblock_size=code_stream[p++];
var code_table=new Int32Array(4096);
var prev_code=null;
while (true){
while (cur_shift < 16){
if(subblock_size===0) break;
cur |=code_stream[p++] << cur_shift;
cur_shift +=8;
if(subblock_size===1){
subblock_size=code_stream[p++];
}else{
--subblock_size;
}}
if(cur_shift < cur_code_size) break;
var code=cur & code_mask;
cur >>=cur_code_size;
cur_shift -=cur_code_size;
if(code===clear_code){
next_code=eoi_code + 1;
cur_code_size=min_code_size + 1;
code_mask=(1 << cur_code_size) - 1;
prev_code=null;
continue;
}else if(code===eoi_code){
break;
}
var chase_code=code < next_code ? code:prev_code;
var chase_length=0;
var chase=chase_code;
while (chase > clear_code){
chase=code_table[chase] >> 8;
++chase_length;
}
var k=chase;
var op_end=op + chase_length + (chase_code!==code ? 1:0);
if(op_end > output_length){
console.log("Warning, gif stream longer than expected.");
return;
}
output[op++]=k;
op +=chase_length;
var b=op;
if(chase_code!==code)
output[op++]=k;
chase=chase_code;
while (chase_length--){
chase=code_table[chase];
output[--b]=chase & 0xff;
chase >>=8;
}
if(prev_code!==null&&next_code < 4096){
code_table[next_code++]=(prev_code << 8) | k;
if(next_code >=code_mask + 1&&cur_code_size < 12){
++cur_code_size;
code_mask=(code_mask << 1) | 1;
}}
prev_code=code;
}
if(op!==output_length){
console.log("Warning, gif stream shorter than expected.");
}
return output;
}
function JPEGEncoder(quality){
var ffloor=Math.floor;
var YTable=new Array(64);
var UVTable=new Array(64);
var fdtbl_Y=new Array(64);
var fdtbl_UV=new Array(64);
var YDC_HT;
var UVDC_HT;
var YAC_HT;
var UVAC_HT;
var bitcode=new Array(65535);
var category=new Array(65535);
var outputfDCTQuant=new Array(64);
var DU=new Array(64);
var byteout=[];
var bytenew=0;
var bytepos=7;
var YDU=new Array(64);
var UDU=new Array(64);
var VDU=new Array(64);
var clt=new Array(256);
var RGB_YUV_TABLE=new Array(2048);
var currentQuality;
var ZigZag=[
0,
1,
5,
6,
14,
15,
27,
28,
2,
4,
7,
13,
16,
26,
29,
42,
3,
8,
12,
17,
25,
30,
41,
43,
9,
11,
18,
24,
31,
40,
44,
53,
10,
19,
23,
32,
39,
45,
52,
54,
20,
22,
33,
38,
46,
51,
55,
60,
21,
34,
37,
47,
50,
56,
59,
61,
35,
36,
48,
49,
57,
58,
62,
63
];
var std_dc_luminance_nrcodes=[
0,
0,
1,
5,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0
];
var std_dc_luminance_values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
var std_ac_luminance_nrcodes=[
0,
0,
2,
1,
3,
3,
2,
4,
3,
5,
5,
4,
4,
0,
0,
1,
0x7d
];
var std_ac_luminance_values=[
0x01,
0x02,
0x03,
0x00,
0x04,
0x11,
0x05,
0x12,
0x21,
0x31,
0x41,
0x06,
0x13,
0x51,
0x61,
0x07,
0x22,
0x71,
0x14,
0x32,
0x81,
0x91,
0xa1,
0x08,
0x23,
0x42,
0xb1,
0xc1,
0x15,
0x52,
0xd1,
0xf0,
0x24,
0x33,
0x62,
0x72,
0x82,
0x09,
0x0a,
0x16,
0x17,
0x18,
0x19,
0x1a,
0x25,
0x26,
0x27,
0x28,
0x29,
0x2a,
0x34,
0x35,
0x36,
0x37,
0x38,
0x39,
0x3a,
0x43,
0x44,
0x45,
0x46,
0x47,
0x48,
0x49,
0x4a,
0x53,
0x54,
0x55,
0x56,
0x57,
0x58,
0x59,
0x5a,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x83,
0x84,
0x85,
0x86,
0x87,
0x88,
0x89,
0x8a,
0x92,
0x93,
0x94,
0x95,
0x96,
0x97,
0x98,
0x99,
0x9a,
0xa2,
0xa3,
0xa4,
0xa5,
0xa6,
0xa7,
0xa8,
0xa9,
0xaa,
0xb2,
0xb3,
0xb4,
0xb5,
0xb6,
0xb7,
0xb8,
0xb9,
0xba,
0xc2,
0xc3,
0xc4,
0xc5,
0xc6,
0xc7,
0xc8,
0xc9,
0xca,
0xd2,
0xd3,
0xd4,
0xd5,
0xd6,
0xd7,
0xd8,
0xd9,
0xda,
0xe1,
0xe2,
0xe3,
0xe4,
0xe5,
0xe6,
0xe7,
0xe8,
0xe9,
0xea,
0xf1,
0xf2,
0xf3,
0xf4,
0xf5,
0xf6,
0xf7,
0xf8,
0xf9,
0xfa
];
var std_dc_chrominance_nrcodes=[
0,
0,
3,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0
];
var std_dc_chrominance_values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
var std_ac_chrominance_nrcodes=[
0,
0,
2,
1,
2,
4,
4,
3,
4,
7,
5,
4,
4,
0,
1,
2,
0x77
];
var std_ac_chrominance_values=[
0x00,
0x01,
0x02,
0x03,
0x11,
0x04,
0x05,
0x21,
0x31,
0x06,
0x12,
0x41,
0x51,
0x07,
0x61,
0x71,
0x13,
0x22,
0x32,
0x81,
0x08,
0x14,
0x42,
0x91,
0xa1,
0xb1,
0xc1,
0x09,
0x23,
0x33,
0x52,
0xf0,
0x15,
0x62,
0x72,
0xd1,
0x0a,
0x16,
0x24,
0x34,
0xe1,
0x25,
0xf1,
0x17,
0x18,
0x19,
0x1a,
0x26,
0x27,
0x28,
0x29,
0x2a,
0x35,
0x36,
0x37,
0x38,
0x39,
0x3a,
0x43,
0x44,
0x45,
0x46,
0x47,
0x48,
0x49,
0x4a,
0x53,
0x54,
0x55,
0x56,
0x57,
0x58,
0x59,
0x5a,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x82,
0x83,
0x84,
0x85,
0x86,
0x87,
0x88,
0x89,
0x8a,
0x92,
0x93,
0x94,
0x95,
0x96,
0x97,
0x98,
0x99,
0x9a,
0xa2,
0xa3,
0xa4,
0xa5,
0xa6,
0xa7,
0xa8,
0xa9,
0xaa,
0xb2,
0xb3,
0xb4,
0xb5,
0xb6,
0xb7,
0xb8,
0xb9,
0xba,
0xc2,
0xc3,
0xc4,
0xc5,
0xc6,
0xc7,
0xc8,
0xc9,
0xca,
0xd2,
0xd3,
0xd4,
0xd5,
0xd6,
0xd7,
0xd8,
0xd9,
0xda,
0xe2,
0xe3,
0xe4,
0xe5,
0xe6,
0xe7,
0xe8,
0xe9,
0xea,
0xf2,
0xf3,
0xf4,
0xf5,
0xf6,
0xf7,
0xf8,
0xf9,
0xfa
];
function initQuantTables(sf){
var YQT=[
16,
11,
10,
16,
24,
40,
51,
61,
12,
12,
14,
19,
26,
58,
60,
55,
14,
13,
16,
24,
40,
57,
69,
56,
14,
17,
22,
29,
51,
87,
80,
62,
18,
22,
37,
56,
68,
109,
103,
77,
24,
35,
55,
64,
81,
104,
113,
92,
49,
64,
78,
87,
103,
121,
120,
101,
72,
92,
95,
98,
112,
100,
103,
99
];
for (var i=0; i < 64; i++){
var t=ffloor((YQT[i] * sf + 50) / 100);
t=Math.min(Math.max(t, 1), 255);
YTable[ZigZag[i]]=t;
}
var UVQT=[
17,
18,
24,
47,
99,
99,
99,
99,
18,
21,
26,
66,
99,
99,
99,
99,
24,
26,
56,
99,
99,
99,
99,
99,
47,
66,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99,
99
];
for (var j=0; j < 64; j++){
var u=ffloor((UVQT[j] * sf + 50) / 100);
u=Math.min(Math.max(u, 1), 255);
UVTable[ZigZag[j]]=u;
}
var aasf=[
1.0,
1.387039845,
1.306562965,
1.175875602,
1.0,
0.785694958,
0.5411961,
0.275899379
];
var k=0;
for (var row=0; row < 8; row++){
for (var col=0; col < 8; col++){
fdtbl_Y[k]=1.0 / (YTable[ZigZag[k]] * aasf[row] * aasf[col] * 8.0);
fdtbl_UV[k]=1.0 / (UVTable[ZigZag[k]] * aasf[row] * aasf[col] * 8.0);
k++;
}}
}
function computeHuffmanTbl(nrcodes, std_table){
var codevalue=0;
var pos_in_table=0;
var HT=new Array();
for (var k=1; k <=16; k++){
for (var j=1; j <=nrcodes[k]; j++){
HT[std_table[pos_in_table]]=[];
HT[std_table[pos_in_table]][0]=codevalue;
HT[std_table[pos_in_table]][1]=k;
pos_in_table++;
codevalue++;
}
codevalue *=2;
}
return HT;
}
function initHuffmanTbl(){
YDC_HT=computeHuffmanTbl(
std_dc_luminance_nrcodes,
std_dc_luminance_values
);
UVDC_HT=computeHuffmanTbl(
std_dc_chrominance_nrcodes,
std_dc_chrominance_values
);
YAC_HT=computeHuffmanTbl(
std_ac_luminance_nrcodes,
std_ac_luminance_values
);
UVAC_HT=computeHuffmanTbl(
std_ac_chrominance_nrcodes,
std_ac_chrominance_values
);
}
function initCategoryNumber(){
var nrlower=1;
var nrupper=2;
for (var cat=1; cat <=15; cat++){
for (var nr=nrlower; nr < nrupper; nr++){
category[32767 + nr]=cat;
bitcode[32767 + nr]=[];
bitcode[32767 + nr][1]=cat;
bitcode[32767 + nr][0]=nr;
}
for (var nrneg=-(nrupper - 1); nrneg <=-nrlower; nrneg++){
category[32767 + nrneg]=cat;
bitcode[32767 + nrneg]=[];
bitcode[32767 + nrneg][1]=cat;
bitcode[32767 + nrneg][0]=nrupper - 1 + nrneg;
}
nrlower <<=1;
nrupper <<=1;
}}
function initRGBYUVTable(){
for (var i=0; i < 256; i++){
RGB_YUV_TABLE[i]=19595 * i;
RGB_YUV_TABLE[(i + 256) >> 0]=38470 * i;
RGB_YUV_TABLE[(i + 512) >> 0]=7471 * i + 0x8000;
RGB_YUV_TABLE[(i + 768) >> 0]=-11059 * i;
RGB_YUV_TABLE[(i + 1024) >> 0]=-21709 * i;
RGB_YUV_TABLE[(i + 1280) >> 0]=32768 * i + 0x807fff;
RGB_YUV_TABLE[(i + 1536) >> 0]=-27439 * i;
RGB_YUV_TABLE[(i + 1792) >> 0]=-5329 * i;
}}
function writeBits(bs){
var value=bs[0];
var posval=bs[1] - 1;
while (posval >=0){
if(value & (1 << posval)){
bytenew |=1 << bytepos;
}
posval--;
bytepos--;
if(bytepos < 0){
if(bytenew==0xff){
writeByte(0xff);
writeByte(0);
}else{
writeByte(bytenew);
}
bytepos=7;
bytenew=0;
}}
}
function writeByte(value){
byteout.push(value);
}
function writeWord(value){
writeByte((value >> 8) & 0xff);
writeByte(value & 0xff);
}
function fDCTQuant(data, fdtbl){
var d0, d1, d2, d3, d4, d5, d6, d7;
var dataOff=0;
var i;
var I8=8;
var I64=64;
for (i=0; i < I8; ++i){
d0=data[dataOff];
d1=data[dataOff + 1];
d2=data[dataOff + 2];
d3=data[dataOff + 3];
d4=data[dataOff + 4];
d5=data[dataOff + 5];
d6=data[dataOff + 6];
d7=data[dataOff + 7];
var tmp0=d0 + d7;
var tmp7=d0 - d7;
var tmp1=d1 + d6;
var tmp6=d1 - d6;
var tmp2=d2 + d5;
var tmp5=d2 - d5;
var tmp3=d3 + d4;
var tmp4=d3 - d4;
var tmp10=tmp0 + tmp3; 
var tmp13=tmp0 - tmp3;
var tmp11=tmp1 + tmp2;
var tmp12=tmp1 - tmp2;
data[dataOff]=tmp10 + tmp11; 
data[dataOff + 4]=tmp10 - tmp11;
var z1=(tmp12 + tmp13) * 0.707106781; 
data[dataOff + 2]=tmp13 + z1; 
data[dataOff + 6]=tmp13 - z1;
tmp10=tmp4 + tmp5; 
tmp11=tmp5 + tmp6;
tmp12=tmp6 + tmp7;
var z5=(tmp10 - tmp12) * 0.382683433; 
var z2=0.5411961 * tmp10 + z5; 
var z4=1.306562965 * tmp12 + z5; 
var z3=tmp11 * 0.707106781; 
var z11=tmp7 + z3; 
var z13=tmp7 - z3;
data[dataOff + 5]=z13 + z2; 
data[dataOff + 3]=z13 - z2;
data[dataOff + 1]=z11 + z4;
data[dataOff + 7]=z11 - z4;
dataOff +=8; 
}
dataOff=0;
for (i=0; i < I8; ++i){
d0=data[dataOff];
d1=data[dataOff + 8];
d2=data[dataOff + 16];
d3=data[dataOff + 24];
d4=data[dataOff + 32];
d5=data[dataOff + 40];
d6=data[dataOff + 48];
d7=data[dataOff + 56];
var tmp0p2=d0 + d7;
var tmp7p2=d0 - d7;
var tmp1p2=d1 + d6;
var tmp6p2=d1 - d6;
var tmp2p2=d2 + d5;
var tmp5p2=d2 - d5;
var tmp3p2=d3 + d4;
var tmp4p2=d3 - d4;
var tmp10p2=tmp0p2 + tmp3p2; 
var tmp13p2=tmp0p2 - tmp3p2;
var tmp11p2=tmp1p2 + tmp2p2;
var tmp12p2=tmp1p2 - tmp2p2;
data[dataOff]=tmp10p2 + tmp11p2; 
data[dataOff + 32]=tmp10p2 - tmp11p2;
var z1p2=(tmp12p2 + tmp13p2) * 0.707106781; 
data[dataOff + 16]=tmp13p2 + z1p2; 
data[dataOff + 48]=tmp13p2 - z1p2;
tmp10p2=tmp4p2 + tmp5p2; 
tmp11p2=tmp5p2 + tmp6p2;
tmp12p2=tmp6p2 + tmp7p2;
var z5p2=(tmp10p2 - tmp12p2) * 0.382683433; 
var z2p2=0.5411961 * tmp10p2 + z5p2; 
var z4p2=1.306562965 * tmp12p2 + z5p2; 
var z3p2=tmp11p2 * 0.707106781; 
var z11p2=tmp7p2 + z3p2; 
var z13p2=tmp7p2 - z3p2;
data[dataOff + 40]=z13p2 + z2p2; 
data[dataOff + 24]=z13p2 - z2p2;
data[dataOff + 8]=z11p2 + z4p2;
data[dataOff + 56]=z11p2 - z4p2;
dataOff++; 
}
var fDCTQuant;
for (i=0; i < I64; ++i){
fDCTQuant=data[i] * fdtbl[i];
outputfDCTQuant[i] =
fDCTQuant > 0.0 ? (fDCTQuant + 0.5) | 0:(fDCTQuant - 0.5) | 0;
}
return outputfDCTQuant;
}
function writeAPP0(){
writeWord(0xffe0);
writeWord(16);
writeByte(0x4a);
writeByte(0x46);
writeByte(0x49);
writeByte(0x46);
writeByte(0);
writeByte(1);
writeByte(1);
writeByte(0);
writeWord(1);
writeWord(1);
writeByte(0);
writeByte(0);
}
function writeSOF0(width, height){
writeWord(0xffc0);
writeWord(17);
writeByte(8);
writeWord(height);
writeWord(width);
writeByte(3);
writeByte(1);
writeByte(0x11);
writeByte(0);
writeByte(2);
writeByte(0x11);
writeByte(1);
writeByte(3);
writeByte(0x11);
writeByte(1);
}
function writeDQT(){
writeWord(0xffdb);
writeWord(132);
writeByte(0);
for (var i=0; i < 64; i++){
writeByte(YTable[i]);
}
writeByte(1);
for (var j=0; j < 64; j++){
writeByte(UVTable[j]);
}}
function writeDHT(){
writeWord(0xffc4);
writeWord(0x01a2);
writeByte(0);
for (var i=0; i < 16; i++){
writeByte(std_dc_luminance_nrcodes[i + 1]);
}
for (var j=0; j <=11; j++){
writeByte(std_dc_luminance_values[j]);
}
writeByte(0x10);
for (var k=0; k < 16; k++){
writeByte(std_ac_luminance_nrcodes[k + 1]);
}
for (var l=0; l <=161; l++){
writeByte(std_ac_luminance_values[l]);
}
writeByte(1);
for (var m=0; m < 16; m++){
writeByte(std_dc_chrominance_nrcodes[m + 1]);
}
for (var n=0; n <=11; n++){
writeByte(std_dc_chrominance_values[n]);
}
writeByte(0x11);
for (var o=0; o < 16; o++){
writeByte(std_ac_chrominance_nrcodes[o + 1]);
}
for (var p=0; p <=161; p++){
writeByte(std_ac_chrominance_values[p]);
}}
function writeSOS(){
writeWord(0xffda);
writeWord(12);
writeByte(3);
writeByte(1);
writeByte(0);
writeByte(2);
writeByte(0x11);
writeByte(3);
writeByte(0x11);
writeByte(0);
writeByte(0x3f);
writeByte(0);
}
function processDU(CDU, fdtbl, DC, HTDC, HTAC){
var EOB=HTAC[0x00];
var M16zeroes=HTAC[0xf0];
var pos;
var I16=16;
var I63=63;
var I64=64;
var DU_DCT=fDCTQuant(CDU, fdtbl);
for (var j=0; j < I64; ++j){
DU[ZigZag[j]]=DU_DCT[j];
}
var Diff=DU[0] - DC;
DC=DU[0];
if(Diff==0){
writeBits(HTDC[0]);
}else{
pos=32767 + Diff;
writeBits(HTDC[category[pos]]);
writeBits(bitcode[pos]);
}
var end0pos=63;
while (end0pos > 0&&DU[end0pos]==0){
end0pos--;
}
if(end0pos==0){
writeBits(EOB);
return DC;
}
var i=1;
var lng;
while (i <=end0pos){
var startpos=i;
while (DU[i]==0&&i <=end0pos){
++i;
}
var nrzeroes=i - startpos;
if(nrzeroes >=I16){
lng=nrzeroes >> 4;
for (var nrmarker=1; nrmarker <=lng; ++nrmarker)
writeBits(M16zeroes);
nrzeroes=nrzeroes & 0xf;
}
pos=32767 + DU[i];
writeBits(HTAC[(nrzeroes << 4) + category[pos]]);
writeBits(bitcode[pos]);
i++;
}
if(end0pos!=I63){
writeBits(EOB);
}
return DC;
}
function initCharLookupTable(){
var sfcc=String.fromCharCode;
for (var i=0; i < 256; i++){
clt[i]=sfcc(i);
}}
this.encode=function(
image,
quality
){
if(quality) setQuality(quality);
byteout=new Array();
bytenew=0;
bytepos=7;
writeWord(0xffd8);
writeAPP0();
writeDQT();
writeSOF0(image.width, image.height);
writeDHT();
writeSOS();
var DCY=0;
var DCU=0;
var DCV=0;
bytenew=0;
bytepos=7;
this.encode.displayName="_encode_";
var imageData=image.data;
var width=image.width;
var height=image.height;
var quadWidth=width * 4;
var x,
y=0;
var r, g, b;
var start, p, col, row, pos;
while (y < height){
x=0;
while (x < quadWidth){
start=quadWidth * y + x;
col=-1;
row=0;
for (pos=0; pos < 64; pos++){
row=pos >> 3;
col=(pos & 7) * 4;
p=start + row * quadWidth + col;
if(y + row >=height){
p -=quadWidth * (y + 1 + row - height);
}
if(x + col >=quadWidth){
p -=x + col - quadWidth + 4;
}
r=imageData[p++];
g=imageData[p++];
b=imageData[p++];
YDU[pos] =
((RGB_YUV_TABLE[r] +
RGB_YUV_TABLE[(g + 256) >> 0] +
RGB_YUV_TABLE[(b + 512) >> 0]) >>
16) -
128;
UDU[pos] =
((RGB_YUV_TABLE[(r + 768) >> 0] +
RGB_YUV_TABLE[(g + 1024) >> 0] +
RGB_YUV_TABLE[(b + 1280) >> 0]) >>
16) -
128;
VDU[pos] =
((RGB_YUV_TABLE[(r + 1280) >> 0] +
RGB_YUV_TABLE[(g + 1536) >> 0] +
RGB_YUV_TABLE[(b + 1792) >> 0]) >>
16) -
128;
}
DCY=processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT);
DCU=processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV=processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
x +=32;
}
y +=8;
}
if(bytepos >=0){
var fillbits=[];
fillbits[1]=bytepos + 1;
fillbits[0]=(1 << (bytepos + 1)) - 1;
writeBits(fillbits);
}
writeWord(0xffd9);
return new Uint8Array(byteout);
};
function setQuality(quality){
quality=Math.min(Math.max(quality, 1), 100);
if(currentQuality==quality) return;
var sf =
quality < 50 ? Math.floor(5000 / quality):Math.floor(200 - quality * 2);
initQuantTables(sf);
currentQuality=quality;
}
function init(){
quality=quality||50;
initCharLookupTable();
initHuffmanTbl();
initCategoryNumber();
initRGBYUVTable();
setQuality(quality);
}
init();
}
(function(jsPDFAPI){
jsPDFAPI.processGIF89A=function(imageData, index, alias, compression){
var reader=new GifReader(imageData);
var width=reader.width,
height=reader.height;
var qu=100;
var pixels=[];
reader.decodeAndBlitFrameRGBA(0, pixels);
var rawImageData={
data: pixels,
width: width,
height: height
};
var encoder=new JPEGEncoder(qu);
var data=encoder.encode(rawImageData, qu);
return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);
};
jsPDFAPI.processGIF87A=jsPDFAPI.processGIF89A;
})(jsPDF.API);
function BmpDecoder(buffer, is_with_alpha){
this.pos=0;
this.buffer=buffer;
this.datav=new DataView(buffer.buffer);
this.is_with_alpha = !!is_with_alpha;
this.bottom_up=true;
this.flag =
String.fromCharCode(this.buffer[0]) + String.fromCharCode(this.buffer[1]);
this.pos +=2;
if(["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag)===-1)
throw new Error("Invalid BMP File");
this.parseHeader();
this.parseBGR();
}
BmpDecoder.prototype.parseHeader=function(){
this.fileSize=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.reserved=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.offset=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.headerSize=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.width=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.height=this.datav.getInt32(this.pos, true);
this.pos +=4;
this.planes=this.datav.getUint16(this.pos, true);
this.pos +=2;
this.bitPP=this.datav.getUint16(this.pos, true);
this.pos +=2;
this.compress=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.rawSize=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.hr=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.vr=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.colors=this.datav.getUint32(this.pos, true);
this.pos +=4;
this.importantColors=this.datav.getUint32(this.pos, true);
this.pos +=4;
if(this.bitPP===16&&this.is_with_alpha){
this.bitPP=15;
}
if(this.bitPP < 15){
var len=this.colors===0 ? 1 << this.bitPP:this.colors;
this.palette=new Array(len);
for (var i=0; i < len; i++){
var blue=this.datav.getUint8(this.pos++, true);
var green=this.datav.getUint8(this.pos++, true);
var red=this.datav.getUint8(this.pos++, true);
var quad=this.datav.getUint8(this.pos++, true);
this.palette[i]={
red: red,
green: green,
blue: blue,
quad: quad
};}}
if(this.height < 0){
this.height *=-1;
this.bottom_up=false;
}};
BmpDecoder.prototype.parseBGR=function(){
this.pos=this.offset;
try {
var bitn="bit" + this.bitPP;
var len=this.width * this.height * 4;
this.data=new Uint8Array(len);
this[bitn]();
} catch (e){
console.log("bit decode error:" + e);
}};
BmpDecoder.prototype.bit1=function(){
var xlen=Math.ceil(this.width / 8);
var mode=xlen % 4;
var y;
for (y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < xlen; x++){
var b=this.datav.getUint8(this.pos++, true);
var location=line * this.width * 4 + x * 8 * 4;
for (var i=0; i < 8; i++){
if(x * 8 + i < this.width){
var rgb=this.palette[(b >> (7 - i)) & 0x1];
this.data[location + i * 4]=rgb.blue;
this.data[location + i * 4 + 1]=rgb.green;
this.data[location + i * 4 + 2]=rgb.red;
this.data[location + i * 4 + 3]=0xff;
}else{
break;
}}
}
if(mode!==0){
this.pos +=4 - mode;
}}
};
BmpDecoder.prototype.bit4=function(){
var xlen=Math.ceil(this.width / 2);
var mode=xlen % 4;
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < xlen; x++){
var b=this.datav.getUint8(this.pos++, true);
var location=line * this.width * 4 + x * 2 * 4;
var before=b >> 4;
var after=b & 0x0f;
var rgb=this.palette[before];
this.data[location]=rgb.blue;
this.data[location + 1]=rgb.green;
this.data[location + 2]=rgb.red;
this.data[location + 3]=0xff;
if(x * 2 + 1 >=this.width) break;
rgb=this.palette[after];
this.data[location + 4]=rgb.blue;
this.data[location + 4 + 1]=rgb.green;
this.data[location + 4 + 2]=rgb.red;
this.data[location + 4 + 3]=0xff;
}
if(mode!==0){
this.pos +=4 - mode;
}}
};
BmpDecoder.prototype.bit8=function(){
var mode=this.width % 4;
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < this.width; x++){
var b=this.datav.getUint8(this.pos++, true);
var location=line * this.width * 4 + x * 4;
if(b < this.palette.length){
var rgb=this.palette[b];
this.data[location]=rgb.red;
this.data[location + 1]=rgb.green;
this.data[location + 2]=rgb.blue;
this.data[location + 3]=0xff;
}else{
this.data[location]=0xff;
this.data[location + 1]=0xff;
this.data[location + 2]=0xff;
this.data[location + 3]=0xff;
}}
if(mode!==0){
this.pos +=4 - mode;
}}
};
BmpDecoder.prototype.bit15=function(){
var dif_w=this.width % 3;
var _11111=parseInt("11111", 2),
_1_5=_11111;
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < this.width; x++){
var B=this.datav.getUint16(this.pos, true);
this.pos +=2;
var blue=(((B & _1_5) / _1_5) * 255) | 0;
var green=((((B >> 5) & _1_5) / _1_5) * 255) | 0;
var red=((((B >> 10) & _1_5) / _1_5) * 255) | 0;
var alpha=B >> 15 ? 0xff:0x00;
var location=line * this.width * 4 + x * 4;
this.data[location]=red;
this.data[location + 1]=green;
this.data[location + 2]=blue;
this.data[location + 3]=alpha;
}
this.pos +=dif_w;
}};
BmpDecoder.prototype.bit16=function(){
var dif_w=this.width % 3;
var _11111=parseInt("11111", 2),
_1_5=_11111;
var _111111=parseInt("111111", 2),
_1_6=_111111;
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < this.width; x++){
var B=this.datav.getUint16(this.pos, true);
this.pos +=2;
var alpha=0xff;
var blue=(((B & _1_5) / _1_5) * 255) | 0;
var green=((((B >> 5) & _1_6) / _1_6) * 255) | 0;
var red=(((B >> 11) / _1_5) * 255) | 0;
var location=line * this.width * 4 + x * 4;
this.data[location]=red;
this.data[location + 1]=green;
this.data[location + 2]=blue;
this.data[location + 3]=alpha;
}
this.pos +=dif_w;
}};
BmpDecoder.prototype.bit24=function(){
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < this.width; x++){
var blue=this.datav.getUint8(this.pos++, true);
var green=this.datav.getUint8(this.pos++, true);
var red=this.datav.getUint8(this.pos++, true);
var location=line * this.width * 4 + x * 4;
this.data[location]=red;
this.data[location + 1]=green;
this.data[location + 2]=blue;
this.data[location + 3]=0xff;
}
this.pos +=this.width % 4;
}};
BmpDecoder.prototype.bit32=function(){
for (var y=this.height - 1; y >=0; y--){
var line=this.bottom_up ? y:this.height - 1 - y;
for (var x=0; x < this.width; x++){
var blue=this.datav.getUint8(this.pos++, true);
var green=this.datav.getUint8(this.pos++, true);
var red=this.datav.getUint8(this.pos++, true);
var alpha=this.datav.getUint8(this.pos++, true);
var location=line * this.width * 4 + x * 4;
this.data[location]=red;
this.data[location + 1]=green;
this.data[location + 2]=blue;
this.data[location + 3]=alpha;
}}
};
BmpDecoder.prototype.getData=function(){
return this.data;
};
(function(jsPDFAPI){
jsPDFAPI.processBMP=function(imageData, index, alias, compression){
var reader=new BmpDecoder(imageData, false);
var width=reader.width,
height=reader.height;
var qu=100;
var pixels=reader.getData();
var rawImageData={
data: pixels,
width: width,
height: height
};
var encoder=new JPEGEncoder(qu);
var data=encoder.encode(rawImageData, qu);
return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);
};})(jsPDF.API);
function WebPDecoder(imageData){
function x(F){
if(!F) throw Error("assert :P");
}
function fa(F, L, J){
for (var H=0; 4 > H; H++) if(F[L + H]!=J.charCodeAt(H)) return !0;
return !1;
}
function I(F, L, J, H, Z){
for (var O=0; O < Z; O++) F[L + O]=J[H + O];
}
function M(F, L, J, H){
for (var Z=0; Z < H; Z++) F[L + Z]=J;
}
function V(F){
return new Int32Array(F);
}
function wa(F, L){
for (var J=[], H=0; H < F; H++) J.push(new L());
return J;
}
function wb(){
function F(J, H, Z){
for (var O=Z[H], L=0; L < O; L++){
J.push(Z.length > H + 1 ? []:0);
if(Z.length < H + 1) break;
F(J[L], H + 1, Z);
}}
var L=[];
F(L, 0, [3, 11]);
return L;
}
function Ed(F, L){
function J(H, O, F){
for (var Z=F[O], ma=0; ma < Z; ma++){
H.push(F.length > O + 1 ? []:new L());
if(F.length < O + 1) break;
J(H[ma], O + 1, F);
}}
var H=[];
J(H, 0, F);
return H;
}
WebPDecoder=function(){
var self=this;
function L(a, b){
for (var c=(1 << (b - 1)) >>> 0; a & c;) c >>>=1;
return c ? (a & (c - 1)) + c:a;
}
function J(a, b, c, d, e){
x(!(d % c));
do (d -=c), (a[b + d]=e);
while (0 < d);
}
function H(a, b, c, d, e, f){
var g=b,
h=1 << c,
k,
l,
m=V(16),
n=V(16);
x(0!=e);
x(null!=d);
x(null!=a);
x(0 < c);
for (l=0; l < e; ++l){
if(15 < d[l]) return 0;
++m[d[l]];
}
if(m[0]==e) return 0;
n[1]=0;
for (k=1; 15 > k; ++k){
if(m[k] > 1 << k) return 0;
n[k + 1]=n[k] + m[k];
}
for (l=0; l < e; ++l) (k=d[l]), 0 < d[l]&&(f[n[k]++]=l);
if(1==n[15])
return (d=new O()), (d.g=0), (d.value=f[0]), J(a, g, 1, h, d), h;
var r=-1,
q=h - 1,
t=0,
v=1,
p=1,
u,
w=1 << c;
l=0;
k=1;
for (e=2; k <=c; ++k, e <<=1){
p <<=1;
v +=p;
p -=m[k];
if(0 > p) return 0;
for (; 0 < m[k]; --m[k])
(d=new O()),
(d.g=k),
(d.value=f[l++]),
J(a, g + t, e, w, d),
(t=L(t, k));
}
k=c + 1;
for (e=2; 15 >=k; ++k, e <<=1){
p <<=1;
v +=p;
p -=m[k];
if(0 > p) return 0;
for (; 0 < m[k]; --m[k]){
d=new O();
if((t & q)!=r){
g +=w;
r=k;
for (u=1 << (r - c); 15 > r;){
u -=m[r];
if(0 >=u) break;
++r;
u <<=1;
}
u=r - c;
w=1 << u;
h +=w;
r=t & q;
a[b + r].g=u + c;
a[b + r].value=g - b - r;
}
d.g=k - c;
d.value=f[l++];
J(a, g + (t >> c), e, w, d);
t=L(t, k);
}}
return v!=2 * n[15] - 1 ? 0:h;
}
function Z(a, b, c, d, e){
x(2328 >=e);
if(512 >=e) var f=V(512);
else if(((f=V(e)), null==f)) return 0;
return H(a, b, c, d, e, f);
}
function O(){
this.value=this.g=0;
}
function Fd(){
this.value=this.g=0;
}
function Ub(){
this.G=wa(5, O);
this.H=V(5);
this.jc=this.Qb=this.qb=this.nd=0;
this.pd=wa(xb, Fd);
}
function ma(a, b, c, d){
x(null!=a);
x(null!=b);
x(2147483648 > d);
a.Ca=254;
a.I=0;
a.b=-8;
a.Ka=0;
a.oa=b;
a.pa=c;
a.Jd=b;
a.Yc=c + d;
a.Zc=4 <=d ? c + d - 4 + 1:c;
Qa(a);
}
function na(a, b){
for (var c=0; 0 < b--;) c |=K(a, 128) << b;
return c;
}
function ca(a, b){
var c=na(a, b);
return G(a) ? -c:c;
}
function cb(a, b, c, d){
var e,
f=0;
x(null!=a);
x(null!=b);
x(4294967288 > d);
a.Sb=d;
a.Ra=0;
a.u=0;
a.h=0;
4 < d&&(d=4);
for (e=0; e < d; ++e) f +=b[c + e] << (8 * e);
a.Ra=f;
a.bb=d;
a.oa=b;
a.pa=c;
}
function Vb(a){
for (; 8 <=a.u&&a.bb < a.Sb;)
(a.Ra >>>=8),
(a.Ra +=(a.oa[a.pa + a.bb] << (ob - 8)) >>> 0),
++a.bb,
(a.u -=8);
db(a)&&((a.h=1), (a.u=0));
}
function D(a, b){
x(0 <=b);
if(!a.h&&b <=Gd){
var c=pb(a) & Hd[b];
a.u +=b;
Vb(a);
return c;
}
a.h=1;
return (a.u=0);
}
function Wb(){
this.b=this.Ca=this.I=0;
this.oa=[];
this.pa=0;
this.Jd=[];
this.Yc=0;
this.Zc=[];
this.Ka=0;
}
function Ra(){
this.Ra=0;
this.oa=[];
this.h=this.u=this.bb=this.Sb=this.pa=0;
}
function pb(a){
return (a.Ra >>> (a.u & (ob - 1))) >>> 0;
}
function db(a){
x(a.bb <=a.Sb);
return a.h||(a.bb==a.Sb&&a.u > ob);
}
function qb(a, b){
a.u=b;
a.h=db(a);
}
function Sa(a){
a.u >=Xb&&(x(a.u >=Xb), Vb(a));
}
function Qa(a){
x(null!=a&&null!=a.oa);
a.pa < a.Zc
? ((a.I=(a.oa[a.pa++] | (a.I << 8)) >>> 0), (a.b +=8))
: (x(null!=a&&null!=a.oa),
a.pa < a.Yc
? ((a.b +=8), (a.I=a.oa[a.pa++] | (a.I << 8)))
: a.Ka
? (a.b=0)
: ((a.I <<=8), (a.b +=8), (a.Ka=1)));
}
function G(a){
return na(a, 1);
}
function K(a, b){
var c=a.Ca;
0 > a.b&&Qa(a);
var d=a.b,
e=(c * b) >>> 8,
f=(a.I >>> d > e) + 0;
f ? ((c -=e), (a.I -=((e + 1) << d) >>> 0)):(c=e + 1);
d=c;
for (e=0; 256 <=d;) (e +=8), (d >>=8);
d=7 ^ (e + Id[d]);
a.b -=d;
a.Ca=(c << d) - 1;
return f;
}
function ra(a, b, c){
a[b + 0]=(c >> 24) & 255;
a[b + 1]=(c >> 16) & 255;
a[b + 2]=(c >> 8) & 255;
a[b + 3]=(c >> 0) & 255;
}
function Ta(a, b){
return (a[b + 0] << 0) | (a[b + 1] << 8);
}
function Yb(a, b){
return Ta(a, b) | (a[b + 2] << 16);
}
function Ha(a, b){
return Ta(a, b) | (Ta(a, b + 2) << 16);
}
function Zb(a, b){
var c=1 << b;
x(null!=a);
x(0 < b);
a.X=V(c);
if(null==a.X) return 0;
a.Mb=32 - b;
a.Xa=b;
return 1;
}
function $b(a, b){
x(null!=a);
x(null!=b);
x(a.Xa==b.Xa);
I(b.X, 0, a.X, 0, 1 << b.Xa);
}
function ac(){
this.X=[];
this.Xa=this.Mb=0;
}
function bc(a, b, c, d){
x(null!=c);
x(null!=d);
var e=c[0],
f=d[0];
0==e&&(e=(a * f + b / 2) / b);
0==f&&(f=(b * e + a / 2) / a);
if(0 >=e||0 >=f) return 0;
c[0]=e;
d[0]=f;
return 1;
}
function xa(a, b){
return (a + (1 << b) - 1) >>> b;
}
function yb(a, b){
return (
(((((a & 4278255360) + (b & 4278255360)) >>> 0) & 4278255360) +
((((a & 16711935) + (b & 16711935)) >>> 0) & 16711935)) >>>
0
);
}
function X(a, b){
self[b]=function(b, d, e, f, g, h, k){
var c;
for (c=0; c < g; ++c){
var m=self[a](h[k + c - 1], e, f + c);
h[k + c]=yb(b[d + c], m);
}};}
function Jd(){
this.ud=this.hd=this.jd=0;
}
function aa(a, b){
return ((((a ^ b) & 4278124286) >>> 1) + (a & b)) >>> 0;
}
function sa(a){
if(0 <=a&&256 > a) return a;
if(0 > a) return 0;
if(255 < a) return 255;
}
function eb(a, b){
return sa(a + ((a - b + 0.5) >> 1));
}
function Ia(a, b, c){
return Math.abs(b - c) - Math.abs(a - c);
}
function cc(a, b, c, d, e, f, g){
d=f[g - 1];
for (c=0; c < e; ++c) f[g + c]=d = yb(a[b + c], d);
}
function Kd(a, b, c, d, e){
var f;
for (f=0; f < c; ++f){
var g=a[b + f],
h=(g >> 8) & 255,
k=g & 16711935,
k=k + ((h << 16) + h),
k=k & 16711935;
d[e + f]=((g & 4278255360) + k) >>> 0;
}}
function dc(a, b){
b.jd=(a >> 0) & 255;
b.hd=(a >> 8) & 255;
b.ud=(a >> 16) & 255;
}
function Ld(a, b, c, d, e, f){
var g;
for (g=0; g < d; ++g){
var h=b[c + g],
k=h >>> 8,
l=h >>> 16,
m=h,
l=l + ((((a.jd << 24) >> 24) * ((k << 24) >> 24)) >>> 5),
l=l & 255,
m=m + ((((a.hd << 24) >> 24) * ((k << 24) >> 24)) >>> 5),
m=m + ((((a.ud << 24) >> 24) * ((l << 24) >> 24)) >>> 5),
m=m & 255;
e[f + g]=(h & 4278255360) + (l << 16) + m;
}}
function ec(a, b, c, d, e){
self[b]=function(a, b, c, k, l, m, n, r, q){
for (k=n; k < r; ++k)
for (n=0; n < q; ++n) l[m++]=e(c[d(a[b++])]);
};
self[a]=function(a, b, h, k, l, m, n){
var f=8 >> a.b,
g=a.Ea,
t=a.K[0],
v=a.w;
if(8 > f)
for (a=(1 << a.b) - 1, v=(1 << f) - 1; b < h; ++b){
var p=0,
u;
for (u=0; u < g; ++u)
u & a||(p=d(k[l++])), (m[n++]=e(t[p & v])), (p >>=f);
}
else self["VP8LMapColor" + c](k, l, t, v, m, n, b, h, g);
};}
function Md(a, b, c, d, e){
for (c=b + c; b < c;){
var f=a[b++];
d[e++]=(f >> 16) & 255;
d[e++]=(f >> 8) & 255;
d[e++]=(f >> 0) & 255;
}}
function Nd(a, b, c, d, e){
for (c=b + c; b < c;){
var f=a[b++];
d[e++]=(f >> 16) & 255;
d[e++]=(f >> 8) & 255;
d[e++]=(f >> 0) & 255;
d[e++]=(f >> 24) & 255;
}}
function Od(a, b, c, d, e){
for (c=b + c; b < c;){
var f=a[b++],
g=((f >> 16) & 240) | ((f >> 12) & 15),
f=((f >> 0) & 240) | ((f >> 28) & 15);
d[e++]=g;
d[e++]=f;
}}
function Pd(a, b, c, d, e){
for (c=b + c; b < c;){
var f=a[b++],
g=((f >> 16) & 248) | ((f >> 13) & 7),
f=((f >> 5) & 224) | ((f >> 3) & 31);
d[e++]=g;
d[e++]=f;
}}
function Qd(a, b, c, d, e){
for (c=b + c; b < c;){
var f=a[b++];
d[e++]=(f >> 0) & 255;
d[e++]=(f >> 8) & 255;
d[e++]=(f >> 16) & 255;
}}
function fb(a, b, c, d, e, f){
if(0==f)
for (c=b + c; b < c;)
(f=a[b++]),
ra(
d,
((f[0] >> 24) |
((f[1] >> 8) & 65280) |
((f[2] << 8) & 16711680) |
(f[3] << 24)) >>>
0
),
(e +=32);
else I(d, e, a, b, c);
}
function gb(a, b){
self[b][0]=self[a + "0"];
self[b][1]=self[a + "1"];
self[b][2]=self[a + "2"];
self[b][3]=self[a + "3"];
self[b][4]=self[a + "4"];
self[b][5]=self[a + "5"];
self[b][6]=self[a + "6"];
self[b][7]=self[a + "7"];
self[b][8]=self[a + "8"];
self[b][9]=self[a + "9"];
self[b][10]=self[a + "10"];
self[b][11]=self[a + "11"];
self[b][12]=self[a + "12"];
self[b][13]=self[a + "13"];
self[b][14]=self[a + "0"];
self[b][15]=self[a + "0"];
}
function hb(a){
return a==zb||a==Ab||a==Ja||a==Bb;
}
function Rd(){
this.eb=[];
this.size=this.A=this.fb=0;
}
function Sd(){
this.y=[];
this.f=[];
this.ea=[];
this.F=[];
this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0;
}
function Cb(){
this.Rd=this.height=this.width=this.S=0;
this.f={};
this.f.RGBA=new Rd();
this.f.kb=new Sd();
this.sd=null;
}
function Td(){
this.width=[0];
this.height=[0];
this.Pd=[0];
this.Qd=[0];
this.format=[0];
}
function Ud(){
this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0;
}
function Vd(a){
alert("todo:WebPSamplerProcessPlane");
return a.T;
}
function Wd(a, b){
var c=a.T,
d=b.ba.f.RGBA,
e=d.eb,
f=d.fb + a.ka * d.A,
g=P[b.ba.S],
h=a.y,
k=a.O,
l=a.f,
m=a.N,
n=a.ea,
r=a.W,
q=b.cc,
t=b.dc,
v=b.Mc,
p=b.Nc,
u=a.ka,
w=a.ka + a.T,
y=a.U,
A=(y + 1) >> 1;
0==u
? g(h, k, null, null, l, m, n, r, l, m, n, r, e, f, null, null, y)
: (g(b.ec, b.fc, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y),
++c);
for (; u + 2 < w; u +=2)
(q=l),
(t=m),
(v=n),
(p=r),
(m +=a.Rc),
(r +=a.Rc),
(f +=2 * d.A),
(k +=2 * a.fa),
g(h, k - a.fa, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y);
k +=a.fa;
a.j + w < a.o
? (I(b.ec, b.fc, h, k, y),
I(b.cc, b.dc, l, m, A),
I(b.Mc, b.Nc, n, r, A),
c--)
: w & 1 ||
g(
h,
k,
null,
null,
l,
m,
n,
r,
l,
m,
n,
r,
e,
f + d.A,
null,
null,
y
);
return c;
}
function Xd(a, b, c){
var d=a.F,
e=[a.J];
if(null!=d){
var f=a.U,
g=b.ba.S,
h=g==ya||g==Ja;
b=b.ba.f.RGBA;
var k=[0],
l=a.ka;
k[0]=a.T;
a.Kb &&
(0==l ? --k[0]:(--l, (e[0] -=a.width)),
a.j + a.ka + a.T==a.o&&(k[0]=a.o - a.j - l));
var m=b.eb,
l=b.fb + l * b.A;
a=fc(d, e[0], a.width, f, k, m, l + (h ? 0:3), b.A);
x(c==k);
a&&hb(g)&&za(m, l, h, f, k, b.A);
}
return 0;
}
function gc(a){
var b=a.ma,
c=b.ba.S,
d=11 > c,
e=c==Ua||c==Va||c==ya||c==Db||12==c||hb(c);
b.memory=null;
b.Ib=null;
b.Jb=null;
b.Nd=null;
if(!hc(b.Oa, a, e ? 11:12)) return 0;
e&&hb(c)&&ic();
if(a.da) alert("todo:use_scaling");
else {
if(d){
if(((b.Ib=Vd), a.Kb)){
c=(a.U + 1) >> 1;
b.memory=V(a.U + 2 * c);
if(null==b.memory) return 0;
b.ec=b.memory;
b.fc=0;
b.cc=b.ec;
b.dc=b.fc + a.U;
b.Mc=b.cc;
b.Nc=b.dc + c;
b.Ib=Wd;
ic();
}} else alert("todo:EmitYUV");
e&&((b.Jb=Xd), d&&Aa());
}
if(d&&!jc){
for (a=0; 256 > a; ++a)
(Yd[a]=(89858 * (a - 128) + Ba) >> Wa),
(Zd[a]=-22014 * (a - 128) + Ba),
($d[a]=-45773 * (a - 128)),
(ae[a]=(113618 * (a - 128) + Ba) >> Wa);
for (a=ta; a < Eb; ++a)
(b=(76283 * (a - 16) + Ba) >> Wa),
(be[a - ta]=ga(b, 255)),
(ce[a - ta]=ga((b + 8) >> 4, 15));
jc=1;
}
return 1;
}
function kc(a){
var b=a.ma,
c=a.U,
d=a.T;
x(!(a.ka & 1));
if(0 >=c||0 >=d) return 0;
c=b.Ib(a, b);
null!=b.Jb&&b.Jb(a, b, c);
b.Dc +=c;
return 1;
}
function lc(a){
a.ma.memory=null;
}
function mc(a, b, c, d){
if(47!=D(a, 8)) return 0;
b[0]=D(a, 14) + 1;
c[0]=D(a, 14) + 1;
d[0]=D(a, 1);
return 0!=D(a, 3) ? 0:!a.h;
}
function ib(a, b){
if(4 > a) return a + 1;
var c=(a - 2) >> 1;
return ((2 + (a & 1)) << c) + D(b, c) + 1;
}
function nc(a, b){
if(120 < b) return b - 120;
var c=de[b - 1],
c=(c >> 4) * a + (8 - (c & 15));
return 1 <=c ? c:1;
}
function ua(a, b, c){
var d=pb(c);
b +=d & 255;
var e=a[b].g - 8;
0 < e &&
(qb(c, c.u + 8),
(d=pb(c)),
(b +=a[b].value),
(b +=d & ((1 << e) - 1)));
qb(c, c.u + a[b].g);
return a[b].value;
}
function ub(a, b, c){
c.g +=a.g;
c.value +=(a.value << b) >>> 0;
x(8 >=c.g);
return a.g;
}
function ha(a, b, c){
var d=a.xc;
b=0==d ? 0:a.vc[a.md * (c >> d) + (b >> d)];
x(b < a.Wb);
return a.Ya[b];
}
function oc(a, b, c, d){
var e=a.ab,
f=a.c * b,
g=a.C;
b=g + b;
var h=c,
k=d;
d=a.Ta;
for (c=a.Ua; 0 < e--;){
var l=a.gc[e],
m=g,
n=b,
r=h,
q=k,
k=d,
h=c,
t=l.Ea;
x(m < n);
x(n <=l.nc);
switch (l.hc){
case 2:
pc(r, q, (n - m) * t, k, h);
break;
case 0:
var v=l,
p=m,
u=n,
w=k,
y=h,
A=v.Ea;
0==p &&
(ee(r, q, null, null, 1, w, y),
cc(r, q + 1, 0, 0, A - 1, w, y + 1),
(q +=A),
(y +=A),
++p);
for (
var E=1 << v.b,
B=E - 1,
C=xa(A, v.b),
N=v.K,
v=v.w + (p >> v.b) * C;
p < u;
){
var z=N,
Q=v,
S=1;
for (fe(r, q, w, y - A, 1, w, y); S < A;){
var K=qc[(z[Q++] >> 8) & 15],
D=(S & ~B) + E;
D > A&&(D=A);
K(r, q + +S, w, y + S - A, D - S, w, y + S);
S=D;
}
q +=A;
y +=A;
++p;
p & B||(v +=C);
}
n!=l.nc&&I(k, h - t, k, h + (n - m - 1) * t, t);
break;
case 1:
t=r;
u=q;
r=l.Ea;
q=1 << l.b;
w=q - 1;
y=r & ~w;
A=r - y;
p=xa(r, l.b);
E=l.K;
for (l=l.w + (m >> l.b) * p; m < n;){
B=E;
C=l;
N=new Jd();
v=u + y;
for (z=u + r; u < v;)
dc(B[C++], N), Fb(N, t, u, q, k, h), (u +=q), (h +=q);
u < z &&
(dc(B[C++], N), Fb(N, t, u, A, k, h), (u +=A), (h +=A));
++m;
m & w||(l +=p);
}
break;
case 3:
if(r==k&&q==h&&0 < l.b){
y=(n - m) * xa(l.Ea, l.b);
t=h + (n - m) * t - y;
u=k;
r=t;
q=k;
w=h;
A=y;
p=[];
for (y=A - 1; 0 <=y; --y) p[y]=q[w + y];
for (y=A - 1; 0 <=y; --y) u[r + y]=p[y];
rc(l, m, n, k, t, k, h);
} else rc(l, m, n, r, q, k, h);
}
h=d;
k=c;
}
k!=c&&I(d, c, h, k, f);
}
function ge(a, b){
var c=a.V,
d=a.Ba + a.c * a.C,
e=b - a.C;
x(b <=a.l.o);
x(16 >=e);
if(0 < e){
var f=a.l,
g=a.Ta,
h=a.Ua,
k=f.width;
oc(a, e, c, d);
h=[h];
c=a.C;
d=b;
e=h;
x(c < d);
x(f.v < f.va);
d > f.o&&(d=f.o);
if(c < f.j){
var l=f.j - c,
c=f.j;
e[0] +=l * k;
}
c >=d
? (c=0)
: ((e[0] +=4 * f.v),
(f.ka=c - f.j),
(f.U=f.va - f.v),
(f.T=d - c),
(c=1));
if(c){
h=h[0];
c=a.ca;
if(11 > c.S){
for (
var m=c.f.RGBA,
d=c.S,
e=f.U,
f=f.T,
l=m.eb,
n=m.A,
r=f,
m=m.fb + a.Ma * m.A;
0 < r--;
){
var q=g,
t=h,
v=e,
p=l,
u=m;
switch (d){
case Ca:
sc(q, t, v, p, u);
break;
case Ua:
Gb(q, t, v, p, u);
break;
case zb:
Gb(q, t, v, p, u);
za(p, u, 0, v, 1, 0);
break;
case tc:
uc(q, t, v, p, u);
break;
case Va:
fb(q, t, v, p, u, 1);
break;
case Ab:
fb(q, t, v, p, u, 1);
za(p, u, 0, v, 1, 0);
break;
case ya:
fb(q, t, v, p, u, 0);
break;
case Ja:
fb(q, t, v, p, u, 0);
za(p, u, 1, v, 1, 0);
break;
case Db:
Hb(q, t, v, p, u);
break;
case Bb:
Hb(q, t, v, p, u);
vc(p, u, v, 1, 0);
break;
case wc:
xc(q, t, v, p, u);
break;
default:
x(0);
}
h +=k;
m +=n;
}
a.Ma +=f;
} else alert("todo:EmitRescaledRowsYUVA");
x(a.Ma <=c.height);
}}
a.C=b;
x(a.C <=a.i);
}
function yc(a){
var b;
if(0 < a.ua) return 0;
for (b=0; b < a.Wb; ++b){
var c=a.Ya[b].G,
d=a.Ya[b].H;
if(0 < c[1][d[1] + 0].g ||
0 < c[2][d[2] + 0].g ||
0 < c[3][d[3] + 0].g
)
return 0;
}
return 1;
}
function zc(a, b, c, d, e, f){
if(0!=a.Z){
var g=a.qd,
h=a.rd;
for (x(null!=ia[a.Z]); b < c; ++b)
ia[a.Z](g, h, d, e, d, e, f), (g=d), (h=e), (e +=f);
a.qd=g;
a.rd=h;
}}
function Ib(a, b){
var c=a.l.ma,
d=0==c.Z||1==c.Z ? a.l.j:a.C,
d=a.C < d ? d:a.C;
x(b <=a.l.o);
if(b > d){
var e=a.l.width,
f=c.ca,
g=c.tb + e * d,
h=a.V,
k=a.Ba + a.c * d,
l=a.gc;
x(1==a.ab);
x(3==l[0].hc);
he(l[0], d, b, h, k, f, g);
zc(c, d, b, f, g, e);
}
a.C=a.Ma=b;
}
function Jb(a, b, c, d, e, f, g){
var h=a.$ / d,
k=a.$ % d,
l=a.m,
m=a.s,
n=c + a.$,
r=n;
e=c + d * e;
var q=c + d * f,
t=280 + m.ua,
v=a.Pb ? h:16777216,
p=0 < m.ua ? m.Wa:null,
u=m.wc,
w=n < q ? ha(m, k, h):null;
x(a.C < f);
x(q <=e);
var y = !1;
a: for (;;){
for (; y||n < q;){
var A=0;
if(h >=v){
var v=a,
E=n - c;
x(v.Pb);
v.wd=v.m;
v.xd=E;
0 < v.s.ua&&$b(v.s.Wa, v.s.vb);
v=h + ie;
}
k & u||(w=ha(m, k, h));
x(null!=w);
w.Qb&&((b[n]=w.qb), (y = !0));
if(!y)
if((Sa(l), w.jc)){
var A=l,
E=b,
B=n,
C=w.pd[pb(A) & (xb - 1)];
x(w.jc);
256 > C.g
? (qb(A, A.u + C.g), (E[B]=C.value), (A=0))
: (qb(A, A.u + C.g - 256), x(256 <=C.value), (A=C.value));
0==A&&(y = !0);
} else A=ua(w.G[0], w.H[0], l);
if(l.h) break;
if(y||256 > A){
if(!y)
if(w.nd) b[n]=(w.qb | (A << 8)) >>> 0;
else {
Sa(l);
y=ua(w.G[1], w.H[1], l);
Sa(l);
E=ua(w.G[2], w.H[2], l);
B=ua(w.G[3], w.H[3], l);
if(l.h) break;
b[n]=((B << 24) | (y << 16) | (A << 8) | E) >>> 0;
}
y = !1;
++n;
++k;
if(k >=d &&
((k=0),
++h,
null!=g&&h <=f&&!(h % 16)&&g(a, h),
null!=p)
)
for (; r < n;)
(A=b[r++]),
(p.X[((506832829 * A) & 4294967295) >>> p.Mb]=A);
}else if(280 > A){
A=ib(A - 256, l);
E=ua(w.G[4], w.H[4], l);
Sa(l);
E=ib(E, l);
E=nc(d, E);
if(l.h) break;
if(n - c < E||e - n < A) break a;
else for (B=0; B < A; ++B) b[n + B]=b[n + B - E];
n +=A;
for (k +=A; k >=d;)
(k -=d), ++h, null!=g&&h <=f&&!(h % 16)&&g(a, h);
x(n <=e);
k & u&&(w=ha(m, k, h));
if(null!=p)
for (; r < n;)
(A=b[r++]),
(p.X[((506832829 * A) & 4294967295) >>> p.Mb]=A);
}else if(A < t){
y=A - 280;
for (x(null!=p); r < n;)
(A=b[r++]), (p.X[((506832829 * A) & 4294967295) >>> p.Mb]=A);
A=n;
E=p;
x(!(y >>> E.Xa));
b[A]=E.X[y];
y = !0;
} else break a;
y||x(l.h==db(l));
}
if(a.Pb&&l.h&&n < e)
x(a.m.h),
(a.a=5),
(a.m=a.wd),
(a.$=a.xd),
0 < a.s.ua&&$b(a.s.vb, a.s.Wa);
else if(l.h) break a;
else null!=g&&g(a, h > f ? f:h), (a.a=0), (a.$=n - c);
return 1;
}
a.a=3;
return 0;
}
function Ac(a){
x(null!=a);
a.vc=null;
a.yc=null;
a.Ya=null;
var b=a.Wa;
null!=b&&(b.X=null);
a.vb=null;
x(null!=a);
}
function Bc(){
var a=new je();
if(null==a) return null;
a.a=0;
a.xb=Cc;
gb("Predictor", "VP8LPredictors");
gb("Predictor", "VP8LPredictors_C");
gb("PredictorAdd", "VP8LPredictorsAdd");
gb("PredictorAdd", "VP8LPredictorsAdd_C");
pc=Kd;
Fb=Ld;
sc=Md;
Gb=Nd;
Hb=Od;
xc=Pd;
uc=Qd;
self.VP8LMapColor32b=ke;
self.VP8LMapColor8b=le;
return a;
}
function rb(a, b, c, d, e){
var f=1,
g=[a],
h=[b],
k=d.m,
l=d.s,
m=null,
n=0;
a: for (;;){
if(c)
for (; f&&D(k, 1);){
var r=g,
q=h,
t=d,
v=1,
p=t.m,
u=t.gc[t.ab],
w=D(p, 2);
if(t.Oc & (1 << w)) f=0;
else {
t.Oc |=1 << w;
u.hc=w;
u.Ea=r[0];
u.nc=q[0];
u.K=[null];
++t.ab;
x(4 >=t.ab);
switch (w){
case 0:
case 1:
u.b=D(p, 3) + 2;
v=rb(xa(u.Ea, u.b), xa(u.nc, u.b), 0, t, u.K);
u.K=u.K[0];
break;
case 3:
var y=D(p, 8) + 1,
A=16 < y ? 0:4 < y ? 1:2 < y ? 2:3;
r[0]=xa(u.Ea, A);
u.b=A;
var v=rb(y, 1, 0, t, u.K),
E;
if((E=v)){
var B,
C=y,
N=u,
z=1 << (8 >> N.b),
Q=V(z);
if(null==Q) E=0;
else {
var S=N.K[0],
K=N.w;
Q[0]=N.K[0][0];
for (B=1; B < 1 * C; ++B) Q[B]=yb(S[K + B], Q[B - 1]);
for (; B < 4 * z; ++B) Q[B]=0;
N.K[0]=null;
N.K[0]=Q;
E=1;
}}
v=E;
break;
case 2:
break;
default:
x(0);
}
f=v;
}}
g=g[0];
h=h[0];
if(f&&D(k, 1)&&((n=D(k, 4)), (f=1 <=n&&11 >=n), !f)){
d.a=3;
break a;
}
var H;
if((H=f))
b: {
var F=d,
G=g,
L=h,
J=n,
T=c,
Da,
ba,
X=F.m,
R=F.s,
P=[null],
U,
W=1,
aa=0,
na=me[J];
c: for (;;){
if(T&&D(X, 1)){
var ca=D(X, 3) + 2,
ga=xa(G, ca),
ka=xa(L, ca),
qa=ga * ka;
if(!rb(ga, ka, 0, F, P)) break c;
P=P[0];
R.xc=ca;
for (Da=0; Da < qa; ++Da){
var ia=(P[Da] >> 8) & 65535;
P[Da]=ia;
ia >=W&&(W=ia + 1);
}}
if(X.h) break c;
for (ba=0; 5 > ba; ++ba){
var Y=Dc[ba];
!ba&&0 < J&&(Y +=1 << J);
aa < Y&&(aa=Y);
}
var ma=wa(W * na, O);
var ua=W,
va=wa(ua, Ub);
if(null==va) var la=null;
else x(65536 >=ua), (la=va);
var ha=V(aa);
if(null==la||null==ha||null==ma){
F.a=1;
break c;
}
var pa=ma;
for (Da=U = 0; Da < W; ++Da){
var ja=la[Da],
da=ja.G,
ea=ja.H,
Fa=0,
ra=1,
Ha=0;
for (ba=0; 5 > ba; ++ba){
Y=Dc[ba];
da[ba]=pa;
ea[ba]=U;
!ba&&0 < J&&(Y +=1 << J);
d: {
var sa,
za=Y,
ta=F,
oa=ha,
db=pa,
eb=U,
Ia=0,
Ka=ta.m,
fb=D(Ka, 1);
M(oa, 0, 0, za);
if(fb){
var gb=D(Ka, 1) + 1,
hb=D(Ka, 1),
Ja=D(Ka, 0==hb ? 1:8);
oa[Ja]=1;
2==gb&&((Ja=D(Ka, 8)), (oa[Ja]=1));
var ya=1;
}else{
var Ua=V(19),
Va=D(Ka, 4) + 4;
if(19 < Va){
ta.a=3;
var Aa=0;
break d;
}
for (sa=0; sa < Va; ++sa) Ua[ne[sa]]=D(Ka, 3);
var Ba=void 0,
sb=void 0,
Wa=ta,
ib=Ua,
Ca=za,
Xa=oa,
Oa=0,
La=Wa.m,
Ya=8,
Za=wa(128, O);
e: for (;;){
if(!Z(Za, 0, 7, ib, 19)) break e;
if(D(La, 1)){
var kb=2 + 2 * D(La, 3),
Ba=2 + D(La, kb);
if(Ba > Ca) break e;
} else Ba=Ca;
for (sb=0; sb < Ca&&Ba--;){
Sa(La);
var $a=Za[0 + (pb(La) & 127)];
qb(La, La.u + $a.g);
var jb=$a.value;
if(16 > jb) (Xa[sb++]=jb), 0!=jb&&(Ya=jb);
else {
var lb=16==jb,
ab=jb - 16,
mb=oe[ab],
bb=D(La, pe[ab]) + mb;
if(sb + bb > Ca) break e;
else
for (var nb=lb ? Ya:0; 0 < bb--;)
Xa[sb++]=nb;
}}
Oa=1;
break e;
}
Oa||(Wa.a=3);
ya=Oa;
}
(ya=ya&&!Ka.h)&&(Ia=Z(db, eb, 8, oa, za));
ya&&0!=Ia ? (Aa=Ia):((ta.a=3), (Aa=0));
}
if(0==Aa) break c;
ra&&1==qe[ba]&&(ra=0==pa[U].g);
Fa +=pa[U].g;
U +=Aa;
if(3 >=ba){
var Pa=ha[0],
tb;
for (tb=1; tb < Y; ++tb) ha[tb] > Pa&&(Pa=ha[tb]);
Ha +=Pa;
}}
ja.nd=ra;
ja.Qb=0;
ra &&
((ja.qb =
((da[3][ea[3] + 0].value << 24) |
(da[1][ea[1] + 0].value << 16) |
da[2][ea[2] + 0].value) >>>
0),
0==Fa &&
256 > da[0][ea[0] + 0].value &&
((ja.Qb=1), (ja.qb +=da[0][ea[0] + 0].value << 8)));
ja.jc = !ja.Qb&&6 > Ha;
if(ja.jc){
var Ga,
Ea=ja;
for (Ga=0; Ga < xb; ++Ga){
var Ma=Ga,
Na=Ea.pd[Ma],
vb=Ea.G[0][Ea.H[0] + Ma];
256 <=vb.value
? ((Na.g=vb.g + 256), (Na.value=vb.value))
: ((Na.g=0),
(Na.value=0),
(Ma >>=ub(vb, 8, Na)),
(Ma >>=ub(Ea.G[1][Ea.H[1] + Ma], 16, Na)),
(Ma >>=ub(Ea.G[2][Ea.H[2] + Ma], 0, Na)),
ub(Ea.G[3][Ea.H[3] + Ma], 24, Na));
}}
}
R.vc=P;
R.Wb=W;
R.Ya=la;
R.yc=ma;
H=1;
break b;
}
H=0;
}
f=H;
if(!f){
d.a=3;
break a;
}
if(0 < n){
if(((l.ua=1 << n), !Zb(l.Wa, n))){
d.a=1;
f=0;
break a;
}} else l.ua=0;
var Qa=d,
cb=g,
ob=h,
Ra=Qa.s,
Ta=Ra.xc;
Qa.c=cb;
Qa.i=ob;
Ra.md=xa(cb, Ta);
Ra.wc=0==Ta ? -1:(1 << Ta) - 1;
if(c){
d.xb=re;
break a;
}
m=V(g * h);
if(null==m){
d.a=1;
f=0;
break a;
}
f=(f=Jb(d, m, 0, g, h, h, null))&&!k.h;
break a;
}
f
? (null!=e ? (e[0]=m):(x(null==m), x(c)), (d.$=0), c||Ac(l))
: Ac(l);
return f;
}
function Ec(a, b){
var c=a.c * a.i,
d=c + b + 16 * b;
x(a.c <=b);
a.V=V(d);
if(null==a.V) return (a.Ta=null), (a.Ua=0), (a.a=1), 0;
a.Ta=a.V;
a.Ua=a.Ba + c + b;
return 1;
}
function se(a, b){
var c=a.C,
d=b - c,
e=a.V,
f=a.Ba + a.c * c;
for (x(b <=a.l.o); 0 < d;){
var g=16 < d ? 16:d,
h=a.l.ma,
k=a.l.width,
l=k * g,
m=h.ca,
n=h.tb + k * c,
r=a.Ta,
q=a.Ua;
oc(a, g, e, f);
Fc(r, q, m, n, l);
zc(h, c, c + g, m, n, k);
d -=g;
e +=g * a.c;
c +=g;
}
x(c==b);
a.C=a.Ma=b;
}
function te(a, b){
var c=[0],
d=[0],
e=[0];
a: for (;;){
if(null==a) return 0;
if(null==b) return (a.a=2), 0;
a.l=b;
a.a=0;
cb(a.m, b.data, b.w, b.ha);
if(!mc(a.m, c, d, e)){
a.a=3;
break a;
}
a.xb=Cc;
b.width=c[0];
b.height=d[0];
if(!rb(c[0], d[0], 1, a, null)) break a;
return 1;
}
x(0!=a.a);
return 0;
}
function ue(){
this.ub=this.yd=this.td=this.Rb=0;
}
function ve(){
this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0;
}
function we(){
this.Fb=this.Bb=this.Cb=0;
this.Zb=V(4);
this.Lb=V(4);
}
function Gc(){
this.Yb=wb();
}
function xe(){
this.jb=V(3);
this.Wc=Ed([4, 8], Gc);
this.Xc=Ed([4, 17], Gc);
}
function ye(){
this.Pc=this.wb=this.Tb=this.zd=0;
this.vd=new V(4);
this.od=new V(4);
}
function Xa(){
this.ld=this.La=this.dd=this.tc=0;
}
function Hc(){
this.Na=this.la=0;
}
function ze(){
this.Sc=[0, 0];
this.Eb=[0, 0];
this.Qc=[0, 0];
this.ia=this.lc=0;
}
function Kb(){
this.ad=V(384);
this.Za=0;
this.Ob=V(16);
this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0;
}
function Ae(){
this.uc=this.M=this.Nb=0;
this.wa=Array(new Xa());
this.Y=0;
this.ya=Array(new Kb());
this.aa=0;
this.l=new Oa();
}
function Ic(){
this.y=V(16);
this.f=V(8);
this.ea=V(8);
}
function Be(){
this.cb=this.a=0;
this.sc="";
this.m=new Wb();
this.Od=new ue();
this.Kc=new ve();
this.ed=new ye();
this.Qa=new we();
this.Ic=this.$c=this.Aa=0;
this.D=new Ae();
this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0;
this.Jc=wa(8, Wb);
this.ia=0;
this.pb=wa(4, ze);
this.Pa=new xe();
this.Bd=this.kc=0;
this.Ac=[];
this.Bc=0;
this.zc=[0, 0, 0, 0];
this.Gd=Array(new Ic());
this.Hd=0;
this.rb=Array(new Hc());
this.sb=0;
this.wa=Array(new Xa());
this.Y=0;
this.oc=[];
this.pc=0;
this.sa=[];
this.ta=0;
this.qa=[];
this.ra=0;
this.Ha=[];
this.B=this.R=this.Ia=0;
this.Ec=[];
this.M=this.ja=this.Vb=this.Fc=0;
this.ya=Array(new Kb());
this.L=this.aa=0;
this.gd=Ed([4, 2], Xa);
this.ga=null;
this.Fa=[];
this.Cc=this.qc=this.P=0;
this.Gb=[];
this.Uc=0;
this.mb=[];
this.nb=0;
this.rc=[];
this.Ga=this.Vc=0;
}
function ga(a, b){
return 0 > a ? 0:a > b ? b:a;
}
function Oa(){
this.T=this.U=this.ka=this.height=this.width=0;
this.y=[];
this.f=[];
this.ea=[];
this.Rc=this.fa=this.W=this.N=this.O=0;
this.ma="void";
this.put="VP8IoPutHook";
this.ac="VP8IoSetupHook";
this.bc="VP8IoTeardownHook";
this.ha=this.Kb=0;
this.data=[];
this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0;
this.F=[];
this.J=0;
}
function Ce(){
var a=new Be();
null!=a &&
((a.a=0), (a.sc="OK"), (a.cb=0), (a.Xb=0), oa||(oa=De));
return a;
}
function T(a, b, c){
0==a.a&&((a.a=b), (a.sc=c), (a.cb=0));
return 0;
}
function Jc(a, b, c){
return 3 <=c&&157==a[b + 0]&&1==a[b + 1]&&42==a[b + 2];
}
function Kc(a, b){
if(null==a) return 0;
a.a=0;
a.sc="OK";
if(null==b) return T(a, 2, "null VP8Io passed to VP8GetHeaders()");
var c=b.data;
var d=b.w;
var e=b.ha;
if(4 > e) return T(a, 7, "Truncated header.");
var f=c[d + 0] | (c[d + 1] << 8) | (c[d + 2] << 16);
var g=a.Od;
g.Rb = !(f & 1);
g.td=(f >> 1) & 7;
g.yd=(f >> 4) & 1;
g.ub=f >> 5;
if(3 < g.td) return T(a, 3, "Incorrect keyframe parameters.");
if(!g.yd) return T(a, 4, "Frame not displayable.");
d +=3;
e -=3;
var h=a.Kc;
if(g.Rb){
if(7 > e) return T(a, 7, "cannot parse picture header");
if(!Jc(c, d, e)) return T(a, 3, "Bad code word");
h.c=((c[d + 4] << 8) | c[d + 3]) & 16383;
h.Td=c[d + 4] >> 6;
h.i=((c[d + 6] << 8) | c[d + 5]) & 16383;
h.Ud=c[d + 6] >> 6;
d +=7;
e -=7;
a.za=(h.c + 15) >> 4;
a.Ub=(h.i + 15) >> 4;
b.width=h.c;
b.height=h.i;
b.Da=0;
b.j=0;
b.v=0;
b.va=b.width;
b.o=b.height;
b.da=0;
b.ib=b.width;
b.hb=b.height;
b.U=b.width;
b.T=b.height;
f=a.Pa;
M(f.jb, 0, 255, f.jb.length);
f=a.Qa;
x(null!=f);
f.Cb=0;
f.Bb=0;
f.Fb=1;
M(f.Zb, 0, 0, f.Zb.length);
M(f.Lb, 0, 0, f.Lb);
}
if(g.ub > e) return T(a, 7, "bad partition length");
f=a.m;
ma(f, c, d, g.ub);
d +=g.ub;
e -=g.ub;
g.Rb&&((h.Ld=G(f)), (h.Kd=G(f)));
h=a.Qa;
var k=a.Pa,
l;
x(null!=f);
x(null!=h);
h.Cb=G(f);
if(h.Cb){
h.Bb=G(f);
if(G(f)){
h.Fb=G(f);
for (l=0; 4 > l; ++l) h.Zb[l]=G(f) ? ca(f, 7):0;
for (l=0; 4 > l; ++l) h.Lb[l]=G(f) ? ca(f, 6):0;
}
if(h.Bb) for (l=0; 3 > l; ++l) k.jb[l]=G(f) ? na(f, 8):255;
} else h.Bb=0;
if(f.Ka) return T(a, 3, "cannot parse segment header");
h=a.ed;
h.zd=G(f);
h.Tb=na(f, 6);
h.wb=na(f, 3);
h.Pc=G(f);
if(h.Pc&&G(f)){
for (k=0; 4 > k; ++k) G(f)&&(h.vd[k]=ca(f, 6));
for (k=0; 4 > k; ++k) G(f)&&(h.od[k]=ca(f, 6));
}
a.L=0==h.Tb ? 0:h.zd ? 1:2;
if(f.Ka) return T(a, 3, "cannot parse filter header");
l=d;
var m=e;
e=l;
d=l + m;
h=m;
a.Xb=(1 << na(a.m, 2)) - 1;
k=a.Xb;
if(m < 3 * k) c=7;
else {
l +=3 * k;
h -=3 * k;
for (m=0; m < k; ++m){
var n=c[e + 0] | (c[e + 1] << 8) | (c[e + 2] << 16);
n > h&&(n=h);
ma(a.Jc[+m], c, l, n);
l +=n;
h -=n;
e +=3;
}
ma(a.Jc[+k], c, l, h);
c=l < d ? 0:5;
}
if(0!=c) return T(a, c, "cannot parse partitions");
l=a.m;
c=na(l, 7);
e=G(l) ? ca(l, 4):0;
d=G(l) ? ca(l, 4):0;
h=G(l) ? ca(l, 4):0;
k=G(l) ? ca(l, 4):0;
l=G(l) ? ca(l, 4):0;
m=a.Qa;
for (n=0; 4 > n; ++n){
if(m.Cb){
var r=m.Zb[n];
m.Fb||(r +=c);
}else if(0 < n){
a.pb[n]=a.pb[0];
continue;
} else r=c;
var q=a.pb[n];
q.Sc[0]=Lb[ga(r + e, 127)];
q.Sc[1]=Mb[ga(r + 0, 127)];
q.Eb[0]=2 * Lb[ga(r + d, 127)];
q.Eb[1]=(101581 * Mb[ga(r + h, 127)]) >> 16;
8 > q.Eb[1]&&(q.Eb[1]=8);
q.Qc[0]=Lb[ga(r + k, 117)];
q.Qc[1]=Mb[ga(r + l, 127)];
q.lc=r + l;
}
if(!g.Rb) return T(a, 4, "Not a key frame.");
G(f);
g=a.Pa;
for (c=0; 4 > c; ++c){
for (e=0; 8 > e; ++e)
for (d=0; 3 > d; ++d)
for (h=0; 11 > h; ++h)
(k=K(f, Ee[c][e][d][h]) ? na(f, 8):Fe[c][e][d][h]),
(g.Wc[c][e].Yb[d][h]=k);
for (e=0; 17 > e; ++e) g.Xc[c][e]=g.Wc[c][Ge[e]];
}
a.kc=G(f);
a.kc&&(a.Bd=na(f, 8));
return (a.cb=1);
}
function De(a, b, c, d, e, f, g){
var h=b[e].Yb[c];
for (c=0; 16 > e; ++e){
if(!K(a, h[c + 0])) return e;
for (; !K(a, h[c + 1]);)
if(((h=b[++e].Yb[0]), (c=0), 16==e)) return 16;
var k=b[e + 1].Yb;
if(K(a, h[c + 2])){
var l=a,
m=h,
n=c;
var r=0;
if(K(l, m[n + 3]))
if(K(l, m[n + 6])){
h=0;
r=K(l, m[n + 8]);
m=K(l, m[n + 9 + r]);
n=2 * r + m;
r=0;
for (m=He[n]; m[h]; ++h) r +=r + K(l, m[h]);
r +=3 + (8 << n);
} else
K(l, m[n + 7])
? ((r=7 + 2 * K(l, 165)), (r +=K(l, 145)))
: (r=5 + K(l, 159));
else K(l, m[n + 4]) ? (r=3 + K(l, m[n + 5])):(r=2);
h=k[2];
} else (r=1), (h=k[1]);
k=g + Ie[e];
l=a;
0 > l.b&&Qa(l);
var m=l.b,
n=l.Ca >> 1,
q=(n - (l.I >> m)) >> 31;
--l.b;
l.Ca +=q;
l.Ca |=1;
l.I -=((n + 1) & q) << m;
f[k]=((r ^ q) - q) * d[(0 < e) + 0];
}
return 16;
}
function Lc(a){
var b=a.rb[a.sb - 1];
b.la=0;
b.Na=0;
M(a.zc, 0, 0, a.zc.length);
a.ja=0;
}
function Je(a, b){
for (a.M=0; a.M < a.Va; ++a.M){
var c=a.Jc[a.M & a.Xb],
d=a.m,
e=a,
f;
for (f=0; f < e.za; ++f){
var g=d;
var h=e;
var k=h.Ac,
l=h.Bc + 4 * f,
m=h.zc,
n=h.ya[h.aa + f];
h.Qa.Bb
? (n.$b=K(g, h.Pa.jb[0])
? 2 + K(g, h.Pa.jb[2])
: K(g, h.Pa.jb[1]))
: (n.$b=0);
h.kc&&(n.Ad=K(g, h.Bd));
n.Za = !K(g, 145) + 0;
if(n.Za){
var r=n.Ob,
q=0;
for (h=0; 4 > h; ++h){
var t=m[0 + h];
var v;
for (v=0; 4 > v; ++v){
t=Ke[k[l + v]][t];
for (var p=Mc[K(g, t[0])]; 0 < p;)
p=Mc[2 * p + K(g, t[p])];
t=-p;
k[l + v]=t;
}
I(r, q, k, l, 4);
q +=4;
m[0 + h]=t;
}} else
(t=K(g, 156) ? (K(g, 128) ? 1:3):K(g, 163) ? 2:0),
(n.Ob[0]=t),
M(k, l, t, 4),
M(m, 0, t, 4);
n.Dd=K(g, 142) ? (K(g, 114) ? (K(g, 183) ? 1:3):2):0;
}
if(e.m.Ka) return T(a, 7, "Premature end-of-partition0 encountered.");
for (; a.ja < a.za; ++a.ja){
d=a;
e=c;
g=d.rb[d.sb - 1];
k=d.rb[d.sb + d.ja];
f=d.ya[d.aa + d.ja];
if((l=d.kc ? f.Ad:0))
(g.la=k.la=0),
f.Za||(g.Na=k.Na=0),
(f.Hc=0),
(f.Gc=0),
(f.ia=0);
else {
var u,
w,
g=k,
k=e,
l=d.Pa.Xc,
m=d.ya[d.aa + d.ja],
n=d.pb[m.$b];
h=m.ad;
r=0;
q=d.rb[d.sb - 1];
t=v = 0;
M(h, r, 0, 384);
if(m.Za){
var y=0;
var A=l[3];
}else{
p=V(16);
var E=g.Na + q.Na;
E=oa(k, l[1], E, n.Eb, 0, p, 0);
g.Na=q.Na=(0 < E) + 0;
if(1 < E) Nc(p, 0, h, r);
else {
var B=(p[0] + 3) >> 3;
for (p=0; 256 > p; p +=16) h[r + p]=B;
}
y=1;
A=l[0];
}
var C=g.la & 15;
var N=q.la & 15;
for (p=0; 4 > p; ++p){
var z=N & 1;
for (B=w = 0; 4 > B; ++B)
(E=z + (C & 1)),
(E=oa(k, A, E, n.Sc, y, h, r)),
(z=E > y),
(C=(C >> 1) | (z << 7)),
(w=(w << 2) | (3 < E ? 3:1 < E ? 2:0!=h[r + 0])),
(r +=16);
C >>=4;
N=(N >> 1) | (z << 7);
v=((v << 8) | w) >>> 0;
}
A=C;
y=N >> 4;
for (u=0; 4 > u; u +=2){
w=0;
C=g.la >> (4 + u);
N=q.la >> (4 + u);
for (p=0; 2 > p; ++p){
z=N & 1;
for (B=0; 2 > B; ++B)
(E=z + (C & 1)),
(E=oa(k, l[2], E, n.Qc, 0, h, r)),
(z=0 < E),
(C=(C >> 1) | (z << 3)),
(w=(w << 2) | (3 < E ? 3:1 < E ? 2:0!=h[r + 0])),
(r +=16);
C >>=2;
N=(N >> 1) | (z << 5);
}
t |=w << (4 * u);
A |=(C << 4) << u;
y |=(N & 240) << u;
}
g.la=A;
q.la=y;
m.Hc=v;
m.Gc=t;
m.ia=t & 43690 ? 0:n.ia;
l = !(v | t);
}
0 < d.L &&
((d.wa[d.Y + d.ja]=d.gd[f.$b][f.Za]),
(d.wa[d.Y + d.ja].La |= !l));
if(e.Ka) return T(a, 7, "Premature end-of-file encountered.");
}
Lc(a);
c=a;
d=b;
e=1;
f=c.D;
g=0 < c.L&&c.M >=c.zb&&c.M <=c.Va;
if(0==c.Aa)
a: {
(f.M=c.M), (f.uc=g), Oc(c, f), (e=1);
w=c.D;
f=w.Nb;
t=Ya[c.L];
g=t * c.R;
k=(t / 2) * c.B;
p=16 * f * c.R;
B=8 * f * c.B;
l=c.sa;
m=c.ta - g + p;
n=c.qa;
h=c.ra - k + B;
r=c.Ha;
q=c.Ia - k + B;
C=w.M;
N=0==C;
v=C >=c.Va - 1;
2==c.Aa&&Oc(c, w);
if(w.uc)
for (E=c, z=E.D.M, x(E.D.uc), w=E.yb; w < E.Hb; ++w){
var Q=E;
y=w;
A=z;
var S=Q.D,
D=S.Nb;
u=Q.R;
var S=S.wa[S.Y + y],
F=Q.sa,
H=Q.ta + 16 * D * u + 16 * y,
J=S.dd,
G=S.tc;
if(0!=G)
if((x(3 <=G), 1==Q.L))
0 < y&&Pc(F, H, u, G + 4),
S.La&&Qc(F, H, u, G),
0 < A&&Rc(F, H, u, G + 4),
S.La&&Sc(F, H, u, G);
else {
var L=Q.B,
O=Q.qa,
P=Q.ra + 8 * D * L + 8 * y,
R=Q.Ha,
Q=Q.Ia + 8 * D * L + 8 * y,
D=S.ld;
0 < y &&
(Tc(F, H, u, G + 4, J, D),
Uc(O, P, R, Q, L, G + 4, J, D));
S.La&&(Vc(F, H, u, G, J, D), Wc(O, P, R, Q, L, G, J, D));
0 < A &&
(Xc(F, H, u, G + 4, J, D),
Yc(O, P, R, Q, L, G + 4, J, D));
S.La&&(Zc(F, H, u, G, J, D), $c(O, P, R, Q, L, G, J, D));
}}
c.ia&&alert("todo:DitherRow");
if(null!=d.put){
w=16 * C;
C=16 * (C + 1);
N
? ((d.y=c.sa),
(d.O=c.ta + p),
(d.f=c.qa),
(d.N=c.ra + B),
(d.ea=c.Ha),
(d.W=c.Ia + B))
: ((w -=t),
(d.y=l),
(d.O=m),
(d.f=n),
(d.N=h),
(d.ea=r),
(d.W=q));
v||(C -=t);
C > d.o&&(C=d.o);
d.F=null;
d.J=null;
if(null!=c.Fa &&
0 < c.Fa.length &&
w < C &&
((d.J=Le(c, d, w, C - w)),
(d.F=c.mb),
null==d.F&&0==d.F.length)
){
e=T(c, 3, "Could not decode alpha data.");
break a;
}
w < d.j &&
((t=d.j - w),
(w=d.j),
x(!(t & 1)),
(d.O +=c.R * t),
(d.N +=c.B * (t >> 1)),
(d.W +=c.B * (t >> 1)),
null!=d.F&&(d.J +=d.width * t));
w < C &&
((d.O +=d.v),
(d.N +=d.v >> 1),
(d.W +=d.v >> 1),
null!=d.F&&(d.J +=d.v),
(d.ka=w - d.j),
(d.U=d.va - d.v),
(d.T=C - w),
(e=d.put(d)));
}
f + 1!=c.Ic ||
v ||
(I(c.sa, c.ta - g, l, m + 16 * c.R, g),
I(c.qa, c.ra - k, n, h + 8 * c.B, k),
I(c.Ha, c.Ia - k, r, q + 8 * c.B, k));
}
if(!e) return T(a, 6, "Output aborted.");
}
return 1;
}
function Me(a, b){
if(null==a) return 0;
if(null==b) return T(a, 2, "NULL VP8Io parameter in VP8Decode().");
if(!a.cb&&!Kc(a, b)) return 0;
x(a.cb);
if(null==b.ac||b.ac(b)){
b.ob&&(a.L=0);
var c=Ya[a.L];
2==a.L
? ((a.yb=0), (a.zb=0))
: ((a.yb=(b.v - c) >> 4),
(a.zb=(b.j - c) >> 4),
0 > a.yb&&(a.yb=0),
0 > a.zb&&(a.zb=0));
a.Va=(b.o + 15 + c) >> 4;
a.Hb=(b.va + 15 + c) >> 4;
a.Hb > a.za&&(a.Hb=a.za);
a.Va > a.Ub&&(a.Va=a.Ub);
if(0 < a.L){
var d=a.ed;
for (c=0; 4 > c; ++c){
var e;
if(a.Qa.Cb){
var f=a.Qa.Lb[c];
a.Qa.Fb||(f +=d.Tb);
} else f=d.Tb;
for (e=0; 1 >=e; ++e){
var g=a.gd[c][e],
h=f;
d.Pc&&((h +=d.vd[0]), e&&(h +=d.od[0]));
h=0 > h ? 0:63 < h ? 63:h;
if(0 < h){
var k=h;
0 < d.wb &&
((k=4 < d.wb ? k >> 2:k >> 1),
k > 9 - d.wb&&(k=9 - d.wb));
1 > k&&(k=1);
g.dd=k;
g.tc=2 * h + k;
g.ld=40 <=h ? 2:15 <=h ? 1:0;
} else g.tc=0;
g.La=e;
}}
}
c=0;
} else T(a, 6, "Frame setup failed"), (c=a.a);
if((c=0==c)){
if(c){
a.$c=0;
0 < a.Aa||(a.Ic=Ne);
b: {
c=a.Ic;
var k=a.za,
d=4 * k,
l=32 * k,
m=k + 1,
n=0 < a.L ? k * (0 < a.Aa ? 2:1):0,
r=(2==a.Aa ? 2:1) * k;
e=((3 * (16 * c + Ya[a.L])) / 2) * l;
f=null!=a.Fa&&0 < a.Fa.length ? a.Kc.c * a.Kc.i:0;
g=d + 832 + e + f;
if(g!=g) c=0;
else {
if(g > a.Vb){
a.Vb=0;
a.Ec=V(g);
a.Fc=0;
if(null==a.Ec){
c=T(a, 1, "no memory during frame initialization.");
break b;
}
a.Vb=g;
}
g=a.Ec;
h=a.Fc;
a.Ac=g;
a.Bc=h;
h +=d;
a.Gd=wa(l, Ic);
a.Hd=0;
a.rb=wa(m + 1, Hc);
a.sb=1;
a.wa=n ? wa(n, Xa):null;
a.Y=0;
a.D.Nb=0;
a.D.wa=a.wa;
a.D.Y=a.Y;
0 < a.Aa&&(a.D.Y +=k);
x(!0);
a.oc=g;
a.pc=h;
h +=832;
a.ya=wa(r, Kb);
a.aa=0;
a.D.ya=a.ya;
a.D.aa=a.aa;
2==a.Aa&&(a.D.aa +=k);
a.R=16 * k;
a.B=8 * k;
l=Ya[a.L];
k=l * a.R;
l=(l / 2) * a.B;
a.sa=g;
a.ta=h + k;
a.qa=a.sa;
a.ra=a.ta + 16 * c * a.R + l;
a.Ha=a.qa;
a.Ia=a.ra + 8 * c * a.B + l;
a.$c=0;
h +=e;
a.mb=f ? g:null;
a.nb=f ? h:null;
x(h + f <=a.Fc + a.Vb);
Lc(a);
M(a.Ac, a.Bc, 0, d);
c=1;
}}
if(c){
b.ka=0;
b.y=a.sa;
b.O=a.ta;
b.f=a.qa;
b.N=a.ra;
b.ea=a.Ha;
b.Vd=a.Ia;
b.fa=a.R;
b.Rc=a.B;
b.F=null;
b.J=0;
if(!ad){
for (c=-255; 255 >=c; ++c) bd[255 + c]=0 > c ? -c:c;
for (c=-1020; 1020 >=c; ++c)
cd[1020 + c]=-128 > c ? -128:127 < c ? 127:c;
for (c=-112; 112 >=c; ++c)
dd[112 + c]=-16 > c ? -16:15 < c ? 15:c;
for (c=-255; 510 >=c; ++c)
ed[255 + c]=0 > c ? 0:255 < c ? 255:c;
ad=1;
}
Nc=Oe;
Za=Pe;
Nb=Qe;
pa=Re;
Ob=Se;
fd=Te;
Xc=Ue;
Tc=Ve;
Yc=We;
Uc=Xe;
Zc=Ye;
Vc=Ze;
$c=$e;
Wc=af;
Rc=gd;
Pc=hd;
Sc=bf;
Qc=cf;
W[0]=df;
W[1]=ef;
W[2]=ff;
W[3]=gf;
W[4]=hf;
W[5]=jf;
W[6]=kf;
W[7]=lf;
W[8]=mf;
W[9]=nf;
Y[0]=of;
Y[1]=pf;
Y[2]=qf;
Y[3]=rf;
Y[4]=sf;
Y[5]=tf;
Y[6]=uf;
ka[0]=vf;
ka[1]=wf;
ka[2]=xf;
ka[3]=yf;
ka[4]=zf;
ka[5]=Af;
ka[6]=Bf;
c=1;
} else c=0;
}
c&&(c=Je(a, b));
null!=b.bc&&b.bc(b);
c &=1;
}
if(!c) return 0;
a.cb=0;
return c;
}
function qa(a, b, c, d, e){
e=a[b + c + 32 * d] + (e >> 3);
a[b + c + 32 * d]=e & -256 ? (0 > e ? 0:255):e;
}
function kb(a, b, c, d, e, f){
qa(a, b, 0, c, d + e);
qa(a, b, 1, c, d + f);
qa(a, b, 2, c, d - f);
qa(a, b, 3, c, d - e);
}
function da(a){
return ((20091 * a) >> 16) + a;
}
function id(a, b, c, d){
var e=0,
f;
var g=V(16);
for (f=0; 4 > f; ++f){
var h=a[b + 0] + a[b + 8];
var k=a[b + 0] - a[b + 8];
var l=((35468 * a[b + 4]) >> 16) - da(a[b + 12]);
var m=da(a[b + 4]) + ((35468 * a[b + 12]) >> 16);
g[e + 0]=h + m;
g[e + 1]=k + l;
g[e + 2]=k - l;
g[e + 3]=h - m;
e +=4;
b++;
}
for (f=e = 0; 4 > f; ++f)
(a=g[e + 0] + 4),
(h=a + g[e + 8]),
(k=a - g[e + 8]),
(l=((35468 * g[e + 4]) >> 16) - da(g[e + 12])),
(m=da(g[e + 4]) + ((35468 * g[e + 12]) >> 16)),
qa(c, d, 0, 0, h + m),
qa(c, d, 1, 0, k + l),
qa(c, d, 2, 0, k - l),
qa(c, d, 3, 0, h - m),
e++,
(d +=32);
}
function Te(a, b, c, d){
var e=a[b + 0] + 4,
f=(35468 * a[b + 4]) >> 16,
g=da(a[b + 4]),
h=(35468 * a[b + 1]) >> 16;
a=da(a[b + 1]);
kb(c, d, 0, e + g, a, h);
kb(c, d, 1, e + f, a, h);
kb(c, d, 2, e - f, a, h);
kb(c, d, 3, e - g, a, h);
}
function Pe(a, b, c, d, e){
id(a, b, c, d);
e&&id(a, b + 16, c, d + 4);
}
function Qe(a, b, c, d){
Za(a, b + 0, c, d, 1);
Za(a, b + 32, c, d + 128, 1);
}
function Re(a, b, c, d){
a=a[b + 0] + 4;
var e;
for (e=0; 4 > e; ++e) for (b=0; 4 > b; ++b) qa(c, d, b, e, a);
}
function Se(a, b, c, d){
a[b + 0]&&pa(a, b + 0, c, d);
a[b + 16]&&pa(a, b + 16, c, d + 4);
a[b + 32]&&pa(a, b + 32, c, d + 128);
a[b + 48]&&pa(a, b + 48, c, d + 128 + 4);
}
function Oe(a, b, c, d){
var e=V(16),
f;
for (f=0; 4 > f; ++f){
var g=a[b + 0 + f] + a[b + 12 + f];
var h=a[b + 4 + f] + a[b + 8 + f];
var k=a[b + 4 + f] - a[b + 8 + f];
var l=a[b + 0 + f] - a[b + 12 + f];
e[0 + f]=g + h;
e[8 + f]=g - h;
e[4 + f]=l + k;
e[12 + f]=l - k;
}
for (f=0; 4 > f; ++f)
(a=e[0 + 4 * f] + 3),
(g=a + e[3 + 4 * f]),
(h=e[1 + 4 * f] + e[2 + 4 * f]),
(k=e[1 + 4 * f] - e[2 + 4 * f]),
(l=a - e[3 + 4 * f]),
(c[d + 0]=(g + h) >> 3),
(c[d + 16]=(l + k) >> 3),
(c[d + 32]=(g - h) >> 3),
(c[d + 48]=(l - k) >> 3),
(d +=64);
}
function Pb(a, b, c){
var d=b - 32,
e=R,
f=255 - a[d - 1],
g;
for (g=0; g < c; ++g){
var h=e,
k=f + a[b - 1],
l;
for (l=0; l < c; ++l) a[b + l]=h[k + a[d + l]];
b +=32;
}}
function ef(a, b){
Pb(a, b, 4);
}
function wf(a, b){
Pb(a, b, 8);
}
function pf(a, b){
Pb(a, b, 16);
}
function qf(a, b){
var c;
for (c=0; 16 > c; ++c) I(a, b + 32 * c, a, b - 32, 16);
}
function rf(a, b){
var c;
for (c=16; 0 < c; --c) M(a, b, a[b - 1], 16), (b +=32);
}
function $a(a, b, c){
var d;
for (d=0; 16 > d; ++d) M(b, c + 32 * d, a, 16);
}
function of(a, b){
var c=16,
d;
for (d=0; 16 > d; ++d) c +=a[b - 1 + 32 * d] + a[b + d - 32];
$a(c >> 5, a, b);
}
function sf(a, b){
var c=8,
d;
for (d=0; 16 > d; ++d) c +=a[b - 1 + 32 * d];
$a(c >> 4, a, b);
}
function tf(a, b){
var c=8,
d;
for (d=0; 16 > d; ++d) c +=a[b + d - 32];
$a(c >> 4, a, b);
}
function uf(a, b){
$a(128, a, b);
}
function z(a, b, c){
return (a + 2 * b + c + 2) >> 2;
}
function ff(a, b){
var c=b - 32,
c=new Uint8Array([
z(a[c - 1], a[c + 0], a[c + 1]),
z(a[c + 0], a[c + 1], a[c + 2]),
z(a[c + 1], a[c + 2], a[c + 3]),
z(a[c + 2], a[c + 3], a[c + 4])
]),
d;
for (d=0; 4 > d; ++d) I(a, b + 32 * d, c, 0, c.length);
}
function gf(a, b){
var c=a[b - 1],
d=a[b - 1 + 32],
e=a[b - 1 + 64],
f=a[b - 1 + 96];
ra(a, b + 0, 16843009 * z(a[b - 1 - 32], c, d));
ra(a, b + 32, 16843009 * z(c, d, e));
ra(a, b + 64, 16843009 * z(d, e, f));
ra(a, b + 96, 16843009 * z(e, f, f));
}
function df(a, b){
var c=4,
d;
for (d=0; 4 > d; ++d) c +=a[b + d - 32] + a[b - 1 + 32 * d];
c >>=3;
for (d=0; 4 > d; ++d) M(a, b + 32 * d, c, 4);
}
function hf(a, b){
var c=a[b - 1 + 0],
d=a[b - 1 + 32],
e=a[b - 1 + 64],
f=a[b - 1 - 32],
g=a[b + 0 - 32],
h=a[b + 1 - 32],
k=a[b + 2 - 32],
l=a[b + 3 - 32];
a[b + 0 + 96]=z(d, e, a[b - 1 + 96]);
a[b + 1 + 96]=a[b + 0 + 64]=z(c, d, e);
a[b + 2 + 96]=a[b + 1 + 64]=a[b + 0 + 32]=z(f, c, d);
a[b + 3 + 96]=a[b + 2 + 64]=a[b + 1 + 32]=a[b + 0 + 0]=z(g, f, c);
a[b + 3 + 64]=a[b + 2 + 32]=a[b + 1 + 0]=z(h, g, f);
a[b + 3 + 32]=a[b + 2 + 0]=z(k, h, g);
a[b + 3 + 0]=z(l, k, h);
}
function kf(a, b){
var c=a[b + 1 - 32],
d=a[b + 2 - 32],
e=a[b + 3 - 32],
f=a[b + 4 - 32],
g=a[b + 5 - 32],
h=a[b + 6 - 32],
k=a[b + 7 - 32];
a[b + 0 + 0]=z(a[b + 0 - 32], c, d);
a[b + 1 + 0]=a[b + 0 + 32]=z(c, d, e);
a[b + 2 + 0]=a[b + 1 + 32]=a[b + 0 + 64]=z(d, e, f);
a[b + 3 + 0]=a[b + 2 + 32]=a[b + 1 + 64]=a[b + 0 + 96]=z(e, f, g);
a[b + 3 + 32]=a[b + 2 + 64]=a[b + 1 + 96]=z(f, g, h);
a[b + 3 + 64]=a[b + 2 + 96]=z(g, h, k);
a[b + 3 + 96]=z(h, k, k);
}
function jf(a, b){
var c=a[b - 1 + 0],
d=a[b - 1 + 32],
e=a[b - 1 + 64],
f=a[b - 1 - 32],
g=a[b + 0 - 32],
h=a[b + 1 - 32],
k=a[b + 2 - 32],
l=a[b + 3 - 32];
a[b + 0 + 0]=a[b + 1 + 64]=(f + g + 1) >> 1;
a[b + 1 + 0]=a[b + 2 + 64]=(g + h + 1) >> 1;
a[b + 2 + 0]=a[b + 3 + 64]=(h + k + 1) >> 1;
a[b + 3 + 0]=(k + l + 1) >> 1;
a[b + 0 + 96]=z(e, d, c);
a[b + 0 + 64]=z(d, c, f);
a[b + 0 + 32]=a[b + 1 + 96]=z(c, f, g);
a[b + 1 + 32]=a[b + 2 + 96]=z(f, g, h);
a[b + 2 + 32]=a[b + 3 + 96]=z(g, h, k);
a[b + 3 + 32]=z(h, k, l);
}
function lf(a, b){
var c=a[b + 0 - 32],
d=a[b + 1 - 32],
e=a[b + 2 - 32],
f=a[b + 3 - 32],
g=a[b + 4 - 32],
h=a[b + 5 - 32],
k=a[b + 6 - 32],
l=a[b + 7 - 32];
a[b + 0 + 0]=(c + d + 1) >> 1;
a[b + 1 + 0]=a[b + 0 + 64]=(d + e + 1) >> 1;
a[b + 2 + 0]=a[b + 1 + 64]=(e + f + 1) >> 1;
a[b + 3 + 0]=a[b + 2 + 64]=(f + g + 1) >> 1;
a[b + 0 + 32]=z(c, d, e);
a[b + 1 + 32]=a[b + 0 + 96]=z(d, e, f);
a[b + 2 + 32]=a[b + 1 + 96]=z(e, f, g);
a[b + 3 + 32]=a[b + 2 + 96]=z(f, g, h);
a[b + 3 + 64]=z(g, h, k);
a[b + 3 + 96]=z(h, k, l);
}
function nf(a, b){
var c=a[b - 1 + 0],
d=a[b - 1 + 32],
e=a[b - 1 + 64],
f=a[b - 1 + 96];
a[b + 0 + 0]=(c + d + 1) >> 1;
a[b + 2 + 0]=a[b + 0 + 32]=(d + e + 1) >> 1;
a[b + 2 + 32]=a[b + 0 + 64]=(e + f + 1) >> 1;
a[b + 1 + 0]=z(c, d, e);
a[b + 3 + 0]=a[b + 1 + 32]=z(d, e, f);
a[b + 3 + 32]=a[b + 1 + 64]=z(e, f, f);
a[b + 3 + 64]=a[b + 2 + 64]=a[b + 0 + 96]=a[b + 1 + 96]=a[
b + 2 + 96
]=a[b + 3 + 96]=f;
}
function mf(a, b){
var c=a[b - 1 + 0],
d=a[b - 1 + 32],
e=a[b - 1 + 64],
f=a[b - 1 + 96],
g=a[b - 1 - 32],
h=a[b + 0 - 32],
k=a[b + 1 - 32],
l=a[b + 2 - 32];
a[b + 0 + 0]=a[b + 2 + 32]=(c + g + 1) >> 1;
a[b + 0 + 32]=a[b + 2 + 64]=(d + c + 1) >> 1;
a[b + 0 + 64]=a[b + 2 + 96]=(e + d + 1) >> 1;
a[b + 0 + 96]=(f + e + 1) >> 1;
a[b + 3 + 0]=z(h, k, l);
a[b + 2 + 0]=z(g, h, k);
a[b + 1 + 0]=a[b + 3 + 32]=z(c, g, h);
a[b + 1 + 32]=a[b + 3 + 64]=z(d, c, g);
a[b + 1 + 64]=a[b + 3 + 96]=z(e, d, c);
a[b + 1 + 96]=z(f, e, d);
}
function xf(a, b){
var c;
for (c=0; 8 > c; ++c) I(a, b + 32 * c, a, b - 32, 8);
}
function yf(a, b){
var c;
for (c=0; 8 > c; ++c) M(a, b, a[b - 1], 8), (b +=32);
}
function lb(a, b, c){
var d;
for (d=0; 8 > d; ++d) M(b, c + 32 * d, a, 8);
}
function vf(a, b){
var c=8,
d;
for (d=0; 8 > d; ++d) c +=a[b + d - 32] + a[b - 1 + 32 * d];
lb(c >> 4, a, b);
}
function Af(a, b){
var c=4,
d;
for (d=0; 8 > d; ++d) c +=a[b + d - 32];
lb(c >> 3, a, b);
}
function zf(a, b){
var c=4,
d;
for (d=0; 8 > d; ++d) c +=a[b - 1 + 32 * d];
lb(c >> 3, a, b);
}
function Bf(a, b){
lb(128, a, b);
}
function ab(a, b, c){
var d=a[b - c],
e=a[b + 0],
f=3 * (e - d) + Qb[1020 + a[b - 2 * c] - a[b + c]],
g=mb[112 + ((f + 4) >> 3)];
a[b - c]=R[255 + d + mb[112 + ((f + 3) >> 3)]];
a[b + 0]=R[255 + e - g];
}
function jd(a, b, c, d){
var e=a[b + 0],
f=a[b + c];
return U[255 + a[b - 2 * c] - a[b - c]] > d||U[255 + f - e] > d;
}
function kd(a, b, c, d){
return (
4 * U[255 + a[b - c] - a[b + 0]] + U[255 + a[b - 2 * c] - a[b + c]] <=d
);
}
function ld(a, b, c, d, e){
var f=a[b - 3 * c],
g=a[b - 2 * c],
h=a[b - c],
k=a[b + 0],
l=a[b + c],
m=a[b + 2 * c],
n=a[b + 3 * c];
return 4 * U[255 + h - k] + U[255 + g - l] > d
? 0
: U[255 + a[b - 4 * c] - f] <=e &&
U[255 + f - g] <=e &&
U[255 + g - h] <=e &&
U[255 + n - m] <=e &&
U[255 + m - l] <=e &&
U[255 + l - k] <=e;
}
function gd(a, b, c, d){
var e=2 * d + 1;
for (d=0; 16 > d; ++d) kd(a, b + d, c, e)&&ab(a, b + d, c);
}
function hd(a, b, c, d){
var e=2 * d + 1;
for (d=0; 16 > d; ++d) kd(a, b + d * c, 1, e)&&ab(a, b + d * c, 1);
}
function bf(a, b, c, d){
var e;
for (e=3; 0 < e; --e) (b +=4 * c), gd(a, b, c, d);
}
function cf(a, b, c, d){
var e;
for (e=3; 0 < e; --e) (b +=4), hd(a, b, c, d);
}
function ea(a, b, c, d, e, f, g, h){
for (f=2 * f + 1; 0 < e--;){
if(ld(a, b, c, f, g))
if(jd(a, b, c, h)) ab(a, b, c);
else {
var k=a,
l=b,
m=c,
n=k[l - 2 * m],
r=k[l - m],
q=k[l + 0],
t=k[l + m],
v=k[l + 2 * m],
p=Qb[1020 + 3 * (q - r) + Qb[1020 + n - t]],
u=(27 * p + 63) >> 7,
w=(18 * p + 63) >> 7,
p=(9 * p + 63) >> 7;
k[l - 3 * m]=R[255 + k[l - 3 * m] + p];
k[l - 2 * m]=R[255 + n + w];
k[l - m]=R[255 + r + u];
k[l + 0]=R[255 + q - u];
k[l + m]=R[255 + t - w];
k[l + 2 * m]=R[255 + v - p];
}
b +=d;
}}
function Fa(a, b, c, d, e, f, g, h){
for (f=2 * f + 1; 0 < e--;){
if(ld(a, b, c, f, g))
if(jd(a, b, c, h)) ab(a, b, c);
else {
var k=a,
l=b,
m=c,
n=k[l - m],
r=k[l + 0],
q=k[l + m],
t=3 * (r - n),
v=mb[112 + ((t + 4) >> 3)],
t=mb[112 + ((t + 3) >> 3)],
p=(v + 1) >> 1;
k[l - 2 * m]=R[255 + k[l - 2 * m] + p];
k[l - m]=R[255 + n + t];
k[l + 0]=R[255 + r - v];
k[l + m]=R[255 + q - p];
}
b +=d;
}}
function Ue(a, b, c, d, e, f){
ea(a, b, c, 1, 16, d, e, f);
}
function Ve(a, b, c, d, e, f){
ea(a, b, 1, c, 16, d, e, f);
}
function Ye(a, b, c, d, e, f){
var g;
for (g=3; 0 < g; --g) (b +=4 * c), Fa(a, b, c, 1, 16, d, e, f);
}
function Ze(a, b, c, d, e, f){
var g;
for (g=3; 0 < g; --g) (b +=4), Fa(a, b, 1, c, 16, d, e, f);
}
function We(a, b, c, d, e, f, g, h){
ea(a, b, e, 1, 8, f, g, h);
ea(c, d, e, 1, 8, f, g, h);
}
function Xe(a, b, c, d, e, f, g, h){
ea(a, b, 1, e, 8, f, g, h);
ea(c, d, 1, e, 8, f, g, h);
}
function $e(a, b, c, d, e, f, g, h){
Fa(a, b + 4 * e, e, 1, 8, f, g, h);
Fa(c, d + 4 * e, e, 1, 8, f, g, h);
}
function af(a, b, c, d, e, f, g, h){
Fa(a, b + 4, 1, e, 8, f, g, h);
Fa(c, d + 4, 1, e, 8, f, g, h);
}
function Cf(){
this.ba=new Cb();
this.ec=[];
this.cc=[];
this.Mc=[];
this.Dc=this.Nc=this.dc=this.fc=0;
this.Oa=new Ud();
this.memory=0;
this.Ib="OutputFunc";
this.Jb="OutputAlphaFunc";
this.Nd="OutputRowFunc";
}
function md(){
this.data=[];
this.offset=this.kd=this.ha=this.w=0;
this.na=[];
this.xa=this.gb=this.Ja=this.Sa=this.P=0;
}
function Df(){
this.nc=this.Ea=this.b=this.hc=0;
this.K=[];
this.w=0;
}
function Ef(){
this.ua=0;
this.Wa=new ac();
this.vb=new ac();
this.md=this.xc=this.wc=0;
this.vc=[];
this.Wb=0;
this.Ya=new Ub();
this.yc=new O();
}
function je(){
this.xb=this.a=0;
this.l=new Oa();
this.ca=new Cb();
this.V=[];
this.Ba=0;
this.Ta=[];
this.Ua=0;
this.m=new Ra();
this.Pb=0;
this.wd=new Ra();
this.Ma=this.$=this.C=this.i=this.c=this.xd=0;
this.s=new Ef();
this.ab=0;
this.gc=wa(4, Df);
this.Oc=0;
}
function Ff(){
this.Lc=this.Z=this.$a=this.i=this.c=0;
this.l=new Oa();
this.ic=0;
this.ca=[];
this.tb=0;
this.qd=null;
this.rd=0;
}
function Rb(a, b, c, d, e, f, g){
a=null==a ? 0:a[b + 0];
for (b=0; b < g; ++b) (e[f + b]=(a + c[d + b]) & 255), (a=e[f + b]);
}
function Gf(a, b, c, d, e, f, g){
if(null==a) Rb(null, null, c, d, e, f, g);
else {
var h;
for (h=0; h < g; ++h) e[f + h]=(a[b + h] + c[d + h]) & 255;
}}
function Hf(a, b, c, d, e, f, g){
if(null==a) Rb(null, null, c, d, e, f, g);
else {
var h=a[b + 0],
k=h,
l=h,
m;
for (m=0; m < g; ++m)
(h=a[b + m]),
(k=l + h - k),
(l=(c[d + m] + (k & -256 ? (0 > k ? 0:255):k)) & 255),
(k=h),
(e[f + m]=l);
}}
function Le(a, b, c, d){
var e=b.width,
f=b.o;
x(null!=a&&null!=b);
if(0 > c||0 >=d||c + d > f) return null;
if(!a.Cc){
if(null==a.ga){
a.ga=new Ff();
var g;
(g=null==a.ga) ||
((g=b.width * b.o),
x(0==a.Gb.length),
(a.Gb=V(g)),
(a.Uc=0),
null==a.Gb
? (g=0)
: ((a.mb=a.Gb), (a.nb=a.Uc), (a.rc=null), (g=1)),
(g = !g));
if(!g){
g=a.ga;
var h=a.Fa,
k=a.P,
l=a.qc,
m=a.mb,
n=a.nb,
r=k + 1,
q=l - 1,
t=g.l;
x(null!=h&&null!=m&&null!=b);
ia[0]=null;
ia[1]=Rb;
ia[2]=Gf;
ia[3]=Hf;
g.ca=m;
g.tb=n;
g.c=b.width;
g.i=b.height;
x(0 < g.c&&0 < g.i);
if(1 >=l) b=0;
else if(((g.$a=(h[k + 0] >> 0) & 3),
(g.Z=(h[k + 0] >> 2) & 3),
(g.Lc=(h[k + 0] >> 4) & 3),
(k=(h[k + 0] >> 6) & 3),
0 > g.$a||1 < g.$a||4 <=g.Z||1 < g.Lc||k)
)
b=0;
else if(((t.put=kc),
(t.ac=gc),
(t.bc=lc),
(t.ma=g),
(t.width=b.width),
(t.height=b.height),
(t.Da=b.Da),
(t.v=b.v),
(t.va=b.va),
(t.j=b.j),
(t.o=b.o),
g.$a)
)
b: {
x(1==g.$a), (b=Bc());
c: for (;;){
if(null==b){
b=0;
break b;
}
x(null!=g);
g.mc=b;
b.c=g.c;
b.i=g.i;
b.l=g.l;
b.l.ma=g;
b.l.width=g.c;
b.l.height=g.i;
b.a=0;
cb(b.m, h, r, q);
if(!rb(g.c, g.i, 1, b, null)) break c;
1==b.ab&&3==b.gc[0].hc&&yc(b.s)
? ((g.ic=1),
(h=b.c * b.i),
(b.Ta=null),
(b.Ua=0),
(b.V=V(h)),
(b.Ba=0),
null==b.V ? ((b.a=1), (b=0)):(b=1))
: ((g.ic=0), (b=Ec(b, g.c)));
if(!b) break c;
b=1;
break b;
}
g.mc=null;
b=0;
}
else b=q >=g.c * g.i;
g = !b;
}
if(g) return null;
1!=a.ga.Lc ? (a.Ga=0):(d=f - c);
}
x(null!=a.ga);
x(c + d <=f);
a: {
h=a.ga;
b=h.c;
f=h.l.o;
if(0==h.$a){
r=a.rc;
q=a.Vc;
t=a.Fa;
k=a.P + 1 + c * b;
l=a.mb;
m=a.nb + c * b;
x(k <=a.P + a.qc);
if(0!=h.Z)
for (x(null!=ia[h.Z]), g=0; g < d; ++g)
ia[h.Z](r, q, t, k, l, m, b),
(r=l),
(q=m),
(m +=b),
(k +=b);
else
for (g=0; g < d; ++g)
I(l, m, t, k, b), (r=l), (q=m), (m +=b), (k +=b);
a.rc=r;
a.Vc=q;
}else{
x(null!=h.mc);
b=c + d;
g=h.mc;
x(null!=g);
x(b <=g.i);
if(g.C >=b) b=1;
else if((h.ic||Aa(), h.ic)){
var h=g.V,
r=g.Ba,
q=g.c,
v=g.i,
t=1,
k=g.$ / q,
l=g.$ % q,
m=g.m,
n=g.s,
p=g.$,
u=q * v,
w=q * b,
y=n.wc,
A=p < w ? ha(n, l, k):null;
x(p <=u);
x(b <=v);
x(yc(n));
c: for (;;){
for (; !m.h&&p < w;){
l & y||(A=ha(n, l, k));
x(null!=A);
Sa(m);
v=ua(A.G[0], A.H[0], m);
if(256 > v)
(h[r + p]=v),
++p,
++l,
l >=q&&((l=0), ++k, k <=b&&!(k % 16)&&Ib(g, k));
else if(280 > v){
var v=ib(v - 256, m);
var E=ua(A.G[4], A.H[4], m);
Sa(m);
E=ib(E, m);
E=nc(q, E);
if(p >=E&&u - p >=v){
var B;
for (B=0; B < v; ++B) h[r + p + B]=h[r + p + B - E];
}else{
t=0;
break c;
}
p +=v;
for (l +=v; l >=q;)
(l -=q), ++k, k <=b&&!(k % 16)&&Ib(g, k);
p < w&&l & y&&(A=ha(n, l, k));
}else{
t=0;
break c;
}
x(m.h==db(m));
}
Ib(g, k > b ? b:k);
break c;
}
!t||(m.h&&p < u) ? ((t=0), (g.a=m.h ? 5:3)):(g.$=p);
b=t;
} else b=Jb(g, g.V, g.Ba, g.c, g.i, b, se);
if(!b){
d=0;
break a;
}}
c + d >=f&&(a.Cc=1);
d=1;
}
if(!d) return null;
if(a.Cc &&
((d=a.ga), null!=d&&(d.mc=null), (a.ga=null), 0 < a.Ga)
)
return alert("todo:WebPDequantizeLevels"), null;
}
return a.nb + c * e;
}
function If(a, b, c, d, e, f){
for (; 0 < e--;){
var g=a,
h=b + (c ? 1:0),
k=a,
l=b + (c ? 0:3),
m;
for (m=0; m < d; ++m){
var n=k[l + 4 * m];
255!=n &&
((n *=32897),
(g[h + 4 * m + 0]=(g[h + 4 * m + 0] * n) >> 23),
(g[h + 4 * m + 1]=(g[h + 4 * m + 1] * n) >> 23),
(g[h + 4 * m + 2]=(g[h + 4 * m + 2] * n) >> 23));
}
b +=f;
}}
function Jf(a, b, c, d, e){
for (; 0 < d--;){
var f;
for (f=0; f < c; ++f){
var g=a[b + 2 * f + 0],
h=a[b + 2 * f + 1],
k=h & 15,
l=4369 * k,
h=(((h & 240) | (h >> 4)) * l) >> 16;
a[b + 2 * f + 0] =
(((((g & 240) | (g >> 4)) * l) >> 16) & 240) |
((((((g & 15) | (g << 4)) * l) >> 16) >> 4) & 15);
a[b + 2 * f + 1]=(h & 240) | k;
}
b +=e;
}}
function Kf(a, b, c, d, e, f, g, h){
var k=255,
l,
m;
for (m=0; m < e; ++m){
for (l=0; l < d; ++l){
var n=a[b + l];
f[g + 4 * l]=n;
k &=n;
}
b +=c;
g +=h;
}
return 255!=k;
}
function Lf(a, b, c, d, e){
var f;
for (f=0; f < e; ++f) c[d + f]=a[b + f] >> 8;
}
function Aa(){
za=If;
vc=Jf;
fc=Kf;
Fc=Lf;
}
function va(a, b, c){
self[a]=function(a, e, f, g, h, k, l, m, n, r, q, t, v, p, u, w, y){
var d,
E=(y - 1) >> 1;
var B=h[k + 0] | (l[m + 0] << 16);
var C=n[r + 0] | (q[t + 0] << 16);
x(null!=a);
var z=(3 * B + C + 131074) >> 2;
b(a[e + 0], z & 255, z >> 16, v, p);
null!=f &&
((z=(3 * C + B + 131074) >> 2),
b(f[g + 0], z & 255, z >> 16, u, w));
for (d=1; d <=E; ++d){
var D=h[k + d] | (l[m + d] << 16);
var G=n[r + d] | (q[t + d] << 16);
var F=B + D + C + G + 524296;
var H=(F + 2 * (D + C)) >> 3;
F=(F + 2 * (B + G)) >> 3;
z=(H + B) >> 1;
B=(F + D) >> 1;
b(a[e + 2 * d - 1], z & 255, z >> 16, v, p + (2 * d - 1) * c);
b(a[e + 2 * d - 0], B & 255, B >> 16, v, p + (2 * d - 0) * c);
null!=f &&
((z=(F + C) >> 1),
(B=(H + G) >> 1),
b(f[g + 2 * d - 1], z & 255, z >> 16, u, w + (2 * d - 1) * c),
b(f[g + 2 * d + 0], B & 255, B >> 16, u, w + (2 * d + 0) * c));
B=D;
C=G;
}
y & 1 ||
((z=(3 * B + C + 131074) >> 2),
b(a[e + y - 1], z & 255, z >> 16, v, p + (y - 1) * c),
null!=f &&
((z=(3 * C + B + 131074) >> 2),
b(f[g + y - 1], z & 255, z >> 16, u, w + (y - 1) * c)));
};}
function ic(){
P[Ca]=Mf;
P[Ua]=nd;
P[tc]=Nf;
P[Va]=od;
P[ya]=pd;
P[Db]=qd;
P[wc]=Of;
P[zb]=nd;
P[Ab]=od;
P[Ja]=pd;
P[Bb]=qd;
}
function Sb(a){
return a & ~Pf ? (0 > a ? 0:255):a >> rd;
}
function bb(a, b){
return Sb(((19077 * a) >> 8) + ((26149 * b) >> 8) - 14234);
}
function nb(a, b, c){
return Sb(
((19077 * a) >> 8) - ((6419 * b) >> 8) - ((13320 * c) >> 8) + 8708
);
}
function Pa(a, b){
return Sb(((19077 * a) >> 8) + ((33050 * b) >> 8) - 17685);
}
function Ga(a, b, c, d, e){
d[e + 0]=bb(a, c);
d[e + 1]=nb(a, b, c);
d[e + 2]=Pa(a, b);
}
function Tb(a, b, c, d, e){
d[e + 0]=Pa(a, b);
d[e + 1]=nb(a, b, c);
d[e + 2]=bb(a, c);
}
function sd(a, b, c, d, e){
var f=nb(a, b, c);
b=((f << 3) & 224) | (Pa(a, b) >> 3);
d[e + 0]=(bb(a, c) & 248) | (f >> 5);
d[e + 1]=b;
}
function td(a, b, c, d, e){
var f=(Pa(a, b) & 240) | 15;
d[e + 0]=(bb(a, c) & 240) | (nb(a, b, c) >> 4);
d[e + 1]=f;
}
function ud(a, b, c, d, e){
d[e + 0]=255;
Ga(a, b, c, d, e + 1);
}
function vd(a, b, c, d, e){
Tb(a, b, c, d, e);
d[e + 3]=255;
}
function wd(a, b, c, d, e){
Ga(a, b, c, d, e);
d[e + 3]=255;
}
function ga(a, b){
return 0 > a ? 0:a > b ? b:a;
}
function la(a, b, c){
self[a]=function(a, e, f, g, h, k, l, m, n){
for (var d=m + (n & -2) * c; m!=d;)
b(a[e + 0], f[g + 0], h[k + 0], l, m),
b(a[e + 1], f[g + 0], h[k + 0], l, m + c),
(e +=2),
++g,
++k,
(m +=2 * c);
n & 1&&b(a[e + 0], f[g + 0], h[k + 0], l, m);
};}
function xd(a, b, c){
return 0==c ? (0==a ? (0==b ? 6:5):0==b ? 4:0):c;
}
function yd(a, b, c, d, e){
switch (a >>> 30){
case 3:
Za(b, c, d, e, 0);
break;
case 2:
fd(b, c, d, e);
break;
case 1:
pa(b, c, d, e);
}}
function Oc(a, b){
var c,
d,
e=b.M,
f=b.Nb,
g=a.oc,
h=a.pc + 40,
k=a.oc,
l=a.pc + 584,
m=a.oc,
n=a.pc + 600;
for (c=0; 16 > c; ++c) g[h + 32 * c - 1]=129;
for (c=0; 8 > c; ++c)
(k[l + 32 * c - 1]=129), (m[n + 32 * c - 1]=129);
0 < e
? (g[h - 1 - 32]=k[l - 1 - 32]=m[n - 1 - 32]=129)
: (M(g, h - 32 - 1, 127, 21),
M(k, l - 32 - 1, 127, 9),
M(m, n - 32 - 1, 127, 9));
for (d=0; d < a.za; ++d){
var r=b.ya[b.aa + d];
if(0 < d){
for (c=-1; 16 > c; ++c) I(g, h + 32 * c - 4, g, h + 32 * c + 12, 4);
for (c=-1; 8 > c; ++c)
I(k, l + 32 * c - 4, k, l + 32 * c + 4, 4),
I(m, n + 32 * c - 4, m, n + 32 * c + 4, 4);
}
var q=a.Gd,
t=a.Hd + d,
v=r.ad,
p=r.Hc;
0 < e &&
(I(g, h - 32, q[t].y, 0, 16),
I(k, l - 32, q[t].f, 0, 8),
I(m, n - 32, q[t].ea, 0, 8));
if(r.Za){
var u=g;
var w=h - 32 + 16;
0 < e &&
(d >=a.za - 1
? M(u, w, q[t].y[15], 4)
: I(u, w, q[t + 1].y, 0, 4));
for (c=0; 4 > c; c++)
u[w + 128 + c]=u[w + 256 + c]=u[w + 384 + c]=u[w + 0 + c];
for (c=0; 16 > c; ++c, p <<=2)
(u=g), (w=h + zd[c]), W[r.Ob[c]](u, w), yd(p, v, 16 * +c, u, w);
}else if(((u=xd(d, e, r.Ob[0])), Y[u](g, h), 0!=p))
for (c=0; 16 > c; ++c, p <<=2) yd(p, v, 16 * +c, g, h + zd[c]);
c=r.Gc;
u=xd(d, e, r.Dd);
ka[u](k, l);
ka[u](m, n);
r=c >> 0;
p=v;
u=k;
w=l;
r & 255&&(r & 170 ? Nb(p, 256, u, w):Ob(p, 256, u, w));
c >>=8;
r=m;
p=n;
c & 255&&(c & 170 ? Nb(v, 320, r, p):Ob(v, 320, r, p));
e < a.Ub - 1 &&
(I(q[t].y, 0, g, h + 480, 16),
I(q[t].f, 0, k, l + 224, 8),
I(q[t].ea, 0, m, n + 224, 8));
c=8 * f * a.B;
q=a.sa;
t=a.ta + 16 * d + 16 * f * a.R;
v=a.qa;
r=a.ra + 8 * d + c;
p=a.Ha;
u=a.Ia + 8 * d + c;
for (c=0; 16 > c; ++c) I(q, t + c * a.R, g, h + 32 * c, 16);
for (c=0; 8 > c; ++c)
I(v, r + c * a.B, k, l + 32 * c, 8),
I(p, u + c * a.B, m, n + 32 * c, 8);
}}
function Ad(a, b, c, d, e, f, g, h, k){
var l=[0],
m=[0],
n=0,
r=null!=k ? k.kd:0,
q=null!=k ? k:new md();
if(null==a||12 > c) return 7;
q.data=a;
q.w=b;
q.ha=c;
b=[b];
c=[c];
q.gb=[q.gb];
a: {
var t=b;
var v=c;
var p=q.gb;
x(null!=a);
x(null!=v);
x(null!=p);
p[0]=0;
if(12 <=v[0]&&!fa(a, t[0], "RIFF")){
if(fa(a, t[0] + 8, "WEBP")){
p=3;
break a;
}
var u=Ha(a, t[0] + 4);
if(12 > u||4294967286 < u){
p=3;
break a;
}
if(r&&u > v[0] - 8){
p=7;
break a;
}
p[0]=u;
t[0] +=12;
v[0] -=12;
}
p=0;
}
if(0!=p) return p;
u=0 < q.gb[0];
for (c=c[0]; ;){
t=[0];
n=[n];
a: {
var w=a;
v=b;
p=c;
var y=n,
A=l,
z=m,
B=t;
y[0]=0;
if(8 > p[0]) p=7;
else {
if(!fa(w, v[0], "VP8X")){
if(10!=Ha(w, v[0] + 4)){
p=3;
break a;
}
if(18 > p[0]){
p=7;
break a;
}
var C=Ha(w, v[0] + 8);
var D=1 + Yb(w, v[0] + 12);
w=1 + Yb(w, v[0] + 15);
if(2147483648 <=D * w){
p=3;
break a;
}
null!=B&&(B[0]=C);
null!=A&&(A[0]=D);
null!=z&&(z[0]=w);
v[0] +=18;
p[0] -=18;
y[0]=1;
}
p=0;
}}
n=n[0];
t=t[0];
if(0!=p) return p;
v = !!(t & 2);
if(!u&&n) return 3;
null!=f&&(f[0] = !!(t & 16));
null!=g&&(g[0]=v);
null!=h&&(h[0]=0);
g=l[0];
t=m[0];
if(n&&v && null==k){
p=0;
break;
}
if(4 > c){
p=7;
break;
}
if((u&&n)||(!u&&!n&&!fa(a, b[0], "ALPH"))){
c=[c];
q.na=[q.na];
q.P=[q.P];
q.Sa=[q.Sa];
a: {
C=a;
p=b;
u=c;
var y=q.gb,
A=q.na,
z=q.P,
B=q.Sa;
D=22;
x(null!=C);
x(null!=u);
w=p[0];
var F=u[0];
x(null!=A);
x(null!=B);
A[0]=null;
z[0]=null;
for (B[0]=0; ;){
p[0]=w;
u[0]=F;
if(8 > F){
p=7;
break a;
}
var G=Ha(C, w + 4);
if(4294967286 < G){
p=3;
break a;
}
var H=(8 + G + 1) & -2;
D +=H;
if(0 < y&&D > y){
p=3;
break a;
}
if(!fa(C, w, "VP8 ")||!fa(C, w, "VP8L")){
p=0;
break a;
}
if(F[0] < H){
p=7;
break a;
}
fa(C, w, "ALPH")||((A[0]=C), (z[0]=w + 8), (B[0]=G));
w +=H;
F -=H;
}}
c=c[0];
q.na=q.na[0];
q.P=q.P[0];
q.Sa=q.Sa[0];
if(0!=p) break;
}
c=[c];
q.Ja=[q.Ja];
q.xa=[q.xa];
a: if(((y=a),
(p=b),
(u=c),
(A=q.gb[0]),
(z=q.Ja),
(B=q.xa),
(C=p[0]),
(w = !fa(y, C, "VP8 ")),
(D = !fa(y, C, "VP8L")),
x(null!=y),
x(null!=u),
x(null!=z),
x(null!=B),
8 > u[0])
)
p=7;
else {
if(w||D){
y=Ha(y, C + 4);
if(12 <=A&&y > A - 12){
p=3;
break a;
}
if(r&&y > u[0] - 8){
p=7;
break a;
}
z[0]=y;
p[0] +=8;
u[0] -=8;
B[0]=D;
} else
(B[0]=5 <=u[0]&&47==y[C + 0]&&!(y[C + 4] >> 5)),
(z[0]=u[0]);
p=0;
}
c=c[0];
q.Ja=q.Ja[0];
q.xa=q.xa[0];
b=b[0];
if(0!=p) break;
if(4294967286 < q.Ja) return 3;
null==h||v || (h[0]=q.xa ? 2:1);
g=[g];
t=[t];
if(q.xa){
if(5 > c){
p=7;
break;
}
h=g;
r=t;
v=f;
null==a||5 > c
? (a=0)
: 5 <=c&&47==a[b + 0]&&!(a[b + 4] >> 5)
? ((u=[0]),
(y=[0]),
(A=[0]),
(z=new Ra()),
cb(z, a, b, c),
mc(z, u, y, A)
? (null!=h&&(h[0]=u[0]),
null!=r&&(r[0]=y[0]),
null!=v&&(v[0]=A[0]),
(a=1))
: (a=0))
: (a=0);
}else{
if(10 > c){
p=7;
break;
}
h=t;
null==a||10 > c||!Jc(a, b + 3, c - 3)
? (a=0)
: ((r=a[b + 0] | (a[b + 1] << 8) | (a[b + 2] << 16)),
(v=((a[b + 7] << 8) | a[b + 6]) & 16383),
(a=((a[b + 9] << 8) | a[b + 8]) & 16383),
r & 1 ||
3 < ((r >> 1) & 7) ||
!((r >> 4) & 1) ||
r >> 5 >=q.Ja ||
!v ||
!a
? (a=0)
: (g&&(g[0]=v), h&&(h[0]=a), (a=1)));
}
if(!a) return 3;
g=g[0];
t=t[0];
if(n&&(l[0]!=g||m[0]!=t)) return 3;
null!=k &&
((k[0]=q),
(k.offset=b - k.w),
x(4294967286 > b - k.w),
x(k.offset==k.ha - c));
break;
}
return 0==p||(7==p&&n && null==k)
? (null!=f&&(f[0] |=null!=q.na&&0 < q.na.length),
null!=d&&(d[0]=g),
null!=e&&(e[0]=t),
0)
: p;
}
function hc(a, b, c){
var d=b.width,
e=b.height,
f=0,
g=0,
h=d,
k=e;
b.Da=null!=a&&0 < a.Da;
if(b.Da &&
((h=a.cd),
(k=a.bd),
(f=a.v),
(g=a.j),
11 > c||((f &=-2), (g &=-2)),
0 > f||0 > g||0 >=h||0 >=k||f + h > d||g + k > e)
)
return 0;
b.v=f;
b.j=g;
b.va=f + h;
b.o=g + k;
b.U=h;
b.T=k;
b.da=null!=a&&0 < a.da;
if(b.da){
c=[a.ib];
f=[a.hb];
if(!bc(h, k, c, f)) return 0;
b.ib=c[0];
b.hb=f[0];
}
b.ob=null!=a&&a.ob;
b.Kb=null==a||!a.Sd;
b.da&&((b.ob=b.ib < (3 * d) / 4&&b.hb < (3 * e) / 4), (b.Kb=0));
return 1;
}
function Bd(a){
if(null==a) return 2;
if(11 > a.S){
var b=a.f.RGBA;
b.fb +=(a.height - 1) * b.A;
b.A=-b.A;
} else
(b=a.f.kb),
(a=a.height),
(b.O +=(a - 1) * b.fa),
(b.fa=-b.fa),
(b.N +=((a - 1) >> 1) * b.Ab),
(b.Ab=-b.Ab),
(b.W +=((a - 1) >> 1) * b.Db),
(b.Db=-b.Db),
null!=b.F&&((b.J +=(a - 1) * b.lb), (b.lb=-b.lb));
return 0;
}
function Cd(a, b, c, d){
if(null==d||0 >=a||0 >=b) return 2;
if(null!=c){
if(c.Da){
var e=c.cd,
f=c.bd,
g=c.v & -2,
h=c.j & -2;
if(0 > g||0 > h||0 >=e||0 >=f||g + e > a||h + f > b)
return 2;
a=e;
b=f;
}
if(c.da){
e=[c.ib];
f=[c.hb];
if(!bc(a, b, e, f)) return 2;
a=e[0];
b=f[0];
}}
d.width=a;
d.height=b;
a: {
var k=d.width;
var l=d.height;
a=d.S;
if(0 >=k||0 >=l||!(a >=Ca&&13 > a)) a=2;
else {
if(0 >=d.Rd&&null==d.sd){
var g=(f=e = b=0),
h=k * Dd[a],
m=h * l;
11 > a ||
((b=(k + 1) / 2),
(f=((l + 1) / 2) * b),
12==a&&((e=k), (g=e * l)));
l=V(m + 2 * f + g);
if(null==l){
a=1;
break a;
}
d.sd=l;
11 > a
? ((k=d.f.RGBA),
(k.eb=l),
(k.fb=0),
(k.A=h),
(k.size=m))
: ((k=d.f.kb),
(k.y=l),
(k.O=0),
(k.fa=h),
(k.Fd=m),
(k.f=l),
(k.N=0 + m),
(k.Ab=b),
(k.Cd=f),
(k.ea=l),
(k.W=0 + m + f),
(k.Db=b),
(k.Ed=f),
12==a&&((k.F=l), (k.J=0 + m + 2 * f)),
(k.Tc=g),
(k.lb=e));
}
b=1;
e=d.S;
f=d.width;
g=d.height;
if(e >=Ca&&13 > e)
if(11 > e)
(a=d.f.RGBA),
(h=Math.abs(a.A)),
(b &=h * (g - 1) + f <=a.size),
(b &=h >=f * Dd[e]),
(b &=null!=a.eb);
else {
a=d.f.kb;
h=(f + 1) / 2;
m=(g + 1) / 2;
k=Math.abs(a.fa);
var l=Math.abs(a.Ab),
n=Math.abs(a.Db),
r=Math.abs(a.lb),
q=r * (g - 1) + f;
b &=k * (g - 1) + f <=a.Fd;
b &=l * (m - 1) + h <=a.Cd;
b &=n * (m - 1) + h <=a.Ed;
b=b & (k >=f) & (l >=h) & (n >=h);
b &=null!=a.y;
b &=null!=a.f;
b &=null!=a.ea;
12==e&&((b &=r >=f), (b &=q <=a.Tc), (b &=null!=a.F));
}
else b=0;
a=b ? 0:2;
}}
if(0!=a) return a;
null!=c&&c.fd&&(a=Bd(d));
return a;
}
var xb=64,
Hd=[
0,
1,
3,
7,
15,
31,
63,
127,
255,
511,
1023,
2047,
4095,
8191,
16383,
32767,
65535,
131071,
262143,
524287,
1048575,
2097151,
4194303,
8388607,
16777215
],
Gd=24,
ob=32,
Xb=8,
Id=[
0,
0,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
3,
3,
3,
3,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7
];
X("Predictor0", "PredictorAdd0");
self.Predictor0=function(){
return 4278190080;
};
self.Predictor1=function(a){
return a;
};
self.Predictor2=function(a, b, c){
return b[c + 0];
};
self.Predictor3=function(a, b, c){
return b[c + 1];
};
self.Predictor4=function(a, b, c){
return b[c - 1];
};
self.Predictor5=function(a, b, c){
return aa(aa(a, b[c + 1]), b[c + 0]);
};
self.Predictor6=function(a, b, c){
return aa(a, b[c - 1]);
};
self.Predictor7=function(a, b, c){
return aa(a, b[c + 0]);
};
self.Predictor8=function(a, b, c){
return aa(b[c - 1], b[c + 0]);
};
self.Predictor9=function(a, b, c){
return aa(b[c + 0], b[c + 1]);
};
self.Predictor10=function(a, b, c){
return aa(aa(a, b[c - 1]), aa(b[c + 0], b[c + 1]));
};
self.Predictor11=function(a, b, c){
var d=b[c + 0];
b=b[c - 1];
return 0 >=
Ia((d >> 24) & 255, (a >> 24) & 255, (b >> 24) & 255) +
Ia((d >> 16) & 255, (a >> 16) & 255, (b >> 16) & 255) +
Ia((d >> 8) & 255, (a >> 8) & 255, (b >> 8) & 255) +
Ia(d & 255, a & 255, b & 255)
? d
: a;
};
self.Predictor12=function(a, b, c){
var d=b[c + 0];
b=b[c - 1];
return (
((sa(((a >> 24) & 255) + ((d >> 24) & 255) - ((b >> 24) & 255)) << 24) |
(sa(((a >> 16) & 255) + ((d >> 16) & 255) - ((b >> 16) & 255)) <<
16) |
(sa(((a >> 8) & 255) + ((d >> 8) & 255) - ((b >> 8) & 255)) << 8) |
sa((a & 255) + (d & 255) - (b & 255))) >>>
0
);
};
self.Predictor13=function(a, b, c){
var d=b[c - 1];
a=aa(a, b[c + 0]);
return (
((eb((a >> 24) & 255, (d >> 24) & 255) << 24) |
(eb((a >> 16) & 255, (d >> 16) & 255) << 16) |
(eb((a >> 8) & 255, (d >> 8) & 255) << 8) |
eb((a >> 0) & 255, (d >> 0) & 255)) >>>
0
);
};
var ee=self.PredictorAdd0;
self.PredictorAdd1=cc;
X("Predictor2", "PredictorAdd2");
X("Predictor3", "PredictorAdd3");
X("Predictor4", "PredictorAdd4");
X("Predictor5", "PredictorAdd5");
X("Predictor6", "PredictorAdd6");
X("Predictor7", "PredictorAdd7");
X("Predictor8", "PredictorAdd8");
X("Predictor9", "PredictorAdd9");
X("Predictor10", "PredictorAdd10");
X("Predictor11", "PredictorAdd11");
X("Predictor12", "PredictorAdd12");
X("Predictor13", "PredictorAdd13");
var fe=self.PredictorAdd2;
ec(
"ColorIndexInverseTransform",
"MapARGB",
"32b",
function(a){
return (a >> 8) & 255;
},
function(a){
return a;
}
);
ec(
"VP8LColorIndexInverseTransformAlpha",
"MapAlpha",
"8b",
function(a){
return a;
},
function(a){
return (a >> 8) & 255;
}
);
var rc=self.ColorIndexInverseTransform,
ke=self.MapARGB,
he=self.VP8LColorIndexInverseTransformAlpha,
le=self.MapAlpha,
pc,
qc=(self.VP8LPredictorsAdd=[]);
qc.length=16;
(self.VP8LPredictors=[]).length=16;
(self.VP8LPredictorsAdd_C=[]).length=16;
(self.VP8LPredictors_C=[]).length=16;
var Fb,
sc,
Gb,
Hb,
xc,
uc,
bd=V(511),
cd=V(2041),
dd=V(225),
ed=V(767),
ad=0,
Qb=cd,
mb=dd,
R=ed,
U=bd,
Ca=0,
Ua=1,
tc=2,
Va=3,
ya=4,
Db=5,
wc=6,
zb=7,
Ab=8,
Ja=9,
Bb=10,
pe=[2, 3, 7],
oe=[3, 3, 11],
Dc=[280, 256, 256, 256, 40],
qe=[0, 1, 1, 1, 0],
ne=[17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
de=[
24,
7,
23,
25,
40,
6,
39,
41,
22,
26,
38,
42,
56,
5,
55,
57,
21,
27,
54,
58,
37,
43,
72,
4,
71,
73,
20,
28,
53,
59,
70,
74,
36,
44,
88,
69,
75,
52,
60,
3,
87,
89,
19,
29,
86,
90,
35,
45,
68,
76,
85,
91,
51,
61,
104,
2,
103,
105,
18,
30,
102,
106,
34,
46,
84,
92,
67,
77,
101,
107,
50,
62,
120,
1,
119,
121,
83,
93,
17,
31,
100,
108,
66,
78,
118,
122,
33,
47,
117,
123,
49,
63,
99,
109,
82,
94,
0,
116,
124,
65,
79,
16,
32,
98,
110,
48,
115,
125,
81,
95,
64,
114,
126,
97,
111,
80,
113,
127,
96,
112
],
me=[
2954,
2956,
2958,
2962,
2970,
2986,
3018,
3082,
3212,
3468,
3980,
5004
],
ie=8,
Lb=[
4,
5,
6,
7,
8,
9,
10,
10,
11,
12,
13,
14,
15,
16,
17,
17,
18,
19,
20,
20,
21,
21,
22,
22,
23,
23,
24,
25,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
91,
93,
95,
96,
98,
100,
101,
102,
104,
106,
108,
110,
112,
114,
116,
118,
122,
124,
126,
128,
130,
132,
134,
136,
138,
140,
143,
145,
148,
151,
154,
157
],
Mb=[
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
60,
62,
64,
66,
68,
70,
72,
74,
76,
78,
80,
82,
84,
86,
88,
90,
92,
94,
96,
98,
100,
102,
104,
106,
108,
110,
112,
114,
116,
119,
122,
125,
128,
131,
134,
137,
140,
143,
146,
149,
152,
155,
158,
161,
164,
167,
170,
173,
177,
181,
185,
189,
193,
197,
201,
205,
209,
213,
217,
221,
225,
229,
234,
239,
245,
249,
254,
259,
264,
269,
274,
279,
284
],
oa=null,
He=[
[173, 148, 140, 0],
[176, 155, 140, 135, 0],
[180, 157, 141, 134, 130, 0],
[254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0]
],
Ie=[0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15],
Mc=[-0, 1, -1, 2, -2, 3, 4, 6, -3, 5, -4, -5, -6, 7, -7, 8, -8, -9],
Fe=[
[
[
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128],
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128],
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]
],
[
[253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128],
[189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128],
[106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128]
],
[
[1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128],
[181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128],
[78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128]
],
[
[1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128],
[184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128],
[77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128]
],
[
[1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128],
[170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128],
[37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128]
],
[
[1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128],
[207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128],
[102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128]
],
[
[1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128],
[177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128],
[80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128]
],
[
[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]
]
],
[
[
[198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62],
[131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1],
[68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128]
],
[
[1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128],
[184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128],
[81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128]
],
[
[1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128],
[99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128],
[23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128]
],
[
[1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128],
[109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128],
[44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128]
],
[
[1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128],
[94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128],
[22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128]
],
[
[1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128],
[124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128],
[35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128]
],
[
[1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128],
[121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128],
[45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128]
],
[
[1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128],
[203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128],
[137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128]
]
],
[
[
[253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128],
[175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128],
[73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128]
],
[
[1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128],
[239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128],
[155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128]
],
[
[1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128],
[201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128],
[69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128]
],
[
[1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128],
[223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128],
[141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128]
],
[
[1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128],
[190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128],
[149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]
],
[
[1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128]
],
[
[1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128],
[213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128],
[55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128]
],
[
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128],
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128],
[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]
]
],
[
[
[202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255],
[126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128],
[61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128]
],
[
[1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128],
[166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128],
[39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128]
],
[
[1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128],
[124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128],
[24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128]
],
[
[1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128],
[149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128],
[28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128]
],
[
[1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128],
[123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128],
[20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128]
],
[
[1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128],
[168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128],
[47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128]
],
[
[1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128],
[141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128],
[42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128]
],
[
[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128],
[238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]
]
]
],
Ke=[
[
[231, 120, 48, 89, 115, 113, 120, 152, 112],
[152, 179, 64, 126, 170, 118, 46, 70, 95],
[175, 69, 143, 80, 85, 82, 72, 155, 103],
[56, 58, 10, 171, 218, 189, 17, 13, 152],
[114, 26, 17, 163, 44, 195, 21, 10, 173],
[121, 24, 80, 195, 26, 62, 44, 64, 85],
[144, 71, 10, 38, 171, 213, 144, 34, 26],
[170, 46, 55, 19, 136, 160, 33, 206, 71],
[63, 20, 8, 114, 114, 208, 12, 9, 226],
[81, 40, 11, 96, 182, 84, 29, 16, 36]
],
[
[134, 183, 89, 137, 98, 101, 106, 165, 148],
[72, 187, 100, 130, 157, 111, 32, 75, 80],
[66, 102, 167, 99, 74, 62, 40, 234, 128],
[41, 53, 9, 178, 241, 141, 26, 8, 107],
[74, 43, 26, 146, 73, 166, 49, 23, 157],
[65, 38, 105, 160, 51, 52, 31, 115, 128],
[104, 79, 12, 27, 217, 255, 87, 17, 7],
[87, 68, 71, 44, 114, 51, 15, 186, 23],
[47, 41, 14, 110, 182, 183, 21, 17, 194],
[66, 45, 25, 102, 197, 189, 23, 18, 22]
],
[
[88, 88, 147, 150, 42, 46, 45, 196, 205],
[43, 97, 183, 117, 85, 38, 35, 179, 61],
[39, 53, 200, 87, 26, 21, 43, 232, 171],
[56, 34, 51, 104, 114, 102, 29, 93, 77],
[39, 28, 85, 171, 58, 165, 90, 98, 64],
[34, 22, 116, 206, 23, 34, 43, 166, 73],
[107, 54, 32, 26, 51, 1, 81, 43, 31],
[68, 25, 106, 22, 64, 171, 36, 225, 114],
[34, 19, 21, 102, 132, 188, 16, 76, 124],
[62, 18, 78, 95, 85, 57, 50, 48, 51]
],
[
[193, 101, 35, 159, 215, 111, 89, 46, 111],
[60, 148, 31, 172, 219, 228, 21, 18, 111],
[112, 113, 77, 85, 179, 255, 38, 120, 114],
[40, 42, 1, 196, 245, 209, 10, 25, 109],
[88, 43, 29, 140, 166, 213, 37, 43, 154],
[61, 63, 30, 155, 67, 45, 68, 1, 209],
[100, 80, 8, 43, 154, 1, 51, 26, 71],
[142, 78, 78, 16, 255, 128, 34, 197, 171],
[41, 40, 5, 102, 211, 183, 4, 1, 221],
[51, 50, 17, 168, 209, 192, 23, 25, 82]
],
[
[138, 31, 36, 171, 27, 166, 38, 44, 229],
[67, 87, 58, 169, 82, 115, 26, 59, 179],
[63, 59, 90, 180, 59, 166, 93, 73, 154],
[40, 40, 21, 116, 143, 209, 34, 39, 175],
[47, 15, 16, 183, 34, 223, 49, 45, 183],
[46, 17, 33, 183, 6, 98, 15, 32, 183],
[57, 46, 22, 24, 128, 1, 54, 17, 37],
[65, 32, 73, 115, 28, 128, 23, 128, 205],
[40, 3, 9, 115, 51, 192, 18, 6, 223],
[87, 37, 9, 115, 59, 77, 64, 21, 47]
],
[
[104, 55, 44, 218, 9, 54, 53, 130, 226],
[64, 90, 70, 205, 40, 41, 23, 26, 57],
[54, 57, 112, 184, 5, 41, 38, 166, 213],
[30, 34, 26, 133, 152, 116, 10, 32, 134],
[39, 19, 53, 221, 26, 114, 32, 73, 255],
[31, 9, 65, 234, 2, 15, 1, 118, 73],
[75, 32, 12, 51, 192, 255, 160, 43, 51],
[88, 31, 35, 67, 102, 85, 55, 186, 85],
[56, 21, 23, 111, 59, 205, 45, 37, 192],
[55, 38, 70, 124, 73, 102, 1, 34, 98]
],
[
[125, 98, 42, 88, 104, 85, 117, 175, 82],
[95, 84, 53, 89, 128, 100, 113, 101, 45],
[75, 79, 123, 47, 51, 128, 81, 171, 1],
[57, 17, 5, 71, 102, 57, 53, 41, 49],
[38, 33, 13, 121, 57, 73, 26, 1, 85],
[41, 10, 67, 138, 77, 110, 90, 47, 114],
[115, 21, 2, 10, 102, 255, 166, 23, 6],
[101, 29, 16, 10, 85, 128, 101, 196, 26],
[57, 18, 10, 102, 102, 213, 34, 20, 43],
[117, 20, 15, 36, 163, 128, 68, 1, 26]
],
[
[102, 61, 71, 37, 34, 53, 31, 243, 192],
[69, 60, 71, 38, 73, 119, 28, 222, 37],
[68, 45, 128, 34, 1, 47, 11, 245, 171],
[62, 17, 19, 70, 146, 85, 55, 62, 70],
[37, 43, 37, 154, 100, 163, 85, 160, 1],
[63, 9, 92, 136, 28, 64, 32, 201, 85],
[75, 15, 9, 9, 64, 255, 184, 119, 16],
[86, 6, 28, 5, 64, 255, 25, 248, 1],
[56, 8, 17, 132, 137, 255, 55, 116, 128],
[58, 15, 20, 82, 135, 57, 26, 121, 40]
],
[
[164, 50, 31, 137, 154, 133, 25, 35, 218],
[51, 103, 44, 131, 131, 123, 31, 6, 158],
[86, 40, 64, 135, 148, 224, 45, 183, 128],
[22, 26, 17, 131, 240, 154, 14, 1, 209],
[45, 16, 21, 91, 64, 222, 7, 1, 197],
[56, 21, 39, 155, 60, 138, 23, 102, 213],
[83, 12, 13, 54, 192, 255, 68, 47, 28],
[85, 26, 85, 85, 128, 128, 32, 146, 171],
[18, 11, 7, 63, 144, 171, 4, 4, 246],
[35, 27, 10, 146, 174, 171, 12, 26, 128]
],
[
[190, 80, 35, 99, 180, 80, 126, 54, 45],
[85, 126, 47, 87, 176, 51, 41, 20, 32],
[101, 75, 128, 139, 118, 146, 116, 128, 85],
[56, 41, 15, 176, 236, 85, 37, 9, 62],
[71, 30, 17, 119, 118, 255, 17, 18, 138],
[101, 38, 60, 138, 55, 70, 43, 26, 142],
[146, 36, 19, 30, 171, 255, 97, 27, 20],
[138, 45, 61, 62, 219, 1, 81, 188, 64],
[32, 41, 20, 117, 151, 142, 20, 21, 163],
[112, 19, 12, 61, 195, 128, 48, 4, 24]
]
],
Ee=[
[
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255],
[249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255],
[234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255],
[250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255],
[254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
]
],
[
[
[217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255],
[234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255]
],
[
[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
]
],
[
[
[186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255],
[234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255],
[251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255]
],
[
[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
]
],
[
[
[248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255],
[248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255]
],
[
[255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255],
[248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255],
[250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
],
[
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
]
]
],
Ge=[0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0],
Nc,
Y=[],
W=[],
ka=[],
Za,
fd,
Nb,
pa,
Ob,
Xc,
Tc,
Yc,
Uc,
Zc,
Vc,
$c,
Wc,
Rc,
Pc,
Sc,
Qc,
re=1,
Cc=2,
ia=[],
za,
vc,
fc,
Fc,
P=[];
va("UpsampleRgbLinePair", Ga, 3);
va("UpsampleBgrLinePair", Tb, 3);
va("UpsampleRgbaLinePair", wd, 4);
va("UpsampleBgraLinePair", vd, 4);
va("UpsampleArgbLinePair", ud, 4);
va("UpsampleRgba4444LinePair", td, 2);
va("UpsampleRgb565LinePair", sd, 2);
var Mf=self.UpsampleRgbLinePair,
Nf=self.UpsampleBgrLinePair,
nd=self.UpsampleRgbaLinePair,
od=self.UpsampleBgraLinePair,
pd=self.UpsampleArgbLinePair,
qd=self.UpsampleRgba4444LinePair,
Of=self.UpsampleRgb565LinePair,
Wa=16,
Ba=1 << (Wa - 1),
ta=-227,
Eb=482,
rd=6,
Pf=(256 << rd) - 1,
jc=0,
Yd=V(256),
ae=V(256),
$d=V(256),
Zd=V(256),
be=V(Eb - ta),
ce=V(Eb - ta);
la("YuvToRgbRow", Ga, 3);
la("YuvToBgrRow", Tb, 3);
la("YuvToRgbaRow", wd, 4);
la("YuvToBgraRow", vd, 4);
la("YuvToArgbRow", ud, 4);
la("YuvToRgba4444Row", td, 2);
la("YuvToRgb565Row", sd, 2);
var zd=[
0,
4,
8,
12,
128,
132,
136,
140,
256,
260,
264,
268,
384,
388,
392,
396
],
Ya=[0, 2, 8],
Qf=[8, 7, 6, 4, 4, 2, 2, 2, 1, 1, 1, 1],
Ne=1;
this.WebPDecodeRGBA=function(a, b, c, d, e){
var f=Ua;
var g=new Cf(),
h=new Cb();
g.ba=h;
h.S=f;
h.width=[h.width];
h.height=[h.height];
var k=h.width;
var l=h.height,
m=new Td();
if(null==m||null==a) var n=2;
else
x(null!=m),
(n=Ad(a, b, c, m.width, m.height, m.Pd, m.Qd, m.format, null));
0!=n
? (k=0)
: (null!=k&&(k[0]=m.width[0]),
null!=l&&(l[0]=m.height[0]),
(k=1));
if(k){
h.width=h.width[0];
h.height=h.height[0];
null!=d&&(d[0]=h.width);
null!=e&&(e[0]=h.height);
b: {
d=new Oa();
e=new md();
e.data=a;
e.w=b;
e.ha=c;
e.kd=1;
b=[0];
x(null!=e);
a=Ad(e.data, e.w, e.ha, null, null, null, b, null, e);
(0==a||7==a)&&b[0]&&(a=4);
b=a;
if(0==b){
x(null!=g);
d.data=e.data;
d.w=e.w + e.offset;
d.ha=e.ha - e.offset;
d.put=kc;
d.ac=gc;
d.bc=lc;
d.ma=g;
if(e.xa){
a=Bc();
if(null==a){
g=1;
break b;
}
if(te(a, d)){
b=Cd(d.width, d.height, g.Oa, g.ba);
if((d=0==b)){
c: {
d=a;
d: for (;;){
if(null==d){
d=0;
break c;
}
x(null!=d.s.yc);
x(null!=d.s.Ya);
x(0 < d.s.Wb);
c=d.l;
x(null!=c);
e=c.ma;
x(null!=e);
if(0!=d.xb){
d.ca=e.ba;
d.tb=e.tb;
x(null!=d.ca);
if(!hc(e.Oa, c, Va)){
d.a=2;
break d;
}
if(!Ec(d, c.width)) break d;
if(c.da) break d;
(c.da||hb(d.ca.S))&&Aa();
11 > d.ca.S ||
(alert("todo:WebPInitConvertARGBToYUV"),
null!=d.ca.f.kb.F&&Aa());
if(d.Pb &&
0 < d.s.ua &&
null==d.s.vb.X &&
!Zb(d.s.vb, d.s.Wa.Xa)
){
d.a=1;
break d;
}
d.xb=0;
}
if(!Jb(d, d.V, d.Ba, d.c, d.i, c.o, ge)) break d;
e.Dc=d.Ma;
d=1;
break c;
}
x(0!=d.a);
d=0;
}
d = !d;
}
d&&(b=a.a);
} else b=a.a;
}else{
a=new Ce();
if(null==a){
g=1;
break b;
}
a.Fa=e.na;
a.P=e.P;
a.qc=e.Sa;
if(Kc(a, d)){
if(((b=Cd(d.width, d.height, g.Oa, g.ba)), 0==b)){
a.Aa=0;
c=g.Oa;
e=a;
x(null!=e);
if(null!=c){
k=c.Md;
k=0 > k ? 0:100 < k ? 255:(255 * k) / 100;
if(0 < k){
for (l=m = 0; 4 > l; ++l)
(n=e.pb[l]),
12 > n.lc &&
(n.ia=(k * Qf[0 > n.lc ? 0:n.lc]) >> 3),
(m |=n.ia);
m&&(alert("todo:VP8InitRandom"), (e.ia=1));
}
e.Ga=c.Id;
100 < e.Ga ? (e.Ga=100):0 > e.Ga&&(e.Ga=0);
}
Me(a, d)||(b=a.a);
}} else b=a.a;
}
0==b&&null!=g.Oa&&g.Oa.fd&&(b=Bd(g.ba));
}
g=b;
}
f=0!=g ? null:11 > f ? h.f.RGBA.eb:h.f.kb.y;
} else f=null;
return f;
};
var Dd=[3, 4, 3, 4, 4, 2, 2, 4, 4, 4, 2, 1, 1];
};
new WebPDecoder();
function memcmp(data, data_off, str, size){
for (var i=0; i < size; i++)
if(data[data_off + i]!=str.charCodeAt(i)) return true;
return false;
}
function GetTag(data, data_off){
var str="";
for (var i=0; i < 4; i++) str +=String.fromCharCode(data[data_off++]);
return str;
}
function GetLE16(data, data_off){
return (data[data_off + 0] << 0) | (data[data_off + 1] << 8);
}
function GetLE24(data, data_off){
return (
((data[data_off + 0] << 0) |
(data[data_off + 1] << 8) |
(data[data_off + 2] << 16)) >>>
0
);
}
function GetLE32(data, data_off){
return (
((data[data_off + 0] << 0) |
(data[data_off + 1] << 8) |
(data[data_off + 2] << 16) |
(data[data_off + 3] << 24)) >>>
0
);
}
function WebPRiffParser(src, src_off){
var imagearray={};
var i=0;
var alpha_chunk=false;
var alpha_size=0;
var alpha_offset=0;
imagearray["frames"]=[];
if(memcmp(src, src_off, "RIFF", 4)) return;
src_off +=4;
var riff_size=GetLE32(src, src_off) + 8;
src_off +=8;
while (src_off < src.length){
var fourcc=GetTag(src, src_off);
src_off +=4;
var payload_size=GetLE32(src, src_off);
src_off +=4;
var payload_size_padded=payload_size + (payload_size & 1);
switch (fourcc){
case "VP8 ":
case "VP8L":
if(typeof imagearray["frames"][i]==="undefined")
imagearray["frames"][i]={};
var obj=imagearray["frames"][i];
var height=[0];
var width=[0];
obj["src_off"]=alpha_chunk ? alpha_offset:src_off - 8;
obj["src_size"]=alpha_size + payload_size + 8;
i++;
if(alpha_chunk){
alpha_chunk=false;
alpha_size=0;
alpha_offset=0;
}
break;
case "VP8X":
var obj=(imagearray["header"]={});
var feature_flags=(obj["feature_flags"]=src[src_off]);
var src_off_=src_off + 4;
var canvas_width=(obj["canvas_width"]=1 + GetLE24(src, src_off_));
src_off_ +=3;
var canvas_height=(obj["canvas_height"] =
1 + GetLE24(src, src_off_));
src_off_ +=3;
break;
case "ALPH":
alpha_chunk=true;
alpha_size=payload_size_padded + 8;
alpha_offset=src_off - 8;
break;
case "ANIM":
var obj=imagearray["header"];
var bgcolor=(obj["bgcolor"]=GetLE32(src, src_off));
src_off_=src_off + 4;
var loop_count=(obj["loop_count"]=GetLE16(src, src_off_));
src_off_ +=2;
break;
case "ANMF":
var offset_x=0,
offset_y=0,
width=0,
height=0,
duration=0,
blend=0,
dispose=0,
temp=0;
var obj=(imagearray["frames"][i]={});
obj["offset_x"]=offset_x=2 * GetLE24(src, src_off);
src_off +=3;
obj["offset_y"]=offset_y=2 * GetLE24(src, src_off);
src_off +=3;
obj["width"]=width=1 + GetLE24(src, src_off);
src_off +=3;
obj["height"]=height=1 + GetLE24(src, src_off);
src_off +=3;
obj["duration"]=duration=GetLE24(src, src_off);
src_off +=3;
temp=src[src_off++];
obj["dispose"]=dispose=temp & 1;
obj["blend"]=blend=(temp >> 1) & 1;
break;
}
if(fourcc!="ANMF") src_off +=payload_size_padded;
}
return imagearray;
}
var height=[0];
var width=[0];
var pixels=[];
var webpdecoder=new WebPDecoder();
var response=imageData;
var imagearray=WebPRiffParser(response, 0);
imagearray["response"]=response;
imagearray["rgbaoutput"]=true;
imagearray["dataurl"]=false;
var header=imagearray["header"] ? imagearray["header"]:null;
var frames=imagearray["frames"] ? imagearray["frames"]:null;
if(header){
header["loop_counter"]=header["loop_count"];
height=[header["canvas_height"]];
width=[header["canvas_width"]];
for (var f=0; f < frames.length; f++)
if(frames[f]["blend"]==0){
break;
}}
var frame=frames[0];
var rgba=webpdecoder.WebPDecodeRGBA(response,
frame["src_off"],
frame["src_size"],
width,
height
);
frame["rgba"]=rgba;
frame["imgwidth"]=width[0];
frame["imgheight"]=height[0];
for (var i=0; i < width[0] * height[0] * 4; i++){
pixels[i]=rgba[i];
}
this.width=width;
this.height=height;
this.data=pixels;
return this;
}
WebPDecoder.prototype.getData=function(){
return this.data;
};
(function(jsPDFAPI){
jsPDFAPI.processWEBP=function(imageData, index, alias, compression){
var reader=new WebPDecoder(imageData, false);
var width=reader.width,
height=reader.height;
var qu=100;
var pixels=reader.getData();
var rawImageData={
data: pixels,
width: width,
height: height
};
var encoder=new JPEGEncoder(qu);
var data=encoder.encode(rawImageData, qu);
return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);
};})(jsPDF.API);
(function(jsPDFAPI){
jsPDFAPI.setLanguage=function(langCode){
var langCodes={
af: "Afrikaans",
sq: "Albanian",
ar: "Arabic (Standard)",
"ar-DZ": "Arabic (Algeria)",
"ar-BH": "Arabic (Bahrain)",
"ar-EG": "Arabic (Egypt)",
"ar-IQ": "Arabic (Iraq)",
"ar-JO": "Arabic (Jordan)",
"ar-KW": "Arabic (Kuwait)",
"ar-LB": "Arabic (Lebanon)",
"ar-LY": "Arabic (Libya)",
"ar-MA": "Arabic (Morocco)",
"ar-OM": "Arabic (Oman)",
"ar-QA": "Arabic (Qatar)",
"ar-SA": "Arabic (Saudi Arabia)",
"ar-SY": "Arabic (Syria)",
"ar-TN": "Arabic (Tunisia)",
"ar-AE": "Arabic (U.A.E.)",
"ar-YE": "Arabic (Yemen)",
an: "Aragonese",
hy: "Armenian",
as: "Assamese",
ast: "Asturian",
az: "Azerbaijani",
eu: "Basque",
be: "Belarusian",
bn: "Bengali",
bs: "Bosnian",
br: "Breton",
bg: "Bulgarian",
my: "Burmese",
ca: "Catalan",
ch: "Chamorro",
ce: "Chechen",
zh: "Chinese",
"zh-HK": "Chinese (Hong Kong)",
"zh-CN": "Chinese (PRC)",
"zh-SG": "Chinese (Singapore)",
"zh-TW": "Chinese (Taiwan)",
cv: "Chuvash",
co: "Corsican",
cr: "Cree",
hr: "Croatian",
cs: "Czech",
da: "Danish",
nl: "Dutch (Standard)",
"nl-BE": "Dutch (Belgian)",
en: "English",
"en-AU": "English (Australia)",
"en-BZ": "English (Belize)",
"en-CA": "English (Canada)",
"en-IE": "English (Ireland)",
"en-JM": "English (Jamaica)",
"en-NZ": "English (New Zealand)",
"en-PH": "English (Philippines)",
"en-ZA": "English (South Africa)",
"en-TT": "English (Trinidad & Tobago)",
"en-GB": "English (United Kingdom)",
"en-US": "English (United States)",
"en-ZW": "English (Zimbabwe)",
eo: "Esperanto",
et: "Estonian",
fo: "Faeroese",
fj: "Fijian",
fi: "Finnish",
fr: "French (Standard)",
"fr-BE": "French (Belgium)",
"fr-CA": "French (Canada)",
"fr-FR": "French (France)",
"fr-LU": "French (Luxembourg)",
"fr-MC": "French (Monaco)",
"fr-CH": "French (Switzerland)",
fy: "Frisian",
fur: "Friulian",
gd: "Gaelic (Scots)",
"gd-IE": "Gaelic (Irish)",
gl: "Galacian",
ka: "Georgian",
de: "German (Standard)",
"de-AT": "German (Austria)",
"de-DE": "German (Germany)",
"de-LI": "German (Liechtenstein)",
"de-LU": "German (Luxembourg)",
"de-CH": "German (Switzerland)",
el: "Greek",
gu: "Gujurati",
ht: "Haitian",
he: "Hebrew",
hi: "Hindi",
hu: "Hungarian",
is: "Icelandic",
id: "Indonesian",
iu: "Inuktitut",
ga: "Irish",
it: "Italian (Standard)",
"it-CH": "Italian (Switzerland)",
ja: "Japanese",
kn: "Kannada",
ks: "Kashmiri",
kk: "Kazakh",
km: "Khmer",
ky: "Kirghiz",
tlh: "Klingon",
ko: "Korean",
"ko-KP": "Korean (North Korea)",
"ko-KR": "Korean (South Korea)",
la: "Latin",
lv: "Latvian",
lt: "Lithuanian",
lb: "Luxembourgish",
mk: "FYRO Macedonian",
ms: "Malay",
ml: "Malayalam",
mt: "Maltese",
mi: "Maori",
mr: "Marathi",
mo: "Moldavian",
nv: "Navajo",
ng: "Ndonga",
ne: "Nepali",
no: "Norwegian",
nb: "Norwegian (Bokmal)",
nn: "Norwegian (Nynorsk)",
oc: "Occitan",
or: "Oriya",
om: "Oromo",
fa: "Persian",
"fa-IR": "Persian/Iran",
pl: "Polish",
pt: "Portuguese",
"pt-BR": "Portuguese (Brazil)",
pa: "Punjabi",
"pa-IN": "Punjabi (India)",
"pa-PK": "Punjabi (Pakistan)",
qu: "Quechua",
rm: "Rhaeto-Romanic",
ro: "Romanian",
"ro-MO": "Romanian (Moldavia)",
ru: "Russian",
"ru-MO": "Russian (Moldavia)",
sz: "Sami (Lappish)",
sg: "Sango",
sa: "Sanskrit",
sc: "Sardinian",
sd: "Sindhi",
si: "Singhalese",
sr: "Serbian",
sk: "Slovak",
sl: "Slovenian",
so: "Somani",
sb: "Sorbian",
es: "Spanish",
"es-AR": "Spanish (Argentina)",
"es-BO": "Spanish (Bolivia)",
"es-CL": "Spanish (Chile)",
"es-CO": "Spanish (Colombia)",
"es-CR": "Spanish (Costa Rica)",
"es-DO": "Spanish (Dominican Republic)",
"es-EC": "Spanish (Ecuador)",
"es-SV": "Spanish (El Salvador)",
"es-GT": "Spanish (Guatemala)",
"es-HN": "Spanish (Honduras)",
"es-MX": "Spanish (Mexico)",
"es-NI": "Spanish (Nicaragua)",
"es-PA": "Spanish (Panama)",
"es-PY": "Spanish (Paraguay)",
"es-PE": "Spanish (Peru)",
"es-PR": "Spanish (Puerto Rico)",
"es-ES": "Spanish (Spain)",
"es-UY": "Spanish (Uruguay)",
"es-VE": "Spanish (Venezuela)",
sx: "Sutu",
sw: "Swahili",
sv: "Swedish",
"sv-FI": "Swedish (Finland)",
"sv-SV": "Swedish (Sweden)",
ta: "Tamil",
tt: "Tatar",
te: "Teluga",
th: "Thai",
tig: "Tigre",
ts: "Tsonga",
tn: "Tswana",
tr: "Turkish",
tk: "Turkmen",
uk: "Ukrainian",
hsb: "Upper Sorbian",
ur: "Urdu",
ve: "Venda",
vi: "Vietnamese",
vo: "Volapuk",
wa: "Walloon",
cy: "Welsh",
xh: "Xhosa",
ji: "Yiddish",
zu: "Zulu"
};
if(this.internal.languageSettings===undefined){
this.internal.languageSettings={};
this.internal.languageSettings.isSubscribed=false;
}
if(langCodes[langCode]!==undefined){
this.internal.languageSettings.languageCode=langCode;
if(this.internal.languageSettings.isSubscribed===false){
this.internal.events.subscribe("putCatalog", function(){
this.internal.write("/Lang (" + this.internal.languageSettings.languageCode + ")"
);
});
this.internal.languageSettings.isSubscribed=true;
}}
return this;
};})(jsPDF.API);
(function(API){
var getCharWidthsArray=(API.getCharWidthsArray=function(text, options){
options=options||{};
var activeFont=options.font||this.internal.getFont();
var fontSize=options.fontSize||this.internal.getFontSize();
var charSpace=options.charSpace||this.internal.getCharSpace();
var widths=options.widths
? options.widths
: activeFont.metadata.Unicode.widths;
var widthsFractionOf=widths.fof ? widths.fof:1;
var kerning=options.kerning
? options.kerning
: activeFont.metadata.Unicode.kerning;
var kerningFractionOf=kerning.fof ? kerning.fof:1;
var doKerning=options.doKerning===false ? false:true;
var kerningValue=0;
var i;
var length=text.length;
var char_code;
var prior_char_code=0;
var default_char_width=widths[0]||widthsFractionOf;
var output=[];
for (i=0; i < length; i++){
char_code=text.charCodeAt(i);
if(typeof activeFont.metadata.widthOfString==="function"){
output.push((activeFont.metadata.widthOfGlyph(activeFont.metadata.characterToGlyph(char_code)
) +
charSpace * (1000 / fontSize)||0) / 1000
);
}else{
if(doKerning &&
typeof kerning[char_code]==="object" &&
!isNaN(parseInt(kerning[char_code][prior_char_code], 10))
){
kerningValue =
kerning[char_code][prior_char_code] / kerningFractionOf;
}else{
kerningValue=0;
}
output.push((widths[char_code]||default_char_width) / widthsFractionOf +
kerningValue
);
}
prior_char_code=char_code;
}
return output;
});
var getStringUnitWidth=(API.getStringUnitWidth=function(text, options){
options=options||{};
var fontSize=options.fontSize||this.internal.getFontSize();
var font=options.font||this.internal.getFont();
var charSpace=options.charSpace||this.internal.getCharSpace();
var result=0;
if(API.processArabic){
text=API.processArabic(text);
}
if(typeof font.metadata.widthOfString==="function"){
result =
font.metadata.widthOfString(text, fontSize, charSpace) / fontSize;
}else{
result=getCharWidthsArray
.apply(this, arguments)
.reduce(function(pv, cv){
return pv + cv;
}, 0);
}
return result;
});
var splitLongWord=function(word, widths_array, firstLineMaxLen, maxLen){
var answer=[];
var i=0,
l=word.length,
workingLen=0;
while (i!==l&&workingLen + widths_array[i] < firstLineMaxLen){
workingLen +=widths_array[i];
i++;
}
answer.push(word.slice(0, i));
var startOfLine=i;
workingLen=0;
while (i!==l){
if(workingLen + widths_array[i] > maxLen){
answer.push(word.slice(startOfLine, i));
workingLen=0;
startOfLine=i;
}
workingLen +=widths_array[i];
i++;
}
if(startOfLine!==i){
answer.push(word.slice(startOfLine, i));
}
return answer;
};
var splitParagraphIntoLines=function(text, maxlen, options){
if(!options){
options={};}
var line=[],
lines=[line],
line_length=options.textIndent||0,
separator_length=0,
current_word_length=0,
word,
widths_array,
words=text.split(" "),
spaceCharWidth=getCharWidthsArray.apply(this, [" ", options])[0],
i,
l,
tmp,
lineIndent;
if(options.lineIndent===-1){
lineIndent=words[0].length + 2;
}else{
lineIndent=options.lineIndent||0;
}
if(lineIndent){
var pad=Array(lineIndent).join(" "),
wrds=[];
words.map(function(wrd){
wrd=wrd.split(/\s*\n/);
if(wrd.length > 1){
wrds=wrds.concat(wrd.map(function(wrd, idx){
return (idx&&wrd.length ? "\n":"") + wrd;
})
);
}else{
wrds.push(wrd[0]);
}});
words=wrds;
lineIndent=getStringUnitWidth.apply(this, [pad, options]);
}
for (i=0, l=words.length; i < l; i++){
var force=0;
word=words[i];
if(lineIndent&&word[0]=="\n"){
word=word.substr(1);
force=1;
}
widths_array=getCharWidthsArray.apply(this, [word, options]);
current_word_length=widths_array.reduce(function(pv, cv){
return pv + cv;
}, 0);
if(line_length + separator_length + current_word_length > maxlen ||
force
){
if(current_word_length > maxlen){
tmp=splitLongWord.apply(this, [
word,
widths_array,
maxlen - (line_length + separator_length),
maxlen
]);
line.push(tmp.shift());
line=[tmp.pop()];
while (tmp.length){
lines.push([tmp.shift()]);
}
current_word_length=widths_array
.slice(word.length - (line[0] ? line[0].length:0))
.reduce(function(pv, cv){
return pv + cv;
}, 0);
}else{
line=[word];
}
lines.push(line);
line_length=current_word_length + lineIndent;
separator_length=spaceCharWidth;
}else{
line.push(word);
line_length +=separator_length + current_word_length;
separator_length=spaceCharWidth;
}}
var postProcess;
if(lineIndent){
postProcess=function(ln, idx){
return (idx ? pad:"") + ln.join(" ");
};}else{
postProcess=function(ln){
return ln.join(" ");
};}
return lines.map(postProcess);
};
API.splitTextToSize=function(text, maxlen, options){
options=options||{};
var fsize=options.fontSize||this.internal.getFontSize(),
newOptions=function(options){
var widths={
0: 1
},
kerning={};
if(!options.widths||!options.kerning){
var f=this.internal.getFont(options.fontName, options.fontStyle),
encoding="Unicode";
if(f.metadata[encoding]){
return {
widths: f.metadata[encoding].widths||widths,
kerning: f.metadata[encoding].kerning||kerning
};}else{
return {
font: f.metadata,
fontSize: this.internal.getFontSize(),
charSpace: this.internal.getCharSpace()
};}}else{
return {
widths: options.widths,
kerning: options.kerning
};}}.call(this, options);
var paragraphs;
if(Array.isArray(text)){
paragraphs=text;
}else{
paragraphs=text.split(/\r?\n/);
}
var fontUnit_maxLen=(1.0 * this.internal.scaleFactor * maxlen) / fsize;
newOptions.textIndent=options.textIndent
? (options.textIndent * 1.0 * this.internal.scaleFactor) / fsize
: 0;
newOptions.lineIndent=options.lineIndent;
var i,
l,
output=[];
for (i=0, l=paragraphs.length; i < l; i++){
output=output.concat(splitParagraphIntoLines.apply(this, [
paragraphs[i],
fontUnit_maxLen,
newOptions
])
);
}
return output;
};})(jsPDF.API);
(function(API){
API.__fontmetrics__=API.__fontmetrics__||{};
var decoded="0123456789abcdef",
encoded="klmnopqrstuvwxyz",
mappingUncompress={},
mappingCompress={};
for (var i=0; i < encoded.length; i++){
mappingUncompress[encoded[i]]=decoded[i];
mappingCompress[decoded[i]]=encoded[i];
}
var hex=function(value){
return "0x" + parseInt(value, 10).toString(16);
};
var compress=(API.__fontmetrics__.compress=function(data){
var vals=["{"];
var value, keystring, valuestring, numberprefix;
for (var key in data){
value=data[key];
if(!isNaN(parseInt(key, 10))){
key=parseInt(key, 10);
keystring=hex(key).slice(2);
keystring =
keystring.slice(0, -1) + mappingCompress[keystring.slice(-1)];
}else{
keystring="'" + key + "'";
}
if(typeof value=="number"){
if(value < 0){
valuestring=hex(value).slice(3);
numberprefix="-";
}else{
valuestring=hex(value).slice(2);
numberprefix="";
}
valuestring =
numberprefix +
valuestring.slice(0, -1) +
mappingCompress[valuestring.slice(-1)];
}else{
if(typeof value==="object"){
valuestring=compress(value);
}else{
throw new Error(
"Don't know what to do with value type " + typeof value + "."
);
}}
vals.push(keystring + valuestring);
}
vals.push("}");
return vals.join("");
});
var uncompress=(API.__fontmetrics__.uncompress=function(data){
if(typeof data!=="string"){
throw new Error("Invalid argument passed to uncompress.");
}
var output={},
sign=1,
stringparts,
activeobject=output,
parentchain=[],
parent_key_pair,
keyparts="",
valueparts="",
key,
datalen=data.length - 1,
ch;
for (var i=1; i < datalen; i +=1){
ch=data[i];
if(ch=="'"){
if(stringparts){
key=stringparts.join("");
stringparts=undefined;
}else{
stringparts=[];
}}else if(stringparts){
stringparts.push(ch);
}else if(ch=="{"){
parentchain.push([activeobject, key]);
activeobject={};
key=undefined;
}else if(ch=="}"){
parent_key_pair=parentchain.pop();
parent_key_pair[0][parent_key_pair[1]]=activeobject;
key=undefined;
activeobject=parent_key_pair[0];
}else if(ch=="-"){
sign=-1;
}else{
if(key===undefined){
if(mappingUncompress.hasOwnProperty(ch)){
keyparts +=mappingUncompress[ch];
key=parseInt(keyparts, 16) * sign;
sign=+1;
keyparts="";
}else{
keyparts +=ch;
}}else{
if(mappingUncompress.hasOwnProperty(ch)){
valueparts +=mappingUncompress[ch];
activeobject[key]=parseInt(valueparts, 16) * sign;
sign=+1;
key=undefined;
valueparts="";
}else{
valueparts +=ch;
}}
}}
return output;
});
var encodingBlock={
codePages: ["WinAnsiEncoding"],
WinAnsiEncoding: uncompress(
"{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}"
)
};
var encodings={
Unicode: {
Courier: encodingBlock,
"Courier-Bold": encodingBlock,
"Courier-BoldOblique": encodingBlock,
"Courier-Oblique": encodingBlock,
Helvetica: encodingBlock,
"Helvetica-Bold": encodingBlock,
"Helvetica-BoldOblique": encodingBlock,
"Helvetica-Oblique": encodingBlock,
"Times-Roman": encodingBlock,
"Times-Bold": encodingBlock,
"Times-BoldItalic": encodingBlock,
"Times-Italic": encodingBlock
}};
var fontMetrics={
Unicode: {
"Courier-Oblique": uncompress(
"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"
),
"Times-BoldItalic": uncompress(
"{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"
),
"Helvetica-Bold": uncompress(
"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"
),
Courier: uncompress("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),
"Courier-BoldOblique": uncompress(
"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"
),
"Times-Bold": uncompress(
"{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"
),
Symbol: uncompress(
"{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"
),
Helvetica: uncompress(
"{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"
),
"Helvetica-BoldOblique": uncompress(
"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"
),
ZapfDingbats: uncompress("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),
"Courier-Bold": uncompress("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),
"Times-Italic": uncompress(
"{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"
),
"Times-Roman": uncompress(
"{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"
),
"Helvetica-Oblique": uncompress(
"{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"
)
}};
API.events.push([
"addFont",
function(data){
var font=data.font;
var metrics=fontMetrics["Unicode"][font.postScriptName];
if(metrics){
font.metadata["Unicode"]={};
font.metadata["Unicode"].widths=metrics.widths;
font.metadata["Unicode"].kerning=metrics.kerning;
}
var encodingBlock=encodings["Unicode"][font.postScriptName];
if(encodingBlock){
font.metadata["Unicode"].encoding=encodingBlock;
font.encoding=encodingBlock.codePages[0];
}}
]);
})(jsPDF.API);
(function(jsPDF){
var binaryStringToUint8Array=function(binary_string){
var len=binary_string.length;
var bytes=new Uint8Array(len);
for (var i=0; i < len; i++){
bytes[i]=binary_string.charCodeAt(i);
}
return bytes;
};
var addFont=function(font, file){
if(/^\x00\x01\x00\x00/.test(file)){
file=binaryStringToUint8Array(file);
}else{
file=binaryStringToUint8Array(atob(file));
}
font.metadata=jsPDF.API.TTFFont.open(file);
font.metadata.Unicode=font.metadata.Unicode||{
encoding: {},
kerning: {},
widths: []
};
font.metadata.glyIdsUsed=[0];
};
jsPDF.API.events.push([
"addFont",
function(data){
var file=undefined;
var font=data.font;
var instance=data.instance;
if(font.isStandardFont){
return;
}
if(typeof instance!=="undefined"){
if(instance.existsFileInVFS(font.postScriptName)===false){
file=instance.loadFile(font.postScriptName);
}else{
file=instance.getFileFromVFS(font.postScriptName);
}
if(typeof file!=="string"){
throw new Error(
"Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('" +
font.postScriptName +
"')."
);
}
addFont(font, file);
}else{
throw new Error(
"Font does not exist in vFS, import fonts or remove declaration doc.addFont('" +
font.postScriptName +
"')."
);
}}
]);
})(jsPDF);
(function(jsPDFAPI){
jsPDFAPI.addSvg=function(svgtext, x, y, w, h){
if(x===undefined||y===undefined){
throw new Error("addSVG needs values for 'x' and 'y'");
}
function InjectCSS(cssbody, document){
var styletag=document.createElement("style");
styletag.type="text/css";
if(styletag.styleSheet){
styletag.styleSheet.cssText=cssbody;
}else{
styletag.appendChild(document.createTextNode(cssbody));
}
document.getElementsByTagName("head")[0].appendChild(styletag);
}
function createWorkerNode(document){
var frameID="childframe",
frame=document.createElement("iframe");
InjectCSS(
".jsPDF_sillysvg_iframe {display:none;position:absolute;}",
document
);
frame.name=frameID;
frame.setAttribute("width", 0);
frame.setAttribute("height", 0);
frame.setAttribute("frameborder", "0");
frame.setAttribute("scrolling", "no");
frame.setAttribute("seamless", "seamless");
frame.setAttribute("class", "jsPDF_sillysvg_iframe");
document.body.appendChild(frame);
return frame;
}
function attachSVGToWorkerNode(svgtext, frame){
var framedoc=(frame.contentWindow||frame.contentDocument).document;
framedoc.write(svgtext);
framedoc.close();
return framedoc.getElementsByTagName("svg")[0];
}
function convertPathToPDFLinesArgs(path){
var x=parseFloat(path[1]),
y=parseFloat(path[2]),
vectors=[],
position=3,
len=path.length;
while (position < len){
if(path[position]==="c"){
vectors.push([
parseFloat(path[position + 1]),
parseFloat(path[position + 2]),
parseFloat(path[position + 3]),
parseFloat(path[position + 4]),
parseFloat(path[position + 5]),
parseFloat(path[position + 6])
]);
position +=7;
}else if(path[position]==="l"){
vectors.push([
parseFloat(path[position + 1]),
parseFloat(path[position + 2])
]);
position +=3;
}else{
position +=1;
}}
return [x, y, vectors];
}
var workernode=createWorkerNode(document),
svgnode=attachSVGToWorkerNode(svgtext, workernode),
scale=[1, 1],
svgw=parseFloat(svgnode.getAttribute("width")),
svgh=parseFloat(svgnode.getAttribute("height"));
if(svgw&&svgh){
if(w&&h){
scale=[w / svgw, h / svgh];
}
else if(w){
scale=[w / svgw, w / svgw];
}else if(h){
scale=[h / svgh, h / svgh];
}}
var i,
l,
tmp,
linesargs,
items=svgnode.childNodes;
for (i=0, l=items.length; i < l; i++){
tmp=items[i];
if(tmp.tagName&&tmp.tagName.toUpperCase()==="PATH"){
linesargs=convertPathToPDFLinesArgs(
tmp
.getAttribute("d")
.split(tmp.getAttribute("d").indexOf(",")===-1 ? " ":",")
);
linesargs[0]=linesargs[0] * scale[0] + x;
linesargs[1]=linesargs[1] * scale[1] + y;
this.lines.call(this,
linesargs[2],
linesargs[0],
linesargs[1],
scale
);
}}
return this;
};
jsPDFAPI.addSVG=jsPDFAPI.addSvg;
jsPDFAPI.addSvgAsImage=function(
svg,
x,
y,
w,
h,
alias,
compression,
rotation
){
if(isNaN(x)||isNaN(y)){
console.error("jsPDF.addSvgAsImage: Invalid coordinates", arguments);
throw new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");
}
if(isNaN(w)||isNaN(h)){
console.error("jsPDF.addSvgAsImage: Invalid measurements", arguments);
throw new Error(
"Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage"
);
}
var canvas=document.createElement("canvas");
canvas.width=w;
canvas.height=h;
var ctx=canvas.getContext("2d");
ctx.fillStyle="#fff"; /// set white fill style
ctx.fillRect(0, 0, canvas.width, canvas.height);
var options={
ignoreMouse: true,
ignoreAnimation: true,
ignoreDimensions: true
};
var doc=this;
return loadOptionalLibrary("canvg")
.then(function(canvg){
return canvg.Canvg.fromString(ctx, svg, options);
},
function(){
return Promise.reject(new Error("Could not load canvg."));
}
)
.then(function(instance){
return instance.render(options);
})
.then(function(){
doc.addImage(canvas.toDataURL("image/jpeg", 1.0),
x,
y,
w,
h,
compression,
rotation
);
});
};})(jsPDF.API);
(function(jsPDFAPI){
jsPDFAPI.putTotalPages=function(pageExpression){
var replaceExpression;
var totalNumberOfPages=0;
if(parseInt(this.internal.getFont().id.substr(1), 10) < 15){
replaceExpression=new RegExp(pageExpression, "g");
totalNumberOfPages=this.internal.getNumberOfPages();
}else{
replaceExpression=new RegExp(
this.pdfEscape16(pageExpression, this.internal.getFont()),
"g"
);
totalNumberOfPages=this.pdfEscape16(
this.internal.getNumberOfPages() + "",
this.internal.getFont()
);
}
for (var n=1; n <=this.internal.getNumberOfPages(); n++){
for (var i=0; i < this.internal.pages[n].length; i++){
this.internal.pages[n][i]=this.internal.pages[n][i].replace(replaceExpression,
totalNumberOfPages
);
}}
return this;
};})(jsPDF.API);
(function(jsPDFAPI){
jsPDFAPI.viewerPreferences=function(options, doReset){
options=options||{};
doReset=doReset||false;
var configuration;
var configurationTemplate={
HideToolbar: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.3
},
HideMenubar: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.3
},
HideWindowUI: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.3
},
FitWindow: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.3
},
CenterWindow: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.3
},
DisplayDocTitle: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.4
},
NonFullScreenPageMode: {
defaultValue: "UseNone",
value: "UseNone",
type: "name",
explicitSet: false,
valueSet: ["UseNone", "UseOutlines", "UseThumbs", "UseOC"],
pdfVersion: 1.3
},
Direction: {
defaultValue: "L2R",
value: "L2R",
type: "name",
explicitSet: false,
valueSet: ["L2R", "R2L"],
pdfVersion: 1.3
},
ViewArea: {
defaultValue: "CropBox",
value: "CropBox",
type: "name",
explicitSet: false,
valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],
pdfVersion: 1.4
},
ViewClip: {
defaultValue: "CropBox",
value: "CropBox",
type: "name",
explicitSet: false,
valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],
pdfVersion: 1.4
},
PrintArea: {
defaultValue: "CropBox",
value: "CropBox",
type: "name",
explicitSet: false,
valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],
pdfVersion: 1.4
},
PrintClip: {
defaultValue: "CropBox",
value: "CropBox",
type: "name",
explicitSet: false,
valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"],
pdfVersion: 1.4
},
PrintScaling: {
defaultValue: "AppDefault",
value: "AppDefault",
type: "name",
explicitSet: false,
valueSet: ["AppDefault", "None"],
pdfVersion: 1.6
},
Duplex: {
defaultValue: "",
value: "none",
type: "name",
explicitSet: false,
valueSet: [
"Simplex",
"DuplexFlipShortEdge",
"DuplexFlipLongEdge",
"none"
],
pdfVersion: 1.7
},
PickTrayByPDFSize: {
defaultValue: false,
value: false,
type: "boolean",
explicitSet: false,
valueSet: [true, false],
pdfVersion: 1.7
},
PrintPageRange: {
defaultValue: "",
value: "",
type: "array",
explicitSet: false,
valueSet: null,
pdfVersion: 1.7
},
NumCopies: {
defaultValue: 1,
value: 1,
type: "integer",
explicitSet: false,
valueSet: null,
pdfVersion: 1.7
}};
var configurationKeys=Object.keys(configurationTemplate);
var rangeArray=[];
var i=0;
var j=0;
var k=0;
var isValid;
var method;
var value;
function arrayContainsElement(array, element){
var iterator;
var result=false;
for (iterator=0; iterator < array.length; iterator +=1){
if(array[iterator]===element){
result=true;
}}
return result;
}
if(this.internal.viewerpreferences===undefined){
this.internal.viewerpreferences={};
this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(configurationTemplate)
);
this.internal.viewerpreferences.isSubscribed=false;
}
configuration=this.internal.viewerpreferences.configuration;
if(options==="reset"||doReset===true){
var len=configurationKeys.length;
for (k=0; k < len; k +=1){
configuration[configurationKeys[k]].value =
configuration[configurationKeys[k]].defaultValue;
configuration[configurationKeys[k]].explicitSet=false;
}}
if(typeof options==="object"){
for (method in options){
value=options[method];
if(arrayContainsElement(configurationKeys, method) &&
value!==undefined
){
if(configuration[method].type==="boolean" &&
typeof value==="boolean"
){
configuration[method].value=value;
}else if(configuration[method].type==="name" &&
arrayContainsElement(configuration[method].valueSet, value)
){
configuration[method].value=value;
}else if(configuration[method].type==="integer" &&
Number.isInteger(value)
){
configuration[method].value=value;
}else if(configuration[method].type==="array"){
for (i=0; i < value.length; i +=1){
isValid=true;
if(value[i].length===1&&typeof value[i][0]==="number"){
rangeArray.push(String(value[i] - 1));
}else if(value[i].length > 1){
for (j=0; j < value[i].length; j +=1){
if(typeof value[i][j]!=="number"){
isValid=false;
}}
if(isValid===true){
rangeArray.push([value[i][0] - 1, value[i][1] - 1].join(" "));
}}
}
configuration[method].value="[" + rangeArray.join(" ") + "]";
}else{
configuration[method].value=configuration[method].defaultValue;
}
configuration[method].explicitSet=true;
}}
}
if(this.internal.viewerpreferences.isSubscribed===false){
this.internal.events.subscribe("putCatalog", function(){
var pdfDict=[];
var vPref;
for (vPref in configuration){
if(configuration[vPref].explicitSet===true){
if(configuration[vPref].type==="name"){
pdfDict.push("/" + vPref + " /" + configuration[vPref].value);
}else{
pdfDict.push("/" + vPref + " " + configuration[vPref].value);
}}
}
if(pdfDict.length!==0){
this.internal.write("/ViewerPreferences\n<<\n" + pdfDict.join("\n") + "\n>>"
);
}});
this.internal.viewerpreferences.isSubscribed=true;
}
this.internal.viewerpreferences.configuration=configuration;
return this;
};})(jsPDF.API);
(function(jsPDFAPI){
var postPutResources=function(){
var xmpmeta_beginning='<x:xmpmeta xmlns:x="adobe:ns:meta/">';
var rdf_beginning =
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="' +
this.internal.__metadata__.namespaceuri +
'"><jspdf:metadata>';
var rdf_ending="</jspdf:metadata></rdf:Description></rdf:RDF>";
var xmpmeta_ending="</x:xmpmeta>";
var utf8_xmpmeta_beginning=unescape(
encodeURIComponent(xmpmeta_beginning)
);
var utf8_rdf_beginning=unescape(encodeURIComponent(rdf_beginning));
var utf8_metadata=unescape(
encodeURIComponent(this.internal.__metadata__.metadata)
);
var utf8_rdf_ending=unescape(encodeURIComponent(rdf_ending));
var utf8_xmpmeta_ending=unescape(encodeURIComponent(xmpmeta_ending));
var total_len =
utf8_rdf_beginning.length +
utf8_metadata.length +
utf8_rdf_ending.length +
utf8_xmpmeta_beginning.length +
utf8_xmpmeta_ending.length;
this.internal.__metadata__.metadata_object_number=this.internal.newObject();
this.internal.write("<< /Type /Metadata /Subtype /XML /Length " + total_len + " >>"
);
this.internal.write("stream");
this.internal.write(utf8_xmpmeta_beginning +
utf8_rdf_beginning +
utf8_metadata +
utf8_rdf_ending +
utf8_xmpmeta_ending
);
this.internal.write("endstream");
this.internal.write("endobj");
};
var putCatalog=function(){
if(this.internal.__metadata__.metadata_object_number){
this.internal.write("/Metadata " +
this.internal.__metadata__.metadata_object_number +
" 0 R"
);
}};
jsPDFAPI.addMetadata=function(metadata, namespaceuri){
if(typeof this.internal.__metadata__==="undefined"){
this.internal.__metadata__={
metadata: metadata,
namespaceuri: namespaceuri||"http://jspdf.default.namespaceuri/"
};
this.internal.events.subscribe("putCatalog", putCatalog);
this.internal.events.subscribe("postPutResources", postPutResources);
}
return this;
};})(jsPDF.API);
(function(jsPDF){
var jsPDFAPI=jsPDF.API;
var pdfEscape16=(jsPDFAPI.pdfEscape16=function(text, font){
var widths=font.metadata.Unicode.widths;
var padz=["", "0", "00", "000", "0000"];
var ar=[""];
for (var i=0, l=text.length, t; i < l; ++i){
t=font.metadata.characterToGlyph(text.charCodeAt(i));
font.metadata.glyIdsUsed.push(t);
font.metadata.toUnicode[t]=text.charCodeAt(i);
if(widths.indexOf(t)==-1){
widths.push(t);
widths.push([parseInt(font.metadata.widthOfGlyph(t), 10)]);
}
if(t=="0"){
return ar.join("");
}else{
t=t.toString(16);
ar.push(padz[4 - t.length], t);
}}
return ar.join("");
});
var toUnicodeCmap=function(map){
var code, codes, range, unicode, unicodeMap, _i, _len;
unicodeMap =
"/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n  /Registry (Adobe)\n  /Ordering (UCS)\n  /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000><ffff>\nendcodespacerange";
codes=Object.keys(map).sort(function(a, b){
return a - b;
});
range=[];
for (_i=0, _len=codes.length; _i < _len; _i++){
code=codes[_i];
if(range.length >=100){
unicodeMap +=
"\n" +
range.length +
" beginbfchar\n" +
range.join("\n") +
"\nendbfchar";
range=[];
}
if(map[code]!==undefined &&
map[code]!==null &&
typeof map[code].toString==="function"
){
unicode=("0000" + map[code].toString(16)).slice(-4);
code=("0000" + (+code).toString(16)).slice(-4);
range.push("<" + code + "><" + unicode + ">");
}}
if(range.length){
unicodeMap +=
"\n" +
range.length +
" beginbfchar\n" +
range.join("\n") +
"\nendbfchar\n";
}
unicodeMap +=
"endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend";
return unicodeMap;
};
var identityHFunction=function(options){
var font=options.font;
var out=options.out;
var newObject=options.newObject;
var putStream=options.putStream;
var pdfEscapeWithNeededParanthesis=options.pdfEscapeWithNeededParanthesis;
if(font.metadata instanceof jsPDF.API.TTFFont &&
font.encoding==="Identity-H"
){
var widths=font.metadata.Unicode.widths;
var data=font.metadata.subset.encode(font.metadata.glyIdsUsed, 1);
var pdfOutput=data;
var pdfOutput2="";
for (var i=0; i < pdfOutput.length; i++){
pdfOutput2 +=String.fromCharCode(pdfOutput[i]);
}
var fontTable=newObject();
putStream({ data: pdfOutput2, addLength1: true });
out("endobj");
var cmap=newObject();
var cmapData=toUnicodeCmap(font.metadata.toUnicode);
putStream({ data: cmapData, addLength1: true });
out("endobj");
var fontDescriptor=newObject();
out("<<");
out("/Type /FontDescriptor");
out("/FontName /" + pdfEscapeWithNeededParanthesis(font.fontName));
out("/FontFile2 " + fontTable + " 0 R");
out("/FontBBox " + jsPDF.API.PDFObject.convert(font.metadata.bbox));
out("/Flags " + font.metadata.flags);
out("/StemV " + font.metadata.stemV);
out("/ItalicAngle " + font.metadata.italicAngle);
out("/Ascent " + font.metadata.ascender);
out("/Descent " + font.metadata.decender);
out("/CapHeight " + font.metadata.capHeight);
out(">>");
out("endobj");
var DescendantFont=newObject();
out("<<");
out("/Type /Font");
out("/BaseFont /" + pdfEscapeWithNeededParanthesis(font.fontName));
out("/FontDescriptor " + fontDescriptor + " 0 R");
out("/W " + jsPDF.API.PDFObject.convert(widths));
out("/CIDToGIDMap /Identity");
out("/DW 1000");
out("/Subtype /CIDFontType2");
out("/CIDSystemInfo");
out("<<");
out("/Supplement 0");
out("/Registry (Adobe)");
out("/Ordering (" + font.encoding + ")");
out(">>");
out(">>");
out("endobj");
font.objectNumber=newObject();
out("<<");
out("/Type /Font");
out("/Subtype /Type0");
out("/ToUnicode " + cmap + " 0 R");
out("/BaseFont /" + pdfEscapeWithNeededParanthesis(font.fontName));
out("/Encoding /" + font.encoding);
out("/DescendantFonts [" + DescendantFont + " 0 R]");
out(">>");
out("endobj");
font.isAlreadyPutted=true;
}};
jsPDFAPI.events.push([
"putFont",
function(args){
identityHFunction(args);
}
]);
var winAnsiEncodingFunction=function(options){
var font=options.font;
var out=options.out;
var newObject=options.newObject;
var putStream=options.putStream;
var pdfEscapeWithNeededParanthesis=options.pdfEscapeWithNeededParanthesis;
if(font.metadata instanceof jsPDF.API.TTFFont &&
font.encoding==="WinAnsiEncoding"
){
var data=font.metadata.rawData;
var pdfOutput=data;
var pdfOutput2="";
for (var i=0; i < pdfOutput.length; i++){
pdfOutput2 +=String.fromCharCode(pdfOutput[i]);
}
var fontTable=newObject();
putStream({ data: pdfOutput2, addLength1: true });
out("endobj");
var cmap=newObject();
var cmapData=toUnicodeCmap(font.metadata.toUnicode);
putStream({ data: cmapData, addLength1: true });
out("endobj");
var fontDescriptor=newObject();
out("<<");
out("/Descent " + font.metadata.decender);
out("/CapHeight " + font.metadata.capHeight);
out("/StemV " + font.metadata.stemV);
out("/Type /FontDescriptor");
out("/FontFile2 " + fontTable + " 0 R");
out("/Flags 96");
out("/FontBBox " + jsPDF.API.PDFObject.convert(font.metadata.bbox));
out("/FontName /" + pdfEscapeWithNeededParanthesis(font.fontName));
out("/ItalicAngle " + font.metadata.italicAngle);
out("/Ascent " + font.metadata.ascender);
out(">>");
out("endobj");
font.objectNumber=newObject();
for (var j=0; j < font.metadata.hmtx.widths.length; j++){
font.metadata.hmtx.widths[j]=parseInt(
font.metadata.hmtx.widths[j] * (1000 / font.metadata.head.unitsPerEm)
);
}
out(
"<</Subtype/TrueType/Type/Font/ToUnicode " +
cmap +
" 0 R/BaseFont/" +
font.fontName +
"/FontDescriptor " +
fontDescriptor +
" 0 R" +
"/Encoding/" +
font.encoding +
" /FirstChar 29 /LastChar 255 /Widths " +
jsPDF.API.PDFObject.convert(font.metadata.hmtx.widths) +
">>"
);
out("endobj");
font.isAlreadyPutted=true;
}};
jsPDFAPI.events.push([
"putFont",
function(args){
winAnsiEncodingFunction(args);
}
]);
var utf8TextFunction=function(args){
var text=args.text||"";
var x=args.x;
var y=args.y;
var options=args.options||{};
var mutex=args.mutex||{};
var pdfEscape=mutex.pdfEscape;
var activeFontKey=mutex.activeFontKey;
var fonts=mutex.fonts;
var key=activeFontKey;
var str="",
s=0,
cmapConfirm;
var strText="";
var encoding=fonts[key].encoding;
if(fonts[key].encoding!=="Identity-H"){
return {
text: text,
x: x,
y: y,
options: options,
mutex: mutex
};}
strText=text;
key=activeFontKey;
if(Array.isArray(text)){
strText=text[0];
}
for (s=0; s < strText.length; s +=1){
if(fonts[key].metadata.hasOwnProperty("cmap")){
cmapConfirm =
fonts[key].metadata.cmap.unicode.codeMap[strText[s].charCodeAt(0)];
}
if(!cmapConfirm){
if(strText[s].charCodeAt(0) < 256 &&
fonts[key].metadata.hasOwnProperty("Unicode")
){
str +=strText[s];
}else{
str +="";
}}else{
str +=strText[s];
}}
var result="";
if(parseInt(key.slice(1)) < 14||encoding==="WinAnsiEncoding"){
result=pdfEscape(str, key)
.split("")
.map(function(cv){
return cv.charCodeAt(0).toString(16);
})
.join("");
}else if(encoding==="Identity-H"){
result=pdfEscape16(str, fonts[key]);
}
mutex.isHex=true;
return {
text: result,
x: x,
y: y,
options: options,
mutex: mutex
};};
var utf8EscapeFunction=function(parms){
var text=parms.text||"",
x=parms.x,
y=parms.y,
options=parms.options,
mutex=parms.mutex;
var tmpText=[];
var args={
text: text,
x: x,
y: y,
options: options,
mutex: mutex
};
if(Array.isArray(text)){
var i=0;
for (i=0; i < text.length; i +=1){
if(Array.isArray(text[i])){
if(text[i].length===3){
tmpText.push([
utf8TextFunction(Object.assign({}, args, { text: text[i][0] }))
.text,
text[i][1],
text[i][2]
]);
}else{
tmpText.push(utf8TextFunction(Object.assign({}, args, { text: text[i] })).text
);
}}else{
tmpText.push(utf8TextFunction(Object.assign({}, args, { text: text[i] })).text
);
}}
parms.text=tmpText;
}else{
parms.text=utf8TextFunction(
Object.assign({}, args, { text: text })
).text;
}};
jsPDFAPI.events.push(["postProcessText", utf8EscapeFunction]);
})(jsPDF);
(function(jsPDFAPI){
var _initializeVFS=function(){
if(typeof this.internal.vFS==="undefined"){
this.internal.vFS={};}
return true;
};
jsPDFAPI.existsFileInVFS=function(filename){
_initializeVFS.call(this);
return typeof this.internal.vFS[filename]!=="undefined";
};
jsPDFAPI.addFileToVFS=function(filename, filecontent){
_initializeVFS.call(this);
this.internal.vFS[filename]=filecontent;
return this;
};
jsPDFAPI.getFileFromVFS=function(filename){
_initializeVFS.call(this);
if(typeof this.internal.vFS[filename]!=="undefined"){
return this.internal.vFS[filename];
}
return null;
};})(jsPDF.API);
(function(jsPDF){
/**
* Table of Unicode types.
*
* Generated by:
*
* var bidi=require("./bidi/index");
* var bidi_accumulate=bidi.slice(0, 256).concat(bidi.slice(0x0500, 0x0500 + 256 * 3)).
* concat(bidi.slice(0x2000, 0x2000 + 256)).concat(bidi.slice(0xFB00, 0xFB00 + 256)).
* concat(bidi.slice(0xFE00, 0xFE00 + 2 * 256));
*
* for(var i=0; i < bidi_accumulate.length; i++){
* 	if(bidi_accumulate[i]===undefined||bidi_accumulate[i]==='ON')
* 		bidi_accumulate[i]='N';
* }
* var bidiAccumulateStr='return [ "' + bidi_accumulate.toString().replace(/,/g, '", "') + '" ];';
* require("fs").writeFile('unicode-types.js', bidiAccumulateStr);
*
* Based on:
* https://github.com/mathiasbynens/unicode-8.0.0
*/
var bidiUnicodeTypes=[
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"S",
"B",
"S",
"WS",
"B",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"B",
"B",
"B",
"S",
"WS",
"N",
"N",
"ET",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"ES",
"CS",
"ES",
"CS",
"CS",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"CS",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"B",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"CS",
"N",
"ET",
"ET",
"ET",
"ET",
"N",
"N",
"N",
"N",
"L",
"N",
"N",
"BN",
"N",
"N",
"ET",
"ET",
"EN",
"EN",
"N",
"L",
"N",
"N",
"N",
"EN",
"L",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"L",
"N",
"N",
"N",
"N",
"N",
"ET",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"R",
"NSM",
"R",
"NSM",
"NSM",
"R",
"NSM",
"NSM",
"R",
"NSM",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"N",
"N",
"N",
"N",
"N",
"R",
"R",
"R",
"R",
"R",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"N",
"N",
"AL",
"ET",
"ET",
"AL",
"CS",
"AL",
"N",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"AL",
"AL",
"N",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"AN",
"ET",
"AN",
"AN",
"AL",
"AL",
"AL",
"NSM",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"AN",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"AL",
"AL",
"NSM",
"NSM",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"AL",
"AL",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"N",
"AL",
"AL",
"NSM",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"N",
"N",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"AL",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"R",
"R",
"N",
"N",
"N",
"N",
"R",
"N",
"N",
"N",
"N",
"N",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"WS",
"BN",
"BN",
"BN",
"L",
"R",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"WS",
"B",
"LRE",
"RLE",
"PDF",
"LRO",
"RLO",
"CS",
"ET",
"ET",
"ET",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"CS",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"WS",
"BN",
"BN",
"BN",
"BN",
"BN",
"N",
"LRI",
"RLI",
"FSI",
"PDI",
"BN",
"BN",
"BN",
"BN",
"BN",
"BN",
"EN",
"L",
"N",
"N",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"ES",
"ES",
"N",
"N",
"N",
"L",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"ES",
"ES",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"N",
"R",
"NSM",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"ES",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"N",
"R",
"R",
"R",
"R",
"R",
"N",
"R",
"N",
"R",
"R",
"N",
"R",
"R",
"N",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"R",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"NSM",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"CS",
"N",
"CS",
"N",
"N",
"CS",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"ET",
"N",
"N",
"ES",
"ES",
"N",
"N",
"N",
"N",
"N",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"AL",
"AL",
"AL",
"AL",
"AL",
"N",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"AL",
"N",
"N",
"BN",
"N",
"N",
"N",
"ET",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"ES",
"CS",
"ES",
"CS",
"CS",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"EN",
"CS",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"L",
"L",
"L",
"L",
"L",
"L",
"N",
"N",
"L",
"L",
"L",
"N",
"N",
"N",
"ET",
"ET",
"N",
"N",
"N",
"ET",
"ET",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N",
"N"
];
jsPDF.__bidiEngine__=jsPDF.prototype.__bidiEngine__=function(options){
var _UNICODE_TYPES=_bidiUnicodeTypes;
var _STATE_TABLE_LTR=[
[0, 3, 0, 1, 0, 0, 0],
[0, 3, 0, 1, 2, 2, 0],
[0, 3, 0, 0x11, 2, 0, 1],
[0, 3, 5, 5, 4, 1, 0],
[0, 3, 0x15, 0x15, 4, 0, 1],
[0, 3, 5, 5, 4, 2, 0]
];
var _STATE_TABLE_RTL=[
[2, 0, 1, 1, 0, 1, 0],
[2, 0, 1, 1, 0, 2, 0],
[2, 0, 2, 1, 3, 2, 0],
[2, 0, 2, 0x21, 3, 1, 1]
];
var _TYPE_NAMES_MAP={ L: 0, R: 1, EN: 2, AN: 3, N: 4, B: 5, S: 6 };
var _UNICODE_RANGES_MAP={
0: 0,
5: 1,
6: 2,
7: 3,
0x20: 4,
0xfb: 5,
0xfe: 6,
0xff: 7
};
var _SWAP_TABLE=[
"\u0028",
"\u0029",
"\u0028",
"\u003C",
"\u003E",
"\u003C",
"\u005B",
"\u005D",
"\u005B",
"\u007B",
"\u007D",
"\u007B",
"\u00AB",
"\u00BB",
"\u00AB",
"\u2039",
"\u203A",
"\u2039",
"\u2045",
"\u2046",
"\u2045",
"\u207D",
"\u207E",
"\u207D",
"\u208D",
"\u208E",
"\u208D",
"\u2264",
"\u2265",
"\u2264",
"\u2329",
"\u232A",
"\u2329",
"\uFE59",
"\uFE5A",
"\uFE59",
"\uFE5B",
"\uFE5C",
"\uFE5B",
"\uFE5D",
"\uFE5E",
"\uFE5D",
"\uFE64",
"\uFE65",
"\uFE64"
];
var _LTR_RANGES_REG_EXPR=new RegExp(
/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/
);
var _lastArabic=false,
_hasUbatB,
_hasUbatS,
DIR_LTR=0,
DIR_RTL=1,
_isInVisual,
_isInRtl,
_isOutVisual,
_isOutRtl,
_isSymmetricSwapping,
_dir=DIR_LTR;
this.__bidiEngine__={};
var _init=function(text, sourceToTargetMap){
if(sourceToTargetMap){
for (var i=0; i < text.length; i++){
sourceToTargetMap[i]=i;
}}
if(_isInRtl===undefined){
_isInRtl=_isContextualDirRtl(text);
}
if(_isOutRtl===undefined){
_isOutRtl=_isContextualDirRtl(text);
}};
var _getCharType=function(ch){
var charCode=ch.charCodeAt(),
range=charCode >> 8,
rangeIdx=_UNICODE_RANGES_MAP[range];
if(rangeIdx!==undefined){
return _UNICODE_TYPES[rangeIdx * 256 + (charCode & 0xff)];
}else if(range===0xfc||range===0xfd){
return "AL";
}else if(_LTR_RANGES_REG_EXPR.test(range)){
return "L";
}else if(range===8){
return "R";
}
return "N";
};
var _isContextualDirRtl=function(text){
for (var i=0, charType; i < text.length; i++){
charType=_getCharType(text.charAt(i));
if(charType==="L"){
return false;
}else if(charType==="R"){
return true;
}}
return false;
};
var _resolveCharType=function(chars, types, resolvedTypes, index){
var cType=types[index],
wType,
nType,
i,
len;
switch (cType){
case "L":
case "R":
_lastArabic=false;
break;
case "N":
case "AN":
break;
case "EN":
if(_lastArabic){
cType="AN";
}
break;
case "AL":
_lastArabic=true;
cType="R";
break;
case "WS":
cType="N";
break;
case "CS":
if(index < 1 ||
index + 1 >=types.length ||
((wType=resolvedTypes[index - 1])!=="EN"&&wType!=="AN") ||
((nType=types[index + 1])!=="EN"&&nType!=="AN")
){
cType="N";
}else if(_lastArabic){
nType="AN";
}
cType=nType===wType ? nType:"N";
break;
case "ES":
wType=index > 0 ? resolvedTypes[index - 1]:"B";
cType =
wType==="EN" &&
index + 1 < types.length &&
types[index + 1]==="EN"
? "EN"
: "N";
break;
case "ET":
if(index > 0&&resolvedTypes[index - 1]==="EN"){
cType="EN";
break;
}else if(_lastArabic){
cType="N";
break;
}
i=index + 1;
len=types.length;
while (i < len&&types[i]==="ET"){
i++;
}
if(i < len&&types[i]==="EN"){
cType="EN";
}else{
cType="N";
}
break;
case "NSM":
if(_isInVisual&&!_isInRtl){
len=types.length;
i=index + 1;
while (i < len&&types[i]==="NSM"){
i++;
}
if(i < len){
var c=chars[index];
var rtlCandidate=(c >=0x0591&&c <=0x08ff)||c===0xfb1e;
wType=types[i];
if(rtlCandidate&&(wType==="R"||wType==="AL")){
cType="R";
break;
}}
}
if(index < 1||(wType=types[index - 1])==="B"){
cType="N";
}else{
cType=resolvedTypes[index - 1];
}
break;
case "B":
_lastArabic=false;
_hasUbatB=true;
cType=_dir;
break;
case "S":
_hasUbatS=true;
cType="N";
break;
case "LRE":
case "RLE":
case "LRO":
case "RLO":
case "PDF":
_lastArabic=false;
break;
case "BN":
cType="N";
break;
}
return cType;
};
var _handleUbatS=function(types, levels, length){
for (var i=0; i < length; i++){
if(types[i]==="S"){
levels[i]=_dir;
for (var j=i - 1; j >=0; j--){
if(types[j]==="WS"){
levels[j]=_dir;
}else{
break;
}}
}}
};
var _invertString=function(text, sourceToTargetMap, levels){
var charArray=text.split("");
if(levels){
_computeLevels(charArray, levels, { hiLevel: _dir });
}
charArray.reverse();
sourceToTargetMap&&sourceToTargetMap.reverse();
return charArray.join("");
};
var _computeLevels=function(chars, levels, params){
var action,
condition,
i,
index,
newLevel,
prevState,
condPos=-1,
len=chars.length,
newState=0,
resolvedTypes=[],
stateTable=_dir ? _STATE_TABLE_RTL:_STATE_TABLE_LTR,
types=[];
_lastArabic=false;
_hasUbatB=false;
_hasUbatS=false;
for (i=0; i < len; i++){
types[i]=_getCharType(chars[i]);
}
for (index=0; index < len; index++){
prevState=newState;
resolvedTypes[index]=_resolveCharType(
chars,
types,
resolvedTypes,
index
);
newState=stateTable[prevState][_TYPE_NAMES_MAP[resolvedTypes[index]]];
action=newState & 0xf0;
newState &=0x0f;
levels[index]=newLevel=stateTable[newState][5];
if(action > 0){
if(action===0x10){
for (i=condPos; i < index; i++){
levels[i]=1;
}
condPos=-1;
}else{
condPos=-1;
}}
condition=stateTable[newState][6];
if(condition){
if(condPos===-1){
condPos=index;
}}else{
if(condPos > -1){
for (i=condPos; i < index; i++){
levels[i]=newLevel;
}
condPos=-1;
}}
if(types[index]==="B"){
levels[index]=0;
}
params.hiLevel |=newLevel;
}
if(_hasUbatS){
_handleUbatS(types, levels, len);
}};
var _invertByLevel=function(
level,
charArray,
sourceToTargetMap,
levels,
params
){
if(params.hiLevel < level){
return;
}
if(level===1&&_dir===DIR_RTL&&!_hasUbatB){
charArray.reverse();
sourceToTargetMap&&sourceToTargetMap.reverse();
return;
}
var ch,
high,
end,
low,
len=charArray.length,
start=0;
while (start < len){
if(levels[start] >=level){
end=start + 1;
while (end < len&&levels[end] >=level){
end++;
}
for (low=start, high=end - 1; low < high; low++, high--){
ch=charArray[low];
charArray[low]=charArray[high];
charArray[high]=ch;
if(sourceToTargetMap){
ch=sourceToTargetMap[low];
sourceToTargetMap[low]=sourceToTargetMap[high];
sourceToTargetMap[high]=ch;
}}
start=end;
}
start++;
}};
var _symmetricSwap=function(charArray, levels, params){
if(params.hiLevel!==0&&_isSymmetricSwapping){
for (var i=0, index; i < charArray.length; i++){
if(levels[i]===1){
index=_SWAP_TABLE.indexOf(charArray[i]);
if(index >=0){
charArray[i]=_SWAP_TABLE[index + 1];
}}
}}
};
var _reorder=function(text, sourceToTargetMap, levels){
var charArray=text.split(""),
params={ hiLevel: _dir };
if(!levels){
levels=[];
}
_computeLevels(charArray, levels, params);
_symmetricSwap(charArray, levels, params);
_invertByLevel(DIR_RTL + 1, charArray, sourceToTargetMap, levels, params);
_invertByLevel(DIR_RTL, charArray, sourceToTargetMap, levels, params);
return charArray.join("");
};
this.__bidiEngine__.doBidiReorder=function(
text,
sourceToTargetMap,
levels
){
_init(text, sourceToTargetMap);
if(!_isInVisual&&_isOutVisual&&!_isOutRtl){
_dir=_isInRtl ? DIR_RTL:DIR_LTR;
text=_reorder(text, sourceToTargetMap, levels);
}else if(_isInVisual&&_isOutVisual&&_isInRtl ^ _isOutRtl){
_dir=_isInRtl ? DIR_RTL:DIR_LTR;
text=_invertString(text, sourceToTargetMap, levels);
}else if(!_isInVisual&&_isOutVisual&&_isOutRtl){
_dir=_isInRtl ? DIR_RTL:DIR_LTR;
text=_reorder(text, sourceToTargetMap, levels);
text=_invertString(text, sourceToTargetMap);
}else if(_isInVisual&&!_isInRtl&&!_isOutVisual&&!_isOutRtl){
_dir=DIR_LTR;
text=_reorder(text, sourceToTargetMap, levels);
}else if(_isInVisual&&!_isOutVisual&&_isInRtl ^ _isOutRtl){
text=_invertString(text, sourceToTargetMap);
if(_isInRtl){
_dir=DIR_LTR;
text=_reorder(text, sourceToTargetMap, levels);
}else{
_dir=DIR_RTL;
text=_reorder(text, sourceToTargetMap, levels);
text=_invertString(text, sourceToTargetMap);
}}else if(_isInVisual&&_isInRtl&&!_isOutVisual&&_isOutRtl){
_dir=DIR_RTL;
text=_reorder(text, sourceToTargetMap, levels);
text=_invertString(text, sourceToTargetMap);
}else if(!_isInVisual&&!_isOutVisual&&_isInRtl ^ _isOutRtl){
var isSymmetricSwappingOrig=_isSymmetricSwapping;
if(_isInRtl){
_dir=DIR_RTL;
text=_reorder(text, sourceToTargetMap, levels);
_dir=DIR_LTR;
_isSymmetricSwapping=false;
text=_reorder(text, sourceToTargetMap, levels);
_isSymmetricSwapping=isSymmetricSwappingOrig;
}else{
_dir=DIR_LTR;
text=_reorder(text, sourceToTargetMap, levels);
text=_invertString(text, sourceToTargetMap);
_dir=DIR_RTL;
_isSymmetricSwapping=false;
text=_reorder(text, sourceToTargetMap, levels);
_isSymmetricSwapping=isSymmetricSwappingOrig;
text=_invertString(text, sourceToTargetMap);
}}
return text;
};
this.__bidiEngine__.setOptions=function(options){
if(options){
_isInVisual=options.isInputVisual;
_isOutVisual=options.isOutputVisual;
_isInRtl=options.isInputRtl;
_isOutRtl=options.isOutputRtl;
_isSymmetricSwapping=options.isSymmetricSwapping;
}};
this.__bidiEngine__.setOptions(options);
return this.__bidiEngine__;
};
var _bidiUnicodeTypes=bidiUnicodeTypes;
var bidiEngine=new jsPDF.__bidiEngine__({ isInputVisual: true });
var bidiEngineFunction=function(args){
var text=args.text;
var x=args.x;
var y=args.y;
var options=args.options||{};
var mutex=args.mutex||{};
var lang=options.lang;
var tmpText=[];
options.isInputVisual =
typeof options.isInputVisual==="boolean" ? options.isInputVisual:true;
bidiEngine.setOptions(options);
if(Object.prototype.toString.call(text)==="[object Array]"){
var i=0;
tmpText=[];
for (i=0; i < text.length; i +=1){
if(Object.prototype.toString.call(text[i])==="[object Array]"){
tmpText.push([
bidiEngine.doBidiReorder(text[i][0]),
text[i][1],
text[i][2]
]);
}else{
tmpText.push([bidiEngine.doBidiReorder(text[i])]);
}}
args.text=tmpText;
}else{
args.text=bidiEngine.doBidiReorder(text);
}
bidiEngine.setOptions({ isInputVisual: true });
};
jsPDF.API.events.push(["postProcessText", bidiEngineFunction]);
})(jsPDF);
jsPDF.API.TTFFont=(function(){
TTFFont.open=function(file){
return new TTFFont(file);
};
function TTFFont(rawData){
var data;
this.rawData=rawData;
data=this.contents=new Data(rawData);
this.contents.pos=4;
if(data.readString(4)==="ttcf"){
throw new Error("TTCF not supported.");
}else{
data.pos=0;
this.parse();
this.subset=new Subset(this);
this.registerTTF();
}}
TTFFont.prototype.parse=function(){
this.directory=new Directory(this.contents);
this.head=new HeadTable(this);
this.name=new NameTable(this);
this.cmap=new CmapTable(this);
this.toUnicode={};
this.hhea=new HheaTable(this);
this.maxp=new MaxpTable(this);
this.hmtx=new HmtxTable(this);
this.post=new PostTable(this);
this.os2=new OS2Table(this);
this.loca=new LocaTable(this);
this.glyf=new GlyfTable(this);
this.ascender =
(this.os2.exists&&this.os2.ascender)||this.hhea.ascender;
this.decender =
(this.os2.exists&&this.os2.decender)||this.hhea.decender;
this.lineGap=(this.os2.exists&&this.os2.lineGap)||this.hhea.lineGap;
return (this.bbox=[
this.head.xMin,
this.head.yMin,
this.head.xMax,
this.head.yMax
]);
};
TTFFont.prototype.registerTTF=function(){
var e, hi, low, raw, _ref;
this.scaleFactor=1000.0 / this.head.unitsPerEm;
this.bbox=function(){
var _i, _len, _ref, _results;
_ref=this.bbox;
_results=[];
for (_i=0, _len=_ref.length; _i < _len; _i++){
e=_ref[_i];
_results.push(Math.round(e * this.scaleFactor));
}
return _results;
}.call(this);
this.stemV=0;
if(this.post.exists){
raw=this.post.italic_angle;
hi=raw >> 16;
low=raw & 0xff;
if((hi & 0x8000)!==0){
hi=-((hi ^ 0xffff) + 1);
}
this.italicAngle=+("" + hi + "." + low);
}else{
this.italicAngle=0;
}
this.ascender=Math.round(this.ascender * this.scaleFactor);
this.decender=Math.round(this.decender * this.scaleFactor);
this.lineGap=Math.round(this.lineGap * this.scaleFactor);
this.capHeight=(this.os2.exists&&this.os2.capHeight)||this.ascender;
this.xHeight=(this.os2.exists&&this.os2.xHeight)||0;
this.familyClass=((this.os2.exists&&this.os2.familyClass)||0) >> 8;
this.isSerif =
(_ref=this.familyClass)===1 ||
_ref===2 ||
_ref===3 ||
_ref===4 ||
_ref===5 ||
_ref===7;
this.isScript=this.familyClass===10;
this.flags=0;
if(this.post.isFixedPitch){
this.flags |=1 << 0;
}
if(this.isSerif){
this.flags |=1 << 1;
}
if(this.isScript){
this.flags |=1 << 3;
}
if(this.italicAngle!==0){
this.flags |=1 << 6;
}
this.flags |=1 << 5;
if(!this.cmap.unicode){
throw new Error("No unicode cmap for font");
}};
TTFFont.prototype.characterToGlyph=function(character){
var _ref;
return (
((_ref=this.cmap.unicode)!=null ? _ref.codeMap[character]:void 0) ||
0
);
};
TTFFont.prototype.widthOfGlyph=function(glyph){
var scale;
scale=1000.0 / this.head.unitsPerEm;
return this.hmtx.forGlyph(glyph).advance * scale;
};
TTFFont.prototype.widthOfString=function(string, size, charSpace){
var charCode, i, scale, width, _ref;
string="" + string;
width=0;
for (
i=0, _ref=string.length;
0 <=_ref ? i < _ref:i > _ref;
i=0 <=_ref ? ++i:--i
){
charCode=string.charCodeAt(i);
width +=
this.widthOfGlyph(this.characterToGlyph(charCode)) +
charSpace * (1000 / size)||0;
}
scale=size / 1000;
return width * scale;
};
TTFFont.prototype.lineHeight=function(size, includeGap){
var gap;
if(includeGap==null){
includeGap=false;
}
gap=includeGap ? this.lineGap:0;
return ((this.ascender + gap - this.decender) / 1000) * size;
};
return TTFFont;
})();
var Data=(function(){
function Data(data){
this.data=data!=null ? data:[];
this.pos=0;
this.length=this.data.length;
}
Data.prototype.readByte=function(){
return this.data[this.pos++];
};
Data.prototype.writeByte=function(byte){
return (this.data[this.pos++]=byte);
};
Data.prototype.readUInt32=function(){
var b1, b2, b3, b4;
b1=this.readByte() * 0x1000000;
b2=this.readByte() << 16;
b3=this.readByte() << 8;
b4=this.readByte();
return b1 + b2 + b3 + b4;
};
Data.prototype.writeUInt32=function(val){
this.writeByte((val >>> 24) & 0xff);
this.writeByte((val >> 16) & 0xff);
this.writeByte((val >> 8) & 0xff);
return this.writeByte(val & 0xff);
};
Data.prototype.readInt32=function(){
var int;
int=this.readUInt32();
if(int >=0x80000000){
return int - 0x100000000;
}else{
return int;
}};
Data.prototype.writeInt32=function(val){
if(val < 0){
val +=0x100000000;
}
return this.writeUInt32(val);
};
Data.prototype.readUInt16=function(){
var b1, b2;
b1=this.readByte() << 8;
b2=this.readByte();
return b1 | b2;
};
Data.prototype.writeUInt16=function(val){
this.writeByte((val >> 8) & 0xff);
return this.writeByte(val & 0xff);
};
Data.prototype.readInt16=function(){
var int;
int=this.readUInt16();
if(int >=0x8000){
return int - 0x10000;
}else{
return int;
}};
Data.prototype.writeInt16=function(val){
if(val < 0){
val +=0x10000;
}
return this.writeUInt16(val);
};
Data.prototype.readString=function(length){
var i, ret;
ret=[];
for (
i=0;
0 <=length ? i < length:i > length;
i=0 <=length ? ++i:--i
){
ret[i]=String.fromCharCode(this.readByte());
}
return ret.join("");
};
Data.prototype.writeString=function(val){
var i, _ref, _results;
_results=[];
for (
i=0, _ref=val.length;
0 <=_ref ? i < _ref:i > _ref;
i=0 <=_ref ? ++i:--i
){
_results.push(this.writeByte(val.charCodeAt(i)));
}
return _results;
};
Data.prototype.readShort=function(){
return this.readInt16();
};
Data.prototype.writeShort=function(val){
return this.writeInt16(val);
};
Data.prototype.readLongLong=function(){
var b1, b2, b3, b4, b5, b6, b7, b8;
b1=this.readByte();
b2=this.readByte();
b3=this.readByte();
b4=this.readByte();
b5=this.readByte();
b6=this.readByte();
b7=this.readByte();
b8=this.readByte();
if(b1 & 0x80){
return (
((b1 ^ 0xff) * 0x100000000000000 +
(b2 ^ 0xff) * 0x1000000000000 +
(b3 ^ 0xff) * 0x10000000000 +
(b4 ^ 0xff) * 0x100000000 +
(b5 ^ 0xff) * 0x1000000 +
(b6 ^ 0xff) * 0x10000 +
(b7 ^ 0xff) * 0x100 +
(b8 ^ 0xff) +
1) *
-1
);
}
return (
b1 * 0x100000000000000 +
b2 * 0x1000000000000 +
b3 * 0x10000000000 +
b4 * 0x100000000 +
b5 * 0x1000000 +
b6 * 0x10000 +
b7 * 0x100 +
b8
);
};
Data.prototype.writeLongLong=function(val){
var high, low;
high=Math.floor(val / 0x100000000);
low=val & 0xffffffff;
this.writeByte((high >> 24) & 0xff);
this.writeByte((high >> 16) & 0xff);
this.writeByte((high >> 8) & 0xff);
this.writeByte(high & 0xff);
this.writeByte((low >> 24) & 0xff);
this.writeByte((low >> 16) & 0xff);
this.writeByte((low >> 8) & 0xff);
return this.writeByte(low & 0xff);
};
Data.prototype.readInt=function(){
return this.readInt32();
};
Data.prototype.writeInt=function(val){
return this.writeInt32(val);
};
Data.prototype.read=function(bytes){
var buf, i;
buf=[];
for (
i=0;
0 <=bytes ? i < bytes:i > bytes;
i=0 <=bytes ? ++i:--i
){
buf.push(this.readByte());
}
return buf;
};
Data.prototype.write=function(bytes){
var byte, i, _len, _results;
_results=[];
for (i=0, _len=bytes.length; i < _len; i++){
byte=bytes[i];
_results.push(this.writeByte(byte));
}
return _results;
};
return Data;
})();
var Directory=(function(){
var checksum;
function Directory(data){
var entry, i, _ref;
this.scalarType=data.readInt();
this.tableCount=data.readShort();
this.searchRange=data.readShort();
this.entrySelector=data.readShort();
this.rangeShift=data.readShort();
this.tables={};
for (
i=0, _ref=this.tableCount;
0 <=_ref ? i < _ref:i > _ref;
i=0 <=_ref ? ++i:--i
){
entry={
tag: data.readString(4),
checksum: data.readInt(),
offset: data.readInt(),
length: data.readInt()
};
this.tables[entry.tag]=entry;
}}
Directory.prototype.encode=function(tables){
var adjustment,
directory,
directoryLength,
entrySelector,
headOffset,
log2,
offset,
rangeShift,
searchRange,
sum,
table,
tableCount,
tableData,
tag;
tableCount=Object.keys(tables).length;
log2=Math.log(2);
searchRange=Math.floor(Math.log(tableCount) / log2) * 16;
entrySelector=Math.floor(searchRange / log2);
rangeShift=tableCount * 16 - searchRange;
directory=new Data();
directory.writeInt(this.scalarType);
directory.writeShort(tableCount);
directory.writeShort(searchRange);
directory.writeShort(entrySelector);
directory.writeShort(rangeShift);
directoryLength=tableCount * 16;
offset=directory.pos + directoryLength;
headOffset=null;
tableData=[];
for (tag in tables){
table=tables[tag];
directory.writeString(tag);
directory.writeInt(checksum(table));
directory.writeInt(offset);
directory.writeInt(table.length);
tableData=tableData.concat(table);
if(tag==="head"){
headOffset=offset;
}
offset +=table.length;
while (offset % 4){
tableData.push(0);
offset++;
}}
directory.write(tableData);
sum=checksum(directory.data);
adjustment=0xb1b0afba - sum;
directory.pos=headOffset + 8;
directory.writeUInt32(adjustment);
return directory.data;
};
checksum=function(data){
var i, sum, tmp, _ref;
data=__slice.call(data);
while (data.length % 4){
data.push(0);
}
tmp=new Data(data);
sum=0;
for (i=0, _ref=data.length; i < _ref; i=i +=4){
sum +=tmp.readUInt32();
}
return sum & 0xffffffff;
};
return Directory;
})();
var Table,
__hasProp={}.hasOwnProperty,
__extends=function(child, parent){
for (var key in parent){
if(__hasProp.call(parent, key)) child[key]=parent[key];
}
function ctor(){
this.constructor=child;
}
ctor.prototype=parent.prototype;
child.prototype=new ctor();
child.__super__=parent.prototype;
return child;
};
Table=(function(){
function Table(file){
var info;
this.file=file;
info=this.file.directory.tables[this.tag];
this.exists = !!info;
if(info){
(this.offset=info.offset), (this.length=info.length);
this.parse(this.file.contents);
}}
Table.prototype.parse=function(){};
Table.prototype.encode=function(){};
Table.prototype.raw=function(){
if(!this.exists){
return null;
}
this.file.contents.pos=this.offset;
return this.file.contents.read(this.length);
};
return Table;
})();
var HeadTable=(function(_super){
__extends(HeadTable, _super);
function HeadTable(){
return HeadTable.__super__.constructor.apply(this, arguments);
}
HeadTable.prototype.tag="head";
HeadTable.prototype.parse=function(data){
data.pos=this.offset;
this.version=data.readInt();
this.revision=data.readInt();
this.checkSumAdjustment=data.readInt();
this.magicNumber=data.readInt();
this.flags=data.readShort();
this.unitsPerEm=data.readShort();
this.created=data.readLongLong();
this.modified=data.readLongLong();
this.xMin=data.readShort();
this.yMin=data.readShort();
this.xMax=data.readShort();
this.yMax=data.readShort();
this.macStyle=data.readShort();
this.lowestRecPPEM=data.readShort();
this.fontDirectionHint=data.readShort();
this.indexToLocFormat=data.readShort();
return (this.glyphDataFormat=data.readShort());
};
HeadTable.prototype.encode=function(indexToLocFormat){
var table;
table=new Data();
table.writeInt(this.version);
table.writeInt(this.revision);
table.writeInt(this.checkSumAdjustment);
table.writeInt(this.magicNumber);
table.writeShort(this.flags);
table.writeShort(this.unitsPerEm);
table.writeLongLong(this.created);
table.writeLongLong(this.modified);
table.writeShort(this.xMin);
table.writeShort(this.yMin);
table.writeShort(this.xMax);
table.writeShort(this.yMax);
table.writeShort(this.macStyle);
table.writeShort(this.lowestRecPPEM);
table.writeShort(this.fontDirectionHint);
table.writeShort(indexToLocFormat);
table.writeShort(this.glyphDataFormat);
return table.data;
};
return HeadTable;
})(Table);
var CmapEntry=(function(){
function CmapEntry(data, offset){
var code,
count,
endCode,
glyphId,
glyphIds,
i,
idDelta,
idRangeOffset,
index,
saveOffset,
segCount,
segCountX2,
start,
startCode,
tail,
_j,
_k,
_len;
this.platformID=data.readUInt16();
this.encodingID=data.readShort();
this.offset=offset + data.readInt();
saveOffset=data.pos;
data.pos=this.offset;
this.format=data.readUInt16();
this.length=data.readUInt16();
this.language=data.readUInt16();
this.isUnicode =
(this.platformID===3&&this.encodingID===1&&this.format===4) ||
(this.platformID===0&&this.format===4);
this.codeMap={};
switch (this.format){
case 0:
for (i=0; i < 256; ++i){
this.codeMap[i]=data.readByte();
}
break;
case 4:
segCountX2=data.readUInt16();
segCount=segCountX2 / 2;
data.pos +=6;
endCode=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=segCount ? _j < segCount:_j > segCount;
i=0 <=segCount ? ++_j:--_j
){
_results.push(data.readUInt16());
}
return _results;
})();
data.pos +=2;
startCode=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=segCount ? _j < segCount:_j > segCount;
i=0 <=segCount ? ++_j:--_j
){
_results.push(data.readUInt16());
}
return _results;
})();
idDelta=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=segCount ? _j < segCount:_j > segCount;
i=0 <=segCount ? ++_j:--_j
){
_results.push(data.readUInt16());
}
return _results;
})();
idRangeOffset=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=segCount ? _j < segCount:_j > segCount;
i=0 <=segCount ? ++_j:--_j
){
_results.push(data.readUInt16());
}
return _results;
})();
count=(this.length - data.pos + this.offset) / 2;
glyphIds=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=count ? _j < count:_j > count;
i=0 <=count ? ++_j:--_j
){
_results.push(data.readUInt16());
}
return _results;
})();
for (i=_j=0, _len=endCode.length; _j < _len; i=++_j){
tail=endCode[i];
start=startCode[i];
for (
code=_k=start;
start <=tail ? _k <=tail:_k >=tail;
code=start <=tail ? ++_k:--_k
){
if(idRangeOffset[i]===0){
glyphId=code + idDelta[i];
}else{
index=idRangeOffset[i] / 2 + (code - start) - (segCount - i);
glyphId=glyphIds[index]||0;
if(glyphId!==0){
glyphId +=idDelta[i];
}}
this.codeMap[code]=glyphId & 0xffff;
}}
}
data.pos=saveOffset;
}
CmapEntry.encode=function(charmap, encoding){
var charMap,
code,
codeMap,
codes,
delta,
deltas,
diff,
endCode,
endCodes,
entrySelector,
glyphIDs,
i,
id,
indexes,
last,
map,
nextID,
offset,
old,
rangeOffsets,
rangeShift,
searchRange,
segCount,
segCountX2,
startCode,
startCodes,
startGlyph,
subtable,
_i,
_j,
_k,
_l,
_len,
_len1,
_len2,
_len3,
_len4,
_len5,
_len6,
_len7,
_m,
_n,
_name,
_o,
_p,
_q;
subtable=new Data();
codes=Object.keys(charmap).sort(function(a, b){
return a - b;
});
switch (encoding){
case "macroman":
id=0;
indexes=(function(){
var _results=[];
for (i=0; i < 256; ++i){
_results.push(0);
}
return _results;
})();
map={
0: 0
};
codeMap={};
for (_i=0, _len=codes.length; _i < _len; _i++){
code=codes[_i];
if(map[(_name=charmap[code])]==null){
map[_name]=++id;
}
codeMap[code]={
old: charmap[code],
new: map[charmap[code]]
};
indexes[code]=map[charmap[code]];
}
subtable.writeUInt16(1);
subtable.writeUInt16(0);
subtable.writeUInt32(12);
subtable.writeUInt16(0);
subtable.writeUInt16(262);
subtable.writeUInt16(0);
subtable.write(indexes);
return {
charMap: codeMap,
subtable: subtable.data,
maxGlyphID: id + 1
};
case "unicode":
startCodes=[];
endCodes=[];
nextID=0;
map={};
charMap={};
last=diff=null;
for (_j=0, _len1=codes.length; _j < _len1; _j++){
code=codes[_j];
old=charmap[code];
if(map[old]==null){
map[old]=++nextID;
}
charMap[code]={
old: old,
new: map[old]
};
delta=map[old] - code;
if(last==null||delta!==diff){
if(last){
endCodes.push(last);
}
startCodes.push(code);
diff=delta;
}
last=code;
}
if(last){
endCodes.push(last);
}
endCodes.push(0xffff);
startCodes.push(0xffff);
segCount=startCodes.length;
segCountX2=segCount * 2;
searchRange=2 * Math.pow(Math.log(segCount) / Math.LN2, 2);
entrySelector=Math.log(searchRange / 2) / Math.LN2;
rangeShift=2 * segCount - searchRange;
deltas=[];
rangeOffsets=[];
glyphIDs=[];
for (i=_k=0, _len2=startCodes.length; _k < _len2; i=++_k){
startCode=startCodes[i];
endCode=endCodes[i];
if(startCode===0xffff){
deltas.push(0);
rangeOffsets.push(0);
break;
}
startGlyph=charMap[startCode]["new"];
if(startCode - startGlyph >=0x8000){
deltas.push(0);
rangeOffsets.push(2 * (glyphIDs.length + segCount - i));
for (
code=_l=startCode;
startCode <=endCode ? _l <=endCode:_l >=endCode;
code=startCode <=endCode ? ++_l:--_l
){
glyphIDs.push(charMap[code]["new"]);
}}else{
deltas.push(startGlyph - startCode);
rangeOffsets.push(0);
}}
subtable.writeUInt16(3);
subtable.writeUInt16(1);
subtable.writeUInt32(12);
subtable.writeUInt16(4);
subtable.writeUInt16(16 + segCount * 8 + glyphIDs.length * 2);
subtable.writeUInt16(0);
subtable.writeUInt16(segCountX2);
subtable.writeUInt16(searchRange);
subtable.writeUInt16(entrySelector);
subtable.writeUInt16(rangeShift);
for (_m=0, _len3=endCodes.length; _m < _len3; _m++){
code=endCodes[_m];
subtable.writeUInt16(code);
}
subtable.writeUInt16(0);
for (_n=0, _len4=startCodes.length; _n < _len4; _n++){
code=startCodes[_n];
subtable.writeUInt16(code);
}
for (_o=0, _len5=deltas.length; _o < _len5; _o++){
delta=deltas[_o];
subtable.writeUInt16(delta);
}
for (_p=0, _len6=rangeOffsets.length; _p < _len6; _p++){
offset=rangeOffsets[_p];
subtable.writeUInt16(offset);
}
for (_q=0, _len7=glyphIDs.length; _q < _len7; _q++){
id=glyphIDs[_q];
subtable.writeUInt16(id);
}
return {
charMap: charMap,
subtable: subtable.data,
maxGlyphID: nextID + 1
};}};
return CmapEntry;
})();
var CmapTable=(function(_super){
__extends(CmapTable, _super);
function CmapTable(){
return CmapTable.__super__.constructor.apply(this, arguments);
}
CmapTable.prototype.tag="cmap";
CmapTable.prototype.parse=function(data){
var entry, i, tableCount;
data.pos=this.offset;
this.version=data.readUInt16();
tableCount=data.readUInt16();
this.tables=[];
this.unicode=null;
for (
i=0;
0 <=tableCount ? i < tableCount:i > tableCount;
i=0 <=tableCount ? ++i:--i
){
entry=new CmapEntry(data, this.offset);
this.tables.push(entry);
if(entry.isUnicode){
if(this.unicode==null){
this.unicode=entry;
}}
}
return true;
};
CmapTable.encode=function(charmap, encoding){
var result, table;
if(encoding==null){
encoding="macroman";
}
result=CmapEntry.encode(charmap, encoding);
table=new Data();
table.writeUInt16(0);
table.writeUInt16(1);
result.table=table.data.concat(result.subtable);
return result;
};
return CmapTable;
})(Table);
var HheaTable=(function(_super){
__extends(HheaTable, _super);
function HheaTable(){
return HheaTable.__super__.constructor.apply(this, arguments);
}
HheaTable.prototype.tag="hhea";
HheaTable.prototype.parse=function(data){
data.pos=this.offset;
this.version=data.readInt();
this.ascender=data.readShort();
this.decender=data.readShort();
this.lineGap=data.readShort();
this.advanceWidthMax=data.readShort();
this.minLeftSideBearing=data.readShort();
this.minRightSideBearing=data.readShort();
this.xMaxExtent=data.readShort();
this.caretSlopeRise=data.readShort();
this.caretSlopeRun=data.readShort();
this.caretOffset=data.readShort();
data.pos +=4 * 2;
this.metricDataFormat=data.readShort();
return (this.numberOfMetrics=data.readUInt16());
};
return HheaTable;
})(Table);
var OS2Table=(function(_super){
__extends(OS2Table, _super);
function OS2Table(){
return OS2Table.__super__.constructor.apply(this, arguments);
}
OS2Table.prototype.tag="OS/2";
OS2Table.prototype.parse=function(data){
data.pos=this.offset;
this.version=data.readUInt16();
this.averageCharWidth=data.readShort();
this.weightClass=data.readUInt16();
this.widthClass=data.readUInt16();
this.type=data.readShort();
this.ySubscriptXSize=data.readShort();
this.ySubscriptYSize=data.readShort();
this.ySubscriptXOffset=data.readShort();
this.ySubscriptYOffset=data.readShort();
this.ySuperscriptXSize=data.readShort();
this.ySuperscriptYSize=data.readShort();
this.ySuperscriptXOffset=data.readShort();
this.ySuperscriptYOffset=data.readShort();
this.yStrikeoutSize=data.readShort();
this.yStrikeoutPosition=data.readShort();
this.familyClass=data.readShort();
this.panose=(function(){
var i, _results;
_results=[];
for (i=0; i < 10; ++i){
_results.push(data.readByte());
}
return _results;
})();
this.charRange=(function(){
var i, _results;
_results=[];
for (i=0; i < 4; ++i){
_results.push(data.readInt());
}
return _results;
})();
this.vendorID=data.readString(4);
this.selection=data.readShort();
this.firstCharIndex=data.readShort();
this.lastCharIndex=data.readShort();
if(this.version > 0){
this.ascent=data.readShort();
this.descent=data.readShort();
this.lineGap=data.readShort();
this.winAscent=data.readShort();
this.winDescent=data.readShort();
this.codePageRange=(function(){
var i, _results;
_results=[];
for (i=0; i < 2; i=++i){
_results.push(data.readInt());
}
return _results;
})();
if(this.version > 1){
this.xHeight=data.readShort();
this.capHeight=data.readShort();
this.defaultChar=data.readShort();
this.breakChar=data.readShort();
return (this.maxContext=data.readShort());
}}
};
return OS2Table;
})(Table);
var PostTable=(function(_super){
__extends(PostTable, _super);
function PostTable(){
return PostTable.__super__.constructor.apply(this, arguments);
}
PostTable.prototype.tag="post";
PostTable.prototype.parse=function(data){
var length, numberOfGlyphs, _results;
data.pos=this.offset;
this.format=data.readInt();
this.italicAngle=data.readInt();
this.underlinePosition=data.readShort();
this.underlineThickness=data.readShort();
this.isFixedPitch=data.readInt();
this.minMemType42=data.readInt();
this.maxMemType42=data.readInt();
this.minMemType1=data.readInt();
this.maxMemType1=data.readInt();
switch (this.format){
case 0x00010000:
break;
case 0x00020000:
numberOfGlyphs=data.readUInt16();
this.glyphNameIndex=[];
var i;
for (
i=0;
0 <=numberOfGlyphs ? i < numberOfGlyphs:i > numberOfGlyphs;
i=0 <=numberOfGlyphs ? ++i:--i
){
this.glyphNameIndex.push(data.readUInt16());
}
this.names=[];
_results=[];
while (data.pos < this.offset + this.length){
length=data.readByte();
_results.push(this.names.push(data.readString(length)));
}
return _results;
case 0x00025000:
numberOfGlyphs=data.readUInt16();
return (this.offsets=data.read(numberOfGlyphs));
case 0x00030000:
break;
case 0x00040000:
return (this.map=function(){
var _j, _ref, _results1;
_results1=[];
for (
i=_j=0, _ref=this.file.maxp.numGlyphs;
0 <=_ref ? _j < _ref:_j > _ref;
i=0 <=_ref ? ++_j:--_j
){
_results1.push(data.readUInt32());
}
return _results1;
}.call(this));
}};
return PostTable;
})(Table);
var NameEntry=(function(){
function NameEntry(raw, entry){
this.raw=raw;
this.length=raw.length;
this.platformID=entry.platformID;
this.encodingID=entry.encodingID;
this.languageID=entry.languageID;
}
return NameEntry;
})();
var NameTable=(function(_super){
__extends(NameTable, _super);
function NameTable(){
return NameTable.__super__.constructor.apply(this, arguments);
}
NameTable.prototype.tag="name";
NameTable.prototype.parse=function(data){
var count,
entries,
entry,
i,
name,
stringOffset,
strings,
text,
_j,
_len,
_name;
data.pos=this.offset;
data.readShort();
count=data.readShort();
stringOffset=data.readShort();
entries=[];
for (
i=0;
0 <=count ? i < count:i > count;
i=0 <=count ? ++i:--i
){
entries.push({
platformID: data.readShort(),
encodingID: data.readShort(),
languageID: data.readShort(),
nameID: data.readShort(),
length: data.readShort(),
offset: this.offset + stringOffset + data.readShort()
});
}
strings={};
for (i=_j=0, _len=entries.length; _j < _len; i=++_j){
entry=entries[i];
data.pos=entry.offset;
text=data.readString(entry.length);
name=new NameEntry(text, entry);
if(strings[(_name=entry.nameID)]==null){
strings[_name]=[];
}
strings[entry.nameID].push(name);
}
this.strings=strings;
this.copyright=strings[0];
this.fontFamily=strings[1];
this.fontSubfamily=strings[2];
this.uniqueSubfamily=strings[3];
this.fontName=strings[4];
this.version=strings[5];
try {
this.postscriptName=strings[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,
""
);
} catch (e){
this.postscriptName=strings[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,
""
);
}
this.trademark=strings[7];
this.manufacturer=strings[8];
this.designer=strings[9];
this.description=strings[10];
this.vendorUrl=strings[11];
this.designerUrl=strings[12];
this.license=strings[13];
this.licenseUrl=strings[14];
this.preferredFamily=strings[15];
this.preferredSubfamily=strings[17];
this.compatibleFull=strings[18];
return (this.sampleText=strings[19]);
};
return NameTable;
})(Table);
var MaxpTable=(function(_super){
__extends(MaxpTable, _super);
function MaxpTable(){
return MaxpTable.__super__.constructor.apply(this, arguments);
}
MaxpTable.prototype.tag="maxp";
MaxpTable.prototype.parse=function(data){
data.pos=this.offset;
this.version=data.readInt();
this.numGlyphs=data.readUInt16();
this.maxPoints=data.readUInt16();
this.maxContours=data.readUInt16();
this.maxCompositePoints=data.readUInt16();
this.maxComponentContours=data.readUInt16();
this.maxZones=data.readUInt16();
this.maxTwilightPoints=data.readUInt16();
this.maxStorage=data.readUInt16();
this.maxFunctionDefs=data.readUInt16();
this.maxInstructionDefs=data.readUInt16();
this.maxStackElements=data.readUInt16();
this.maxSizeOfInstructions=data.readUInt16();
this.maxComponentElements=data.readUInt16();
return (this.maxComponentDepth=data.readUInt16());
};
return MaxpTable;
})(Table);
var HmtxTable=(function(_super){
__extends(HmtxTable, _super);
function HmtxTable(){
return HmtxTable.__super__.constructor.apply(this, arguments);
}
HmtxTable.prototype.tag="hmtx";
HmtxTable.prototype.parse=function(data){
var i, last, lsbCount, m, _j, _ref, _results;
data.pos=this.offset;
this.metrics=[];
for (
i=0, _ref=this.file.hhea.numberOfMetrics;
0 <=_ref ? i < _ref:i > _ref;
i=0 <=_ref ? ++i:--i
){
this.metrics.push({
advance: data.readUInt16(),
lsb: data.readInt16()
});
}
lsbCount=this.file.maxp.numGlyphs - this.file.hhea.numberOfMetrics;
this.leftSideBearings=(function(){
var _j, _results;
_results=[];
for (
i=_j=0;
0 <=lsbCount ? _j < lsbCount:_j > lsbCount;
i=0 <=lsbCount ? ++_j:--_j
){
_results.push(data.readInt16());
}
return _results;
})();
this.widths=function(){
var _j, _len, _ref1, _results;
_ref1=this.metrics;
_results=[];
for (_j=0, _len=_ref1.length; _j < _len; _j++){
m=_ref1[_j];
_results.push(m.advance);
}
return _results;
}.call(this);
last=this.widths[this.widths.length - 1];
_results=[];
for (
i=_j=0;
0 <=lsbCount ? _j < lsbCount:_j > lsbCount;
i=0 <=lsbCount ? ++_j:--_j
){
_results.push(this.widths.push(last));
}
return _results;
};
HmtxTable.prototype.forGlyph=function(id){
if(id in this.metrics){
return this.metrics[id];
}
return {
advance: this.metrics[this.metrics.length - 1].advance,
lsb: this.leftSideBearings[id - this.metrics.length]
};};
return HmtxTable;
})(Table);
var __slice=[].slice;
var GlyfTable=(function(_super){
__extends(GlyfTable, _super);
function GlyfTable(){
return GlyfTable.__super__.constructor.apply(this, arguments);
}
GlyfTable.prototype.tag="glyf";
GlyfTable.prototype.parse=function(){
return (this.cache={});
};
GlyfTable.prototype.glyphFor=function(id){
var data,
index,
length,
loca,
numberOfContours,
raw,
xMax,
xMin,
yMax,
yMin;
if(id in this.cache){
return this.cache[id];
}
loca=this.file.loca;
data=this.file.contents;
index=loca.indexOf(id);
length=loca.lengthOf(id);
if(length===0){
return (this.cache[id]=null);
}
data.pos=this.offset + index;
raw=new Data(data.read(length));
numberOfContours=raw.readShort();
xMin=raw.readShort();
yMin=raw.readShort();
xMax=raw.readShort();
yMax=raw.readShort();
if(numberOfContours===-1){
this.cache[id]=new CompoundGlyph(raw, xMin, yMin, xMax, yMax);
}else{
this.cache[id]=new SimpleGlyph(
raw,
numberOfContours,
xMin,
yMin,
xMax,
yMax
);
}
return this.cache[id];
};
GlyfTable.prototype.encode=function(glyphs, mapping, old2new){
var glyph, id, offsets, table, _i, _len;
table=[];
offsets=[];
for (_i=0, _len=mapping.length; _i < _len; _i++){
id=mapping[_i];
glyph=glyphs[id];
offsets.push(table.length);
if(glyph){
table=table.concat(glyph.encode(old2new));
}}
offsets.push(table.length);
return {
table: table,
offsets: offsets
};};
return GlyfTable;
})(Table);
var SimpleGlyph=(function(){
function SimpleGlyph(raw, numberOfContours, xMin, yMin, xMax, yMax){
this.raw=raw;
this.numberOfContours=numberOfContours;
this.xMin=xMin;
this.yMin=yMin;
this.xMax=xMax;
this.yMax=yMax;
this.compound=false;
}
SimpleGlyph.prototype.encode=function(){
return this.raw.data;
};
return SimpleGlyph;
})();
var CompoundGlyph=(function(){
var ARG_1_AND_2_ARE_WORDS,
MORE_COMPONENTS,
WE_HAVE_AN_X_AND_Y_SCALE,
WE_HAVE_A_SCALE,
WE_HAVE_A_TWO_BY_TWO;
ARG_1_AND_2_ARE_WORDS=0x0001;
WE_HAVE_A_SCALE=0x0008;
MORE_COMPONENTS=0x0020;
WE_HAVE_AN_X_AND_Y_SCALE=0x0040;
WE_HAVE_A_TWO_BY_TWO=0x0080;
function CompoundGlyph(raw, xMin, yMin, xMax, yMax){
var data, flags;
this.raw=raw;
this.xMin=xMin;
this.yMin=yMin;
this.xMax=xMax;
this.yMax=yMax;
this.compound=true;
this.glyphIDs=[];
this.glyphOffsets=[];
data=this.raw;
while (true){
flags=data.readShort();
this.glyphOffsets.push(data.pos);
this.glyphIDs.push(data.readShort());
if(!(flags & MORE_COMPONENTS)){
break;
}
if(flags & ARG_1_AND_2_ARE_WORDS){
data.pos +=4;
}else{
data.pos +=2;
}
if(flags & WE_HAVE_A_TWO_BY_TWO){
data.pos +=8;
}else if(flags & WE_HAVE_AN_X_AND_Y_SCALE){
data.pos +=4;
}else if(flags & WE_HAVE_A_SCALE){
data.pos +=2;
}}
}
CompoundGlyph.prototype.encode=function(){
var i, result, _len, _ref;
result=new Data(__slice.call(this.raw.data));
_ref=this.glyphIDs;
for (i=0, _len=_ref.length; i < _len; ++i){
result.pos=this.glyphOffsets[i];
}
return result.data;
};
return CompoundGlyph;
})();
var LocaTable=(function(_super){
__extends(LocaTable, _super);
function LocaTable(){
return LocaTable.__super__.constructor.apply(this, arguments);
}
LocaTable.prototype.tag="loca";
LocaTable.prototype.parse=function(data){
var format, i;
data.pos=this.offset;
format=this.file.head.indexToLocFormat;
if(format===0){
return (this.offsets=function(){
var _ref, _results;
_results=[];
for (i=0, _ref=this.length; i < _ref; i +=2){
_results.push(data.readUInt16() * 2);
}
return _results;
}.call(this));
}else{
return (this.offsets=function(){
var _ref, _results;
_results=[];
for (i=0, _ref=this.length; i < _ref; i +=4){
_results.push(data.readUInt32());
}
return _results;
}.call(this));
}};
LocaTable.prototype.indexOf=function(id){
return this.offsets[id];
};
LocaTable.prototype.lengthOf=function(id){
return this.offsets[id + 1] - this.offsets[id];
};
LocaTable.prototype.encode=function(offsets, activeGlyphs){
var LocaTable=new Uint32Array(this.offsets.length);
var glyfPtr=0;
var listGlyf=0;
for (var k=0; k < LocaTable.length; ++k){
LocaTable[k]=glyfPtr;
if(listGlyf < activeGlyphs.length&&activeGlyphs[listGlyf]==k){
++listGlyf;
LocaTable[k]=glyfPtr;
var start=this.offsets[k];
var len=this.offsets[k + 1] - start;
if(len > 0){
glyfPtr +=len;
}}
}
var newLocaTable=new Array(LocaTable.length * 4);
for (var j=0; j < LocaTable.length; ++j){
newLocaTable[4 * j + 3]=LocaTable[j] & 0x000000ff;
newLocaTable[4 * j + 2]=(LocaTable[j] & 0x0000ff00) >> 8;
newLocaTable[4 * j + 1]=(LocaTable[j] & 0x00ff0000) >> 16;
newLocaTable[4 * j]=(LocaTable[j] & 0xff000000) >> 24;
}
return newLocaTable;
};
return LocaTable;
})(Table);
var invert=function(object){
var key, ret, val;
ret={};
for (key in object){
val=object[key];
ret[val]=key;
}
return ret;
};
var Subset=(function(){
function Subset(font){
this.font=font;
this.subset={};
this.unicodes={};
this.next=33;
}
Subset.prototype.generateCmap=function(){
var mapping, roman, unicode, unicodeCmap, _ref;
unicodeCmap=this.font.cmap.tables[0].codeMap;
mapping={};
_ref=this.subset;
for (roman in _ref){
unicode=_ref[roman];
mapping[roman]=unicodeCmap[unicode];
}
return mapping;
};
Subset.prototype.glyphsFor=function(glyphIDs){
var additionalIDs, glyph, glyphs, id, _i, _len, _ref;
glyphs={};
for (_i=0, _len=glyphIDs.length; _i < _len; _i++){
id=glyphIDs[_i];
glyphs[id]=this.font.glyf.glyphFor(id);
}
additionalIDs=[];
for (id in glyphs){
glyph=glyphs[id];
if(glyph!=null ? glyph.compound:void 0){
additionalIDs.push.apply(additionalIDs, glyph.glyphIDs);
}}
if(additionalIDs.length > 0){
_ref=this.glyphsFor(additionalIDs);
for (id in _ref){
glyph=_ref[id];
glyphs[id]=glyph;
}}
return glyphs;
};
Subset.prototype.encode=function(glyID, indexToLocFormat){
var cmap,
code,
glyf,
glyphs,
id,
ids,
loca,
new2old,
newIDs,
nextGlyphID,
old2new,
oldID,
oldIDs,
tables,
_ref;
cmap=CmapTable.encode(this.generateCmap(), "unicode");
glyphs=this.glyphsFor(glyID);
old2new={
0: 0
};
_ref=cmap.charMap;
for (code in _ref){
ids=_ref[code];
old2new[ids.old]=ids["new"];
}
nextGlyphID=cmap.maxGlyphID;
for (oldID in glyphs){
if(!(oldID in old2new)){
old2new[oldID]=nextGlyphID++;
}}
new2old=invert(old2new);
newIDs=Object.keys(new2old).sort(function(a, b){
return a - b;
});
oldIDs=(function(){
var _i, _len, _results;
_results=[];
for (_i=0, _len=newIDs.length; _i < _len; _i++){
id=newIDs[_i];
_results.push(new2old[id]);
}
return _results;
})();
glyf=this.font.glyf.encode(glyphs, oldIDs, old2new);
loca=this.font.loca.encode(glyf.offsets, oldIDs);
tables={
cmap: this.font.cmap.raw(),
glyf: glyf.table,
loca: loca,
hmtx: this.font.hmtx.raw(),
hhea: this.font.hhea.raw(),
maxp: this.font.maxp.raw(),
post: this.font.post.raw(),
name: this.font.name.raw(),
head: this.font.head.encode(indexToLocFormat)
};
if(this.font.os2.exists){
tables["OS/2"]=this.font.os2.raw();
}
return this.font.directory.encode(tables);
};
return Subset;
})();
jsPDF.API.PDFObject=(function(){
var pad;
function PDFObject(){}
pad=function(str, length){
return (Array(length + 1).join("0") + str).slice(-length);
};
PDFObject.convert=function(object){
var e, items, key, out, val;
if(Array.isArray(object)){
items=(function(){
var _i, _len, _results;
_results=[];
for (_i=0, _len=object.length; _i < _len; _i++){
e=object[_i];
_results.push(PDFObject.convert(e));
}
return _results;
})().join(" ");
return "[" + items + "]";
}else if(typeof object==="string"){
return "/" + object;
}else if(object!=null ? object.isString:void 0){
return "(" + object + ")";
}else if(object instanceof Date){
return (
"(D:" +
pad(object.getUTCFullYear(), 4) +
pad(object.getUTCMonth(), 2) +
pad(object.getUTCDate(), 2) +
pad(object.getUTCHours(), 2) +
pad(object.getUTCMinutes(), 2) +
pad(object.getUTCSeconds(), 2) +
"Z)"
);
}else if({}.toString.call(object)==="[object Object]"){
out=["<<"];
for (key in object){
val=object[key];
out.push("/" + key + " " + PDFObject.convert(val));
}
out.push(">>");
return out.join("\n");
}else{
return "" + object;
}};
return PDFObject;
})();
(function(jsPDF, callback){
jsPDF.API.adler32cs=callback();
})(jsPDF, function(){
var _hasArrayBuffer =
typeof ArrayBuffer==="function"&&typeof Uint8Array==="function";
var _Buffer=null,
_isBuffer=(function(){
if(!_hasArrayBuffer)
return function _isBuffer(){
return false;
};
try {
var buffer={};
if(typeof buffer.Buffer==="function") _Buffer=buffer.Buffer;
} catch (error){}
return function _isBuffer(value){
return (
value instanceof ArrayBuffer ||
(_Buffer!==null&&value instanceof _Buffer)
);
};})();
var _utf8ToBinary=(function(){
if(_Buffer!==null){
return function _utf8ToBinary(utf8String){
return new _Buffer(utf8String, "utf8").toString("binary");
};}else{
return function _utf8ToBinary(utf8String){
return unescape(encodeURIComponent(utf8String));
};}})();
var MOD=65521;
var _update=function _update(checksum, binaryString){
var a=checksum & 0xffff,
b=checksum >>> 16;
for (var i=0, length=binaryString.length; i < length; i++){
a=(a + (binaryString.charCodeAt(i) & 0xff)) % MOD;
b=(b + a) % MOD;
}
return ((b << 16) | a) >>> 0;
};
var _updateUint8Array=function _updateUint8Array(checksum, uint8Array){
var a=checksum & 0xffff,
b=checksum >>> 16;
for (var i=0, length=uint8Array.length; i < length; i++){
a=(a + uint8Array[i]) % MOD;
b=(b + a) % MOD;
}
return ((b << 16) | a) >>> 0;
};
var exports={};
var Adler32=(exports.Adler32=(function(){
var ctor=function Adler32(checksum){
if(!(this instanceof ctor)){
throw new TypeError("Constructor cannot called be as a function.");
}
if(!isFinite((checksum=checksum===null ? 1:+checksum))){
throw new Error("First arguments needs to be a finite number.");
}
this.checksum=checksum >>> 0;
};
var proto=(ctor.prototype={});
proto.constructor=ctor;
ctor.from=(function(from){
from.prototype=proto;
return from;
})(function from(binaryString){
if(!(this instanceof ctor)){
throw new TypeError("Constructor cannot called be as a function.");
}
if(binaryString===null)
throw new Error("First argument needs to be a string.");
this.checksum=_update(1, binaryString.toString());
});
ctor.fromUtf8=(function(fromUtf8){
fromUtf8.prototype=proto;
return fromUtf8;
})(function fromUtf8(utf8String){
if(!(this instanceof ctor)){
throw new TypeError("Constructor cannot called be as a function.");
}
if(utf8String===null)
throw new Error("First argument needs to be a string.");
var binaryString=_utf8ToBinary(utf8String.toString());
this.checksum=_update(1, binaryString);
});
if(_hasArrayBuffer){
ctor.fromBuffer=(function(fromBuffer){
fromBuffer.prototype=proto;
return fromBuffer;
})(function fromBuffer(buffer){
if(!(this instanceof ctor)){
throw new TypeError("Constructor cannot called be as a function.");
}
if(!_isBuffer(buffer))
throw new Error("First argument needs to be ArrayBuffer.");
var array=new Uint8Array(buffer);
return (this.checksum=_updateUint8Array(1, array));
});
}
proto.update=function update(binaryString){
if(binaryString===null)
throw new Error("First argument needs to be a string.");
binaryString=binaryString.toString();
return (this.checksum=_update(this.checksum, binaryString));
};
proto.updateUtf8=function updateUtf8(utf8String){
if(utf8String===null)
throw new Error("First argument needs to be a string.");
var binaryString=_utf8ToBinary(utf8String.toString());
return (this.checksum=_update(this.checksum, binaryString));
};
if(_hasArrayBuffer){
proto.updateBuffer=function updateBuffer(buffer){
if(!_isBuffer(buffer))
throw new Error("First argument needs to be ArrayBuffer.");
var array=new Uint8Array(buffer);
return (this.checksum=_updateUint8Array(this.checksum, array));
};}
proto.clone=function clone(){
return new Adler32(this.checksum);
};
return ctor;
})());
exports.from=function from(binaryString){
if(binaryString===null)
throw new Error("First argument needs to be a string.");
return _update(1, binaryString.toString());
};
exports.fromUtf8=function fromUtf8(utf8String){
if(utf8String===null)
throw new Error("First argument needs to be a string.");
var binaryString=_utf8ToBinary(utf8String.toString());
return _update(1, binaryString);
};
if(_hasArrayBuffer){
exports.fromBuffer=function fromBuffer(buffer){
if(!_isBuffer(buffer))
throw new Error("First argument need to be ArrayBuffer.");
var array=new Uint8Array(buffer);
return _updateUint8Array(1, array);
};}
return exports;
});
exports.AcroForm=AcroForm;
exports.AcroFormAppearance=AcroFormAppearance;
exports.AcroFormButton=AcroFormButton;
exports.AcroFormCheckBox=AcroFormCheckBox;
exports.AcroFormChoiceField=AcroFormChoiceField;
exports.AcroFormComboBox=AcroFormComboBox;
exports.AcroFormEditBox=AcroFormEditBox;
exports.AcroFormListBox=AcroFormListBox;
exports.AcroFormPasswordField=AcroFormPasswordField;
exports.AcroFormPushButton=AcroFormPushButton;
exports.AcroFormRadioButton=AcroFormRadioButton;
exports.AcroFormTextField=AcroFormTextField;
exports.GState=GState;
exports.ShadingPattern=ShadingPattern;
exports.TilingPattern=TilingPattern;
exports.default=jsPDF;
exports.jsPDF=jsPDF;
Object.defineProperty(exports, '__esModule', { value: true });
})));