Merge pull request #4507 from Snuffleupagus/src-core-braces
Fix coding style in src/core
This commit is contained in:
commit
8863ee5d7b
@ -55,7 +55,7 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
return this.numChunksLoaded === this.numChunks;
|
return this.numChunksLoaded === this.numChunks;
|
||||||
},
|
},
|
||||||
|
|
||||||
onReceiveData: function(begin, chunk) {
|
onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
|
||||||
var end = begin + chunk.byteLength;
|
var end = begin + chunk.byteLength;
|
||||||
|
|
||||||
assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
|
assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
|
||||||
@ -63,7 +63,7 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
// See ChunkedStream.moveStart()
|
// See ChunkedStream.moveStart()
|
||||||
var length = this.bytes.length;
|
var length = this.bytes.length;
|
||||||
assert(end % this.chunkSize === 0 || end === length,
|
assert(end % this.chunkSize === 0 || end === length,
|
||||||
'Bad end offset: ' + end);
|
'Bad end offset: ' + end);
|
||||||
|
|
||||||
this.bytes.set(new Uint8Array(chunk), begin);
|
this.bytes.set(new Uint8Array(chunk), begin);
|
||||||
var chunkSize = this.chunkSize;
|
var chunkSize = this.chunkSize;
|
||||||
@ -78,11 +78,11 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onReceiveInitialData: function (data) {
|
onReceiveInitialData: function ChunkedStream_onReceiveInitialData(data) {
|
||||||
this.bytes.set(data);
|
this.bytes.set(data);
|
||||||
this.initialDataLength = data.length;
|
this.initialDataLength = data.length;
|
||||||
var endChunk = this.end === data.length ?
|
var endChunk = (this.end === data.length ?
|
||||||
this.numChunks : Math.floor(data.length / this.chunkSize);
|
this.numChunks : Math.floor(data.length / this.chunkSize));
|
||||||
for (var i = 0; i < endChunk; i++) {
|
for (var i = 0; i < endChunk; i++) {
|
||||||
this.loadedChunks[i] = true;
|
this.loadedChunks[i] = true;
|
||||||
++this.numChunksLoaded;
|
++this.numChunksLoaded;
|
||||||
@ -167,8 +167,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var end = pos + length;
|
var end = pos + length;
|
||||||
if (end > strEnd)
|
if (end > strEnd) {
|
||||||
end = strEnd;
|
end = strEnd;
|
||||||
|
}
|
||||||
this.ensureRange(pos, end);
|
this.ensureRange(pos, end);
|
||||||
|
|
||||||
this.pos = end;
|
this.pos = end;
|
||||||
@ -187,8 +188,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
skip: function ChunkedStream_skip(n) {
|
skip: function ChunkedStream_skip(n) {
|
||||||
if (!n)
|
if (!n) {
|
||||||
n = 1;
|
n = 1;
|
||||||
|
}
|
||||||
this.pos += n;
|
this.pos += n;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -406,13 +408,13 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
|
if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
|
||||||
groupedChunks.push({
|
groupedChunks.push({ beginChunk: beginChunk,
|
||||||
beginChunk: beginChunk, endChunk: prevChunk + 1});
|
endChunk: prevChunk + 1 });
|
||||||
beginChunk = chunk;
|
beginChunk = chunk;
|
||||||
}
|
}
|
||||||
if (i + 1 === chunks.length) {
|
if (i + 1 === chunks.length) {
|
||||||
groupedChunks.push({
|
groupedChunks.push({ beginChunk: beginChunk,
|
||||||
beginChunk: beginChunk, endChunk: chunk + 1});
|
endChunk: chunk + 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
prevChunk = chunk;
|
prevChunk = chunk;
|
||||||
@ -421,8 +423,8 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onProgress: function ChunkedStreamManager_onProgress(args) {
|
onProgress: function ChunkedStreamManager_onProgress(args) {
|
||||||
var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize +
|
var bytesLoaded = (this.stream.numChunksLoaded * this.chunkSize +
|
||||||
args.loaded;
|
args.loaded);
|
||||||
this.msgHandler.send('DocProgress', {
|
this.msgHandler.send('DocProgress', {
|
||||||
loaded: bytesLoaded,
|
loaded: bytesLoaded,
|
||||||
total: this.length
|
total: this.length
|
||||||
|
@ -128,8 +128,9 @@ var Page = (function PageClosure() {
|
|||||||
var xref = this.xref;
|
var xref = this.xref;
|
||||||
var i, n = content.length;
|
var i, n = content.length;
|
||||||
var streams = [];
|
var streams = [];
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i) {
|
||||||
streams.push(xref.fetchIfRef(content[i]));
|
streams.push(xref.fetchIfRef(content[i]));
|
||||||
|
}
|
||||||
stream = new StreamsSequenceStream(streams);
|
stream = new StreamsSequenceStream(streams);
|
||||||
} else if (isStream(content)) {
|
} else if (isStream(content)) {
|
||||||
stream = content;
|
stream = content;
|
||||||
@ -181,17 +182,16 @@ var Page = (function PageClosure() {
|
|||||||
// Properties
|
// Properties
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var partialEvaluator = new PartialEvaluator(
|
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref,
|
||||||
pdfManager, this.xref, handler,
|
handler, this.pageIndex,
|
||||||
this.pageIndex, 'p' + this.pageIndex + '_',
|
'p' + this.pageIndex + '_',
|
||||||
this.idCounters, this.fontCache);
|
this.idCounters,
|
||||||
|
this.fontCache);
|
||||||
|
|
||||||
var dataPromises = Promise.all(
|
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise],
|
||||||
[contentStreamPromise, resourcesPromise], reject);
|
reject);
|
||||||
dataPromises.then(function(data) {
|
dataPromises.then(function(data) {
|
||||||
var contentStream = data[0];
|
var contentStream = data[0];
|
||||||
|
|
||||||
|
|
||||||
var opList = new OperatorList(intent, handler, self.pageIndex);
|
var opList = new OperatorList(intent, handler, self.pageIndex);
|
||||||
|
|
||||||
handler.send('StartRenderPage', {
|
handler.send('StartRenderPage', {
|
||||||
@ -249,10 +249,11 @@ var Page = (function PageClosure() {
|
|||||||
resourcesPromise]);
|
resourcesPromise]);
|
||||||
dataPromises.then(function(data) {
|
dataPromises.then(function(data) {
|
||||||
var contentStream = data[0];
|
var contentStream = data[0];
|
||||||
var partialEvaluator = new PartialEvaluator(
|
var partialEvaluator = new PartialEvaluator(pdfManager, self.xref,
|
||||||
pdfManager, self.xref, handler,
|
handler, self.pageIndex,
|
||||||
self.pageIndex, 'p' + self.pageIndex + '_',
|
'p' + self.pageIndex + '_',
|
||||||
self.idCounters, self.fontCache);
|
self.idCounters,
|
||||||
|
self.fontCache);
|
||||||
|
|
||||||
var bidiTexts = partialEvaluator.getTextContent(contentStream,
|
var bidiTexts = partialEvaluator.getTextContent(contentStream,
|
||||||
self.resources);
|
self.resources);
|
||||||
@ -273,7 +274,7 @@ var Page = (function PageClosure() {
|
|||||||
|
|
||||||
get annotations() {
|
get annotations() {
|
||||||
var annotations = [];
|
var annotations = [];
|
||||||
var annotationRefs = this.annotationRefs || [];
|
var annotationRefs = (this.annotationRefs || []);
|
||||||
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
||||||
var annotationRef = annotationRefs[i];
|
var annotationRef = annotationRefs[i];
|
||||||
var annotation = Annotation.fromRef(this.xref, annotationRef);
|
var annotation = Annotation.fromRef(this.xref, annotationRef);
|
||||||
@ -297,12 +298,13 @@ var Page = (function PageClosure() {
|
|||||||
*/
|
*/
|
||||||
var PDFDocument = (function PDFDocumentClosure() {
|
var PDFDocument = (function PDFDocumentClosure() {
|
||||||
function PDFDocument(pdfManager, arg, password) {
|
function PDFDocument(pdfManager, arg, password) {
|
||||||
if (isStream(arg))
|
if (isStream(arg)) {
|
||||||
init.call(this, pdfManager, arg, password);
|
init.call(this, pdfManager, arg, password);
|
||||||
else if (isArrayBuffer(arg))
|
} else if (isArrayBuffer(arg)) {
|
||||||
init.call(this, pdfManager, new Stream(arg), password);
|
init.call(this, pdfManager, new Stream(arg), password);
|
||||||
else
|
} else {
|
||||||
error('PDFDocument: Unknown argument type');
|
error('PDFDocument: Unknown argument type');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(pdfManager, stream, password) {
|
function init(pdfManager, stream, password) {
|
||||||
@ -317,16 +319,18 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
var pos = stream.pos;
|
var pos = stream.pos;
|
||||||
var end = stream.end;
|
var end = stream.end;
|
||||||
var strBuf = [];
|
var strBuf = [];
|
||||||
if (pos + limit > end)
|
if (pos + limit > end) {
|
||||||
limit = end - pos;
|
limit = end - pos;
|
||||||
|
}
|
||||||
for (var n = 0; n < limit; ++n) {
|
for (var n = 0; n < limit; ++n) {
|
||||||
strBuf.push(String.fromCharCode(stream.getByte()));
|
strBuf.push(String.fromCharCode(stream.getByte()));
|
||||||
}
|
}
|
||||||
var str = strBuf.join('');
|
var str = strBuf.join('');
|
||||||
stream.pos = pos;
|
stream.pos = pos;
|
||||||
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
|
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
return false; /* not found */
|
return false; /* not found */
|
||||||
|
}
|
||||||
stream.pos += index;
|
stream.pos += index;
|
||||||
return true; /* found */
|
return true; /* found */
|
||||||
}
|
}
|
||||||
@ -399,16 +403,18 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
if (linearization) {
|
if (linearization) {
|
||||||
// Find end of first obj.
|
// Find end of first obj.
|
||||||
stream.reset();
|
stream.reset();
|
||||||
if (find(stream, 'endobj', 1024))
|
if (find(stream, 'endobj', 1024)) {
|
||||||
startXRef = stream.pos + 6;
|
startXRef = stream.pos + 6;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Find startxref by jumping backward from the end of the file.
|
// Find startxref by jumping backward from the end of the file.
|
||||||
var step = 1024;
|
var step = 1024;
|
||||||
var found = false, pos = stream.end;
|
var found = false, pos = stream.end;
|
||||||
while (!found && pos > 0) {
|
while (!found && pos > 0) {
|
||||||
pos -= step - 'startxref'.length;
|
pos -= step - 'startxref'.length;
|
||||||
if (pos < 0)
|
if (pos < 0) {
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
}
|
||||||
stream.pos = pos;
|
stream.pos = pos;
|
||||||
found = find(stream, 'startxref', step, true);
|
found = find(stream, 'startxref', step, true);
|
||||||
}
|
}
|
||||||
@ -424,8 +430,9 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
ch = stream.getByte();
|
ch = stream.getByte();
|
||||||
}
|
}
|
||||||
startXRef = parseInt(str, 10);
|
startXRef = parseInt(str, 10);
|
||||||
if (isNaN(startXRef))
|
if (isNaN(startXRef)) {
|
||||||
startXRef = 0;
|
startXRef = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// shadow the prototype getter with a data property
|
// shadow the prototype getter with a data property
|
||||||
@ -434,8 +441,9 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
get mainXRefEntriesOffset() {
|
get mainXRefEntriesOffset() {
|
||||||
var mainXRefEntriesOffset = 0;
|
var mainXRefEntriesOffset = 0;
|
||||||
var linearization = this.linearization;
|
var linearization = this.linearization;
|
||||||
if (linearization)
|
if (linearization) {
|
||||||
mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
|
mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
|
||||||
|
}
|
||||||
// shadow the prototype getter with a data property
|
// shadow the prototype getter with a data property
|
||||||
return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
|
return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
|
||||||
},
|
},
|
||||||
@ -496,8 +504,8 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
var value = infoDict.get(key);
|
var value = infoDict.get(key);
|
||||||
// Make sure the value conforms to the spec.
|
// Make sure the value conforms to the spec.
|
||||||
if (validEntries[key](value)) {
|
if (validEntries[key](value)) {
|
||||||
docInfo[key] = typeof value !== 'string' ? value :
|
docInfo[key] = (typeof value !== 'string' ?
|
||||||
stringToPDFString(value);
|
value : stringToPDFString(value));
|
||||||
} else {
|
} else {
|
||||||
info('Bad value in document info for "' + key + '"');
|
info('Bad value in document info for "' + key + '"');
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseCmap(data, start, end) {
|
function parseCmap(data, start, end) {
|
||||||
var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) :
|
var offset = (getUshort(data, start + 2) === 1 ?
|
||||||
getLong(data, start + 16);
|
getLong(data, start + 8) : getLong(data, start + 16));
|
||||||
var format = getUshort(data, start + offset);
|
var format = getUshort(data, start + offset);
|
||||||
if (format === 4) {
|
if (format === 4) {
|
||||||
var length = getUshort(data, start + offset + 2);
|
var length = getUshort(data, start + offset + 2);
|
||||||
@ -79,13 +79,13 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
|
|
||||||
function parseCff(data, start, end) {
|
function parseCff(data, start, end) {
|
||||||
var properties = {};
|
var properties = {};
|
||||||
var parser = new CFFParser(
|
var parser = new CFFParser(new Stream(data, start, end - start),
|
||||||
new Stream(data, start, end - start), properties);
|
properties);
|
||||||
var cff = parser.parse();
|
var cff = parser.parse();
|
||||||
return {
|
return {
|
||||||
glyphs: cff.charStrings.objects,
|
glyphs: cff.charStrings.objects,
|
||||||
subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex &&
|
subrs: (cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex &&
|
||||||
cff.topDict.privateDict.subrsIndex.objects,
|
cff.topDict.privateDict.subrsIndex.objects),
|
||||||
gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
|
gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -413,10 +413,11 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
var xa = x + stack.shift(), ya = y + stack.shift();
|
var xa = x + stack.shift(), ya = y + stack.shift();
|
||||||
var xb = xa + stack.shift(), yb = ya + stack.shift();
|
var xb = xa + stack.shift(), yb = ya + stack.shift();
|
||||||
x = xb; y = yb;
|
x = xb; y = yb;
|
||||||
if (Math.abs(x - x0) > Math.abs(y - y0))
|
if (Math.abs(x - x0) > Math.abs(y - y0)) {
|
||||||
x += stack.shift();
|
x += stack.shift();
|
||||||
else
|
} else {
|
||||||
y += stack.shift();
|
y += stack.shift();
|
||||||
|
}
|
||||||
bezierCurveTo(xa, ya, xb, yb, x, y);
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -562,15 +563,16 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (v < 32)
|
if (v < 32) {
|
||||||
error('unknown operator: ' + v);
|
error('unknown operator: ' + v);
|
||||||
if (v < 247)
|
}
|
||||||
|
if (v < 247) {
|
||||||
stack.push(v - 139);
|
stack.push(v - 139);
|
||||||
else if (v < 251)
|
} else if (v < 251) {
|
||||||
stack.push((v - 247) * 256 + code[i++] + 108);
|
stack.push((v - 247) * 256 + code[i++] + 108);
|
||||||
else if (v < 255)
|
} else if (v < 255) {
|
||||||
stack.push(-(v - 251) * 256 - code[i++] - 108);
|
stack.push(-(v - 251) * 256 - code[i++] - 108);
|
||||||
else {
|
} else {
|
||||||
stack.push(((code[i] << 24) | (code[i + 1] << 16) |
|
stack.push(((code[i] << 24) | (code[i + 1] << 16) |
|
||||||
(code[i + 2] << 8) | code[i + 3]) / 65536);
|
(code[i + 2] << 8) | code[i + 3]) / 65536);
|
||||||
i += 4;
|
i += 4;
|
||||||
@ -654,10 +656,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
this.glyphNameMap = glyphNameMap || GlyphsUnicode;
|
this.glyphNameMap = glyphNameMap || GlyphsUnicode;
|
||||||
|
|
||||||
this.compiledGlyphs = [];
|
this.compiledGlyphs = [];
|
||||||
this.gsubrsBias = this.gsubrs.length < 1240 ? 107 :
|
this.gsubrsBias = (this.gsubrs.length < 1240 ?
|
||||||
this.gsubrs.length < 33900 ? 1131 : 32768;
|
107 : (this.gsubrs.length < 33900 ? 1131 : 32768));
|
||||||
this.subrsBias = this.subrs.length < 1240 ? 107 :
|
this.subrsBias = (this.subrs.length < 1240 ?
|
||||||
this.subrs.length < 33900 ? 1131 : 32768;
|
107 : (this.subrs.length < 33900 ? 1131 : 32768));
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.inherit(Type2Compiled, CompiledFont, {
|
Util.inherit(Type2Compiled, CompiledFont, {
|
||||||
@ -697,8 +699,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (glyf) {
|
if (glyf) {
|
||||||
var fontMatrix = !unitsPerEm ? font.fontMatrix :
|
var fontMatrix = (!unitsPerEm ? font.fontMatrix :
|
||||||
[1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
|
[1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0]);
|
||||||
return new TrueTypeCompiled(
|
return new TrueTypeCompiled(
|
||||||
parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
|
parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
var Stream = (function StreamClosure() {
|
var Stream = (function StreamClosure() {
|
||||||
function Stream(arrayBuffer, start, length, dict) {
|
function Stream(arrayBuffer, start, length, dict) {
|
||||||
this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer :
|
this.bytes = (arrayBuffer instanceof Uint8Array ?
|
||||||
new Uint8Array(arrayBuffer);
|
arrayBuffer : new Uint8Array(arrayBuffer));
|
||||||
this.start = start || 0;
|
this.start = start || 0;
|
||||||
this.pos = this.start;
|
this.pos = this.start;
|
||||||
this.end = (start + length) || this.bytes.length;
|
this.end = (start + length) || this.bytes.length;
|
||||||
@ -36,8 +36,9 @@ var Stream = (function StreamClosure() {
|
|||||||
return this.end - this.start;
|
return this.end - this.start;
|
||||||
},
|
},
|
||||||
getByte: function Stream_getByte() {
|
getByte: function Stream_getByte() {
|
||||||
if (this.pos >= this.end)
|
if (this.pos >= this.end) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return this.bytes[this.pos++];
|
return this.bytes[this.pos++];
|
||||||
},
|
},
|
||||||
getUint16: function Stream_getUint16() {
|
getUint16: function Stream_getUint16() {
|
||||||
@ -59,13 +60,13 @@ var Stream = (function StreamClosure() {
|
|||||||
var pos = this.pos;
|
var pos = this.pos;
|
||||||
var strEnd = this.end;
|
var strEnd = this.end;
|
||||||
|
|
||||||
if (!length)
|
if (!length) {
|
||||||
return bytes.subarray(pos, strEnd);
|
return bytes.subarray(pos, strEnd);
|
||||||
|
}
|
||||||
var end = pos + length;
|
var end = pos + length;
|
||||||
if (end > strEnd)
|
if (end > strEnd) {
|
||||||
end = strEnd;
|
end = strEnd;
|
||||||
|
}
|
||||||
this.pos = end;
|
this.pos = end;
|
||||||
return bytes.subarray(pos, end);
|
return bytes.subarray(pos, end);
|
||||||
},
|
},
|
||||||
@ -75,8 +76,9 @@ var Stream = (function StreamClosure() {
|
|||||||
return bytes;
|
return bytes;
|
||||||
},
|
},
|
||||||
skip: function Stream_skip(n) {
|
skip: function Stream_skip(n) {
|
||||||
if (!n)
|
if (!n) {
|
||||||
n = 1;
|
n = 1;
|
||||||
|
}
|
||||||
this.pos += n;
|
this.pos += n;
|
||||||
},
|
},
|
||||||
reset: function Stream_reset() {
|
reset: function Stream_reset() {
|
||||||
@ -98,8 +100,9 @@ var StringStream = (function StringStreamClosure() {
|
|||||||
function StringStream(str) {
|
function StringStream(str) {
|
||||||
var length = str.length;
|
var length = str.length;
|
||||||
var bytes = new Uint8Array(length);
|
var bytes = new Uint8Array(length);
|
||||||
for (var n = 0; n < length; ++n)
|
for (var n = 0; n < length; ++n) {
|
||||||
bytes[n] = str.charCodeAt(n);
|
bytes[n] = str.charCodeAt(n);
|
||||||
|
}
|
||||||
Stream.call(this, bytes);
|
Stream.call(this, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +152,9 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
getByte: function DecodeStream_getByte() {
|
getByte: function DecodeStream_getByte() {
|
||||||
var pos = this.pos;
|
var pos = this.pos;
|
||||||
while (this.bufferLength <= pos) {
|
while (this.bufferLength <= pos) {
|
||||||
if (this.eof)
|
if (this.eof) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
}
|
}
|
||||||
return this.buffer[this.pos++];
|
return this.buffer[this.pos++];
|
||||||
@ -174,22 +178,24 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
this.ensureBuffer(pos + length);
|
this.ensureBuffer(pos + length);
|
||||||
end = pos + length;
|
end = pos + length;
|
||||||
|
|
||||||
while (!this.eof && this.bufferLength < end)
|
while (!this.eof && this.bufferLength < end) {
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
|
}
|
||||||
var bufEnd = this.bufferLength;
|
var bufEnd = this.bufferLength;
|
||||||
if (end > bufEnd)
|
if (end > bufEnd) {
|
||||||
end = bufEnd;
|
end = bufEnd;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!this.eof)
|
while (!this.eof) {
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
|
}
|
||||||
end = this.bufferLength;
|
end = this.bufferLength;
|
||||||
|
|
||||||
// checking if bufferLength is still 0 then
|
// checking if bufferLength is still 0 then
|
||||||
// the buffer has to be initialized
|
// the buffer has to be initialized
|
||||||
if (!end)
|
if (!end) {
|
||||||
this.buffer = new Uint8Array(0);
|
this.buffer = new Uint8Array(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pos = end;
|
this.pos = end;
|
||||||
@ -202,13 +208,15 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
},
|
},
|
||||||
makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
|
makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
|
||||||
var end = start + length;
|
var end = start + length;
|
||||||
while (this.bufferLength <= end && !this.eof)
|
while (this.bufferLength <= end && !this.eof) {
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
|
}
|
||||||
return new Stream(this.buffer, start, length, dict);
|
return new Stream(this.buffer, start, length, dict);
|
||||||
},
|
},
|
||||||
skip: function Stream_skip(n) {
|
skip: function Stream_skip(n) {
|
||||||
if (!n)
|
if (!n) {
|
||||||
n = 1;
|
n = 1;
|
||||||
|
}
|
||||||
this.pos += n;
|
this.pos += n;
|
||||||
},
|
},
|
||||||
reset: function DecodeStream_reset() {
|
reset: function DecodeStream_reset() {
|
||||||
@ -234,7 +242,7 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
|
|||||||
StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
|
StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
|
||||||
|
|
||||||
StreamsSequenceStream.prototype.readBlock =
|
StreamsSequenceStream.prototype.readBlock =
|
||||||
function streamSequenceStreamReadBlock() {
|
function streamSequenceStreamReadBlock() {
|
||||||
|
|
||||||
var streams = this.streams;
|
var streams = this.streams;
|
||||||
if (streams.length === 0) {
|
if (streams.length === 0) {
|
||||||
@ -365,14 +373,18 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
|
|
||||||
var cmf = str.getByte();
|
var cmf = str.getByte();
|
||||||
var flg = str.getByte();
|
var flg = str.getByte();
|
||||||
if (cmf == -1 || flg == -1)
|
if (cmf == -1 || flg == -1) {
|
||||||
error('Invalid header in flate stream: ' + cmf + ', ' + flg);
|
error('Invalid header in flate stream: ' + cmf + ', ' + flg);
|
||||||
if ((cmf & 0x0f) != 0x08)
|
}
|
||||||
|
if ((cmf & 0x0f) != 0x08) {
|
||||||
error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
|
error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
|
||||||
if ((((cmf << 8) + flg) % 31) !== 0)
|
}
|
||||||
|
if ((((cmf << 8) + flg) % 31) !== 0) {
|
||||||
error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
|
error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
|
||||||
if (flg & 0x20)
|
}
|
||||||
|
if (flg & 0x20) {
|
||||||
error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
|
error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
|
||||||
|
}
|
||||||
|
|
||||||
this.codeSize = 0;
|
this.codeSize = 0;
|
||||||
this.codeBuf = 0;
|
this.codeBuf = 0;
|
||||||
@ -420,8 +432,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
var code = codes[codeBuf & ((1 << maxLen) - 1)];
|
var code = codes[codeBuf & ((1 << maxLen) - 1)];
|
||||||
var codeLen = code >> 16;
|
var codeLen = code >> 16;
|
||||||
var codeVal = code & 0xffff;
|
var codeVal = code & 0xffff;
|
||||||
if (codeSize === 0 || codeSize < codeLen || codeLen === 0)
|
if (codeSize === 0 || codeSize < codeLen || codeLen === 0) {
|
||||||
error('Bad encoding in flate stream');
|
error('Bad encoding in flate stream');
|
||||||
|
}
|
||||||
this.codeBuf = (codeBuf >> codeLen);
|
this.codeBuf = (codeBuf >> codeLen);
|
||||||
this.codeSize = (codeSize - codeLen);
|
this.codeSize = (codeSize - codeLen);
|
||||||
return codeVal;
|
return codeVal;
|
||||||
@ -434,8 +447,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
// find max code length
|
// find max code length
|
||||||
var maxLen = 0;
|
var maxLen = 0;
|
||||||
for (var i = 0; i < n; ++i) {
|
for (var i = 0; i < n; ++i) {
|
||||||
if (lengths[i] > maxLen)
|
if (lengths[i] > maxLen) {
|
||||||
maxLen = lengths[i];
|
maxLen = lengths[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the table
|
// build the table
|
||||||
@ -455,9 +469,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fill the table entries
|
// fill the table entries
|
||||||
for (var i = code2; i < size; i += skip)
|
for (var i = code2; i < size; i += skip) {
|
||||||
codes[i] = (len << 16) | val;
|
codes[i] = (len << 16) | val;
|
||||||
|
}
|
||||||
++code;
|
++code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -470,8 +484,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
var str = this.str;
|
var str = this.str;
|
||||||
// read block header
|
// read block header
|
||||||
var hdr = this.getBits(3);
|
var hdr = this.getBits(3);
|
||||||
if (hdr & 1)
|
if (hdr & 1) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
|
}
|
||||||
hdr >>= 1;
|
hdr >>= 1;
|
||||||
|
|
||||||
if (hdr === 0) { // uncompressed block
|
if (hdr === 0) { // uncompressed block
|
||||||
@ -535,8 +550,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
// build the code lengths code table
|
// build the code lengths code table
|
||||||
var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
|
var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
|
||||||
|
|
||||||
for (var i = 0; i < numCodeLenCodes; ++i)
|
for (var i = 0; i < numCodeLenCodes; ++i) {
|
||||||
codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
|
codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
|
||||||
|
}
|
||||||
var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
|
var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
|
||||||
|
|
||||||
// build the literal and distance code tables
|
// build the literal and distance code tables
|
||||||
@ -558,8 +574,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var repeatLength = this.getBits(bitsLength) + bitsOffset;
|
var repeatLength = this.getBits(bitsLength) + bitsOffset;
|
||||||
while (repeatLength-- > 0)
|
while (repeatLength-- > 0) {
|
||||||
codeLengths[i++] = what;
|
codeLengths[i++] = what;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
litCodeTable =
|
litCodeTable =
|
||||||
@ -590,21 +607,24 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
code1 -= 257;
|
code1 -= 257;
|
||||||
code1 = lengthDecode[code1];
|
code1 = lengthDecode[code1];
|
||||||
var code2 = code1 >> 16;
|
var code2 = code1 >> 16;
|
||||||
if (code2 > 0)
|
if (code2 > 0) {
|
||||||
code2 = this.getBits(code2);
|
code2 = this.getBits(code2);
|
||||||
|
}
|
||||||
var len = (code1 & 0xffff) + code2;
|
var len = (code1 & 0xffff) + code2;
|
||||||
code1 = this.getCode(distCodeTable);
|
code1 = this.getCode(distCodeTable);
|
||||||
code1 = distDecode[code1];
|
code1 = distDecode[code1];
|
||||||
code2 = code1 >> 16;
|
code2 = code1 >> 16;
|
||||||
if (code2 > 0)
|
if (code2 > 0) {
|
||||||
code2 = this.getBits(code2);
|
code2 = this.getBits(code2);
|
||||||
|
}
|
||||||
var dist = (code1 & 0xffff) + code2;
|
var dist = (code1 & 0xffff) + code2;
|
||||||
if (pos + len >= limit) {
|
if (pos + len >= limit) {
|
||||||
buffer = this.ensureBuffer(pos + len);
|
buffer = this.ensureBuffer(pos + len);
|
||||||
limit = buffer.length;
|
limit = buffer.length;
|
||||||
}
|
}
|
||||||
for (var k = 0; k < len; ++k, ++pos)
|
for (var k = 0; k < len; ++k, ++pos) {
|
||||||
buffer[pos] = buffer[pos - dist];
|
buffer[pos] = buffer[pos - dist];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -615,15 +635,18 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
function PredictorStream(str, maybeLength, params) {
|
function PredictorStream(str, maybeLength, params) {
|
||||||
var predictor = this.predictor = params.get('Predictor') || 1;
|
var predictor = this.predictor = params.get('Predictor') || 1;
|
||||||
|
|
||||||
if (predictor <= 1)
|
if (predictor <= 1) {
|
||||||
return str; // no prediction
|
return str; // no prediction
|
||||||
if (predictor !== 2 && (predictor < 10 || predictor > 15))
|
}
|
||||||
|
if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
|
||||||
error('Unsupported predictor: ' + predictor);
|
error('Unsupported predictor: ' + predictor);
|
||||||
|
}
|
||||||
|
|
||||||
if (predictor === 2)
|
if (predictor === 2) {
|
||||||
this.readBlock = this.readBlockTiff;
|
this.readBlock = this.readBlockTiff;
|
||||||
else
|
} else {
|
||||||
this.readBlock = this.readBlockPng;
|
this.readBlock = this.readBlockPng;
|
||||||
|
}
|
||||||
|
|
||||||
this.str = str;
|
this.str = str;
|
||||||
this.dict = str.dict;
|
this.dict = str.dict;
|
||||||
@ -642,7 +665,7 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
PredictorStream.prototype = Object.create(DecodeStream.prototype);
|
PredictorStream.prototype = Object.create(DecodeStream.prototype);
|
||||||
|
|
||||||
PredictorStream.prototype.readBlockTiff =
|
PredictorStream.prototype.readBlockTiff =
|
||||||
function predictorStreamReadBlockTiff() {
|
function predictorStreamReadBlockTiff() {
|
||||||
var rowBytes = this.rowBytes;
|
var rowBytes = this.rowBytes;
|
||||||
|
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
@ -672,8 +695,9 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
inbuf &= 0xFFFF;
|
inbuf &= 0xFFFF;
|
||||||
}
|
}
|
||||||
} else if (bits === 8) {
|
} else if (bits === 8) {
|
||||||
for (var i = 0; i < colors; ++i)
|
for (var i = 0; i < colors; ++i) {
|
||||||
buffer[pos++] = rawBytes[i];
|
buffer[pos++] = rawBytes[i];
|
||||||
|
}
|
||||||
for (; i < rowBytes; ++i) {
|
for (; i < rowBytes; ++i) {
|
||||||
buffer[pos] = buffer[pos - colors] + rawBytes[i];
|
buffer[pos] = buffer[pos - colors] + rawBytes[i];
|
||||||
pos++;
|
pos++;
|
||||||
@ -702,14 +726,14 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
}
|
}
|
||||||
if (outbits > 0) {
|
if (outbits > 0) {
|
||||||
buffer[k++] = (outbuf << (8 - outbits)) +
|
buffer[k++] = (outbuf << (8 - outbits)) +
|
||||||
(inbuf & ((1 << (8 - outbits)) - 1));
|
(inbuf & ((1 << (8 - outbits)) - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.bufferLength += rowBytes;
|
this.bufferLength += rowBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
PredictorStream.prototype.readBlockPng =
|
PredictorStream.prototype.readBlockPng =
|
||||||
function predictorStreamReadBlockPng() {
|
function predictorStreamReadBlockPng() {
|
||||||
|
|
||||||
var rowBytes = this.rowBytes;
|
var rowBytes = this.rowBytes;
|
||||||
var pixBytes = this.pixBytes;
|
var pixBytes = this.pixBytes;
|
||||||
@ -725,30 +749,35 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
||||||
|
|
||||||
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
||||||
if (prevRow.length === 0)
|
if (prevRow.length === 0) {
|
||||||
prevRow = new Uint8Array(rowBytes);
|
prevRow = new Uint8Array(rowBytes);
|
||||||
|
}
|
||||||
|
|
||||||
var j = bufferLength;
|
var j = bufferLength;
|
||||||
switch (predictor) {
|
switch (predictor) {
|
||||||
case 0:
|
case 0:
|
||||||
for (var i = 0; i < rowBytes; ++i)
|
for (var i = 0; i < rowBytes; ++i) {
|
||||||
buffer[j++] = rawBytes[i];
|
buffer[j++] = rawBytes[i];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
for (var i = 0; i < pixBytes; ++i)
|
for (var i = 0; i < pixBytes; ++i) {
|
||||||
buffer[j++] = rawBytes[i];
|
buffer[j++] = rawBytes[i];
|
||||||
|
}
|
||||||
for (; i < rowBytes; ++i) {
|
for (; i < rowBytes; ++i) {
|
||||||
buffer[j] = (buffer[j - pixBytes] + rawBytes[i]) & 0xFF;
|
buffer[j] = (buffer[j - pixBytes] + rawBytes[i]) & 0xFF;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
for (var i = 0; i < rowBytes; ++i)
|
for (var i = 0; i < rowBytes; ++i) {
|
||||||
buffer[j++] = (prevRow[i] + rawBytes[i]) & 0xFF;
|
buffer[j++] = (prevRow[i] + rawBytes[i]) & 0xFF;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
for (var i = 0; i < pixBytes; ++i)
|
for (var i = 0; i < pixBytes; ++i) {
|
||||||
buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
|
buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
|
||||||
|
}
|
||||||
for (; i < rowBytes; ++i) {
|
for (; i < rowBytes; ++i) {
|
||||||
buffer[j] = (((prevRow[i] + buffer[j - pixBytes]) >> 1) +
|
buffer[j] = (((prevRow[i] + buffer[j - pixBytes]) >> 1) +
|
||||||
rawBytes[i]) & 0xFF;
|
rawBytes[i]) & 0xFF;
|
||||||
@ -770,22 +799,26 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
var p = left + up - upLeft;
|
var p = left + up - upLeft;
|
||||||
|
|
||||||
var pa = p - left;
|
var pa = p - left;
|
||||||
if (pa < 0)
|
if (pa < 0) {
|
||||||
pa = -pa;
|
pa = -pa;
|
||||||
|
}
|
||||||
var pb = p - up;
|
var pb = p - up;
|
||||||
if (pb < 0)
|
if (pb < 0) {
|
||||||
pb = -pb;
|
pb = -pb;
|
||||||
|
}
|
||||||
var pc = p - upLeft;
|
var pc = p - upLeft;
|
||||||
if (pc < 0)
|
if (pc < 0) {
|
||||||
pc = -pc;
|
pc = -pc;
|
||||||
|
}
|
||||||
|
|
||||||
var c = rawBytes[i];
|
var c = rawBytes[i];
|
||||||
if (pa <= pb && pa <= pc)
|
if (pa <= pb && pa <= pc) {
|
||||||
buffer[j++] = left + c;
|
buffer[j++] = left + c;
|
||||||
else if (pb <= pc)
|
} else if (pb <= pc) {
|
||||||
buffer[j++] = up + c;
|
buffer[j++] = up + c;
|
||||||
else
|
} else {
|
||||||
buffer[j++] = upLeft + c;
|
buffer[j++] = upLeft + c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -826,12 +859,14 @@ var JpegStream = (function JpegStreamClosure() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
|
JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
|
||||||
if (this.bufferLength)
|
if (this.bufferLength) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
var jpegImage = new JpegImage();
|
var jpegImage = new JpegImage();
|
||||||
if (this.colorTransform != -1)
|
if (this.colorTransform != -1) {
|
||||||
jpegImage.colorTransform = this.colorTransform;
|
jpegImage.colorTransform = this.colorTransform;
|
||||||
|
}
|
||||||
jpegImage.parse(this.bytes);
|
jpegImage.parse(this.bytes);
|
||||||
var width = jpegImage.width;
|
var width = jpegImage.width;
|
||||||
var height = jpegImage.height;
|
var height = jpegImage.height;
|
||||||
@ -851,7 +886,7 @@ var JpegStream = (function JpegStreamClosure() {
|
|||||||
* further processing such as color space conversions.
|
* further processing such as color space conversions.
|
||||||
*/
|
*/
|
||||||
JpegStream.prototype.isNativelySupported =
|
JpegStream.prototype.isNativelySupported =
|
||||||
function JpegStream_isNativelySupported(xref, res) {
|
function JpegStream_isNativelySupported(xref, res) {
|
||||||
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
||||||
return cs.name === 'DeviceGray' || cs.name === 'DeviceRGB';
|
return cs.name === 'DeviceGray' || cs.name === 'DeviceRGB';
|
||||||
};
|
};
|
||||||
@ -859,7 +894,7 @@ var JpegStream = (function JpegStreamClosure() {
|
|||||||
* Checks if the image can be decoded by the browser.
|
* Checks if the image can be decoded by the browser.
|
||||||
*/
|
*/
|
||||||
JpegStream.prototype.isNativelyDecodable =
|
JpegStream.prototype.isNativelyDecodable =
|
||||||
function JpegStream_isNativelyDecodable(xref, res) {
|
function JpegStream_isNativelyDecodable(xref, res) {
|
||||||
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
||||||
var numComps = cs.numComps;
|
var numComps = cs.numComps;
|
||||||
return numComps == 1 || numComps == 3;
|
return numComps == 1 || numComps == 3;
|
||||||
@ -892,8 +927,9 @@ var JpxStream = (function JpxStreamClosure() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
|
JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
|
||||||
if (this.bufferLength)
|
if (this.bufferLength) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var jpxImage = new JpxImage();
|
var jpxImage = new JpxImage();
|
||||||
jpxImage.parse(this.bytes);
|
jpxImage.parse(this.bytes);
|
||||||
@ -901,8 +937,9 @@ var JpxStream = (function JpxStreamClosure() {
|
|||||||
var width = jpxImage.width;
|
var width = jpxImage.width;
|
||||||
var height = jpxImage.height;
|
var height = jpxImage.height;
|
||||||
var componentsCount = jpxImage.componentsCount;
|
var componentsCount = jpxImage.componentsCount;
|
||||||
if (componentsCount != 1 && componentsCount != 3 && componentsCount != 4)
|
if (componentsCount != 1 && componentsCount != 3 && componentsCount != 4) {
|
||||||
error('JPX with ' + componentsCount + ' components is not supported');
|
error('JPX with ' + componentsCount + ' components is not supported');
|
||||||
|
}
|
||||||
|
|
||||||
var data = new Uint8Array(width * height * componentsCount);
|
var data = new Uint8Array(width * height * componentsCount);
|
||||||
|
|
||||||
@ -922,8 +959,9 @@ var JpxStream = (function JpxStreamClosure() {
|
|||||||
rowFeed = width - tileWidth;
|
rowFeed = width - tileWidth;
|
||||||
sourcePosition = 0;
|
sourcePosition = 0;
|
||||||
for (var j = 0; j < tileHeight; j++) {
|
for (var j = 0; j < tileHeight; j++) {
|
||||||
for (var i = 0; i < tileWidth; i++)
|
for (var i = 0; i < tileWidth; i++) {
|
||||||
data[dataPosition++] = data0[sourcePosition++];
|
data[dataPosition++] = data0[sourcePosition++];
|
||||||
|
}
|
||||||
dataPosition += rowFeed;
|
dataPosition += rowFeed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1000,8 +1038,9 @@ var Jbig2Stream = (function Jbig2StreamClosure() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
|
Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
|
||||||
if (this.bufferLength)
|
if (this.bufferLength) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var jbig2Image = new Jbig2Image();
|
var jbig2Image = new Jbig2Image();
|
||||||
|
|
||||||
@ -1026,8 +1065,9 @@ var Jbig2Stream = (function Jbig2StreamClosure() {
|
|||||||
var dataLength = data.length;
|
var dataLength = data.length;
|
||||||
|
|
||||||
// JBIG2 had black as 1 and white as 0, inverting the colors
|
// JBIG2 had black as 1 and white as 0, inverting the colors
|
||||||
for (var i = 0; i < dataLength; i++)
|
for (var i = 0; i < dataLength; i++) {
|
||||||
data[i] ^= 0xFF;
|
data[i] ^= 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
this.buffer = data;
|
this.buffer = data;
|
||||||
this.bufferLength = dataLength;
|
this.bufferLength = dataLength;
|
||||||
@ -1073,8 +1113,9 @@ var DecryptStream = (function DecryptStreamClosure() {
|
|||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var i, n = chunk.length;
|
var i, n = chunk.length;
|
||||||
var buffer = this.ensureBuffer(bufferLength + n);
|
var buffer = this.ensureBuffer(bufferLength + n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++) {
|
||||||
buffer[bufferLength++] = chunk[i];
|
buffer[bufferLength++] = chunk[i];
|
||||||
|
}
|
||||||
this.bufferLength = bufferLength;
|
this.bufferLength = bufferLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1119,8 +1160,9 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
|
|||||||
// special code for z
|
// special code for z
|
||||||
if (c == Z_LOWER_CHAR) {
|
if (c == Z_LOWER_CHAR) {
|
||||||
buffer = this.ensureBuffer(bufferLength + 4);
|
buffer = this.ensureBuffer(bufferLength + 4);
|
||||||
for (var i = 0; i < 4; ++i)
|
for (var i = 0; i < 4; ++i) {
|
||||||
buffer[bufferLength + i] = 0;
|
buffer[bufferLength + i] = 0;
|
||||||
|
}
|
||||||
this.bufferLength += 4;
|
this.bufferLength += 4;
|
||||||
} else {
|
} else {
|
||||||
var input = this.input;
|
var input = this.input;
|
||||||
@ -1133,21 +1175,24 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
|
|||||||
|
|
||||||
input[i] = c;
|
input[i] = c;
|
||||||
|
|
||||||
if (c === EOF || c == TILDA_CHAR)
|
if (c === EOF || c == TILDA_CHAR) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buffer = this.ensureBuffer(bufferLength + i - 1);
|
buffer = this.ensureBuffer(bufferLength + i - 1);
|
||||||
this.bufferLength += i - 1;
|
this.bufferLength += i - 1;
|
||||||
|
|
||||||
// partial ending;
|
// partial ending;
|
||||||
if (i < 5) {
|
if (i < 5) {
|
||||||
for (; i < 5; ++i)
|
for (; i < 5; ++i) {
|
||||||
input[i] = 0x21 + 84;
|
input[i] = 0x21 + 84;
|
||||||
|
}
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
}
|
}
|
||||||
var t = 0;
|
var t = 0;
|
||||||
for (var i = 0; i < 5; ++i)
|
for (var i = 0; i < 5; ++i) {
|
||||||
t = t * 85 + (input[i] - 0x21);
|
t = t * 85 + (input[i] - 0x21);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 3; i >= 0; --i) {
|
for (var i = 3; i >= 0; --i) {
|
||||||
buffer[bufferLength + i] = t & 0xFF;
|
buffer[bufferLength + i] = t & 0xFF;
|
||||||
@ -1257,8 +1302,9 @@ var RunLengthStream = (function RunLengthStreamClosure() {
|
|||||||
n = 257 - n;
|
n = 257 - n;
|
||||||
var b = repeatHeader[1];
|
var b = repeatHeader[1];
|
||||||
var buffer = this.ensureBuffer(bufferLength + n + 1);
|
var buffer = this.ensureBuffer(bufferLength + n + 1);
|
||||||
for (var i = 0; i < n; i++)
|
for (var i = 0; i < n; i++) {
|
||||||
buffer[bufferLength++] = b;
|
buffer[bufferLength++] = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.bufferLength = bufferLength;
|
this.bufferLength = bufferLength;
|
||||||
};
|
};
|
||||||
@ -1706,8 +1752,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.columns = params.get('Columns') || 1728;
|
this.columns = params.get('Columns') || 1728;
|
||||||
this.rows = params.get('Rows') || 0;
|
this.rows = params.get('Rows') || 0;
|
||||||
var eoblock = params.get('EndOfBlock');
|
var eoblock = params.get('EndOfBlock');
|
||||||
if (eoblock === null || eoblock === undefined)
|
if (eoblock === null || eoblock === undefined) {
|
||||||
eoblock = true;
|
eoblock = true;
|
||||||
|
}
|
||||||
this.eoblock = eoblock;
|
this.eoblock = eoblock;
|
||||||
this.black = params.get('BlackIs1') || false;
|
this.black = params.get('BlackIs1') || false;
|
||||||
|
|
||||||
@ -1749,7 +1796,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.addPixels =
|
CCITTFaxStream.prototype.addPixels =
|
||||||
function ccittFaxStreamAddPixels(a1, blackPixels) {
|
function ccittFaxStreamAddPixels(a1, blackPixels) {
|
||||||
var codingLine = this.codingLine;
|
var codingLine = this.codingLine;
|
||||||
var codingPos = this.codingPos;
|
var codingPos = this.codingPos;
|
||||||
|
|
||||||
@ -1769,7 +1816,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.addPixelsNeg =
|
CCITTFaxStream.prototype.addPixelsNeg =
|
||||||
function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
|
function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
|
||||||
var codingLine = this.codingLine;
|
var codingLine = this.codingLine;
|
||||||
var codingPos = this.codingPos;
|
var codingPos = this.codingPos;
|
||||||
|
|
||||||
@ -1779,8 +1826,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.err = true;
|
this.err = true;
|
||||||
a1 = this.columns;
|
a1 = this.columns;
|
||||||
}
|
}
|
||||||
if ((codingPos & 1) ^ blackPixels)
|
if ((codingPos & 1) ^ blackPixels) {
|
||||||
++codingPos;
|
++codingPos;
|
||||||
|
}
|
||||||
|
|
||||||
codingLine[codingPos] = a1;
|
codingLine[codingPos] = a1;
|
||||||
} else if (a1 < codingLine[codingPos]) {
|
} else if (a1 < codingLine[codingPos]) {
|
||||||
@ -1789,8 +1837,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.err = true;
|
this.err = true;
|
||||||
a1 = 0;
|
a1 = 0;
|
||||||
}
|
}
|
||||||
while (codingPos > 0 && a1 < codingLine[codingPos - 1])
|
while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
|
||||||
--codingPos;
|
--codingPos;
|
||||||
|
}
|
||||||
codingLine[codingPos] = a1;
|
codingLine[codingPos] = a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1805,16 +1854,16 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
var refPos, blackPixels, bits;
|
var refPos, blackPixels, bits;
|
||||||
|
|
||||||
if (this.outputBits === 0) {
|
if (this.outputBits === 0) {
|
||||||
if (this.eof)
|
if (this.eof) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
this.err = false;
|
this.err = false;
|
||||||
|
|
||||||
var code1, code2, code3;
|
var code1, code2, code3;
|
||||||
if (this.nextLine2D) {
|
if (this.nextLine2D) {
|
||||||
for (var i = 0; codingLine[i] < columns; ++i)
|
for (var i = 0; codingLine[i] < columns; ++i) {
|
||||||
refLine[i] = codingLine[i];
|
refLine[i] = codingLine[i];
|
||||||
|
}
|
||||||
refLine[i++] = columns;
|
refLine[i++] = columns;
|
||||||
refLine[i] = columns;
|
refLine[i] = columns;
|
||||||
codingLine[0] = 0;
|
codingLine[0] = 0;
|
||||||
@ -1827,8 +1876,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
switch (code1) {
|
switch (code1) {
|
||||||
case twoDimPass:
|
case twoDimPass:
|
||||||
this.addPixels(refLine[refPos + 1], blackPixels);
|
this.addPixels(refLine[refPos + 1], blackPixels);
|
||||||
if (refLine[refPos + 1] < columns)
|
if (refLine[refPos + 1] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimHoriz:
|
case twoDimHoriz:
|
||||||
code1 = code2 = 0;
|
code1 = code2 = 0;
|
||||||
@ -1864,8 +1914,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
++refPos;
|
++refPos;
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimVertR2:
|
case twoDimVertR2:
|
||||||
@ -1885,8 +1936,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
++refPos;
|
++refPos;
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimVert0:
|
case twoDimVert0:
|
||||||
@ -1895,48 +1947,54 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
++refPos;
|
++refPos;
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimVertL3:
|
case twoDimVertL3:
|
||||||
this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
|
this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
|
||||||
blackPixels ^= 1;
|
blackPixels ^= 1;
|
||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
if (refPos > 0)
|
if (refPos > 0) {
|
||||||
--refPos;
|
--refPos;
|
||||||
else
|
} else {
|
||||||
++refPos;
|
++refPos;
|
||||||
|
}
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimVertL2:
|
case twoDimVertL2:
|
||||||
this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
|
this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
|
||||||
blackPixels ^= 1;
|
blackPixels ^= 1;
|
||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
if (refPos > 0)
|
if (refPos > 0) {
|
||||||
--refPos;
|
--refPos;
|
||||||
else
|
} else {
|
||||||
++refPos;
|
++refPos;
|
||||||
|
}
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case twoDimVertL1:
|
case twoDimVertL1:
|
||||||
this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
|
this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
|
||||||
blackPixels ^= 1;
|
blackPixels ^= 1;
|
||||||
if (codingLine[this.codingPos] < columns) {
|
if (codingLine[this.codingPos] < columns) {
|
||||||
if (refPos > 0)
|
if (refPos > 0) {
|
||||||
--refPos;
|
--refPos;
|
||||||
else
|
} else {
|
||||||
++refPos;
|
++refPos;
|
||||||
|
}
|
||||||
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
while (refLine[refPos] <= codingLine[this.codingPos] &&
|
||||||
refLine[refPos] < columns)
|
refLine[refPos] < columns) {
|
||||||
refPos += 2;
|
refPos += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOF:
|
case EOF:
|
||||||
@ -1969,8 +2027,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.byteAlign)
|
if (this.byteAlign) {
|
||||||
this.inputBits &= ~7;
|
this.inputBits &= ~7;
|
||||||
|
}
|
||||||
|
|
||||||
var gotEOL = false;
|
var gotEOL = false;
|
||||||
|
|
||||||
@ -2006,8 +2065,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (this.encoding >= 0) {
|
if (this.encoding >= 0) {
|
||||||
for (var i = 0; i < 4; ++i) {
|
for (var i = 0; i < 4; ++i) {
|
||||||
code1 = this.lookBits(12);
|
code1 = this.lookBits(12);
|
||||||
if (code1 != 1)
|
if (code1 != 1) {
|
||||||
info('bad rtc code: ' + code1);
|
info('bad rtc code: ' + code1);
|
||||||
|
}
|
||||||
this.eatBits(12);
|
this.eatBits(12);
|
||||||
if (this.encoding > 0) {
|
if (this.encoding > 0) {
|
||||||
this.lookBits(1);
|
this.lookBits(1);
|
||||||
@ -2036,10 +2096,11 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codingLine[0] > 0)
|
if (codingLine[0] > 0) {
|
||||||
this.outputBits = codingLine[this.codingPos = 0];
|
this.outputBits = codingLine[this.codingPos = 0];
|
||||||
else
|
} else {
|
||||||
this.outputBits = codingLine[this.codingPos = 1];
|
this.outputBits = codingLine[this.codingPos = 1];
|
||||||
|
}
|
||||||
this.row++;
|
this.row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2094,15 +2155,17 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
// returned. The second array element is the actual code. The third array
|
// returned. The second array element is the actual code. The third array
|
||||||
// element indicates whether EOF was reached.
|
// element indicates whether EOF was reached.
|
||||||
CCITTFaxStream.prototype.findTableCode =
|
CCITTFaxStream.prototype.findTableCode =
|
||||||
function ccittFaxStreamFindTableCode(start, end, table, limit) {
|
function ccittFaxStreamFindTableCode(start, end, table, limit) {
|
||||||
|
|
||||||
var limitValue = limit || 0;
|
var limitValue = limit || 0;
|
||||||
for (var i = start; i <= end; ++i) {
|
for (var i = start; i <= end; ++i) {
|
||||||
var code = this.lookBits(i);
|
var code = this.lookBits(i);
|
||||||
if (code == EOF)
|
if (code == EOF) {
|
||||||
return [true, 1, false];
|
return [true, 1, false];
|
||||||
if (i < end)
|
}
|
||||||
|
if (i < end) {
|
||||||
code <<= end - i;
|
code <<= end - i;
|
||||||
|
}
|
||||||
if (!limitValue || code >= limitValue) {
|
if (!limitValue || code >= limitValue) {
|
||||||
var p = table[code - limitValue];
|
var p = table[code - limitValue];
|
||||||
if (p[0] == i) {
|
if (p[0] == i) {
|
||||||
@ -2115,7 +2178,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.getTwoDimCode =
|
CCITTFaxStream.prototype.getTwoDimCode =
|
||||||
function ccittFaxStreamGetTwoDimCode() {
|
function ccittFaxStreamGetTwoDimCode() {
|
||||||
|
|
||||||
var code = 0;
|
var code = 0;
|
||||||
var p;
|
var p;
|
||||||
@ -2128,28 +2191,31 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var result = this.findTableCode(1, 7, twoDimTable);
|
var result = this.findTableCode(1, 7, twoDimTable);
|
||||||
if (result[0] && result[2])
|
if (result[0] && result[2]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
info('Bad two dim code');
|
info('Bad two dim code');
|
||||||
return EOF;
|
return EOF;
|
||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.getWhiteCode =
|
CCITTFaxStream.prototype.getWhiteCode =
|
||||||
function ccittFaxStreamGetWhiteCode() {
|
function ccittFaxStreamGetWhiteCode() {
|
||||||
|
|
||||||
var code = 0;
|
var code = 0;
|
||||||
var p;
|
var p;
|
||||||
var n;
|
var n;
|
||||||
if (this.eoblock) {
|
if (this.eoblock) {
|
||||||
code = this.lookBits(12);
|
code = this.lookBits(12);
|
||||||
if (code == EOF)
|
if (code == EOF) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((code >> 5) === 0)
|
if ((code >> 5) === 0) {
|
||||||
p = whiteTable1[code];
|
p = whiteTable1[code];
|
||||||
else
|
} else {
|
||||||
p = whiteTable2[code >> 3];
|
p = whiteTable2[code >> 3];
|
||||||
|
}
|
||||||
|
|
||||||
if (p[0] > 0) {
|
if (p[0] > 0) {
|
||||||
this.eatBits(p[0]);
|
this.eatBits(p[0]);
|
||||||
@ -2157,12 +2223,14 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var result = this.findTableCode(1, 9, whiteTable2);
|
var result = this.findTableCode(1, 9, whiteTable2);
|
||||||
if (result[0])
|
if (result[0]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
|
|
||||||
result = this.findTableCode(11, 12, whiteTable1);
|
result = this.findTableCode(11, 12, whiteTable1);
|
||||||
if (result[0])
|
if (result[0]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
info('bad white code');
|
info('bad white code');
|
||||||
this.eatBits(1);
|
this.eatBits(1);
|
||||||
@ -2170,19 +2238,21 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.getBlackCode =
|
CCITTFaxStream.prototype.getBlackCode =
|
||||||
function ccittFaxStreamGetBlackCode() {
|
function ccittFaxStreamGetBlackCode() {
|
||||||
|
|
||||||
var code, p;
|
var code, p;
|
||||||
if (this.eoblock) {
|
if (this.eoblock) {
|
||||||
code = this.lookBits(13);
|
code = this.lookBits(13);
|
||||||
if (code == EOF)
|
if (code == EOF) {
|
||||||
return 1;
|
return 1;
|
||||||
if ((code >> 7) === 0)
|
}
|
||||||
|
if ((code >> 7) === 0) {
|
||||||
p = blackTable1[code];
|
p = blackTable1[code];
|
||||||
else if ((code >> 9) === 0 && (code >> 7) !== 0)
|
} else if ((code >> 9) === 0 && (code >> 7) !== 0) {
|
||||||
p = blackTable2[(code >> 1) - 64];
|
p = blackTable2[(code >> 1) - 64];
|
||||||
else
|
} else {
|
||||||
p = blackTable3[code >> 7];
|
p = blackTable3[code >> 7];
|
||||||
|
}
|
||||||
|
|
||||||
if (p[0] > 0) {
|
if (p[0] > 0) {
|
||||||
this.eatBits(p[0]);
|
this.eatBits(p[0]);
|
||||||
@ -2190,16 +2260,19 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var result = this.findTableCode(2, 6, blackTable3);
|
var result = this.findTableCode(2, 6, blackTable3);
|
||||||
if (result[0])
|
if (result[0]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
|
|
||||||
result = this.findTableCode(7, 12, blackTable2, 64);
|
result = this.findTableCode(7, 12, blackTable2, 64);
|
||||||
if (result[0])
|
if (result[0]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
|
|
||||||
result = this.findTableCode(10, 13, blackTable1);
|
result = this.findTableCode(10, 13, blackTable1);
|
||||||
if (result[0])
|
if (result[0]) {
|
||||||
return result[1];
|
return result[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
info('bad black code');
|
info('bad black code');
|
||||||
this.eatBits(1);
|
this.eatBits(1);
|
||||||
@ -2210,8 +2283,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
var c;
|
var c;
|
||||||
while (this.inputBits < n) {
|
while (this.inputBits < n) {
|
||||||
if ((c = this.str.getByte()) === -1) {
|
if ((c = this.str.getByte()) === -1) {
|
||||||
if (this.inputBits === 0)
|
if (this.inputBits === 0) {
|
||||||
return EOF;
|
return EOF;
|
||||||
|
}
|
||||||
return ((this.inputBuf << (n - this.inputBits)) &
|
return ((this.inputBuf << (n - this.inputBits)) &
|
||||||
(0xFFFF >> (16 - n)));
|
(0xFFFF >> (16 - n)));
|
||||||
}
|
}
|
||||||
@ -2222,8 +2296,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
|
CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
|
||||||
if ((this.inputBits -= n) < 0)
|
if ((this.inputBits -= n) < 0) {
|
||||||
this.inputBits = 0;
|
this.inputBits = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return CCITTFaxStream;
|
return CCITTFaxStream;
|
||||||
@ -2282,8 +2357,9 @@ var LZWStream = (function LZWStreamClosure() {
|
|||||||
var i, j, q;
|
var i, j, q;
|
||||||
|
|
||||||
var lzwState = this.lzwState;
|
var lzwState = this.lzwState;
|
||||||
if (!lzwState)
|
if (!lzwState) {
|
||||||
return; // eof was found
|
return; // eof was found
|
||||||
|
}
|
||||||
|
|
||||||
var earlyChange = lzwState.earlyChange;
|
var earlyChange = lzwState.earlyChange;
|
||||||
var nextCode = lzwState.nextCode;
|
var nextCode = lzwState.nextCode;
|
||||||
@ -2344,8 +2420,9 @@ var LZWStream = (function LZWStreamClosure() {
|
|||||||
} while (estimatedDecodedSize < decodedLength);
|
} while (estimatedDecodedSize < decodedLength);
|
||||||
buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
|
buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
|
||||||
}
|
}
|
||||||
for (j = 0; j < currentSequenceLength; j++)
|
for (j = 0; j < currentSequenceLength; j++) {
|
||||||
buffer[currentBufferLength++] = currentSequence[j];
|
buffer[currentBufferLength++] = currentSequence[j];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lzwState.nextCode = nextCode;
|
lzwState.nextCode = nextCode;
|
||||||
lzwState.codeLength = codeLength;
|
lzwState.codeLength = codeLength;
|
||||||
|
@ -38,9 +38,8 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
var encryptedPromise = pdfManager.ensureXRef('encrypt');
|
var encryptedPromise = pdfManager.ensureXRef('encrypt');
|
||||||
var javaScriptPromise = pdfManager.ensureCatalog('javaScript');
|
var javaScriptPromise = pdfManager.ensureCatalog('javaScript');
|
||||||
Promise.all([numPagesPromise, fingerprintPromise, outlinePromise,
|
Promise.all([numPagesPromise, fingerprintPromise, outlinePromise,
|
||||||
infoPromise, metadataPromise, encryptedPromise,
|
infoPromise, metadataPromise, encryptedPromise,
|
||||||
javaScriptPromise]).then(
|
javaScriptPromise]).then(function onDocReady(results) {
|
||||||
function onDocReady(results) {
|
|
||||||
|
|
||||||
var doc = {
|
var doc = {
|
||||||
numPages: results[0],
|
numPages: results[0],
|
||||||
@ -63,7 +62,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
pdfManager.ensureDoc('checkHeader', []).then(function() {
|
pdfManager.ensureDoc('checkHeader', []).then(function() {
|
||||||
pdfManager.ensureDoc('parseStartXRef', []).then(function() {
|
pdfManager.ensureDoc('parseStartXRef', []).then(function() {
|
||||||
pdfManager.ensureDoc('parse', [recoveryMode]).then(
|
pdfManager.ensureDoc('parse', [recoveryMode]).then(
|
||||||
parseSuccess, parseFailure);
|
parseSuccess, parseFailure);
|
||||||
}, parseFailure);
|
}, parseFailure);
|
||||||
}, parseFailure);
|
}, parseFailure);
|
||||||
|
|
||||||
@ -153,13 +152,13 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
|
|
||||||
onError: function onError(status) {
|
onError: function onError(status) {
|
||||||
if (status == 404) {
|
if (status == 404) {
|
||||||
var exception = new MissingPDFException( 'Missing PDF "' +
|
var exception = new MissingPDFException('Missing PDF "' +
|
||||||
source.url + '".');
|
source.url + '".');
|
||||||
handler.send('MissingPDF', { exception: exception });
|
handler.send('MissingPDF', { exception: exception });
|
||||||
} else {
|
} else {
|
||||||
handler.send('DocError', 'Unexpected server response (' +
|
handler.send('DocError', 'Unexpected server response (' +
|
||||||
status + ') while retrieving PDF "' +
|
status + ') while retrieving PDF "' +
|
||||||
source.url + '".');
|
source.url + '".');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -254,8 +253,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
if (ex instanceof PasswordException) {
|
if (ex instanceof PasswordException) {
|
||||||
// after password exception prepare to receive a new password
|
// after password exception prepare to receive a new password
|
||||||
// to repeat loading
|
// to repeat loading
|
||||||
pdfManager.passwordChangedPromise =
|
pdfManager.passwordChangedPromise = new LegacyPromise();
|
||||||
new LegacyPromise();
|
|
||||||
pdfManager.passwordChangedPromise.then(pdfManagerReady);
|
pdfManager.passwordChangedPromise.then(pdfManagerReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +344,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
}, function(e) {
|
}, function(e) {
|
||||||
|
|
||||||
var minimumStackMessage =
|
var minimumStackMessage =
|
||||||
'worker.js: while trying to getPage() and getOperatorList()';
|
'worker.js: while trying to getPage() and getOperatorList()';
|
||||||
|
|
||||||
var wrappedException;
|
var wrappedException;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user