PdfScriptPolicy

class PdfScriptPolicy(val enabled: Boolean = true, val budgetMillis: Long, val documentBudgetMillis: Long = 0, val instructionBudget: Int = 0, val onStillRunning: (elapsedMillis: Long) -> Boolean? = null)

What a document's scripts are allowed to do, and for how long.

A script inside a PDF is input from whoever made the file, so nothing runs unless the host says so. This is where that decision lives: whether a document may run scripts at all, how long one event may take, and what happens when a script asks to leave the document, for example by submitting a form or opening a link.

The defaults are the careful ones: scripts run, they stop after a few seconds, and everything that reaches outside the document is refused until the host handles it.

Constructors

Link copied to clipboard
constructor(enabled: Boolean = true, budgetMillis: Long, documentBudgetMillis: Long = 0, instructionBudget: Int = 0, onStillRunning: (elapsedMillis: Long) -> Boolean? = null)

Types

Link copied to clipboard
object Companion

A policy that runs nothing, for a viewer that has not been told to trust the file.

Properties

Link copied to clipboard

How long one event may run before the engine stops it. A form script finishes in milliseconds. A document that does real work in its open script, such as a game, needs a larger budget, and the host is the one that decides to give it.

Link copied to clipboard

How long the whole document may spend in scripts, counted across every event. Zero means no limit beyond the per-event budget.

Link copied to clipboard

Whether this document's scripts run at all. False makes every run a no-op.

Link copied to clipboard

Interpreter steps one call may take, as a second line of defence for a loop that never asks the clock. Zero means the wall clock is the only limit.

Link copied to clipboard
val onStillRunning: (elapsedMillis: Long) -> Boolean?

Called every second or so while a script is still running, so a viewer can offer to stop it.