voilab-pdf-table
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "voilab-pdf-table", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "PdfKit wrapper that helps to draw informations in simple tables.", | ||
@@ -18,3 +18,3 @@ "main": "voilab-table.js", | ||
"dependencies": { | ||
"lodash": "4.*" | ||
"lodash": "^4.17.10" | ||
}, | ||
@@ -21,0 +21,0 @@ "author": { |
@@ -9,3 +9,3 @@ Voilab Pdf Table | ||
``` | ||
node install --save voilab-pdf-table | ||
npm install --save voilab-pdf-table | ||
``` | ||
@@ -110,2 +110,10 @@ | ||
### 0.4.1 | ||
Thank you, contributors! | ||
**From #vikram1992** | ||
+ added `headerOpacity` and `headerBorderOpacity` in column configuration | ||
+ added `headerCellAdded` and `cellAdded` as a function in column configuration | ||
### 0.4.0 | ||
@@ -121,3 +129,3 @@ Thank you, contributors! | ||
+ added `addonCellBackgroundAdd` and `onCellBackgroundAdded` events | ||
+ added `onCellBackgroundAdd` and `onCellBackgroundAdded` events | ||
+ added `onCellBorderAdd` and `onCellBorderAdded` events | ||
@@ -124,0 +132,0 @@ + the current row index is passed in events |
@@ -59,15 +59,23 @@ /*jslint node: true, unparam: true, nomen: true */ | ||
y: pos.y + row._renderedContent.height | ||
}, | ||
doStroke = function () { | ||
var opacity = (!isHeader && column.borderOpacity) || (isHeader && column.headerBorderOpacity); | ||
self.pdf.lineCap('square').opacity(opacity || 1).stroke().restore(); | ||
}; | ||
if (border.indexOf('L') !== -1) { | ||
self.pdf.save().moveTo(pos.x, pos.y).lineTo(pos.x, bpos.y).lineCap('square').stroke().restore(); | ||
self.pdf.save().moveTo(pos.x, pos.y).lineTo(pos.x, bpos.y); | ||
doStroke(); | ||
} | ||
if (border.indexOf('T') !== -1) { | ||
self.pdf.save().moveTo(pos.x, pos.y).lineTo(bpos.x, pos.y).lineCap('square').stroke().restore(); | ||
self.pdf.save().moveTo(pos.x, pos.y).lineTo(bpos.x, pos.y); | ||
doStroke(); | ||
} | ||
if (border.indexOf('B') !== -1) { | ||
self.pdf.save().moveTo(pos.x, bpos.y).lineTo(bpos.x, bpos.y).lineCap('square').stroke().restore(); | ||
self.pdf.save().moveTo(pos.x, bpos.y).lineTo(bpos.x, bpos.y); | ||
doStroke(); | ||
} | ||
if (border.indexOf('R') !== -1) { | ||
self.pdf.save().moveTo(bpos.x, pos.y).lineTo(bpos.x, bpos.y).lineCap('square').stroke().restore(); | ||
self.pdf.save().moveTo(bpos.x, pos.y).lineTo(bpos.x, bpos.y); | ||
doStroke(); | ||
} | ||
@@ -86,2 +94,3 @@ | ||
renderer = isHeader ? column.headerRenderer : column.renderer, | ||
cellAdded = isHeader ? column.headerCellAdded : column.cellAdded, | ||
y = pos.y, | ||
@@ -132,2 +141,4 @@ x = pos.x; | ||
cellAdded && cellAdded(self, row, column, { x: x, y: self.pdf.y, baseY: y }, padding, isHeader); | ||
pos.x += column.width; | ||
@@ -178,3 +189,3 @@ }, | ||
var renderer = isHeader ? column.headerRenderer : column.renderer, | ||
content = renderer ? renderer(self, row, false) : row[column.id], | ||
content = renderer ? renderer(self, row, false, column) : row[column.id], | ||
height = !content ? 1 : self.pdf.heightOfString(content, lodash.assign(lodash.clone(column), { | ||
@@ -185,3 +196,3 @@ width: column.width - getPaddingValue('horizontal', column.padding) | ||
// Ssetup the content height | ||
// Setup the content height | ||
row._renderedContent.contentHeight[column.id] = height; | ||
@@ -522,14 +533,2 @@ | ||
/** | ||
* Temporary hack to manage overriden addPage() for pdfkit | ||
* | ||
* @deprecated | ||
* @param {Function} fn | ||
* @return {PdfTable} | ||
*/ | ||
setNewPageFn: function (fn) { | ||
console.log('setNewPageFn is deprecated. Adding a page during process is automatic now. It will be removed on the next release'); | ||
return this; | ||
}, | ||
/** | ||
* Add a plugin | ||
@@ -542,3 +541,6 @@ * | ||
if (!plugin || !plugin.configure) { | ||
throw new Error('Plugin [' + (plugin && plugin.id) + '] must have a configure() method.'); | ||
var err = new Error('Plugin [' + (plugin && plugin.id) + '] must have a configure() method.'); | ||
err.module = 'pdftable'; | ||
err.code = 2; | ||
throw err; | ||
} | ||
@@ -583,3 +585,3 @@ this.plugins.push(plugin); | ||
/** | ||
* Define a column. Config array is mostly what we find in .text() | ||
* Define a column. Config array is mostly what we find in .text(), plus: | ||
* | ||
@@ -590,5 +592,9 @@ * <ul> | ||
* Recieve (PdfTable table, row, draw).</li> | ||
* <li><i>Function</i> <b>cellAdded</b>: renderer function for cell, | ||
* after main data is drawn. Recieve (PdfTable table, row, draw).</li> | ||
* <li><i>Boolean</i> <b>hidden</b>: True to define the column as | ||
* hidden (default to false)</li> | ||
* <li><i>String</i> <b>border</b>: cell border (LTBR)</li> | ||
* <li><i>Number</i> <b>borderOpacity</b>: cell border opacity, from 0 | ||
* to 1</li> | ||
* <li><i>Number</i> <b>width</b>: column width</li> | ||
@@ -613,3 +619,8 @@ * <li><i>Number</i> <b>height</b>: min height for cell (default to | ||
* header cell. Recieve (PdfTable table, row)</li> | ||
* <li><i>Function</i> <b>haederCellAdded</b>: renderer function for | ||
* cell, after main data is drawn. Recieve (PdfTable table, row, | ||
* draw).</li> | ||
* <li><i>String</i> <b>headerBorder</b>: cell border (LTBR)</li> | ||
* <li><i>Number</i> <b>headerBorderOpacity</b>: cell border opacity, | ||
* from 0 to 1</li> | ||
* <li><i>Boolean</i> <b>headerFill</b>: True to fill the header with | ||
@@ -664,3 +675,3 @@ * the predefined color (with pdf.fillColor(color))</li> | ||
* @param {Array} columns | ||
* @param {Boolean} add true to add these columns to existing columns | ||
* @param {Boolean} [add] true to add these columns to existing columns | ||
* @return {PdfTable} | ||
@@ -682,3 +693,3 @@ */ | ||
* | ||
* @param {Boolean} withHidden true to get hidden columns too | ||
* @param {Boolean} [withHidden] true to get hidden columns too | ||
* @return {Array} | ||
@@ -802,3 +813,3 @@ */ | ||
* @param {Number} width | ||
* @param {Boolean} silent True to prevent event to be emitted | ||
* @param {Boolean} [silent] True to prevent event to be emitted | ||
* @return {PdfTable} | ||
@@ -828,3 +839,3 @@ */ | ||
* @param {mixed} value definition value | ||
* @param {Boolean} silent True to prevent event to be emitted | ||
* @param {Boolean} [silent] True to prevent event to be emitted | ||
* @return {PdfTable} | ||
@@ -859,3 +870,6 @@ */ | ||
if (!this.pdf.page) { | ||
throw new Error("No page available. Add a page to the PDF before calling addBody()"); | ||
var err = new Error("No page available. Add a page to the PDF before calling addBody()"); | ||
err.module = 'pdftable'; | ||
err.code = 1; | ||
throw err; | ||
} | ||
@@ -862,0 +876,0 @@ |
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
38294
937
150
5
Updatedlodash@^4.17.10