Font and XObject entries can be refs, and dump image magic bytes

This commit is contained in:
Chris Jones 2011-06-02 14:24:46 -05:00
parent 9b9a258a57
commit ebc483a0c7
2 changed files with 12 additions and 1 deletions

12
pdf.js
View File

@ -2129,6 +2129,7 @@ var CanvasGraphics = (function() {
this.xref = xref; this.xref = xref;
this.res = resources || new Dict(); this.res = resources || new Dict();
this.xobjs = this.res.get("XObject") || new Dict(); this.xobjs = this.res.get("XObject") || new Dict();
this.xobjs = this.xref.fetchIfRef(this.xobjs);
var args = []; var args = [];
var map = this.map; var map = this.map;
@ -2252,7 +2253,11 @@ var CanvasGraphics = (function() {
endText: function() { endText: function() {
}, },
setFont: function(fontRef, size) { setFont: function(fontRef, size) {
var font = this.res.get("Font").get(fontRef.name); var fontRes = this.res.get("Font");
if (!fontRes)
return;
fontRes = this.xref.fetchIfRef(fontRes);
var font = fontRes.get(fontRef.name);
if (!font) if (!font)
return; return;
this.current.fontSize = size; this.current.fontSize = size;
@ -2353,6 +2358,11 @@ var CanvasGraphics = (function() {
var type = xobj.dict.get("Subtype"); var type = xobj.dict.get("Subtype");
assertWellFormed(IsName(type), "XObject should have a Name subtype"); assertWellFormed(IsName(type), "XObject should have a Name subtype");
if ("Image" == type.name) { if ("Image" == type.name) {
var magic = "";
for (var i = 0; i < 8; ++i)
magic += xobj.bytes[i].toString(16) +" ";
console.log("Image magic bytes: "+ magic);
TODO("Image XObjects"); TODO("Image XObjects");
} else if ("Form" == type.name) { } else if ("Form" == type.name) {
this.paintFormXObject(xobj); this.paintFormXObject(xobj);

View File

@ -41,6 +41,7 @@ function load() {
pageDisplay = document.getElementById("pageNumber"); pageDisplay = document.getElementById("pageNumber");
infoDisplay = document.getElementById("info"); infoDisplay = document.getElementById("info");
open("uncompressed.tracemonkey-pldi-09.pdf"); open("uncompressed.tracemonkey-pldi-09.pdf");
// open("uncompressed.report.pdf");
} }
function open(url) { function open(url) {