1.0.4 • Published 4 years ago
gendocio v1.0.4
Gendoc.io - Javascript SDK
PDF document generator API
To use with www.gendoc.io
More information at:
- https://gendoc.io/documentation : To learn how to use the Gendoc API
- https://gendoc.io/guide : To learn how to create Gendoc templates
How to use
The API is quite simple to use.
Just issue a call to gendoc.generate
with the following parameters (template, data, token).
- Template is the HTML template with Handlbars placeholders, which you will use to create your PDF
- Data is the JSON data used to fill in the template placeholders (see example below)
- Token is an API token, which you can get at https://app.gendoc.io, and will avoid you hitting rate limits.
This function returns a promise, which can either resolve with a HTTP payload, where data is the base64 encoded version of the generated PDF. Or, it can raise an error.
Example: Generate a simple PDF
const gendoc = require('gendocio')
const fs = require('fs');
gendoc.generate(
'<html><body>{{a}}</body></html>',
{"a": 2},
''
)
.then((result)=>{
let buff = new Buffer(result.data, 'base64');
fs.writeFileSync('out.pdf', buff);
})
.catch((result) => console.log(result.data))