pdfkit-table
Advanced tools
Comparing version 0.1.74 to 0.1.75
10
index.js
@@ -84,3 +84,3 @@ // jshint esversion: 6 | ||
options.divider.horizontal || (options.divider.horizontal = {disabled: false, width: undefined, opacity: undefined}); | ||
options.divider.vertical || (options.divider.vertical = {disabled: false, width: undefined, opacity: undefined}); | ||
options.divider.vertical || (options.divider.vertical = {disabled: true, width: undefined, opacity: undefined}); | ||
@@ -172,3 +172,7 @@ if(!table.headers.length) throw new Error('Headers not defined'); | ||
}; | ||
const separationsColumn = () => { | ||
} | ||
const separationsRow = (type, x, y, width, opacity) => { | ||
@@ -412,3 +416,3 @@ | ||
// Check to have enough room for header and first rows. default 3 | ||
// if (startY + 2 * rowHeight > maxY) this.addPage(); | ||
// if (startY + 2 * rowHeight >= maxY) this.addPage(); | ||
@@ -415,0 +419,0 @@ if(table.headers.length > 0) { |
{ | ||
"name": "pdfkit-table", | ||
"version": "0.1.74", | ||
"version": "0.1.75", | ||
"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", |
@@ -36,8 +36,8 @@ <p align="center"> | ||
const fs = require("fs"); | ||
const PDFDocument = require("pdfkit-table"); | ||
const doc = new PDFDocument({ margin: 30, size: 'A4' }); | ||
const PDFDocument = require("pdfkit-table"); | ||
// start pdf document | ||
let doc = new PDFDocument({ margin: 30, size: 'A4' }); | ||
// file name | ||
doc.pipe(fs.createWriteStream("./file-table.pdf")); | ||
doc.pipe(fs.createWriteStream("./document.pdf")); | ||
// table | ||
@@ -57,2 +57,6 @@ const table = { | ||
// if your run express.js server: | ||
// HTTP response only to show pdf | ||
// doc.pipe(res); | ||
// done! | ||
@@ -102,2 +106,3 @@ doc.end(); | ||
], | ||
// complex data | ||
datas: [ | ||
@@ -117,17 +122,11 @@ { | ||
price1: 'bold:$1', | ||
price3: '$3', | ||
price2: '$2', | ||
price4: '4', | ||
}, | ||
{ | ||
name: 'Name 3', | ||
description: 'Lorem ipsum dolor.', | ||
price1: 'bold:$1', | ||
price4: '4', | ||
price2: '$2', | ||
price3: { | ||
label: 'PRICE $3', options: { fontSize: 12 } | ||
}, | ||
price2: '$2', | ||
price4: '4', | ||
}, | ||
// {...}, | ||
], | ||
// simeple data | ||
rows: [ | ||
@@ -142,10 +141,3 @@ [ | ||
], | ||
[ | ||
"Tire", | ||
"Donec ac tincidunt nisi, sit amet tincidunt mauris. Fusce venenatis tristique quam, nec rhoncus eros volutpat nec. Donec fringilla ut lorem vitae maximus. Morbi ex erat, luctus eu nulla sit amet, facilisis porttitor mi.", | ||
"$ 105,99", | ||
"$ 105,99", | ||
"$ 105,99", | ||
"105.99", | ||
], | ||
// [...], | ||
], | ||
@@ -156,3 +148,3 @@ }; | ||
prepareHeader: () => doc.font("Helvetica-Bold").fontSize(8), | ||
prepareRow: (row, indexColumn, indexRow, rectRow) => { | ||
prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => { | ||
doc.font("Helvetica").fontSize(8); | ||
@@ -191,4 +183,5 @@ indexColumn === 0 && doc.addBackground(rectRow, 'blue', 0.15); | ||
or | ||
### Example 4 - Json file (many tables) | ||
```js | ||
@@ -204,22 +197,2 @@ const json = require('./table.json'); | ||
### Example 4 - Full Code | ||
```js | ||
// require | ||
const fs = require("fs"); | ||
const PDFDocument = require("pdfkit-table"); | ||
const doc = new PDFDocument({ margin: 30, size: 'A4', }); | ||
// file name | ||
doc.pipe(fs.createWriteStream("./file-table.pdf")); | ||
// ------------------ | ||
// table code here | ||
// ------------------ | ||
// if your run express.js server: | ||
// HTTP response only to show pdf | ||
doc.pipe(res); | ||
// done | ||
doc.end(); | ||
``` | ||
## Table | ||
@@ -262,3 +235,4 @@ | ||
Example code: | ||
#### Simple headers example | ||
```js | ||
@@ -274,3 +248,7 @@ const table = { | ||
}; | ||
``` | ||
#### Complex headers example | ||
```js | ||
const table = { | ||
@@ -311,6 +289,7 @@ // complex headers work with ROWS and DATAS | ||
| **prepareHeader** | <code>Function</code> | Function | () | | ||
| **prepareRow** | <code>Function</code> | Function | (row, indexColumn, indexRow, rectRow) => {} | | ||
| **prepareRow** | <code>Function</code> | Function | (row, indexColumn, indexRow, rectRow, rectCell) => {} | | ||
Example code: | ||
#### Options example | ||
```js | ||
@@ -331,3 +310,3 @@ const options = { | ||
prepareHeader: () => doc.font("Helvetica-Bold").fontSize(8), // {Function} | ||
prepareRow: (row, indexColumn, indexRow, rectRow) => doc.font("Helvetica").fontSize(8), // {Function} | ||
prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => doc.font("Helvetica").fontSize(8), // {Function} | ||
} | ||
@@ -549,3 +528,3 @@ ``` | ||
+ **prepareRow** <code>{Function}</code> | ||
- const options = { prepareRow: (row, indexColumn, indexRow, rectRow) => { indexColumn === 0 && doc.addBackground(rectRow, 'red', 0.5) } } | ||
- const options = { prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => { indexColumn === 0 && doc.addBackground(rectRow, 'red', 0.5) } } | ||
@@ -552,0 +531,0 @@ ### 0.1.38 |
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
602
43558
588