Function API only Updated 17 Oct 2026
generateDocument(file, template)
Produces a file using the specified template (HTML, PDF etc) and returns it as a byte array. Runs as the user who published the site, not as the visitor.
Parameters
filestringrequiredAbsolute path to file.
templatestringrequiredName of the template to use to generate this file's output.
Returns
The generated file as a byte array. null when file or template is missing, and the text Load failed for '<file>' and template '<template>' when the file does not exist.
Example
Normal JavaScript, running in the browser or on the Docly™ server.
// Generate a PDF and store it in a variable
let data = docly.generateDocument(
"somefile",
"Contract.html.pdf");