A PDF action is similar to a web hyperlink, but it’s much more flexible. PSPDFKit supports most common actions defined in Adobe’s PDF Reference (page 417ff).
PSPDFAction subclass can either be parsed from a PDF or created in code. It can also be serialized via
NSSecureCoding) or serialized/deserialized via
|Action||PSPDFKit Class||Use Case|
||Go to a destination (page) in the current document.|
||Go to a destination in another document.|
||Go to a destination in an embedded file.|
||Launch an application, usually to open a file.|
||Resolve a uniform resource identifier (web link).|
||Set an annotation’s hidden flag.|
||Control the playing of multimedia content.|
||Send data to a uniform resource locator.|
||Set fields to their default values.|
||Execute an action predefined by the conforming reader.|
Unsupported actions include Thread, Sound, Movie, ImportData, SetOCGState, Trans, and GoTo3DView.
Actions are chainable via the
subActions property. Certain annotations, such as the
PSPDFLinkAnnotation and the
PSPDFWidgetAnnotation, can contain an
action. Furthermore, every annotation can contain
additionalActions that are executed on certain trigger events. You can use the
additionalActions property to add actions to annotation types that don’t have an action handler by default, such as stamp annotations. In most cases, the
PSPDFAnnotationTriggerEventMouseUp event is what you want.
PSPDFAnnotationTriggerEvent for available trigger events. PSPDFKit supports a subset of these events.
You can use
-executePDFAction:targetRect:pageIndex:animated:actionContainer: to execute PDF actions, such as the
action property of
pdfController.execute(linkAnnotation.action, targetRect: linkAnnotation.boundingBox, pageIndex: linkAnnotation.absolutePageIndex, animated: true, actionContainer: linkAnnotation)
[pdfController executePDFAction:linkAnnotation.action targetRect:linkAnnotation.boundingBox pageIndex:linkAnnotation.absolutePageIndex animated:YES actionContainer:linkAnnotation];
Note: The file structure for the action has to be correctly specified for it to work. The files in question should be in a local folder.