Create a PDF from simple HTML text elements
npm install @shipper/pdfkit-html-simpleCreate a PDF from simple HTML text elements
Usage:
``js`
const PDFKitHTML = require('@shipper/pdfkit-html-simple'),
html = `
H1
H2
H3
H4
H5
H6
This is bold
This is bold and underlined
This is italic
This is underlined
This is also underlined
;`
PDFKitHTML.parse(html)
.then(function(transformations) {
// We now have an array of functions to invoke with a document
});
The result of the promise being an array of functions, each of which expect one parameter, document, and
will return a promise resolving with that document
To apply the transformations to the document you can do something like this:
`js``
const promise = transformations.reduce(function(promise, transformation) {
return promise.then(transformation);
}, Promise.resolve(document));
Once the promise is resolved all transformations will be complete and you will have your document.
See examples/simple for example usage