6 lines
6.3 KiB
JavaScript
6 lines
6.3 KiB
JavaScript
|
/**
|
||
|
* html2pdf.js v0.8.2
|
||
|
* Copyright (c) 2017 Erik Koopmans
|
||
|
* Released under the MIT License.
|
||
|
*/
|
||
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("es6-promise/auto"),require("jspdf"),require("html2canvas")):"function"==typeof define&&define.amd?define(["es6-promise/auto","jspdf","html2canvas"],t):e.html2pdf=t(null,e.jsPDF,e.html2canvas)}(this,function(e,t,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n;var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getPageSize=function(e,t,n){if("object"===(void 0===e?"undefined":a(e))){var i=e;e=i.orientation,t=i.unit||t,n=i.format||n}t=t||"mm",n=n||"a4",e=(""+(e||"P")).toLowerCase();var r=(""+n).toLowerCase(),o={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]};switch(t){case"pt":l=1;break;case"mm":l=72/25.4;break;case"cm":l=72/2.54;break;case"in":l=72;break;case"px":l=.75;break;case"pc":case"em":l=12;break;case"ex":var l=6;break;default:throw"Invalid unit: "+t}if(o.hasOwnProperty(r))var c=o[r][1]/l,d=o[r][0]/l;else try{var c=n[1],d=n[0]}catch(e){throw new Error("Invalid format: "+n)}if("p"===e||"portrait"===e){if(e="p",d>c){s=d;d=c,c=s}}else{if("l"!==e&&"landscape"!==e)throw"Invalid orientation: "+e;if(e="l",c>d){var s=d;d=c,c=s}}return{width:d,height:c,unit:t,k:l}};var i=function(e){var t=void 0===e?"undefined":a(e);return"undefined"===t?"undefined":"string"===t||e instanceof String?"string":"number"===t||e instanceof Number?"number":"function"===t||e instanceof Function?"function":e&&e.constructor===Array?"array":e&&1===e.nodeType?"element":"object"===t?"object":"unknown"},r=function(e,t){var n=document.createElement(e);if(t.className&&(n.className=t.className),t.innerHTML){n.innerHTML=t.innerHTML;for(var a=n.getElementsByTagName("script"),i=a.length;i-- >0;null)a[i].parentNode.removeChild(a[i])}for(var r in t.style)n.style[r]=t.style[r];return n},o=function(e,t){var n={};for(var a in e)n[a]=72*e[a]/96/t;return n},l=function e(a,r){r="object"===i(r)?r:{};var a=e.parseInput(a,r),l=t.getPageSize(r.jsPDF);l.inner={width:l.width-r.margin[1]-r.margin[3],height:l.height-r.margin[0]-r.margin[2]},l.inner.ratio=l.inner.height/l.inner.width;var c=e.makeContainer(a,l),d=c.parentElement;if(r.enableLinks){r.links=[];var s=c.querySelectorAll("a"),m=o(c.getBoundingClientRect(),l.k);Array.prototype.forEach.call(s,function(e){for(var t=e.getClientRects(),n=0;n<t.length;n++){var a=o(t[n],l.k);a.left-=m.left,a.top-=m.top,r.links.push({el:e,clientRect:a})}})}var h=r.html2canvas.onrendered||function(){};delete r.html2canvas.onrendered;n(c,r.html2canvas).then(function(t){h(t),document.body.removeChild(d),e.makePDF(t,l,r)})};return l.parseInput=function(e,t){switch(t.jsPDF=t.jsPDF||{},t.html2canvas=t.html2canvas||{},t.filename=t.filename&&"string"===i(t.filename)?t.filename:"file.pdf",t.enableLinks=!t.hasOwnProperty("enableLinks")||t.enableLinks,t.image=t.image||{},t.image.type=t.image.type||"jpeg",t.image.quality=t.image.quality||.95,i(t.margin)){case"undefined":t.margin=0;case"number":t.margin=[t.margin,t.margin,t.margin,t.margin];break;case"array":if(2===t.margin.length&&(t.margin=[t.margin[0],t.margin[1],t.margin[0],t.margin[1]]),4===t.margin.length)break;default:throw"Invalid margin a
|