PdfScriptHandler

What a viewer needs from a document's scripts, without knowing how they run.

kitepdf-javascript implements this over KiteJS, and a host may implement it over any other engine. The viewer talks to this interface only, so an app that shows PDFs does not carry a JavaScript engine unless it asks for one.

Every method is allowed to do nothing: a handler that runs no scripts is a valid handler, and a viewer with no handler behaves as it always did.

Properties

Link copied to clipboard
abstract val formState: PdfFormState

Where the form's live values are, which the viewer draws and the scripts write.

Link copied to clipboard
open val hasTimers: Boolean

True when a script is waiting on a timer.

Functions

Link copied to clipboard
open fun blur(fieldName: String)

A field lost the caret.

Link copied to clipboard
open fun commit(fieldName: String, value: String): Boolean

The reader finished with a field, so its value is committed: validate, store, recalculate and format. Returns false when a script refused the value.

Link copied to clipboard
open fun documentOpened()

The document opened: run its own scripts and its open action.

Link copied to clipboard
open fun focus(fieldName: String)

A field took the caret.

Link copied to clipboard
open fun keystroke(fieldName: String, change: String, selectionStart: Int, selectionEnd: Int): String?

The reader typed into a field. change is what is being inserted, replacing the text between selectionStart and selectionEnd.

Link copied to clipboard
open fun mouseDown(fieldName: String)

A pointer went down on a widget.

Link copied to clipboard
open fun mouseUp(fieldName: String)

A pointer came up on a widget.

Link copied to clipboard
open fun pageClosed(pageIndex: Int)

The reader left this page: run its close script.

Link copied to clipboard
open fun pageOpened(pageIndex: Int)

The reader reached this page: run its open script.

Link copied to clipboard
open fun pumpTimers(nowMillis: Long): Long?

Runs the timers a script set, and answers how long to wait before the next one, or null when none is waiting. The viewer calls this once a frame while hasTimers is true.

Link copied to clipboard

The reader tapped something whose action is a script, such as a link.