}
function error(msg) {
+ console.log(backtrace());
throw new Error(msg);
}
malformed(msg);
}
+function backtrace() {
+ var stackStr;
+ try {
+ throw new Error();
+ } catch(e) {
+ stackStr = e.stack;
+ };
+ return stackStr.split('\n').slice(1).join('\n');
+}
+
function shadow(obj, prop, value) {
Object.defineProperty(obj, prop, { value: value, enumerable: true, configurable: true, writable: false });
return value;
return this.fetch(obj);
},
fetch: function(ref) {
+
+
+ if ("undefined" == typeof ref) {
+ console.log(backtrace());
+ }
+
+
var num = ref.num;
var e = this.cache[num];
if (e)
return shadow(this, 'mediaBox',
((IsArray(obj) && obj.length == 4) ? obj : null));
},
- startRendering: function(canvasCtx, continuation) {
+ startRendering: function(canvasCtx, continuation, onerror) {
var self = this;
var stats = self.stats;
stats.compile = stats.fonts = stats.render = 0;
// Always defer call to display() to work around bug in
// Firefox error reporting from XHR callbacks.
setTimeout(function () {
- self.display(gfx);
- stats.render = Date.now();
- continuation();
+ var exc = null;
+ try {
+ self.display(gfx);
+ stats.render = Date.now();
+ } catch (e) {
+ exc = e.toString();
+ }
+ continuation(exc);
});
});
},
if (!df)
return null;
compositeFont = true;
- descendant = xref.fetch(df[0]);
+
+ if (IsRef(df)) {
+ df = xref.fetch(df);
+ }
+
+ descendant = xref.fetch(IsRef(df) ? df : df[0]);
subType = descendant.get('Subtype');
fd = descendant.get('FontDescriptor');
} else {
};
constructor.parse = function colorspace_parse(cs, xref, res) {
+
+
+
+ if ("undefined" == typeof(cs))
+ console.log(backtrace());
+
+
+
+
if (IsName(cs)) {
var colorSpaces = res.get('ColorSpace');
if (colorSpaces) {
case 'Lab':
case 'DeviceN':
default:
- error("unrecognized color space object '" + mode + "'");
+ error("unimplemented color space object '" + mode + "'");
}
} else {
- error('unrecognized color space object');
+ error('unrecognized color space object: "'+ cs +"'");
}
};
this.bpc = bitsPerComponent;
var colorSpace = dict.get('ColorSpace', 'CS');
+ if (!colorSpace) {
+ TODO('JPX images (which don"t require color spaces');
+ colorSpace = new Name('DeviceRGB');
+ }
this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
this.numComps = this.colorSpace.numComps;