pdfkit-table
Advanced tools
Comparing version 0.1.34 to 0.1.35
46
index.js
@@ -31,2 +31,5 @@ "use strict"; | ||
const title = table.title ? table.title : ( options.title ? options.title : '' ) ; | ||
const subtitle = table.subtitle ? table.subtitle : ( options.subtitle ? options.subtitle : '' ) ; | ||
let columnIsDefined = options.columnsSize.length ? true : false ; | ||
@@ -48,7 +51,46 @@ const columnsCountSize = options.columnsSize.length; // pre-defined coluns size | ||
const startX = options.x || this.page.margins.left; | ||
let startY = options.y || this.y; | ||
let startX = options.x || this.x || this.page.margins.left ; | ||
let startY = options.y || this.y ; | ||
let rowBottomY = 0; | ||
let tableWidth = 0; | ||
// if options.x === null | ||
// reset position to margins.left | ||
if( options.x === null || options.x === -1 ){ | ||
startX = this.page.margins.left; | ||
} | ||
const createTitle = ( data, size, opacity ) => { | ||
// Title | ||
if( !data ) return; | ||
// get height line | ||
let cellHeight = 0; | ||
// if string | ||
if(typeof data === 'string' ){ | ||
// font size | ||
this.fontSize( size ).opacity( opacity ); | ||
// get height line | ||
cellHeight = this.heightOfString( data, { | ||
width: usableWidth, | ||
align: "left", | ||
}); | ||
// write | ||
this.text( data, startX, startY ).opacity( 1 ); // moveDown( 0.5 ) | ||
// startY += cellHeight; | ||
startY = this.y + 2; | ||
// else object | ||
} else if(typeof data === 'object' ){ | ||
// title object | ||
data.label && this.fontSize( data.fontSize || size ).text( data.label, startX, startY ); | ||
} | ||
} | ||
createTitle( title, 12, 1 ); | ||
createTitle( subtitle, 9, 0.7 ); | ||
if( title || subtitle ){ | ||
startY += 3; | ||
} | ||
this.on("pageAdded", () => { | ||
@@ -55,0 +97,0 @@ startY = this.page.margins.top; |
{ | ||
"name": "pdfkit-table", | ||
"version": "0.1.34", | ||
"version": "0.1.35", | ||
"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", |
@@ -354,2 +354,11 @@ # pdfkit-table | ||
### 0.1.35 | ||
+ add **title** <code>{String}</code> | ||
- const table = { title: "", }; | ||
- const options = { title: "", }; | ||
+ add **subtitle** <code>{String}</code> | ||
- const table = { subtitle: "", }; | ||
- const options = { subtitle: "", }; | ||
### 0.1.34 | ||
@@ -356,0 +365,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
27274
349
411