Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
25 changes: 12 additions & 13 deletions src/core/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1600,6 +1601,7 @@ class Catalog {

case "GoTo":
dest = action.get("D");
sDest = action.get("SD");
break;

case "Launch":
Expand Down Expand Up @@ -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");
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/core/file_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
Expand Down
Loading