jspdf-autotable
Advanced tools
Comparing version 2.0.27 to 2.0.28
/** | ||
* jsPDF AutoTable plugin v2.0.27 | ||
* jsPDF AutoTable plugin v2.0.28 | ||
* Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable | ||
@@ -10,2 +10,2 @@ * | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jspdf")):"function"==typeof define&&define.amd?define(["jspdf"],e):e(t.jsPDF)}(this,function(t){"use strict";function e(){return{theme:"striped",styles:{},headerStyles:{},bodyStyles:{},alternateRowStyles:{},columnStyles:{},startY:!1,margin:40,pageBreak:"auto",tableWidth:"auto",createdHeaderCell:function(t,e){},createdCell:function(t,e){},drawHeaderRow:function(t,e){},drawRow:function(t,e){},drawHeaderCell:function(t,e){},drawCell:function(t,e){},beforePageContent:function(t){},afterPageContent:function(t){}}}function n(){return{cellPadding:5,fontSize:10,font:"helvetica",lineColor:200,lineWidth:.1,fontStyle:"normal",overflow:"ellipsize",fillColor:255,textColor:20,halign:"left",valign:"top",fillStyle:"F",rowHeight:20,columnWidth:"auto"}}function o(t,e,n){t&&"object"===("undefined"==typeof t?"undefined":g(t))||console.error("The headers should be an object or array, is: "+("undefined"==typeof t?"undefined":g(t))),e&&"object"===("undefined"==typeof e?"undefined":g(e))||console.error("The data should be an object or array, is: "+("undefined"==typeof e?"undefined":g(e))),n&&"object"!==("undefined"==typeof n?"undefined":g(n))&&console.error("The data should be an object or array, is: "+("undefined"==typeof e?"undefined":g(e))),Array.prototype.forEach||console.error("The current browser does not support Array.prototype.forEach which is required for jsPDF-AutoTable. You can try polyfilling it by including this script https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Polyfill")}function i(t,e){T=new b;var n=/\r\n|\r|\n/g,o=new m(t);o.index=-1;var i=C.styles([W[R.theme].table,W[R.theme].header]);o.styles=Object.assign({},i,R.styles,R.headerStyles),t.forEach(function(t,e){"object"===("undefined"==typeof t?"undefined":g(t))&&(e="undefined"!=typeof t.dataKey?t.dataKey:t.key),"undefined"!=typeof t.width&&console.error("Use of deprecated option: column.width, use column.styles.columnWidth instead.");var i=new x(e);i.styles=R.columnStyles[i.dataKey]||{},T.columns.push(i);var r=new v;r.raw="object"===("undefined"==typeof t?"undefined":g(t))?t.title:t,r.styles=Object.assign({},o.styles),r.text=""+r.raw,r.contentWidth=2*r.styles.cellPadding+y(r.text,r.styles),r.text=r.text.split(n),o.cells[e]=r,R.createdHeaderCell(r,{column:i,row:o,settings:R})}),T.headerRow=o,e.forEach(function(t,e){var o=new m(t),i=e%2===0,r=C.styles([W[R.theme].table,i?W[R.theme].alternateRow:{}]),l=Object.assign({},R.styles,R.bodyStyles,i?R.alternateRowStyles:{});o.styles=Object.assign({},r,l),o.index=e,T.columns.forEach(function(e){var i=new v;i.raw=t[e.dataKey],i.styles=Object.assign({},o.styles,e.styles),i.text="undefined"!=typeof i.raw?""+i.raw:"",o.cells[e.dataKey]=i,R.createdCell(i,c({column:e,row:o})),i.contentWidth=2*i.styles.cellPadding+y(i.text,i.styles),i.text=i.text.split(n)}),T.rows.push(o)})}function r(t,e){var n=0;T.columns.forEach(function(t){t.contentWidth=T.headerRow.cells[t.dataKey].contentWidth,T.rows.forEach(function(e){var n=e.cells[t.dataKey].contentWidth;n>t.contentWidth&&(t.contentWidth=n)}),t.width=t.contentWidth,n+=t.contentWidth}),T.contentWidth=n;var o=e-R.margin.left-R.margin.right,i=o;"number"==typeof R.tableWidth?i=R.tableWidth:"wrap"===R.tableWidth&&(i=T.contentWidth),T.width=i<o?i:o;var r=[],a=0,s=T.width/T.columns.length,d=0;T.columns.forEach(function(t){var e=C.styles([W[R.theme].table,R.styles,t.styles]);"wrap"===e.columnWidth?t.width=t.contentWidth:"number"==typeof e.columnWidth?t.width=e.columnWidth:("auto"===e.columnWidth,t.contentWidth<=s&&T.contentWidth>T.width?t.width=t.contentWidth:(r.push(t),a+=t.contentWidth,t.width=0)),d+=t.width}),l(r,d,a,s),T.height=0;var h=T.rows.concat(T.headerRow);h.forEach(function(e,n){var o=0;T.columns.forEach(function(n){var i=e.cells[n.dataKey];f(i.styles);var r=n.width-2*i.styles.cellPadding;if("linebreak"===i.styles.overflow)try{i.text=t.splitTextToSize(i.text,r+1,{fontSize:i.styles.fontSize})}catch(e){if(!(e instanceof TypeError&&Array.isArray(i.text)))throw e;i.text=t.splitTextToSize(i.text.join(" "),r+1,{fontSize:i.styles.fontSize})}else"ellipsize"===i.styles.overflow?i.text=u(i.text,r,i.styles):"visible"===i.styles.overflow||("hidden"===i.styles.overflow?i.text=u(i.text,r,i.styles,""):"function"==typeof i.styles.overflow?i.text=i.styles.overflow(i.text,r):console.error("Unrecognized overflow type: "+i.styles.overflow));var l=Array.isArray(i.text)?i.text.length-1:0;l>o&&(o=l)}),e.heightStyle=e.styles.rowHeight,e.height=e.heightStyle+o*e.styles.fontSize*S,T.height+=e.height})}function l(t,e,n,o){for(var i=T.width-e-n,r=0;r<t.length;r++){var a=t[r],s=a.contentWidth/n,d=a.contentWidth+i*s<o;if(i<0&&d){t.splice(r,1),n-=a.contentWidth,a.width=o,e+=a.width,l(t,e,n,o);break}a.width=a.contentWidth+i*s}}function a(t){R.afterPageContent(c()),t(),T.pageCount++,j={x:R.margin.left,y:R.margin.top},R.beforePageContent(c()),R.drawHeaderRow(T.headerRow,c({row:T.headerRow}))!==!1&&h(T.headerRow,R.drawHeaderCell)}function s(t){var e=j.y+t+R.margin.bottom;return e>=A.height}function d(t){T.rows.forEach(function(e,n){if(s(e.height)){a(t)}e.y=j.y,R.drawRow(e,c({row:e}))!==!1&&h(e,R.drawCell)})}function h(t,e){j.x=R.margin.left;for(var n=0;n<T.columns.length;n++){var o=T.columns[n],i=t.cells[o.dataKey];if(i){f(i.styles),i.x=j.x,i.y=j.y,i.height=t.height,i.width=o.width,"top"===i.styles.valign?i.textPos.y=j.y+i.styles.cellPadding:"bottom"===i.styles.valign?i.textPos.y=j.y+t.height-i.styles.cellPadding:i.textPos.y=j.y+t.height/2,"right"===i.styles.halign?i.textPos.x=i.x+i.width-i.styles.cellPadding:"center"===i.styles.halign?i.textPos.x=i.x+i.width/2:i.textPos.x=i.x+i.styles.cellPadding;var r=c({column:o,row:t});e(i,r)!==!1&&(P.rect(i.x,i.y,i.width,i.height,i.styles.fillStyle),P.autoTableText(i.text,i.textPos.x,i.textPos.y,{halign:i.styles.halign,valign:i.styles.valign})),j.x+=i.width}}j.y+=t.height}function f(t){Object.keys(z).forEach(function(e){var n=t[e],o=z[e];"undefined"!=typeof n&&(n.constructor===Array?o.apply(this,n):o(n))})}function c(t){return Object.assign({pageCount:T.pageCount,settings:R,table:T,cursor:j},t||{})}function y(t,e){f(e);var n=P.getStringUnitWidth(t);return n*e.fontSize}function u(t,e,n,o){if(o="undefined"!=typeof o?o:"...",Array.isArray(t))return t.forEach(function(i,r){t[r]=u(i,e,n,o)}),t;if(e>=y(t,n))return t;for(;e<y(t+o,n)&&!(t.length<2);)t=t.substring(0,t.length-1);return t.trim()+o}t="default"in t?t.default:t;var g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},w=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},p=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),b=function t(){w(this,t),this.height=0,this.width=0,this.contentWidth=0,this.rows=[],this.columns=[],this.headerRow=null,this.settings={},this.pageCount=1},m=function t(e){w(this,t),this.raw=e||{},this.index=0,this.styles={},this.cells={},this.height=0,this.y=0},v=function t(e){w(this,t),this.raw=e,this.styles={},this.text="",this.contentWidth=0,this.textPos={},this.height=0,this.width=0,this.x=0,this.y=0},x=function t(e){w(this,t),this.dataKey=e,this.options={},this.styles={},this.contentWidth=0,this.width=0,this.x=0},S=1.15,W={striped:{table:{fillColor:255,textColor:80,fontStyle:"normal",fillStyle:"F"},header:{textColor:255,fillColor:[41,128,185],rowHeight:23,fontStyle:"bold"},body:{},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:"normal",lineWidth:.1,fillStyle:"DF"},header:{textColor:255,fillColor:[26,188,156],rowHeight:23,fillStyle:"F",fontStyle:"bold"},body:{},alternateRow:{}},plain:{header:{fontStyle:"bold"}}},C=function(){function t(){w(this,t)}return p(t,null,[{key:"initSettings",value:function(t){var n=Object.assign({},e(),t);"undefined"!=typeof n.extendWidth&&(n.tableWidth=n.extendWidth?"auto":"wrap",console.error("Use of deprecated option: extendWidth, use tableWidth instead.")),"undefined"!=typeof n.margins&&("undefined"==typeof n.margin&&(n.margin=n.margins),console.error("Use of deprecated option: margins, use margin instead.")),[["padding","cellPadding"],["lineHeight","rowHeight"],"fontSize","overflow"].forEach(function(t){var e="string"==typeof t?t:t[0],o="string"==typeof t?t:t[1];"undefined"!=typeof n[e]&&("undefined"==typeof n.styles[o]&&(n.styles[o]=n[e]),console.error("Use of deprecated option: "+e+", use the style "+o+" instead."))});var o=n.margin;return n.margin={},"number"==typeof o.horizontal&&(o.right=o.horizontal,o.left=o.horizontal),"number"==typeof o.vertical&&(o.top=o.vertical,o.bottom=o.vertical),["top","right","bottom","left"].forEach(function(t,e){if("number"==typeof o)n.margin[t]=o;else{var i=Array.isArray(o)?e:t;n.margin[t]="number"==typeof o[i]?o[i]:40}}),n}},{key:"styles",value:function(t){return t.unshift(n()),t.unshift({}),Object.assign.apply(this,t)}}]),t}();"function"!=typeof Object.assign&&!function(){Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var o=arguments[n];if(void 0!==o&&null!==o)for(var i in o)o.hasOwnProperty(i)&&(e[i]=o[i])}return e}}(),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Object.values||(Object.values=function(t){return Object.keys(t).map(function(e){return t[e]})});var P,j,z,A,R,T;t.API.autoTable=function(t,e,n){o(t,e,n),P=this,A=P.internal.pageSize,z={fillColor:P.setFillColor,textColor:P.setTextColor,fontStyle:P.setFontStyle,lineColor:P.setDrawColor,lineWidth:P.setLineWidth,font:P.setFont,fontSize:P.setFontSize},R=C.initSettings(n||{}),j={x:R.margin.left,y:R.startY===!1?R.margin.top:R.startY};var l={textColor:30,fontSize:P.internal.getFontSize(),fontStyle:P.internal.getFont().fontStyle};i(t,e),r(this,A.width);var a=T.rows[0]&&"auto"===R.pageBreak?T.rows[0].height:0,s=R.startY+R.margin.bottom+T.headerRow.height+a;return"avoid"===R.pageBreak&&(s+=T.height),("always"===R.pageBreak&&R.startY!==!1||R.startY!==!1&&s>A.height)&&(this.addPage(this.addPage),j.y=R.margin.top),f(l),R.beforePageContent(c()),R.drawHeaderRow(T.headerRow,c({row:T.headerRow}))!==!1&&h(T.headerRow,R.drawHeaderCell),f(l),d(this.addPage),R.afterPageContent(c()),f(l),this},t.API.autoTableEndPosY=function(){return"undefined"==typeof j||"undefined"==typeof j.y?0:j.y},t.API.autoTableHtmlToJson=function(t,e){e=e||!1;for(var n={},o=[],i=t.rows[0],r=0;r<i.cells.length;r++){var l=i.cells[r],a=window.getComputedStyle(l);(e||"none"!==a.display)&&(n[r]=l?l.textContent.trim():"")}for(var s=1;s<t.rows.length;s++){var d=t.rows[s],a=window.getComputedStyle(d);if(e||"none"!==a.display){var h=[],f=!0,c=!1,y=void 0;try{for(var u,g=Object.keys(n)[Symbol.iterator]();!(f=(u=g.next()).done);f=!0){var w=u.value,l=d.cells[w],p=l?l.textContent.trim():"";h.push(p)}}catch(t){c=!0,y=t}finally{try{!f&&g.return&&g.return()}finally{if(c)throw y}}o.push(h)}}return{columns:Object.values(n),rows:o,data:o}},t.API.autoTableText=function(t,e,n,o){"number"==typeof e&&"number"==typeof n||console.error("The x and y parameters are required. Missing for the text: ",t);var i=this.internal.getFontSize()/this.internal.scaleFactor,r=S,l=/\r\n|\r|\n/g,a=null,s=1;if("middle"!==o.valign&&"bottom"!==o.valign&&"center"!==o.halign&&"right"!==o.halign||(a="string"==typeof t?t.split(l):t,s=a.length||1),n+=i*(2-r),"middle"===o.valign?n-=s/2*i:"bottom"===o.valign&&(n-=s*i),"center"===o.halign||"right"===o.halign){var d=i;if("center"===o.halign&&(d*=.5),s>=1){for(var h=0;h<a.length;h++)this.text(a[h],e-this.getStringUnitWidth(a[h])*d,n),n+=i;return P}e-=this.getStringUnitWidth(t)*d}return this.text(t,e,n),this}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jspdf")):"function"==typeof define&&define.amd?define(["jspdf"],e):e(t.jsPDF)}(this,function(t){"use strict";function e(){return{theme:"striped",styles:{},headerStyles:{},bodyStyles:{},alternateRowStyles:{},columnStyles:{},startY:!1,margin:40,pageBreak:"auto",tableWidth:"auto",createdHeaderCell:function(t,e){},createdCell:function(t,e){},drawHeaderRow:function(t,e){},drawRow:function(t,e){},drawHeaderCell:function(t,e){},drawCell:function(t,e){},beforePageContent:function(t){},afterPageContent:function(t){}}}function n(){return{cellPadding:5,fontSize:10,font:"helvetica",lineColor:200,lineWidth:.1,fontStyle:"normal",overflow:"ellipsize",fillColor:255,textColor:20,halign:"left",valign:"top",fillStyle:"F",rowHeight:20,columnWidth:"auto"}}function o(t,e,n){t&&"object"===("undefined"==typeof t?"undefined":g(t))||console.error("The headers should be an object or array, is: "+("undefined"==typeof t?"undefined":g(t))),e&&"object"===("undefined"==typeof e?"undefined":g(e))||console.error("The data should be an object or array, is: "+("undefined"==typeof e?"undefined":g(e))),n&&"object"!==("undefined"==typeof n?"undefined":g(n))&&console.error("The data should be an object or array, is: "+("undefined"==typeof e?"undefined":g(e))),Array.prototype.forEach||console.error("The current browser does not support Array.prototype.forEach which is required for jsPDF-AutoTable. You can try polyfilling it by including this script https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Polyfill")}function i(t,e){R=new b;var n=/\r\n|\r|\n/g,o=new m(t);o.index=-1;var i=C.styles([W[T.theme].table,W[T.theme].header]);o.styles=Object.assign({},i,T.styles,T.headerStyles),t.forEach(function(t,e){"object"===("undefined"==typeof t?"undefined":g(t))&&(e="undefined"!=typeof t.dataKey?t.dataKey:t.key),"undefined"!=typeof t.width&&console.error("Use of deprecated option: column.width, use column.styles.columnWidth instead.");var i=new x(e);i.styles=T.columnStyles[i.dataKey]||{},R.columns.push(i);var r=new v;r.raw="object"===("undefined"==typeof t?"undefined":g(t))?t.title:t,r.styles=Object.assign({},o.styles),r.text=""+r.raw,r.contentWidth=2*r.styles.cellPadding+u(r.text,r.styles),r.text=r.text.split(n),o.cells[e]=r,T.createdHeaderCell(r,{column:i,row:o,settings:T})}),R.headerRow=o,e.forEach(function(t,e){var o=new m(t),i=e%2===0,r=C.styles([W[T.theme].table,i?W[T.theme].alternateRow:{}]),l=Object.assign({},T.styles,T.bodyStyles,i?T.alternateRowStyles:{});o.styles=Object.assign({},r,l),o.index=e,R.columns.forEach(function(e){var i=new v;i.raw=t[e.dataKey],i.styles=Object.assign({},o.styles,e.styles),i.text="undefined"!=typeof i.raw?""+i.raw:"",o.cells[e.dataKey]=i,T.createdCell(i,c({column:e,row:o})),i.contentWidth=2*i.styles.cellPadding+u(i.text,i.styles),i.text=i.text.split(n)}),R.rows.push(o)})}function r(t,e){var n=0;R.columns.forEach(function(t){t.contentWidth=R.headerRow.cells[t.dataKey].contentWidth,R.rows.forEach(function(e){var n=e.cells[t.dataKey].contentWidth;n>t.contentWidth&&(t.contentWidth=n)}),t.width=t.contentWidth,n+=t.contentWidth}),R.contentWidth=n;var o=e-T.margin.left-T.margin.right,i=o;"number"==typeof T.tableWidth?i=T.tableWidth:"wrap"===T.tableWidth&&(i=R.contentWidth),R.width=i<o?i:o;var r=[],a=0,s=R.width/R.columns.length,d=0;R.columns.forEach(function(t){var e=C.styles([W[T.theme].table,T.styles,t.styles]);"wrap"===e.columnWidth?t.width=t.contentWidth:"number"==typeof e.columnWidth?t.width=e.columnWidth:("auto"===e.columnWidth,t.contentWidth<=s&&R.contentWidth>R.width?t.width=t.contentWidth:(r.push(t),a+=t.contentWidth,t.width=0)),d+=t.width}),l(r,d,a,s),R.height=0;var h=R.rows.concat(R.headerRow);h.forEach(function(e,n){var o=0;R.columns.forEach(function(n){var i=e.cells[n.dataKey];f(i.styles);var r=n.width-2*i.styles.cellPadding;if("linebreak"===i.styles.overflow)try{i.text=t.splitTextToSize(i.text,r+1,{fontSize:i.styles.fontSize})}catch(e){if(!(e instanceof TypeError&&Array.isArray(i.text)))throw e;i.text=t.splitTextToSize(i.text.join(" "),r+1,{fontSize:i.styles.fontSize})}else"ellipsize"===i.styles.overflow?i.text=y(i.text,r,i.styles):"visible"===i.styles.overflow||("hidden"===i.styles.overflow?i.text=y(i.text,r,i.styles,""):"function"==typeof i.styles.overflow?i.text=i.styles.overflow(i.text,r):console.error("Unrecognized overflow type: "+i.styles.overflow));var l=Array.isArray(i.text)?i.text.length-1:0;l>o&&(o=l)}),e.heightStyle=e.styles.rowHeight,e.height=e.heightStyle+o*e.styles.fontSize*S,R.height+=e.height})}function l(t,e,n,o){for(var i=R.width-e-n,r=0;r<t.length;r++){var a=t[r],s=a.contentWidth/n,d=a.contentWidth+i*s<o;if(i<0&&d){t.splice(r,1),n-=a.contentWidth,a.width=o,e+=a.width,l(t,e,n,o);break}a.width=a.contentWidth+i*s}}function a(t){T.afterPageContent(c()),t(),R.pageCount++,j={x:T.margin.left,y:T.margin.top},T.beforePageContent(c()),T.drawHeaderRow(R.headerRow,c({row:R.headerRow}))!==!1&&h(R.headerRow,T.drawHeaderCell)}function s(t){var e=j.y+t+T.margin.bottom;return e>=z.height}function d(t){R.rows.forEach(function(e,n){if(s(e.height)){a(t)}e.y=j.y,T.drawRow(e,c({row:e}))!==!1&&h(e,T.drawCell)})}function h(t,e){j.x=T.margin.left;for(var n=0;n<R.columns.length;n++){var o=R.columns[n],i=t.cells[o.dataKey];if(i){f(i.styles),i.x=j.x,i.y=j.y,i.height=t.height,i.width=o.width,"top"===i.styles.valign?i.textPos.y=j.y+i.styles.cellPadding:"bottom"===i.styles.valign?i.textPos.y=j.y+t.height-i.styles.cellPadding:i.textPos.y=j.y+t.height/2,"right"===i.styles.halign?i.textPos.x=i.x+i.width-i.styles.cellPadding:"center"===i.styles.halign?i.textPos.x=i.x+i.width/2:i.textPos.x=i.x+i.styles.cellPadding;var r=c({column:o,row:t});e(i,r)!==!1&&(P.rect(i.x,i.y,i.width,i.height,i.styles.fillStyle),P.autoTableText(i.text,i.textPos.x,i.textPos.y,{halign:i.styles.halign,valign:i.styles.valign})),j.x+=i.width}}j.y+=t.height}function f(t){Object.keys(A).forEach(function(e){var n=t[e],o=A[e];"undefined"!=typeof n&&(n.constructor===Array?o.apply(this,n):o(n))})}function c(t){return Object.assign({pageCount:R.pageCount,settings:T,table:R,cursor:j},t||{})}function u(t,e){f(e);var n=P.getStringUnitWidth(t);return n*e.fontSize}function y(t,e,n,o){if(o="undefined"!=typeof o?o:"...",Array.isArray(t))return t.forEach(function(i,r){t[r]=y(i,e,n,o)}),t;if(e>=u(t,n))return t;for(;e<u(t+o,n)&&!(t.length<2);)t=t.substring(0,t.length-1);return t.trim()+o}t="default"in t?t.default:t;var g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},w=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},p=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),b=function t(){w(this,t),this.height=0,this.width=0,this.contentWidth=0,this.rows=[],this.columns=[],this.headerRow=null,this.settings={},this.pageCount=1},m=function t(e){w(this,t),this.raw=e||{},this.index=0,this.styles={},this.cells={},this.height=0,this.y=0},v=function t(e){w(this,t),this.raw=e,this.styles={},this.text="",this.contentWidth=0,this.textPos={},this.height=0,this.width=0,this.x=0,this.y=0},x=function t(e){w(this,t),this.dataKey=e,this.options={},this.styles={},this.contentWidth=0,this.width=0,this.x=0},S=1.15,W={striped:{table:{fillColor:255,textColor:80,fontStyle:"normal",fillStyle:"F"},header:{textColor:255,fillColor:[41,128,185],rowHeight:23,fontStyle:"bold"},body:{},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:"normal",lineWidth:.1,fillStyle:"DF"},header:{textColor:255,fillColor:[26,188,156],rowHeight:23,fillStyle:"F",fontStyle:"bold"},body:{},alternateRow:{}},plain:{header:{fontStyle:"bold"}}},C=function(){function t(){w(this,t)}return p(t,null,[{key:"initSettings",value:function(t){var n=Object.assign({},e(),t);"undefined"!=typeof n.extendWidth&&(n.tableWidth=n.extendWidth?"auto":"wrap",console.error("Use of deprecated option: extendWidth, use tableWidth instead.")),"undefined"!=typeof n.margins&&("undefined"==typeof n.margin&&(n.margin=n.margins),console.error("Use of deprecated option: margins, use margin instead.")),[["padding","cellPadding"],["lineHeight","rowHeight"],"fontSize","overflow"].forEach(function(t){var e="string"==typeof t?t:t[0],o="string"==typeof t?t:t[1];"undefined"!=typeof n[e]&&("undefined"==typeof n.styles[o]&&(n.styles[o]=n[e]),console.error("Use of deprecated option: "+e+", use the style "+o+" instead."))});var o=n.margin;return n.margin={},"number"==typeof o.horizontal&&(o.right=o.horizontal,o.left=o.horizontal),"number"==typeof o.vertical&&(o.top=o.vertical,o.bottom=o.vertical),["top","right","bottom","left"].forEach(function(t,e){if("number"==typeof o)n.margin[t]=o;else{var i=Array.isArray(o)?e:t;n.margin[t]="number"==typeof o[i]?o[i]:40}}),n}},{key:"styles",value:function(t){return t.unshift(n()),t.unshift({}),Object.assign.apply(this,t)}}]),t}();"function"!=typeof Object.assign&&!function(){Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var o=arguments[n];if(void 0!==o&&null!==o)for(var i in o)o.hasOwnProperty(i)&&(e[i]=o[i])}return e}}(),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Object.values||(Object.values=function(t){return Object.keys(t).map(function(e){return t[e]})});var P,j,A,z,T,R;t.API.autoTable=function(t,e,n){o(t,e,n),P=this,z=P.internal.pageSize,A={fillColor:P.setFillColor,textColor:P.setTextColor,fontStyle:P.setFontStyle,lineColor:P.setDrawColor,lineWidth:P.setLineWidth,font:P.setFont,fontSize:P.setFontSize},T=C.initSettings(n||{}),j={x:T.margin.left,y:T.startY===!1?T.margin.top:T.startY};var l={textColor:30,fontSize:P.internal.getFontSize(),fontStyle:P.internal.getFont().fontStyle};i(t,e),r(this,z.width);var a=R.rows[0]&&"auto"===T.pageBreak?R.rows[0].height:0,s=T.startY+T.margin.bottom+R.headerRow.height+a;return"avoid"===T.pageBreak&&(s+=R.height),("always"===T.pageBreak&&T.startY!==!1||T.startY!==!1&&s>z.height)&&(this.addPage(this.addPage),j.y=T.margin.top),f(l),T.beforePageContent(c()),T.drawHeaderRow(R.headerRow,c({row:R.headerRow}))!==!1&&h(R.headerRow,T.drawHeaderCell),f(l),d(this.addPage),T.afterPageContent(c()),f(l),this},t.API.autoTableEndPosY=function(){return"undefined"==typeof j||"undefined"==typeof j.y?0:j.y},t.API.autoTableHtmlToJson=function(t,e){e=e||!1;for(var n={},o=[],i=t.rows[0],r=0;r<i.cells.length;r++){var l=i.cells[r],a=window.getComputedStyle(l);(e||"none"!==a.display)&&(n[r]=l?l.textContent.trim():"")}for(var s=1;s<t.rows.length;s++){var d=t.rows[s],a=window.getComputedStyle(d);if(e||"none"!==a.display){var h=[],f=!0,c=!1,u=void 0;try{for(var y,g=Object.keys(n)[Symbol.iterator]();!(f=(y=g.next()).done);f=!0){var w=y.value,l=d.cells[w],p=l?l.textContent.trim():"";h.push(p)}}catch(t){c=!0,u=t}finally{try{!f&&g.return&&g.return()}finally{if(c)throw u}}o.push(h)}}return{columns:Object.values(n),rows:o,data:o}},t.API.autoTableAddPage=function(){a(P.addPage)},t.API.autoTableText=function(t,e,n,o){"number"==typeof e&&"number"==typeof n||console.error("The x and y parameters are required. Missing for the text: ",t);var i=this.internal.getFontSize()/this.internal.scaleFactor,r=S,l=/\r\n|\r|\n/g,a=null,s=1;if("middle"!==o.valign&&"bottom"!==o.valign&&"center"!==o.halign&&"right"!==o.halign||(a="string"==typeof t?t.split(l):t,s=a.length||1),n+=i*(2-r),"middle"===o.valign?n-=s/2*i:"bottom"===o.valign&&(n-=s*i),"center"===o.halign||"right"===o.halign){var d=i;if("center"===o.halign&&(d*=.5),s>=1){for(var h=0;h<a.length;h++)this.text(a[h],e-this.getStringUnitWidth(a[h])*d,n),n+=i;return P}e-=this.getStringUnitWidth(t)*d}return this.text(t,e,n),this}}); |
/** | ||
* jsPDF AutoTable plugin v2.0.27 | ||
* jsPDF AutoTable plugin v2.0.28 | ||
* Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable | ||
@@ -424,2 +424,13 @@ * | ||
/** | ||
* Add a new page including an autotable header etc. Use this function in the hooks. | ||
* | ||
* @param tableElem Html table element | ||
* @param includeHiddenElements If to include hidden rows and columns (defaults to false) | ||
* @returns Object Object with two properties, columns and rows | ||
*/ | ||
jsPDF.API.autoTableAddPage = function () { | ||
addPage(doc.addPage); | ||
}; | ||
/** | ||
* Improved text function with halign and valign support | ||
@@ -426,0 +437,0 @@ * Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113 |
/** | ||
* jsPDF AutoTable plugin v2.0.27 | ||
* jsPDF AutoTable plugin v2.0.28 | ||
* Copyright (c) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable | ||
@@ -424,2 +424,13 @@ * | ||
/** | ||
* Add a new page including an autotable header etc. Use this function in the hooks. | ||
* | ||
* @param tableElem Html table element | ||
* @param includeHiddenElements If to include hidden rows and columns (defaults to false) | ||
* @returns Object Object with two properties, columns and rows | ||
*/ | ||
jsPDF.API.autoTableAddPage = function () { | ||
addPage(doc.addPage); | ||
}; | ||
/** | ||
* Improved text function with halign and valign support | ||
@@ -426,0 +437,0 @@ * Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113 |
{ | ||
"name": "jspdf-autotable", | ||
"version": "2.0.27", | ||
"version": "2.0.28", | ||
"description": "Generate pdf tables with javascript (jsPDF plugin)", | ||
@@ -5,0 +5,0 @@ "main": "dist/jspdf.plugin.autotable.js", |
@@ -158,6 +158,4 @@ # AutoTable - Table plugin for jsPDF | ||
- `autoTableEndPosY()` Use it if you want to know where on the page the the last row were drawn (see `multiple tables` example) | ||
- `autoTableAddPage` Use in the hooks to continue the table on the next page. Adds a new header automatically. | ||
### Upgrade to Version 2.1 from 2.0 | ||
- Use cursor.x instead of column.x. | ||
### Upgrade to Version 2.0 from 1.x | ||
@@ -164,0 +162,0 @@ - Use the hooks (or styles and themes) instead of `renderCell`, `renderHeaderCell`, `renderFooter`and `renderHeader` |
@@ -133,2 +133,13 @@ 'use strict'; | ||
/** | ||
* Add a new page including an autotable header etc. Use this function in the hooks. | ||
* | ||
* @param tableElem Html table element | ||
* @param includeHiddenElements If to include hidden rows and columns (defaults to false) | ||
* @returns Object Object with two properties, columns and rows | ||
*/ | ||
jsPDF.API.autoTableAddPage = function () { | ||
addPage(doc.addPage); | ||
}; | ||
/** | ||
* Improved text function with halign and valign support | ||
@@ -135,0 +146,0 @@ * Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1571695
10469
214