mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
[api-minor] Expose the /Desc-attribute of file attachments in the viewer (issue 18030)
In the viewer this will be displayed in the `title` of the hyperlink, which is probably the best we can do here given how the viewer is implemented.
This commit is contained in:
parent
1241758605
commit
bf4e36d1b5
7 changed files with 48 additions and 12 deletions
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { stringToPDFString, warn } from "../shared/util.js";
|
||||
import { shadow, stringToPDFString, warn } from "../shared/util.js";
|
||||
import { BaseStream } from "./base_stream.js";
|
||||
import { Dict } from "./primitives.js";
|
||||
|
||||
|
@ -53,9 +53,6 @@ class FileSpec {
|
|||
if (root.has("FS")) {
|
||||
this.fs = root.get("FS");
|
||||
}
|
||||
this.description = root.has("Desc")
|
||||
? stringToPDFString(root.get("Desc"))
|
||||
: "";
|
||||
if (root.has("RF")) {
|
||||
warn("Related file specifications are not supported");
|
||||
}
|
||||
|
@ -102,10 +99,21 @@ class FileSpec {
|
|||
return content;
|
||||
}
|
||||
|
||||
get description() {
|
||||
let description = "";
|
||||
|
||||
const desc = this.root?.get("Desc");
|
||||
if (desc && typeof desc === "string") {
|
||||
description = stringToPDFString(desc);
|
||||
}
|
||||
return shadow(this, "description", description);
|
||||
}
|
||||
|
||||
get serializable() {
|
||||
return {
|
||||
filename: this.filename,
|
||||
content: this.content,
|
||||
description: this.description,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue