Handled case where var "outlineDict" was null (in certain PDFs). Handled
case where var "e" was null in "function xRefGetEntry" (in certain PDFs)
This commit is contained in:
parent
6833f64db3
commit
d6cb3cbbd7
66
src/obj.js
66
src/obj.js
@ -134,37 +134,39 @@ var Catalog = (function CatalogClosure() {
|
|||||||
while (queue.length > 0) {
|
while (queue.length > 0) {
|
||||||
var i = queue.shift();
|
var i = queue.shift();
|
||||||
var outlineDict = xref.fetch(i.obj);
|
var outlineDict = xref.fetch(i.obj);
|
||||||
if (!outlineDict.has('Title'))
|
if(outlineDict != null){
|
||||||
error('Invalid outline item');
|
if (!outlineDict.has('Title'))
|
||||||
var dest = outlineDict.get('A');
|
error('Invalid outline item');
|
||||||
if (dest)
|
var dest = outlineDict.get('A');
|
||||||
dest = xref.fetchIfRef(dest).get('D');
|
if (dest)
|
||||||
else if (outlineDict.has('Dest')) {
|
dest = xref.fetchIfRef(dest).get('D');
|
||||||
dest = outlineDict.get('Dest');
|
else if (outlineDict.has('Dest')) {
|
||||||
if (isName(dest))
|
dest = outlineDict.get('Dest');
|
||||||
dest = dest.name;
|
if (isName(dest))
|
||||||
}
|
dest = dest.name;
|
||||||
var title = xref.fetchIfRef(outlineDict.get('Title'));
|
}
|
||||||
var outlineItem = {
|
var title = xref.fetchIfRef(outlineDict.get('Title'));
|
||||||
dest: dest,
|
var outlineItem = {
|
||||||
title: stringToPDFString(title),
|
dest: dest,
|
||||||
color: outlineDict.get('C') || [0, 0, 0],
|
title: stringToPDFString(title),
|
||||||
count: outlineDict.get('Count'),
|
color: outlineDict.get('C') || [0, 0, 0],
|
||||||
bold: !!(outlineDict.get('F') & 2),
|
count: outlineDict.get('Count'),
|
||||||
italic: !!(outlineDict.get('F') & 1),
|
bold: !!(outlineDict.get('F') & 2),
|
||||||
items: []
|
italic: !!(outlineDict.get('F') & 1),
|
||||||
};
|
items: []
|
||||||
i.parent.items.push(outlineItem);
|
};
|
||||||
obj = outlineDict.get('First');
|
i.parent.items.push(outlineItem);
|
||||||
if (isRef(obj) && !processed.has(obj)) {
|
obj = outlineDict.get('First');
|
||||||
queue.push({obj: obj, parent: outlineItem});
|
if (isRef(obj) && !processed.has(obj)) {
|
||||||
processed.put(obj);
|
queue.push({obj: obj, parent: outlineItem});
|
||||||
}
|
processed.put(obj);
|
||||||
obj = outlineDict.get('Next');
|
}
|
||||||
if (isRef(obj) && !processed.has(obj)) {
|
obj = outlineDict.get('Next');
|
||||||
queue.push({obj: obj, parent: i.parent});
|
if (isRef(obj) && !processed.has(obj)) {
|
||||||
processed.put(obj);
|
queue.push({obj: obj, parent: i.parent});
|
||||||
}
|
processed.put(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,6 +571,8 @@ var XRef = (function XRefClosure() {
|
|||||||
},
|
},
|
||||||
getEntry: function xRefGetEntry(i) {
|
getEntry: function xRefGetEntry(i) {
|
||||||
var e = this.entries[i];
|
var e = this.entries[i];
|
||||||
|
if(e == null)
|
||||||
|
return null;
|
||||||
return e.free ? null : e; // returns null is the entry is free
|
return e.free ? null : e; // returns null is the entry is free
|
||||||
},
|
},
|
||||||
fetchIfRef: function xRefFetchIfRef(obj) {
|
fetchIfRef: function xRefFetchIfRef(obj) {
|
||||||
|
Loading…
Reference in New Issue
Block a user