PDF actions JSON format schema
Types
This section explains how to use type declarations in Instant JSON records.
The optional keys are specified as follows:
{ optionalKey?: value; }
To save traffic, these keys shouldn’t be included in the record if the value is undefined.
Action types
Only a subset of all possible annotation actions is supported. These can be triggered when clicking or pressing on a link annotation:
// Example of an Instant JSON payload for a `GoToAction` action: { "pageIndex": 0, "type": "goTo" }
declare type BaseAction = { subAction?: Action }; declare type GoToAction = BaseAction & { type: "goTo", // The `pageIndex` you want to go to. pageIndex: number }; declare type GoToRemoteAction = BaseAction & { type: "goToRemote", relativePath: string, namedDestination: string }; declare type GoToEmbeddedAction = BaseAction & { type: "goToEmbedded", newWindow: boolean, relativePath: string, targetType: "parent" | "child" }; declare type LaunchAction = BaseAction & { type: "launch", filePath: string }; declare type URIAction = BaseAction & { type: "uri", // URI, e.g.: `https://pspdfkit.com` uri: string }; declare type AnnotationReference = { fieldName?: string, pdfObjectId?: number }; declare type HideAction = BaseAction & { type: "hide", hide: boolean, annotationReferences: Array<AnnotationReference> }; declare type JavaScriptAction = BaseAction & { type: "javaScript", script: string }; declare type SubmitFormFlags = Array< | "includeExclude" | "includeNoValueFields" | "exportFormat" | "getMethod" | "submitCoordinated" | "xfdf" | "includeAppendSaves" | "includeAnnotations" | "submitPDF" | "canonicalFormat" | "excludeNonUserAnnotations" | "excludeFKey" | "embedForm" >; declare type SubmitFormAction = BaseAction & { type: "submitForm", uri: string, flags: SubmitFormFlags, fields?: Array<AnnotationReference> }; declare type ResetFormAction = BaseAction & { type: "resetForm", flags?: "includeExclude", fields?: Array<AnnotationReference> }; declare type NamedAction = BaseAction & { type: "named", action: | "nextPage" | "prevPage" | "firstPage" | "lastPage" | "goBack" | "goForward" | "goToPage" | "find" | "print" | "outline" | "search" | "brightness" | "zoomIn" | "zoomOut" | "saveAs" | "info" }; declare type Action = | GoToAction | GoToRemoteAction | GoToEmbeddedAction | LaunchAction | URIAction | HideAction | JavaScriptAction | SubmitFormAction | ResetFormAction | NamedAction;