[api-minor] Add partial support for the "GoToE" action (issue 8844)

*Please note:* The referenced issue is the only mention that I can find, in either GitHub or Bugzilla, of "GoToE" actions.
Hence why I've purposely settled for a very simple, and partial, "GoToE" implementation to avoid complicating things initially.[1] In particular, this patch only supports "GoToE" actions that references the /EmbeddedFiles-dict in the PDF document.

See https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2048909

---
[1] Usually I always prefer having *real-world* test-cases to work with, whenever I'm implementing new features.
This commit is contained in:
Jonas Jenwald 2022-10-03 17:55:13 +02:00
parent 8c59cc72a3
commit ce66fefbff
8 changed files with 97 additions and 3 deletions

View file

@ -595,6 +595,9 @@ class LinkAnnotationElement extends AnnotationElement {
} else if (data.action) {
this._bindNamedAction(link, data.action);
isBound = true;
} else if (data.attachment) {
this._bindAttachment(link, data.attachment);
isBound = true;
} else if (data.setOCGState) {
this.#bindSetOCGState(link, data.setOCGState);
isBound = true;
@ -679,6 +682,24 @@ class LinkAnnotationElement extends AnnotationElement {
link.className = "internalLink";
}
/**
* Bind attachments to the link element.
* @param {Object} link
* @param {Object} attachment
*/
_bindAttachment(link, attachment) {
link.href = this.linkService.getAnchorUrl("");
link.onclick = () => {
this.downloadManager?.openOrDownloadData(
this.container,
attachment.content,
attachment.filename
);
return false;
};
link.className = "internalLink";
}
/**
* Bind SetOCGState actions to the link element.
* @param {Object} link