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

[api-minor] Implement API to get MarkInfo from the catalog.

This commit is contained in:
Brendan Dahl 2020-10-23 16:30:36 -07:00
parent 8cf27494b3
commit f5c821e9c3
4 changed files with 84 additions and 0 deletions

View file

@ -152,6 +152,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) {