Skip to content

Commit 639774d

Browse files
committed
Merge pull request mozilla#2005 from yurydelendik/issue-2004
Removes horizontal lines in scanned images
2 parents 84d3d2a + 51b2587 commit 639774d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/image.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ var PDFImage = (function PDFImageClosure() {
347347
var rowBytes = (originalWidth * numComps * bpc + 7) >> 3;
348348
var imgArray = this.getImageBytes(originalHeight * rowBytes);
349349

350+
// imgArray can be incomplete (e.g. after CCITT fax encoding)
351+
var actualHeight = 0 | (imgArray.length / rowBytes *
352+
height / originalHeight);
353+
350354
var comps = this.colorSpace.getRgbBuffer(
351355
this.getComponents(imgArray), bpc);
352356
if (originalWidth != width || originalHeight != height)
@@ -355,7 +359,7 @@ var PDFImage = (function PDFImageClosure() {
355359
var compsPos = 0;
356360
var opacity = this.getOpacity(width, height);
357361
var opacityPos = 0;
358-
var length = width * height * 4;
362+
var length = width * actualHeight * 4;
359363

360364
for (var i = 0; i < length; i += 4) {
361365
buffer[i] = comps[compsPos++];

test/pdfs/issue1658.pdf.link

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.ads.tuwien.ac.at/teaching/archiv/praktika/CherkasskyGoldberg-1995-MaxFlow.pdf

test/test_manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,15 @@
539539
"link": true,
540540
"type": "eq"
541541
},
542+
{ "id": "issue1658",
543+
"file": "pdfs/issue1658.pdf",
544+
"md5": "b71a0f641e83ad427b8bcfc180899a05",
545+
"rounds": 1,
546+
"skipPages": [1, 2, 3, 4, 5, 6, 7, 8, 9],
547+
"pageLimit": 10,
548+
"link": true,
549+
"type": "eq"
550+
},
542551
{ "id": "issue1049",
543552
"file": "pdfs/issue1049.pdf",
544553
"md5": "15473fffcdde9fb8f3756a4cf1aab347",

0 commit comments

Comments
 (0)