Skip to content

Commit

Permalink
Merge pull request #8901 from janpe2/ccitt-eofb-false
Browse files Browse the repository at this point in the history
CCITTFaxStream problem when EndOfBlock is false
  • Loading branch information
Snuffleupagus authored Sep 19, 2017
2 parents 9c2e9da + 3d99b8d commit fbd6e47
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
this.inputBits = 0;
this.inputBuf = 0;
this.outputBits = 0;
this.rowsDone = false;

var code1;
while ((code1 = this.lookBits(12)) === 0) {
Expand Down Expand Up @@ -1872,6 +1873,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var refPos, blackPixels, bits, i;

if (this.outputBits === 0) {
if (this.rowsDone) {
this.eof = true;
}
if (this.eof) {
return null;
}
Expand Down Expand Up @@ -2052,7 +2056,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
}

if (!this.eoblock && this.row === this.rows - 1) {
this.eof = true;
this.rowsDone = true;
} else {
code1 = this.lookBits(12);
if (this.eoline) {
Expand All @@ -2074,7 +2078,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
}
}

if (!this.eof && this.encoding > 0) {
if (!this.eof && this.encoding > 0 && !this.rowsDone) {
this.nextLine2D = !this.lookBits(1);
this.eatBits(1);
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,4 @@
!issue8097_reduced.pdf
!transparent.pdf
!xobject-image.pdf
!ccitt_EndOfBlock_false.pdf
Binary file added test/pdfs/ccitt_EndOfBlock_false.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3693,5 +3693,11 @@
"rounds": 1,
"link": true,
"type": "eq"
},
{ "id": "ccitt_EndOfBlock_false",
"file": "pdfs/ccitt_EndOfBlock_false.pdf",
"md5": "ce718efe601cd7491dd00651b4790329",
"rounds": 1,
"type": "eq"
}
]

0 comments on commit fbd6e47

Please sign in to comment.