Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
voilab-pdf-table
Advanced tools
Readme
PdfKit wrapper that helps to draw informations in simple tables.
npm install --save voilab-pdf-table
// in some service
var PdfTable = require('voilab-pdf-table'),
PdfDocument = require('pdfkit');
module.exports = {
create: function () {
// create a PDF from PDFKit, and a table from PDFTable
var pdf = new PdfDocument({
autoFirstPage: false
}),
table = new PdfTable(pdf, {
bottomMargin: 30
});
table
// add some plugins (here, a 'fit-to-width' for a column)
.addPlugin(new (require('voilab-pdf-table/plugins/fitcolumn'))({
column: 'description'
}))
// set defaults to your columns
.setColumnsDefaults({
headerBorder: 'B',
align: 'right'
})
// add table columns
.addColumns([
{
id: 'description',
header: 'Product',
align: 'left'
},
{
id: 'quantity',
header: 'Quantity',
width: 50
},
{
id: 'price',
header: 'Price',
width: 40
},
{
id: 'total',
header: 'Total',
width: 70,
renderer: function (tb, data) {
return 'CHF ' + data.total;
}
}
])
// add events (here, we draw headers on each new page)
.onPageAdded(function (tb) {
tb.addHeader();
});
// if no page already exists in your PDF, do not forget to add one
pdf.addPage();
// draw content, by passing data to the addBody method
table.addBody([
{description: 'Product 1', quantity: 1, price: 20.10, total: 20.10},
{description: 'Product 2', quantity: 4, price: 4.00, total: 16.00},
{description: 'Product 3', quantity: 2, price: 17.85, total: 35.70}
]);
return pdf;
}
};
// with express, in some route
app.get('/some/route', function (req, res, next) {
var pdf = require('some/service').create();
pdf.pipe(res);
pdf.end();
});
You can customize how page breaks are done during table process like this:
table.onPageAdd(function (table, row, ev) {
// do something like
table.pdf.addPage();
// cancel event so the automatic page add is not triggered
ev.cancel = true;
});
From #End-S
various
From #Drieger
Number(0)
the renderer displays it. It could be a breaking
change, so the version is bumped to 0.5.0Thank you, contributors!
From #vikram1992
headerOpacity
and headerBorderOpacity
in column configurationheaderCellAdded
and cellAdded
as a function in column configurationThank you, contributors!
From #MichielDeMey
From #cbwebdevelopment
onCellBackgroundAdd
and onCellBackgroundAdded
eventsonCellBorderAdd
and onCellBorderAdded
eventssetNewPageFn
setNewPageFn
. Check documentation for how you can customize page
add. Deprecated mention will be definitively removed in next releaseonColumnPropertyChanged
onColumnAdded
onColumnWidthChanged
. Use onColumnPropertyChanged
instead.
Deprecated mention will be definitively removed in next releaseFirst shot
This code is released under the MIT License (MIT)
FAQs
PdfKit wrapper that helps to draw informations in simple tables.
The npm package voilab-pdf-table receives a total of 4,315 weekly downloads. As such, voilab-pdf-table popularity was classified as popular.
We found that voilab-pdf-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.