diff --git a/src/core/jbig2.js b/src/core/jbig2.js index e928eaac8..461e5d779 100755 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -572,10 +572,6 @@ var Jbig2Image = (function Jbig2ImageClosure() { var decoder = decodingContext.decoder; var contextCache = decodingContext.contextCache; - - if (transposed) - error('JBIG2 error: transposed is not supported'); - var stripT = -decodeInteger(contextCache, 'IADT', decoder); // 6.4.6 var firstS = 0; var i = 0; @@ -610,28 +606,60 @@ var Jbig2Image = (function Jbig2ImageClosure() { } var offsetT = t - ((referenceCorner & 1) ? 0 : symbolHeight); var offsetS = currentS - ((referenceCorner & 2) ? symbolWidth : 0); - for (var t2 = 0; t2 < symbolHeight; t2++) { - var row = bitmap[offsetT + t2]; - if (!row) continue; - var symbolRow = symbolBitmap[t2]; - switch (combinationOperator) { - case 0: // OR - for (var s2 = 0; s2 < symbolWidth; s2++) - row[offsetS + s2] |= symbolRow[s2]; - break; - case 2: // XOR - for (var s2 = 0; s2 < symbolWidth; s2++) - row[offsetS + s2] ^= symbolRow[s2]; - break; - default: - error('JBIG2 error: operator ' + combinationOperator + - ' is not supported'); + if (transposed) { + // Place Symbol Bitmap from T1,S1 + for (var s2 = 0; s2 < symbolHeight; s2++) { + var row = bitmap[offsetS + s2]; + if (!row) { + continue; + } + var symbolRow = symbolBitmap[s2]; + // To ignore Parts of Symbol bitmap which goes + // outside bitmap region + var maxWidth = Math.min(width - offsetT, symbolWidth); + switch (combinationOperator) { + case 0: // OR + for (var t2 = 0; t2 < maxWidth; t2++) { + row[offsetT + t2] |= symbolRow[t2]; + } + break; + case 2: // XOR + for (var t2 = 0; t2 < maxWidth; t2++) { + row[offsetT + t2] ^= symbolRow[t2]; + } + break; + default: + error('JBIG2 error: operator ' + combinationOperator + + ' is not supported'); + } } + currentS += symbolHeight - 1; + } else { + for (var t2 = 0; t2 < symbolHeight; t2++) { + var row = bitmap[offsetT + t2]; + if (!row) { + continue; + } + var symbolRow = symbolBitmap[t2]; + switch (combinationOperator) { + case 0: // OR + for (var s2 = 0; s2 < symbolWidth; s2++) { + row[offsetS + s2] |= symbolRow[s2]; + } + break; + case 2: // XOR + for (var s2 = 0; s2 < symbolWidth; s2++) { + row[offsetS + s2] ^= symbolRow[s2]; + } + break; + default: + error('JBIG2 error: operator ' + combinationOperator + + ' is not supported'); + } + } + currentS += symbolWidth - 1; } - - currentS += symbolWidth - 1; i++; - var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8 if (deltaS === null) break; // OOB diff --git a/test/pdfs/issue3666.pdf.link b/test/pdfs/issue3666.pdf.link new file mode 100644 index 000000000..b76785986 --- /dev/null +++ b/test/pdfs/issue3666.pdf.link @@ -0,0 +1,2 @@ +http://www.nfbc.com/Assets/Maps/716NiagaraWineTrail.pdf + diff --git a/test/test_manifest.json b/test/test_manifest.json index 6b245d729..03a5d53fd 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1364,5 +1364,14 @@ "firstPage": 1, "lastPage": 1, "type": "load" + }, + { "id": "issue3666", + "file": "pdfs/issue3666.pdf", + "md5": "c2156a34b9634b174556910732ab9df0", + "rounds": 1, + "link": true, + "firstPage": 1, + "lastPage": 2, + "type": "eq" } ]