super-pdfkit
Enhanced pdfkit with some useful methods
(thx to: pdfkit and pdfkit-table authors)
Easy usage:
const PDF = require( 'super-pdfkit' );
const doc = new PDF( {
margin: 50,
pageNum: true,
pageNumText: 'Page ',
header( thisDoc ) {
thisDoc.textCenter( 'HEADER', 15 );
thisDoc.imageCenter( 'header.png', 50 );
},
footer( thisDoc ) {
thisDoc.textCenter( 'FOOTER', thisDoc.page.height - 40 );
}
} );
doc.textCenter(
'LEFT ALIGNED TEXT',
200
);
doc.textCenter(
'CENTERED TEXT',
200
);
doc.textRight(
'RIGHT ALIGNED TEXT',
200
);
doc.imageCenter(
'image.png',
100,
230
);
doc.end();
doc.end( thisDoc => {
thisDoc.text( 'ANY EDIT ON THE DOCUMENT' );
} );
doc.complete()
.then( bufferData => console.log( bufferData ) );