]> git.parisson.com Git - pdf.js.git/commitdiff
Disable encryption when a ToUnicode stream is used in a font
authornotmasteryet <async.processingjs@yahoo.com>
Wed, 14 Sep 2011 00:23:49 +0000 (19:23 -0500)
committernotmasteryet <async.processingjs@yahoo.com>
Wed, 14 Sep 2011 00:23:49 +0000 (19:23 -0500)
pdf.js
test/pdfs/artofwar.pdf.link [new file with mode: 0644]
test/test_manifest.json

diff --git a/pdf.js b/pdf.js
index 939d9e21c2c683686ffbc6e4952459b59d86f057..019961f155b3179aac60584ab8fa0fae95685d13 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3185,7 +3185,7 @@ var XRef = (function() {
         return obj;
       return this.fetch(obj);
     },
-    fetch: function(ref) {
+    fetch: function(ref, suppressEncryption) {
       var num = ref.num;
       var e = this.cache[num];
       if (e)
@@ -3216,7 +3216,7 @@ var XRef = (function() {
           }
           error('bad XRef entry');
         }
-        if (this.encrypt) {
+        if (this.encrypt && !suppressEncryption) {
           e = parser.getObj(this.encrypt.createCipherTransform(num, gen));
         } else {
           e = parser.getObj();
@@ -4356,7 +4356,10 @@ var PartialEvaluator = (function() {
       }
 
       if (type == 'TrueType' && dict.has('ToUnicode') && differences) {
-        var cmapObj = xref.fetchIfRef(dict.get('ToUnicode'));
+        var cmapObj = dict.get('ToUnicode');
+        if (IsRef(cmapObj)) {
+          cmapObj = xref.fetch(cmapObj, true);
+        }
         if (IsName(cmapObj)) {
           error('ToUnicode file cmap translation not implemented');
         } else if (IsStream(cmapObj)) {
diff --git a/test/pdfs/artofwar.pdf.link b/test/pdfs/artofwar.pdf.link
new file mode 100644 (file)
index 0000000..f70b9e2
--- /dev/null
@@ -0,0 +1 @@
+http://www.puppetpress.com/classics/ArtofWarbySunTzu.pdf
index 1155195cb1f512879a937521592b9446cc1e6f2d..3734ee9e4c33ccb5005ecdc3e87fe25b0b56977a 100644 (file)
        "link": true,
        "rounds": 1,
        "type": "eq"
+    },
+    {  "id": "artofwar",
+       "file": "pdfs/artofwar.pdf",
+       "link": true,
+       "rounds": 1,
+       "type": "eq"
     }
 ]