diff --git a/src/core/annotation.js b/src/core/annotation.js index 5dd7887fc68f5..183be7e5070c6 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -714,6 +714,11 @@ class Annotation { structParent: -1, }; + const name = dict.get("Name"); + if (name instanceof Name) { + this.data.name = stringToPDFString(name.name); + } + if (dict.has("A")) { const actionDict = dict.get("A"); if (actionDict instanceof Dict && actionDict.has("R")) { diff --git a/src/core/catalog.js b/src/core/catalog.js index b32ce42d49618..49e1ac273df02 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -1547,7 +1547,8 @@ class Catalog { let action = destDict.get("A"), url, - dest; + dest, + sDest; if (!(action instanceof Dict)) { if (destDict.has("Dest")) { // A /Dest entry should *only* contain a Name or an Array, but some bad @@ -1600,6 +1601,7 @@ class Catalog { case "GoTo": dest = action.get("D"); + sDest = action.get("SD"); break; case "Launch": @@ -1750,19 +1752,16 @@ class Catalog { } resultObj.unsafeUrl = url; } - if (dest) { - if (dest instanceof Name) { - dest = dest.name; - } - if (typeof dest === "string") { - resultObj.dest = stringToPDFString( - dest, - /* keepEscapeSequence = */ true - ); - } else if (isValidExplicitDest(dest)) { - resultObj.dest = dest; - } + + const parseDest = (d, obj, field = "dest") => { + if (d instanceof Name) d = d.name; + + if (typeof d === "string") obj[field] = stringToPDFString(d, /* keepEscapeSequence = */ true); + else if (isValidExplicitDest(d)) obj[field] = d; } + + if (dest) parseDest(dest, resultObj); + if (sDest) parseDest(sDest, resultObj, "sDest"); } } diff --git a/src/core/file_spec.js b/src/core/file_spec.js index d331af04e93ce..841cbcbfac394 100644 --- a/src/core/file_spec.js +++ b/src/core/file_spec.js @@ -117,12 +117,22 @@ class FileSpec { return shadow(this, "description", description); } + get afRelationship() { + let afRelationship = ""; + + const rel = this.root?.get("AFRelationship"); + if (typeof rel === "string") afRelationship = rel; + else if (rel instanceof Name) afRelationship = rel.name; + return shadow(this, "afRelationship", afRelationship); + } + get serializable() { return { rawFilename: this.filename, filename: stripPath(this.filename), content: this.content, description: this.description, + afRelationship: this.afRelationship, }; } }