]> git.parisson.com Git - pdf.js.git/commitdiff
Font and XObject entries can be refs, and dump image magic bytes
authorChris Jones <jones.chris.g@gmail.com>
Thu, 2 Jun 2011 19:24:46 +0000 (14:24 -0500)
committerChris Jones <jones.chris.g@gmail.com>
Thu, 2 Jun 2011 19:24:46 +0000 (14:24 -0500)
pdf.js
test.html

diff --git a/pdf.js b/pdf.js
index 8ac26e93246fa1104c9b2b3a753920516a5cf388..061be93c5f6d2838a01aebdb32072e02689c7d94 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -2129,6 +2129,7 @@ var CanvasGraphics = (function() {
             this.xref = xref;
             this.res = resources || new Dict();
             this.xobjs = this.res.get("XObject") || new Dict();
+            this.xobjs = this.xref.fetchIfRef(this.xobjs);
 
             var args = [];
             var map = this.map;
@@ -2252,7 +2253,11 @@ var CanvasGraphics = (function() {
         endText: function() {
         },
         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)
                 return;
             this.current.fontSize = size;
@@ -2353,6 +2358,11 @@ var CanvasGraphics = (function() {
             var type = xobj.dict.get("Subtype");
             assertWellFormed(IsName(type), "XObject should have a Name subtype");
             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");
             } else if ("Form" == type.name) {
                 this.paintFormXObject(xobj);
index 10a35e16359074aa95a454d965a725d3cf488d4e..0d7d8ce8e80ce9fc3d1c167533c987f5ec7165d4 100644 (file)
--- a/test.html
+++ b/test.html
@@ -41,6 +41,7 @@ function load() {
     pageDisplay = document.getElementById("pageNumber");
     infoDisplay = document.getElementById("info");
     open("uncompressed.tracemonkey-pldi-09.pdf");
+//    open("uncompressed.report.pdf");
 }
 
 function open(url) {