]> git.parisson.com Git - pdf.js.git/commitdiff
Working towards embedded image support
authorJulian Viereck <julian.viereck@gmail.com>
Tue, 6 Sep 2011 01:41:11 +0000 (18:41 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 15:20:42 +0000 (08:20 -0700)
pdf.js
worker/boot.js

diff --git a/pdf.js b/pdf.js
index 4deb1f93408e3b39d103e023f2a052c42b484a06..f12f2213a14819ebe3b83a963460fb866cad8b15 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -4251,12 +4251,33 @@ var PartialEvaluator = (function() {
               );
 
               if ('Form' == type.name) {
-                args[0].code = this.evaluate(xobj, xref,
-                                             xobj.dict.get('Resources'), fonts,
-                                             images);
+                // console.log("got xobj that is a Form");
+                args[0].code = this.eval(xobj, xref, xobj.dict.get('Resources'),
+                                         fonts, images);
               }
-              if (xobj instanceof JpegStream)
+              if (xobj instanceof JpegStream) {
                 images.bind(xobj); // monitoring image load
+                // console.log("got xobj that is a JpegStream");
+              }
+              
+              if (xobj.dict.get('Subtype').name == "Image") {
+                // Check if we have an image that is not rendered by the platform.
+                // Needs to be rendered ourself.
+                if (!(xobj instanceof JpegStream)) {
+                  var image = xobj;
+                  var dict = image.dict;
+                  var w = dict.get('Width', 'W');
+                  var h = dict.get('Height', 'H');
+                  
+                  var inline = false;
+                  
+                  var imageObj = new PDFImage(xref, resources, image, inline);
+                  
+                  console.log("xobj subtype image", w, h, imageObj.imageMask);
+                }
+              }
+              console.log("xobj subtype", xobj.dict.get('Subtype').name);
+
             }
           } else if (cmd == 'Tf') { // eagerly collect all fonts
             var fontName = args[0].name;
@@ -4285,6 +4306,14 @@ var PartialEvaluator = (function() {
             }
           }
 
+          var skips = ["paintXObject"];
+
+          if (skips.indexOf(fn) != -1) {
+            // console.log("skipping", fn);
+            args = [];
+            continue;
+          }
+
           fnArray.push(fn);
           argsArray.push(args);
           args = [];
index da09f21c509903d21dd3469fea8a4db3c2f1e3cd..57314c13f1530b63888b87ff096929080a508400 100644 (file)
@@ -50,6 +50,20 @@ var handler = new MessageHandler("worker", {
     
     // TODO: Handle images here.
     
+    console.log("about to send page", pageNum);
+    
+    // Make a copy of the fnArray and show all cmds it has.
+    var fnArray = preCompilation.fnArray.slice(0).sort();
+    for (var i = 0; i < fnArray.length; true) {
+      if (fnArray[i] == fnArray[i + 1]) {
+        fnArray.splice(i, 1);
+      } else {
+        i++;
+      }
+    }
+    console.log("cmds", fnArray);
+    
+    
     handler.send("page", {
       pageNum:        pageNum,
       fonts:          fontsMin,