mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-13 18:45:52 +02:00
Use the isDict helper in the Catalog.prototype.metadata getter
This commit is contained in:
parent
124228e318
commit
a46ee2b647
@ -279,19 +279,18 @@ class Catalog {
|
|||||||
/* suppressEncryption = */ !this.xref.encrypt?.encryptMetadata
|
/* suppressEncryption = */ !this.xref.encrypt?.encryptMetadata
|
||||||
);
|
);
|
||||||
|
|
||||||
if (stream instanceof BaseStream && stream.dict instanceof Dict) {
|
if (
|
||||||
const type = stream.dict.get("Type");
|
stream instanceof BaseStream &&
|
||||||
const subtype = stream.dict.get("Subtype");
|
isDict(stream.dict, "Metadata") &&
|
||||||
|
isName(stream.dict.get("Subtype"), "XML")
|
||||||
if (isName(type, "Metadata") && isName(subtype, "XML")) {
|
) {
|
||||||
// XXX: This should examine the charset the XML document defines,
|
// XXX: This should examine the charset the XML document defines,
|
||||||
// however since there are currently no real means to decode arbitrary
|
// however since there are currently no real means to decode arbitrary
|
||||||
// charsets, let's just hope that the author of the PDF was reasonable
|
// charsets, let's just hope that the author of the PDF was reasonable
|
||||||
// enough to stick with the XML default charset, which is UTF-8.
|
// enough to stick with the XML default charset, which is UTF-8.
|
||||||
const data = stringToUTF8String(stream.getString());
|
const data = stringToUTF8String(stream.getString());
|
||||||
if (data) {
|
if (data) {
|
||||||
metadata = new MetadataParser(data).serializable;
|
metadata = new MetadataParser(data).serializable;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user