Docly Developers
Function API only Updated 17 Oct 2026

download(file, template, [preview])

Produces a file using the specified template (HTML, PDF etc) and initiates the file download in the browser. Runs as the user who published the site, not as the visitor.

Parameters

filestringrequired

Absolute path to file.

templatestringrequired

Name of the template to use to generate this file's download.

previewbooloptional

Default false, returns a preview and not a download. Meaning it will show / preview in the browser.

Returns

Starts the file download and stops the script. Returns 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 download for a specific Docly document
docly.download("somefile", "Template name.html.pdf");