Output functions

Basic functions for output and formatting.

pro­ces­s(script, cursor)

Executes a Docly script string and returns its output. Requires specific access granted, due to risk of producing unintended back doors.…

con­sole­.a­sser­t(condition, message)

This function checks if a certain condition is false. If it is, outputs an error message and throws an exception with the message.

set­Con­ten­tDis­posi­t­io­n(type, filename)

Tells the browser to download and save the returned result to a file with the specified name.

html­ToXl­sx(filename, html)

Converts an HTML table to an Excel file (XLSX).

html­ToPd­f(filename, html, usePrintCss)

Converts html to a PDF file using headless Chrome.

ba­se6­4(data)

Converts data to base64 encoded string.

set­Mime(mime)

Allows user to set the mime type of a response.

re­pairHt­ml(html)

Parses and repairs an HTML string by adding missing end tags, closing quotes, and fixing malformed markup. Returns a valid, well-formed…

sca­leI­mag­e(bytes, width, height, options)

Scales an image byte array to a target size and returns the scaled image as bytes. Supports several scaling modes and lets you preserve or…

wri­te(text)

Outputs specified text to page content, same as write in javascript. Note that for API functions the output will not be returned to the…

set­Resul­tCo­de(code)

Sets the HTTP result code for the response. This function is used to specify the HTTP status code that should be returned to the client.

get­Hea­der(name)

Reads a header value from the request.

set­Hea­der(name, value)

Sets a header value in the response.

re­ques­t

Get information about the current request from the request object.

for­mat(value, format)

Formats a number or date into a string by given format.

For­mat­tin­g num­ber­s

Information about formatting numbers with the Docly format function.

HTML.­for­m­at(html)

Returns specified HTML string formatted as "prettified" indented HTML.

JSON.­for­m­at(json)

Outputs specified JSON string to "prettified" indented JSON.

re­direc­t(url)

Redirects browser to specified url.

JSON.­par­s­e(json)

Parses a JSON string into an object.

JSON.st­r­in­gify(value)

Converts a JavaScript object or value to a JSON string.

con­sole.­l­og(text)

Outputs specified text to your user's log, same as in JavaScript. You can find your log on your account page in Docly.

set­Cul­tur­e(culture)

Sets culture to use when formatting dates and numbers.

text­ToHt­ml(text)

Converts input text to HTML (line breaks and encoding chars).

Ch­r(code, ...)

Returns character of specified number. Can take multiple values.

as­setUr­l(path)

Returns a versioned URL for a static asset so the browser fetches a fresh copy after each publish (cache-busting). Typically used in…

se­tExe­cut­ion­Timeo­ut(timeout)

Sets the maximum server side execution timeout for API functions. Can be set up to a maximum of 10 minutes (600000 milliseconds). Note:…