From baab676b00c4999440864738742bc27dfff12d64 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Thu, 29 Dec 2011 22:53:25 -0600 Subject: [PATCH 1/4] Fix stitching function --- src/function.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/function.js b/src/function.js index 6b0063218..33bdf8642 100644 --- a/src/function.js +++ b/src/function.js @@ -270,7 +270,6 @@ var PDFFunction = (function PDFFunctionClosure() { constructStiched: function pdfFunctionConstructStiched(fn, dict, xref) { var domain = dict.get('Domain'); - var range = dict.get('Range'); if (!domain) error('No domain'); @@ -279,13 +278,13 @@ var PDFFunction = (function PDFFunctionClosure() { if (inputSize != 1) error('Bad domain for stiched function'); - var fnRefs = dict.get('Functions'); + var fnRefs = xref.fetchIfRef(dict.get('Functions')); var fns = []; for (var i = 0, ii = fnRefs.length; i < ii; ++i) fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i]))); - var bounds = dict.get('Bounds'); - var encode = dict.get('Encode'); + var bounds = xref.fetchIfRef(dict.get('Bounds')); + var encode = xref.fetchIfRef(dict.get('Encode')); return [CONSTRUCT_STICHED, domain, bounds, encode, fns]; }, From 3f286803d0cad3eacf4f44beed2f13b55995ec90 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Fri, 30 Dec 2011 16:45:33 -0600 Subject: [PATCH 2/4] Move the media left-top corner to the (0,0) canvas position --- src/canvas.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/canvas.js b/src/canvas.js index 00858c937..7221b72cb 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -255,6 +255,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { } // Scale so that canvas units are the same as PDF user space units this.ctx.scale(cw / mediaBox.width, ch / mediaBox.height); + // Move the media left-top corner to the (0,0) canvas position + this.ctx.translate(-mediaBox.x, -mediaBox.y); this.textDivs = []; this.textLayerQueue = []; }, From 47ab238c4ccdeeda94e52fec7dd6d1f4a0f518f2 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Fri, 30 Dec 2011 16:55:30 -0600 Subject: [PATCH 3/4] Add external ref test --- test/pdfs/issue1001.pdf.link | 1 + test/test_manifest.json | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 test/pdfs/issue1001.pdf.link diff --git a/test/pdfs/issue1001.pdf.link b/test/pdfs/issue1001.pdf.link new file mode 100644 index 000000000..24e1bebc2 --- /dev/null +++ b/test/pdfs/issue1001.pdf.link @@ -0,0 +1 @@ +http://www.myhillsapartment.com/island_club/floorplans/images/links/Island_IC_brochure.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 5a1efd75d..8bc000b3d 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -356,6 +356,13 @@ "rounds": 1, "type": "eq" }, + { "id": "issue1001", + "file": "pdfs/issue1001.pdf", + "md5": "0f1496e80a82a923e91d9e74c55ad94e", + "rounds": 1, + "link": true, + "type": "eq" + }, { "id": "aboutstacks", "file": "pdfs/aboutstacks.pdf", "md5": "6e7c8416a293ba2d83bc8dd20c6ccf51", From 6672420f8de06585bb7d41b0982079b16043c22c Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Fri, 30 Dec 2011 18:52:15 -0600 Subject: [PATCH 4/4] Fixing CropBox --- src/core.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 26e376327..30da747a4 100644 --- a/src/core.js +++ b/src/core.js @@ -110,9 +110,11 @@ var Page = (function PageClosure() { width: this.width, height: this.height }; + var mediaBox = this.mediaBox; + var offsetX = mediaBox[0], offsetY = mediaBox[1]; if (isArray(obj) && obj.length == 4) { - var tl = this.rotatePoint(obj[0], obj[1]); - var br = this.rotatePoint(obj[2], obj[3]); + var tl = this.rotatePoint(obj[0] - offsetX, obj[1] - offsetY); + var br = this.rotatePoint(obj[2] - offsetX, obj[3] - offsetY); view.x = Math.min(tl.x, br.x); view.y = Math.min(tl.y, br.y); view.width = Math.abs(tl.x - br.x);