From 3d99b8d706749e1f6b56bf2c70ac519815965c36 Mon Sep 17 00:00:00 2001 From: Jani Pehkonen Date: Tue, 19 Sep 2017 22:19:40 +0300 Subject: [PATCH] CCITTFaxStream problem when EndOfBlock is false --- src/core/stream.js | 8 ++++++-- test/pdfs/.gitignore | 1 + test/pdfs/ccitt_EndOfBlock_false.pdf | Bin 0 -> 3256 bytes test/test_manifest.json | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/pdfs/ccitt_EndOfBlock_false.pdf diff --git a/src/core/stream.js b/src/core/stream.js index 08e731885..38a81d5cb 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -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) { @@ -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; } @@ -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) { @@ -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); } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index f4d0713ad..080a6f510 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -297,3 +297,4 @@ !issue8097_reduced.pdf !transparent.pdf !xobject-image.pdf +!ccitt_EndOfBlock_false.pdf diff --git a/test/pdfs/ccitt_EndOfBlock_false.pdf b/test/pdfs/ccitt_EndOfBlock_false.pdf new file mode 100644 index 0000000000000000000000000000000000000000..d3aa89aa26fecb16320612ee2d173e0302c7242b GIT binary patch literal 3256 zcmdT{YfKzf6rR#xaN02;{%9p?t{T*6%DiWHEn;M0DXs5h1Qt(ktq}EbkJ$H5&_5t*dF|wIt z?>+O~@0>a3yLZl%)>nCU@nsT2m;UtE+0Pl8M;y{SdKkLAoS|9Y!3ajITeZ}n-Uaiz z2o68$w=_MB+C)G$Al9QlO^mseHXN3@^=Q~aJdC_r zz)X<>Up51AwHAZz*TBG#atwT73+5)0laa7b;DDx9>iwvV1B>jE%LIq4Ag9EaIh`&i z3B3WEderbk_)>CFwsT@!agGq%QrFRg{T3=OM{I3~M+#X)h5~Y=haz&OhZ1t7hcecik$A()EMf5Nc9s#)Zpl&oqR6p#MDttim;~GOf2sb=h(8306Aa||L=TZBs zuwM@l_T->mHA1GXBVdSz!Y24bY=hnh8%aT|7wv*+bvRJhSsB#*y{JS{4dy zTq2(IE_)hXDf^2@Ah4ajTFb@FMbiLnw@TPfA;mm-S9Ut{r%~Z z_*i6MczDlrZ<{&(=XlBKUjML8rY)^+KJ-fb+cO_jMDJ-Deg4Ye&z@7>o6pyL^>)wu zXMUT#_RUNCj+b*60dvcxbK=B!N$m2V`cZVmcgOh)>Mx$L-EUk_ZyoVfU+&xquJ68D z^H!1P)W8S?Hg@NBYMuI!^LcaECr{kGL(Eq9W++b)Y$5wvr%v|EbF&rdMkhGWRQ!w@WWa0I{srQO+r}k6#Pp+5awfevR z`)e{g$N8Iq7qU0Qf0W{zC~nKpcIxS^>*TuMz|f~ba|YpYD?g;jvM7@dE^XrB^-F#z zykg^FmS