pdfkit-table
Advanced tools
Comparing version 0.1.25 to 0.1.26
44
index.js
@@ -19,9 +19,8 @@ "use strict"; | ||
let startX = this.page.margins.left, | ||
startY = this.y; | ||
if( !options || typeof options !== 'object' ) options = {}; | ||
options.hasOwnProperty('x') && (startX = options.x); | ||
options.hasOwnProperty('y') && (startY = options.y); | ||
table || (table = {}) | ||
table.headers || (table.headers = []); | ||
table.datas || (table.datas = []) | ||
table.rows || (table.rows = []) | ||
@@ -31,9 +30,22 @@ const columnCount = table.headers.length; | ||
const columnSizes = options.columnSizes || []; | ||
const columnPositions = []; // 0,10,20,30,100 | | | | | | ||
const columnPositions = []; // 0, 10, 20, 30, 100 | ||
const rowSpacing = options.rowSpacing || 3; // 5 | ||
const usableWidth = options.width || this.page.width - this.page.margins.left - this.page.margins.right; | ||
const prepareHeader = options.prepareHeader || (() => this.font("Helvetica-Bold").fontSize(8)); | ||
const prepareHeader = options.prepareHeader || (() => this.font("Helvetica-Bold").fontSize(8) ); | ||
const prepareRow = options.prepareRow || (() => this.font("Helvetica").fontSize(8) ); | ||
const columnContainerWidth = usableWidth / columnCount; | ||
const columnWidth = columnContainerWidth - columnSpacing; | ||
const maxY = this.page.height - this.page.margins.bottom; | ||
let startX = options.x || this.page.margins.left; | ||
let startY = options.y || this.y; | ||
let rowBottomY = 0; | ||
this.on("pageAdded", () => { | ||
startY = this.page.margins.top; | ||
rowBottomY = 0; | ||
}); | ||
const prepareRowOptions = ( row ) => { | ||
@@ -50,3 +62,3 @@ if( typeof row !== 'object' || !row.hasOwnProperty('options') ) return; | ||
// reconhece se é uma linha object, content with property | ||
// if row is object, content with property and options | ||
if( !Array.isArray(row) && typeof row === 'object' && !row.hasOwnProperty('property') ){ | ||
@@ -88,13 +100,2 @@ const cells = []; | ||
const columnContainerWidth = usableWidth / columnCount; | ||
const columnWidth = columnContainerWidth - columnSpacing; | ||
const maxY = this.page.height - this.page.margins.bottom; | ||
let rowBottomY = 0; | ||
this.on("pageAdded", () => { | ||
startY = this.page.margins.top; | ||
rowBottomY = 0; | ||
}); | ||
// Allow the user to override style for headers | ||
@@ -177,3 +178,2 @@ prepareHeader(); | ||
// ------------------------------------------------------------------------------ | ||
table.datas || (table.datas = []) | ||
table.datas.forEach((row, i) => { | ||
@@ -262,3 +262,2 @@ const rowHeight = computeRowHeight(row); | ||
// ------------------------------------------------------------------------------ | ||
table.rows || (table.rows = []) | ||
table.rows.forEach((row, i) => { | ||
@@ -295,2 +294,5 @@ const rowHeight = computeRowHeight(row); | ||
}); | ||
// ------------------------------------------------------------------------------ | ||
// rows ------------------------------------------------------------------------- | ||
// ------------------------------------------------------------------------------ | ||
@@ -297,0 +299,0 @@ this.x = startX; |
{ | ||
"name": "pdfkit-table", | ||
"version": "0.1.25", | ||
"version": "0.1.26", | ||
"description": "PdfKit Table. Helps to draw informations in simple tables using pdfkit. #server-side. Generate pdf tables with javascript (PDFKIT plugin) ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
19183
237