From 2e83b0cc0d682ab2f7d6c7d6388da312c15f5e95 Mon Sep 17 00:00:00 2001 From: sbarman Date: Tue, 5 Jul 2011 11:10:14 -0500 Subject: [PATCH 1/5] Fixes to parser for the test pdf in www.unicode.org/charts --- pdf.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index 5644bf036..c34bc76ed 100644 --- a/pdf.js +++ b/pdf.js @@ -2236,6 +2236,9 @@ var Lexer = (function() { var stream = this.stream; var ch; while (true) { + if (!stream.getChar) + log("bad stream"); + if (!(ch = stream.getChar())) return EOF; if (comment) { @@ -2842,7 +2845,7 @@ var Page = (function() { constructor.prototype = { getPageProp: function(key) { - return this.pageDict.get(key); + return this.xref.fetchIfRef(this.pageDict.get(key)); }, inheritPageProp: function(key) { var dict = this.pageDict; @@ -3579,6 +3582,7 @@ var CanvasGraphics = (function() { }, compile: function(stream, xref, resources, fonts) { + resources = xref.fetchIfRef(resources) || new Dict(); var xobjs = xref.fetchIfRef(resources.get("XObject")) || new Dict(); var parser = new Parser(new Lexer(stream), false); From 28a01646bb40328c29593e0d221e3e9817685c86 Mon Sep 17 00:00:00 2001 From: sbarman Date: Tue, 5 Jul 2011 11:13:53 -0500 Subject: [PATCH 2/5] cleanup --- pdf.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/pdf.js b/pdf.js index c34bc76ed..ea28ca647 100644 --- a/pdf.js +++ b/pdf.js @@ -2236,9 +2236,6 @@ var Lexer = (function() { var stream = this.stream; var ch; while (true) { - if (!stream.getChar) - log("bad stream"); - if (!(ch = stream.getChar())) return EOF; if (comment) { From 7d3e08eefd57df07a86910d88f04f14e95e4ce78 Mon Sep 17 00:00:00 2001 From: sbarman Date: Tue, 5 Jul 2011 11:44:26 -0500 Subject: [PATCH 3/5] bug with length of lookup table --- pdf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index 5644bf036..5743876d6 100644 --- a/pdf.js +++ b/pdf.js @@ -4452,7 +4452,7 @@ var ColorSpace = (function() { break; case "Indexed": var base = ColorSpace.parse(cs[1], xref, res); - var hiVal = cs[2]; + var hiVal = cs[2] + 1; var lookup = xref.fetchIfRef(cs[3]); return new IndexedCS(base, hiVal, lookup); case "Lab": From e8f98f4e16ba01976a81f21dc0426b8d6ae616aa Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 5 Jul 2011 13:21:28 -0400 Subject: [PATCH 4/5] add unicode test --- test/pdfs/shavian.pdf.link | 1 + test/test_manifest.json | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 test/pdfs/shavian.pdf.link diff --git a/test/pdfs/shavian.pdf.link b/test/pdfs/shavian.pdf.link new file mode 100644 index 000000000..42c438644 --- /dev/null +++ b/test/pdfs/shavian.pdf.link @@ -0,0 +1 @@ +http://www.unicode.org/charts/PDF/U10450.pdf \ No newline at end of file diff --git a/test/test_manifest.json b/test/test_manifest.json index 06787925f..4302e1f6e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -26,6 +26,12 @@ "rounds": 1, "type": "load" }, + { "id": "shavian-load", + "file": "pdfs/shavian.pdf", + "link": true, + "rounds": 1, + "type": "load" + }, { "id": "sizes", "file": "pdfs/sizes.pdf", "rounds": 1, From b1f717cb7f22247249b1b41e052e651e57f93cf0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 5 Jul 2011 18:46:08 -0400 Subject: [PATCH 5/5] get shavian-load test working --- crypto.js | 4 ++-- pdf.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto.js b/crypto.js index e888d0212..d73408ad6 100644 --- a/crypto.js +++ b/crypto.js @@ -139,9 +139,9 @@ var CipherTransform = (function() { }, decryptString: function(s) { var cipher = new this.stringCipherConstructor(); - var data = string2bytes(s); + var data = stringToBytes(s); data = cipher.encryptBlock(data); - return bytes2string(data); + return bytesToString(data); } }; return constructor; diff --git a/pdf.js b/pdf.js index f7a3359de..a9f0ee935 100644 --- a/pdf.js +++ b/pdf.js @@ -3566,6 +3566,7 @@ var CanvasGraphics = (function() { }, execute: function(code, xref, resources) { + resources = xref.fetchIfRef(resources) || new Dict(); var savedXref = this.xref, savedRes = this.res, savedXobjs = this.xobjs; this.xref = xref; this.res = resources || new Dict();