1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Merge pull request #12525 from brendandahl/mark-info

[api-minor] Implement API to get MarkInfo from the catalog.
This commit is contained in:
Tim van der Meij 2020-10-31 00:05:19 +01:00 committed by GitHub
commit e341e6e542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 116 additions and 0 deletions

View file

@ -153,6 +153,47 @@ class Catalog {
return shadow(this, "metadata", metadata);
}
get markInfo() {
let markInfo = null;
try {
markInfo = this._readMarkInfo();
} catch (ex) {
if (ex instanceof MissingDataException) {
throw ex;
}
warn("Unable to read mark info.");
}
return shadow(this, "markInfo", markInfo);
}
/**
* @private
*/
_readMarkInfo() {
const obj = this._catDict.get("MarkInfo");
if (!isDict(obj)) {
return null;
}
const markInfo = Object.assign(Object.create(null), {
Marked: false,
UserProperties: false,
Suspects: false,
});
for (const key in markInfo) {
if (!obj.has(key)) {
continue;
}
const value = obj.get(key);
if (!isBool(value)) {
continue;
}
markInfo[key] = value;
}
return markInfo;
}
get toplevelPagesDict() {
const pagesObj = this._catDict.get("Pages");
if (!isDict(pagesObj)) {

View file

@ -499,6 +499,10 @@ class WorkerMessageHandler {
]);
});
handler.on("GetMarkInfo", function wphSetupGetMarkInfo(data) {
return pdfManager.ensureCatalog("markInfo");
});
handler.on("GetData", function wphSetupGetData(data) {
pdfManager.requestLoadedStream();
return pdfManager.onLoadedStream().then(function (stream) {