Node.js client API for Fudok
This Node.js API allows to call PDF templating features exposed by Fudok.
Get started
This package can be installed as NPM package: npm install fudok
Then fudok
module can be required in your Node.js code: var fudok = require("fudok")
The main function to merge data (e.g. form submission) with PDF template managed on Fudok is fudok.merge
:
var fudok = ; fudok;
See: Online demo
Example
Some examples using this module are available in the repository: see simple example.
var fudok = ; fudok;
API reference
The module is exposing following Fudok functions.
merge
.merge(options)
: Merge values with specified template;
Object options
is expecting following properties.
token
: Fudok application token (string
).template
: ID of Fudok template (string
).parameters
: Name/value pairs to be merged with areas (object
).success
: Success callback, is given a HTTP response as argument; Optional function, if undefined default handler (console.log
) is used.error
: Error callback, is given HTTP error code (int) as argument; Optional function, if undefined default handler (console.error
) is used.
Application token and template ID are visible in Integration tab on Template screen of Fudok management.
See code sample
auth
.auth(options)
: Authenticate and get the administration token to be able to manage the corresponding Fudok account.
email
: Fudok login (string
).password
: Fudok password (string
, cleartext)success
: Success callback, is given the admin token as argument; Optional, if undefined default handler (console.log) is used.- error: Error callback, is given error details as argument (e.g.
{'code':123, 'cause':"Error cause"}
; Optional, if undefined default handler (console.error) is used.
See code sample
Template list
.templateList(options)
: List the templates of Fudok account specified by the given administration token.
var dok = ; dok; The success handler is given an object with following properties ```javascript{ "token": "app_token", "activePlan": { "credits":1 }, "templates": [ { "id": "tmpl-1", "name": "Template #1", "expiration":1418833775372 }, { "id": "tmpl-2", "name": "Second template" }, { "id": "tmpl-3", "name": "The third one" }, { "id": "tmpl-4", "name": "Template #4", "expiration":1418228986489, "trial":true } ]}