kinda-pdf-document
Easily generate any kind of PDF documents such as reports including headers, footers, tables, etc.
NOTE: This documentation is still work in progress. Please help make it better by adding as much as you can and submitting a pull request.
Installation
NOTE: This module is not yet published on npm.
$ npm install kinda-pdf-document
To use kinda-pdf-document, you need node 0.11.9
or higher for generator support, and must run node with the --harmony flag.
$ node --harmony test/pdf.js
How to use it?
First you create an instance of KindaPDFDocument
:
var KindaPDFDocument = ;var doc = KindaPDFDocument;
After, you can specify an header. It will apear on the top of every pages. You can do it like this:
doc;
Then you can add some text in the header:
header;
Also you can align the text to center or right:
header;
And you can do even more:
header;
You see that there are two variables in the text. They will be replaced by real values when the PDF is rendered. For now, a few variables are supported:
documentTitle
,documentAuthor
,documentSubject
,documentKeywords
: can be specified when you create a document,pageNumber
: current page number,numberOfPages
: how many pages the document have.
Just wrap the variable in double braces {{documentTitle}}
and that's all.
So, there is a header now. You can also add a footer:
doc;
Now, it's time to complete the document with a body. So here we come:
doc;
If you want to add some text in the body, you can do it like this:
body;
The most powerful feature is the ability to add tables:
body;
In the same way, you can add a table header and a table footer. If the table takes more than one page, the table header will appear on every pages but the table footer will only appear on the end of the table.
table; table
Finally, you can generate a PDF file. Just await doc.generatePDFFile()
to do the magic.
await doc;
And voilà! For more details, read the API documentation [TODO].
Dependencies
KindaPDFDocument uses PDFKit to render the PDF.
License
MIT