[Pkg-javascript-commits] [pdf.js] 161/207: Added paintJpegXObject

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 7efd50e64db991ddec75ed50475ee47b0ad25b45
Author: pramodhkp <prmdh1 at gmail.com>
Date:   Wed Jun 25 01:54:00 2014 +0530

    Added paintJpegXObject
---
 examples/svgviewer/viewer.js |  2 +-
 src/display/svg.js           | 29 +++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/examples/svgviewer/viewer.js b/examples/svgviewer/viewer.js
index ceb1bb5..e05807a 100644
--- a/examples/svgviewer/viewer.js
+++ b/examples/svgviewer/viewer.js
@@ -53,7 +53,7 @@ PDFJS.getDocument(url).then(function(pdf) {
         };
         // the next page fetch will start only after this page rendering is done
         return page.getOperatorList().then(function (opList) {
-          var svgGfx = new SVGGraphics(page.commonObjs);
+          var svgGfx = new SVGGraphics(page.commonObjs, page.objs);
           return svgGfx.loadDependencies(opList).then(function (values) {
             return svgGfx.beginDrawing(renderContext.viewport,
               renderContext.pageNum, renderContext.container, opList);
diff --git a/src/display/svg.js b/src/display/svg.js
index fcfe58f..60d2ac0 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -104,18 +104,20 @@ function opListToTree(opList) {
 
 
 var SVGGraphics = (function SVGGraphicsClosure(ctx) {
-  function SVGGraphics(commonObjs) {
+  function SVGGraphics(commonObjs, objs) {
 
     this.current = new SVGExtraState();
     this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix
     this.transformStack = [];
     this.extraStack = [];
     this.commonObjs = commonObjs;
+    this.objs = objs;
     this.pendingEOFill = false;
   }
 
   var NS = 'http://www.w3.org/2000/svg';
   var XML_NS = 'http://www.w3.org/XML/1998/namespace';
+  var XLINK_NS = 'http://www.w3.org/1999/xlink';
   var LINE_CAP_STYLES = ['butt', 'round', 'square'];
   var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
   var NORMAL_CLIP = {};
@@ -157,10 +159,15 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
           for (var n = 0, nn = deps.length; n < nn; n++) {
             var obj = deps[n];
             var common = obj.substring(0, 2) === 'g_';
+            var promise;
             if (common) {
-              var promise = new Promise(function(resolve) {
+              promise = new Promise(function(resolve) {
                 self.commonObjs.get(obj, resolve);
               });
+            } else {
+              promise = new Promise(function(resolve) {
+                self.objs.get(obj, resolve);
+              });
             }
             this.current.dependencies.push(promise);
           }
@@ -303,6 +310,9 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
           case OPS.paintSolidColorImageMask:
             this.paintSolidColorImageMask();
             break;
+          case OPS.paintJpegXObject:
+            this.paintJpegXObject(args[0], args[1], args[2]);
+            break;
           case OPS.closePath:
             this.closePath();
             break;
@@ -684,6 +694,21 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
         rect.setAttributeNS(null, 'fill', current.fillColor);
         this.tgrp.appendChild(rect);
     },
+
+    paintJpegXObject:
+     function SVGGraphics_paintJpegXObject(objId, w, h) {
+       var current = this.current;
+       var imgObj = this.objs.get(objId);
+       var imgEl = document.createElementNS(NS, 'svg:image');
+       imgEl.setAttributeNS(XLINK_NS, 'href', imgObj.src);
+       imgEl.setAttributeNS(null, 'width', imgObj.width);
+       imgEl.setAttributeNS(null, 'height', imgObj.height);
+       imgEl.setAttributeNS(null, 'x', 0);
+       imgEl.setAttributeNS(null, 'y', -h);
+       imgEl.setAttributeNS(null, 'transform', 'scale(' + 1 / w +
+        ' ' + -1 / h + ')');
+       this.tgrp.appendChild(imgEl);
+    },
   };
   return SVGGraphics;
 })();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list