mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Add better support for /Launch actions with /FileSpec dictionaries (issue 17846)
This commit is contained in:
parent
1141af9d6f
commit
0d039937f9
5 changed files with 38 additions and 9 deletions
|
@ -1568,9 +1568,13 @@ class Catalog {
|
|||
case "GoToR":
|
||||
const urlDict = action.get("F");
|
||||
if (urlDict instanceof Dict) {
|
||||
// We assume that we found a FileSpec dictionary
|
||||
// and fetch the URL without checking any further.
|
||||
url = urlDict.get("F") || null;
|
||||
const fs = new FileSpec(
|
||||
urlDict,
|
||||
/* xref = */ null,
|
||||
/* skipContent = */ true
|
||||
);
|
||||
const { filename } = fs.serializable;
|
||||
url = filename;
|
||||
} else if (typeof urlDict === "string") {
|
||||
url = urlDict;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ function pickPlatformItem(dict) {
|
|||
* collections attributes and related files (/RF)
|
||||
*/
|
||||
class FileSpec {
|
||||
constructor(root, xref) {
|
||||
#contentAvailable = false;
|
||||
|
||||
constructor(root, xref, skipContent = false) {
|
||||
if (!(root instanceof Dict)) {
|
||||
return;
|
||||
}
|
||||
|
@ -57,10 +59,12 @@ class FileSpec {
|
|||
if (root.has("RF")) {
|
||||
warn("Related file specifications are not supported");
|
||||
}
|
||||
this.contentAvailable = true;
|
||||
if (!root.has("EF")) {
|
||||
this.contentAvailable = false;
|
||||
warn("Non-embedded file specifications are not supported");
|
||||
if (!skipContent) {
|
||||
if (root.has("EF")) {
|
||||
this.#contentAvailable = true;
|
||||
} else {
|
||||
warn("Non-embedded file specifications are not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +80,7 @@ class FileSpec {
|
|||
}
|
||||
|
||||
get content() {
|
||||
if (!this.contentAvailable) {
|
||||
if (!this.#contentAvailable) {
|
||||
return null;
|
||||
}
|
||||
if (!this.contentRef && this.root) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue