Merge pull request #35 from sbarman/master

Minor fix to dictionary
This commit is contained in:
sbarman 2011-06-21 10:51:50 -07:00
commit 833f785187

16
pdf.js
View File

@ -784,6 +784,16 @@ var Dict = (function() {
get2: function(key1, key2) { get2: function(key1, key2) {
return this.get(key1) || this.get(key2); return this.get(key1) || this.get(key2);
}, },
getOrInherit: function(key, xref) {
var obj = this.map[key];
var dict = this;
while (!obj && dict) {
dict = xref.fetchIfRef(dict.get("Parent"));
if (dict)
obj = dict.get(key);
}
return obj;
},
has: function(key) { has: function(key) {
return key in this.map; return key in this.map;
}, },
@ -1701,10 +1711,11 @@ var Page = (function() {
return shadow(this, "content", this.pageDict.get("Contents")); return shadow(this, "content", this.pageDict.get("Contents"));
}, },
get resources() { get resources() {
return shadow(this, "resources", this.pageDict.get("Resources")); return shadow(this, "resources",
this.pageDict.getOrInherit("Resources", this.xref));
}, },
get mediaBox() { get mediaBox() {
var obj = this.pageDict.get("MediaBox"); var obj = this.pageDict.getOrInherit("MediaBox", this.xref);
return shadow(this, "mediaBox", ((IsArray(obj) && obj.length == 4) return shadow(this, "mediaBox", ((IsArray(obj) && obj.length == 4)
? obj ? obj
: null)); : null));
@ -2154,6 +2165,7 @@ var CanvasGraphics = (function() {
S: "stroke", S: "stroke",
s: "closeStroke", s: "closeStroke",
f: "fill", f: "fill",
F: "fill",
"f*": "eoFill", "f*": "eoFill",
B: "fillStroke", B: "fillStroke",
"B*": "eoFillStroke", "B*": "eoFillStroke",