Blame view

sources/apps/files_svgedit/js/jsPDF/jspdf.min.js 9.09 KB
42e4f8d60   Kload   add all apps
1
2
3
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
59
60
61
62
63
64
65
66
  /*
  
   ====================================================================
   base64 encoder
   MIT, GPL
  
   version: 1109.2015
   discuss at: http://phpjs.org/functions/base64_encode
   +   original by: Tyler Akins (http://rumkin.com)
   +   improved by: Bayron Guevara
   +   improved by: Thunder.m
   +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
   +   bugfixed by: Pellentesque Malesuada
   +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
   +   improved by: Rafal Kukawski (http://kukawski.pl)
   ====================================================================
  
   ==================================================================== 
   jsPDF
   Copyright (c) 2010 James Hall, https://github.com/MrRio/jsPDF
   Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
  
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
   "Software"), to deal in the Software without restriction, including
   without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense, and/or sell copies of the Software, and to
   permit persons to whom the Software is furnished to do so, subject to
   the following conditions:
  
   The above copyright notice and this permission notice shall be
   included in all copies or substantial portions of the Software.
  
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   ====================================================================
  */
  var jsPDF=function(k,s,x){k="undefined"===typeof k?"p":k.toString().toLowerCase();"undefined"===typeof s&&(s="mm");"undefined"===typeof x&&(x="a4");var H=x.toString().toLowerCase(),I=[],y=0,J={a3:[841.89,1190.55],a4:[595.28,841.89],a5:[420.94,595.28],letter:[612,792],legal:[612,1008]},K="0 g",z=0,m=2,E=!1,L=[],A=[],v=[],F={},M="helvetica",N="normal",G,h,B,c,o={},O=16,K="0 g",P=0,Q=0,e=function(a){return a.toFixed(2)},g=function(a){return a.toFixed(3)},C=function(a){var b=a.toFixed(0);return 10>a?
  "0"+b:b},b=function(a){E?L[z].push(a):(I.push(a),y+=a.length+1)},D=function(){m++;A[m]=y;b(m+" 0 obj")},j=function(a,b,d,c){var e="F"+(v.length+1).toString(10);v.push({key:e,number:m,name:a,fontName:b,type:d});F[b]===c&&(F[b]={});F[b][d]=e},T=function(){z++;E=!0;L[z]=[];b(e(0.200025*c)+" w");b("0 G");0!==P&&b(P.toString(10)+" J");0!==Q&&b(Q.toString(10)+" j")},R=function(a,b,d){var c;try{c=F[a][b]}catch(e){c=d}if(!c)throw Error("Unable to look up font label for font '"+a+"', '"+b+"'. Refer to getFontList() for available fonts.");
  return c},S=function(){E=!1;I=[];A=[];b("%PDF-1.3");var a=B*c,f=h*c;for(n=1;n<=z;n++){D();b("<</Type /Page");b("/Parent 1 0 R");b("/Resources 2 0 R");b("/Contents "+(m+1)+" 0 R>>");b("endobj");p=L[n].join("
  ");D();b("<</Length "+p.length+">>");var d=p;b("stream");b(d);b("endstream");b("endobj")}A[1]=y;b("1 0 obj");b("<</Type /Pages");d="/Kids [";for(i=0;i<z;i++)d+=3+2*i+" 0 R ";b(d+"]");b("/Count "+z);b("/MediaBox [0 0 "+e(a)+" "+e(f)+"]");b(">>");b("endobj");a=0;for(f=v.length;a<f;a++)d=v[a],D(),
  d.number=m,b("<</BaseFont/"+d.name+"/Type/Font"),b("/Subtype/Type1>>"),b("endobj");A[2]=y;b("2 0 obj");b("<<");b("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");b("/Font <<");for(a=0;a<v.length;a++)b("/"+v[a].key+" "+v[a].number+" 0 R");b(">>");b("/XObject <<");b(">>");b(">>");b("endobj");D();b("<<");b("/Producer (jsPDF 20120220)");void 0!=o.title&&b("/Title ("+w(o.title)+")");void 0!=o.subject&&b("/Subject ("+w(o.subject)+")");void 0!=o.author&&b("/Author ("+w(o.author)+")");void 0!=o.keywords&&
  b("/Keywords ("+w(o.keywords)+")");void 0!=o.creator&&b("/Creator ("+w(o.creator)+")");a=new Date;b("/CreationDate (D:"+[a.getFullYear(),C(a.getMonth()+1),C(a.getDate()),C(a.getHours()),C(a.getMinutes()),C(a.getSeconds())].join("")+")");b(">>");b("endobj");D();b("<<");b("/Type /Catalog");b("/Pages 1 0 R");b("/OpenAction [3 0 R /FitH null]");b("/PageLayout /OneColumn");b(">>");b("endobj");a=y;b("xref");b("0 "+(m+1));b("0000000000 65535 f ");for(f=1;f<=m;f++)d=A[f].toFixed(0),d=10>d.length?Array(11-
  d.length).join("0")+d:d,b(d+" 00000 n ");b("trailer");b("<<");b("/Size "+(m+1));b("/Root "+m+" 0 R");b("/Info "+(m-1)+" 0 R");b(">>");b("startxref");b(a);b("%%EOF");E=!0;return I.join("
  ")},w=function(a){return a.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},l={addPage:function(){T();return l},text:function(a,f,d){if("string"===typeof d)d=w(d);else{for(var d=d.concat(),t=d.length-1;-1!==t;t--)d[t]=w(d[t]);d=d.join(") Tj
  T* (")}b("BT
  /"+G+" "+O+" Tf
  "+O+" TL
  "+K+"
  "+e(a*c)+
  " "+e((h-f)*c)+" Td
  ("+d+") Tj
  ET");return l},line:function(a,f,d,t){b(e(a*c)+" "+e((h-f)*c)+" m "+e(d*c)+" "+e((h-t)*c)+" l S");return l},lines:function(a,f,d,e){e=void 0===e?[1,1]:e;b(g(a*c)+" "+g((h-f)*c)+" m ");for(var q=e[0],e=e[1],r=0,k=d.length,j,m,o,s,u=f;r<k;r++)f=d[r],2===f.length?(a=f[0]*q+a,u=f[1]*e+u,b(g(a*c)+" "+g((h-u)*c)+" l")):(j=f[0]*q+a,m=f[1]*e+u,o=f[2]*q+a,s=f[3]*e+u,a=f[4]*q+a,u=f[5]*e+u,b(g(j*c)+" "+g((h-m)*c)+" "+g(o*c)+" "+g((h-s)*c)+" "+g(a*c)+" "+g((h-u)*c)+" c"));b("S");
  return l},rect:function(a,f,d,t,g){var r="S";if("F"===g)r="f";else if("FD"===g||"DF"===g)r="B";b([e(a*c),e((h-f)*c),e(d*c),e(-t*c),"re",r].join(" "));return l},ellipse:function(a,f,d,g,q){var r="S";if("F"===q)r="f";else if("FD"===q||"DF"===q)r="B";var q=4/3*(Math.SQRT2-1)*d,j=4/3*(Math.SQRT2-1)*g;b([e((a+d)*c),e((h-f)*c),"m",e((a+d)*c),e((h-(f-j))*c),e((a+q)*c),e((h-(f-g))*c),e(a*c),e((h-(f-g))*c),"c"].join(" "));b([e((a-q)*c),e((h-(f-g))*c),e((a-d)*c),e((h-(f-j))*c),e((a-d)*c),e((h-f)*c),"c"].join(" "));
  b([e((a-d)*c),e((h-(f+j))*c),e((a-q)*c),e((h-(f+g))*c),e(a*c),e((h-(f+g))*c),"c"].join(" "));b([e((a+q)*c),e((h-(f+g))*c),e((a+d)*c),e((h-(f+j))*c),e((a+d)*c),e((h-f)*c),"c",r].join(" "));return l},circle:function(a,b,d,c){return this.ellipse(a,b,d,d,c)},setProperties:function(a){o=a;return l},addImage:function(){return l},setFontSize:function(a){O=a;return l},setFont:function(a){a=a.toLowerCase();G=R(a,N);M=a;return l},setFontType:function(a){a=a.toLowerCase();G=R(M,a);N=a;return l},getFontList:function(){return{HELVETICA:["normal",
  "bold","italic","bolditalic"],TIMES:["normal","bold","italic","bolditalic"],COURIER:["normal","bold","italic","bolditalic"]}},setLineWidth:function(a){b((a*c).toFixed(2)+" w");return l},setDrawColor:function(a,c,d){a=0===a&&0===c&&0===d||"undefined"===typeof c?g(a/255)+" G":[g(a/255),g(c/255),g(d/255),"RG"].join(" ");b(a);return l},setFillColor:function(a,c,d){a=0===a&&0===c&&0===d||"undefined"===typeof c?g(a/255)+" g":[g(a/255),g(c/255),g(d/255),"rg"].join(" ");b(a);return l},setTextColor:function(a,
  b,c){K=0===a&&0===b&&0===c||"undefined"===typeof b?g(a/255)+" g":[g(a/255),g(b/255),g(c/255),"rg"].join(" ");return l},CapJoinStyles:{"0":0,butt:0,but:0,bevel:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,milter:2},setLineCap:function(a,c){var d=this.CapJoinStyles[a];if(d===c)throw Error("Line cap style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");P=d;b(d.toString(10)+" J")},setLineJoin:function(a,c){var d=this.CapJoinStyles[a];if(d===
  c)throw Error("Line join style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");Q=d;b(d.toString(10)+" j")},base64encode:function(a){if("function"===typeof btoa)return btoa(a);var b="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,+,/,=".split(","),c,e,g,h,j=0,l=0,k="",k=[];do c=a.charCodeAt(j++),e=a.charCodeAt(j++),g=a.charCodeAt(j++),h=c<<16|e<<8|g,c=h>>18&63,e=h>>12&63,g=h>>6&63,h&=
  63,k[l++]=b[c]+b[e]+b[g]+b[h];while(j<a.length);k=k.join("");a=a.length%3;return(a?k.slice(0,a-3):k)+"===".slice(a||3)},output:function(a){switch(a){case void 0:return S();case "datauristring":case "datauristrlng":return"data:application/pdf;base64,"+this.base64encode(S());case "datauri":case "dataurl":document.location.href="data:application/pdf;base64,"+this.base64encode(S());break;default:throw Error('Output type "'+a+'" is not supported.');}}};if("pt"==s)c=1;else if("mm"==s)c=72/25.4;else if("cm"==
  s)c=72/2.54;else if("in"==s)c=72;else throw"Invalid unit: "+s;if(H in J)h=J[H][1]/c,B=J[H][0]/c;else try{h=x[1],B=x[0]}catch(U){throw"Invalid format: "+x;}if("p"===k||"portrait"===k)k="p";else if("l"===k||"landscape"===k)k="l",k=B,B=h,h=k;else throw"Invalid orientation: "+k;j("Helvetica","helvetica","normal");j("Helvetica-Bold","helvetica","bold");j("Helvetica-Oblique","helvetica","italic");j("Helvetica-BoldOblique","helvetica","bolditalic");j("Courier","courier","normal");j("Courier-Bold","courier",
  "bold");j("Courier-Oblique","courier","italic");j("Courier-BoldOblique","courier","bolditalic");j("Times-Roman","times","normal");j("Times-Bold","times","bold");j("Times-Italic","times","italic");j("Times-BoldItalic","times","bolditalic");G=R(M,N);T();return l};