The Webvanta system can dynamically generate PDF files. (Note: this feature is available only on certain plans.)
The basic approach is to create a special HTML page, with corresponding CSS. This page can access the database using WebvantaScript, just like any other page. To generate the PDF, you call the JavaScript API with a pointer to the HTML page, and the system generates the PDF. You can then display a link to the PDF, or use the email API to send the PDF.
The PDF generator uses a version of the Webkit rendering engine, so it is capable of rendering HTML5 and CSS3 with high fidelity.
Pages must, however, be self-contained. The environment that a page is rendered in is not the same as a browser, so any state information is not available. This includes:
All references must be absolute, including the protocol and domain name. In particular:
To generate a PDF, call the PDF generation JavaScript API by posting to the PDF endpoint. The endpoint is:
/admin/api/v2/pdf/<webvanta api key>/attach
The Webvanta API key is custom to each site. Contact support to get your key.
All of the information about the requested PDF is passed as a array parameter. The fields are:
After calling the endpoint, you will receive back a standard Webvanta Job Status ID (jid) that you can use to poll for updates.
When the PDF generation has successfully completed, you will receive a data field on the status object that is a JSON array of tuples with asset info:
Here's an example of PDF generation code:
$.post("/admin/api/v2/pdf/2ccfecc0e8ed6ec70997cad406c60c0984d1e861/attach",
{
pdfs: [
{path: "/certificate-print-out/{{item}}",
item: "1453541",
attach: {cit_name: "certificate",cit_field: 'pdf', cit_id: 1440810}
]
},
function(d, ts, jq) {
// use the status object (jid) to set up progress and future handling
if (d.status == "ok" && d.jid) {
progress(d.jid, "Generate PDF", "PDF processing", sendEmail);
} else {
console.log("Something is wrong?", d, ts);
}
});
The PDF generator supports the following optional parameters:
The following are references for the underlying code libraries used for this feature.