Update PDFDocument._getLinearizationPage
to do the /Type-check correctly (PR 14400 follow-up)
I forgot about this in PR 14400, since we should obviously be consistent *and* given that the existing check is actually wrong; sorry about this!
This commit is contained in:
parent
b99927e1ee
commit
a20393e6e4
@ -1264,7 +1264,7 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _getLinearizationPage(pageIndex) {
|
async _getLinearizationPage(pageIndex) {
|
||||||
const { catalog, linearization } = this;
|
const { catalog, linearization, xref } = this;
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev === "undefined" ||
|
typeof PDFJSDev === "undefined" ||
|
||||||
PDFJSDev.test("!PRODUCTION || TESTING")
|
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||||
@ -1277,22 +1277,25 @@ class PDFDocument {
|
|||||||
|
|
||||||
const ref = Ref.get(linearization.objectNumberFirst, 0);
|
const ref = Ref.get(linearization.objectNumberFirst, 0);
|
||||||
try {
|
try {
|
||||||
const obj = await this.xref.fetchAsync(ref);
|
const obj = await xref.fetchAsync(ref);
|
||||||
// Ensure that the object that was found is actually a Page dictionary.
|
// Ensure that the object that was found is actually a Page dictionary.
|
||||||
if (
|
if (obj instanceof Dict) {
|
||||||
isDict(obj, "Page") ||
|
let type = obj.getRaw("Type");
|
||||||
(isDict(obj) && !obj.has("Type") && obj.has("Contents"))
|
if (type instanceof Ref) {
|
||||||
) {
|
type = await xref.fetchAsync(type);
|
||||||
if (ref && !catalog.pageKidsCountCache.has(ref)) {
|
}
|
||||||
catalog.pageKidsCountCache.put(ref, 1); // Cache the Page reference.
|
if (isName(type, "Page") || (!obj.has("Type") && !obj.has("Kids"))) {
|
||||||
|
if (ref && !catalog.pageKidsCountCache.has(ref)) {
|
||||||
|
catalog.pageKidsCountCache.put(ref, 1); // Cache the Page reference.
|
||||||
|
}
|
||||||
|
return [obj, ref];
|
||||||
}
|
}
|
||||||
return [obj, ref];
|
|
||||||
}
|
}
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
"The Linearization dictionary doesn't point to a valid Page dictionary."
|
"The Linearization dictionary doesn't point to a valid Page dictionary."
|
||||||
);
|
);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
info(reason);
|
warn(`_getLinearizationPage: "${reason.message}".`);
|
||||||
return catalog.getPageDict(pageIndex);
|
return catalog.getPageDict(pageIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user