commit
f74772f40e
1
Makefile
1
Makefile
@ -36,6 +36,7 @@ PDF_JS_FILES = \
|
||||
stream.js \
|
||||
worker.js \
|
||||
../external/jpgjs/jpg.js \
|
||||
jpx.js \
|
||||
$(NULL)
|
||||
|
||||
# make server
|
||||
|
@ -23,6 +23,7 @@
|
||||
<script type="text/javascript" src="../../src/stream.js"></script>
|
||||
<script type="text/javascript" src="../../src/worker.js"></script>
|
||||
<script type="text/javascript" src="../../external/jpgjs/jpg.js"></script>
|
||||
<script type="text/javascript" src="../../src/jpx.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Specify the main script used to create a new PDF.JS web worker.
|
||||
|
@ -23,6 +23,7 @@
|
||||
<script type="text/javascript" src="../../src/stream.js"></script>
|
||||
<script type="text/javascript" src="../../src/worker.js"></script>
|
||||
<script type="text/javascript" src="../../external/jpgjs/jpg.js"></script>
|
||||
<script type="text/javascript" src="../../src/jpx.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Specify the main script used to create a new PDF.JS web worker.
|
||||
|
1854
src/jpx.js
Normal file
1854
src/jpx.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -240,6 +240,10 @@ var Parser = (function ParserClosure() {
|
||||
var bytes = stream.getBytes(length);
|
||||
return new JpegStream(bytes, stream.dict, this.xref);
|
||||
}
|
||||
if (name == 'JPXDecode' || name == 'JPX') {
|
||||
var bytes = stream.getBytes(length);
|
||||
return new JpxStream(bytes, stream.dict);
|
||||
}
|
||||
if (name == 'ASCII85Decode' || name == 'A85') {
|
||||
return new Ascii85Stream(stream);
|
||||
}
|
||||
|
103
src/stream.js
103
src/stream.js
@ -835,7 +835,7 @@ var JpegStream = (function JpegStreamClosure() {
|
||||
return bytesToString(this.bytes);
|
||||
};
|
||||
JpegStream.prototype.getChar = function jpegStreamGetChar() {
|
||||
error('internal error: getChar is not valid on JpegStream');
|
||||
error('internal error: getChar is not valid on JpegStream');
|
||||
};
|
||||
/**
|
||||
* Checks if the image can be decoded and displayed by the browser without any
|
||||
@ -869,6 +869,107 @@ var JpegStream = (function JpegStreamClosure() {
|
||||
return JpegStream;
|
||||
})();
|
||||
|
||||
/**
|
||||
* For JPEG 2000's we use a library to decode these images and
|
||||
* the stream behaves like all the other DecodeStreams.
|
||||
*/
|
||||
var JpxStream = (function JpxStreamClosure() {
|
||||
function JpxStream(bytes, dict) {
|
||||
this.dict = dict;
|
||||
this.bytes = bytes;
|
||||
|
||||
DecodeStream.call(this);
|
||||
}
|
||||
|
||||
JpxStream.prototype = Object.create(DecodeStream.prototype);
|
||||
|
||||
JpxStream.prototype.ensureBuffer = function jpxStreamEnsureBuffer(req) {
|
||||
if (this.bufferLength)
|
||||
return;
|
||||
|
||||
var jpxImage = new JpxImage();
|
||||
jpxImage.parse(this.bytes);
|
||||
|
||||
var width = jpxImage.width;
|
||||
var height = jpxImage.height;
|
||||
var componentsCount = jpxImage.componentsCount;
|
||||
if (componentsCount != 1 && componentsCount != 3 && componentsCount != 4)
|
||||
error('JPX with ' + componentsCount + ' components is not supported');
|
||||
|
||||
var data = new Uint8Array(width * height * componentsCount);
|
||||
|
||||
for (var k = 0, kk = jpxImage.tiles.length; k < kk; k++) {
|
||||
var tileCompoments = jpxImage.tiles[k];
|
||||
var tileWidth = tileCompoments[0].width;
|
||||
var tileHeight = tileCompoments[0].height;
|
||||
var tileLeft = tileCompoments[0].left;
|
||||
var tileTop = tileCompoments[0].top;
|
||||
|
||||
var dataPosition, sourcePosition, data0, data1, data2, data3, rowFeed;
|
||||
switch (componentsCount) {
|
||||
case 1:
|
||||
data0 = tileCompoments[0].items;
|
||||
|
||||
dataPosition = width * tileTop + tileLeft;
|
||||
rowFeed = width - tileWidth;
|
||||
sourcePosition = 0;
|
||||
for (var j = 0; j < tileHeight; j++) {
|
||||
for (var i = 0; i < tileWidth; i++)
|
||||
data[dataPosition++] = data0[sourcePosition++];
|
||||
dataPosition += rowFeed;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
data0 = tileCompoments[0].items;
|
||||
data1 = tileCompoments[1].items;
|
||||
data2 = tileCompoments[2].items;
|
||||
|
||||
dataPosition = (width * tileTop + tileLeft) * 3;
|
||||
rowFeed = (width - tileWidth) * 3;
|
||||
sourcePosition = 0;
|
||||
for (var j = 0; j < tileHeight; j++) {
|
||||
for (var i = 0; i < tileWidth; i++) {
|
||||
data[dataPosition++] = data0[sourcePosition];
|
||||
data[dataPosition++] = data1[sourcePosition];
|
||||
data[dataPosition++] = data2[sourcePosition];
|
||||
sourcePosition++;
|
||||
}
|
||||
dataPosition += rowFeed;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
data0 = tileCompoments[0].items;
|
||||
data1 = tileCompoments[1].items;
|
||||
data2 = tileCompoments[2].items;
|
||||
data3 = tileCompoments[3].items;
|
||||
|
||||
dataPosition = (width * tileTop + tileLeft) * 4;
|
||||
rowFeed = (width - tileWidth) * 4;
|
||||
sourcePosition = 0;
|
||||
for (var j = 0; j < tileHeight; j++) {
|
||||
for (var i = 0; i < tileWidth; i++) {
|
||||
data[dataPosition++] = data0[sourcePosition];
|
||||
data[dataPosition++] = data1[sourcePosition];
|
||||
data[dataPosition++] = data2[sourcePosition];
|
||||
data[dataPosition++] = data3[sourcePosition];
|
||||
sourcePosition++;
|
||||
}
|
||||
dataPosition += rowFeed;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.buffer = data;
|
||||
this.bufferLength = data.length;
|
||||
};
|
||||
JpxStream.prototype.getChar = function jpxStreamGetChar() {
|
||||
error('internal error: getChar is not valid on JpxStream');
|
||||
};
|
||||
|
||||
return JpxStream;
|
||||
})();
|
||||
|
||||
var DecryptStream = (function DecryptStreamClosure() {
|
||||
function DecryptStream(str, decrypt) {
|
||||
this.str = str;
|
||||
|
@ -23,7 +23,8 @@ var files = [
|
||||
'pattern.js',
|
||||
'stream.js',
|
||||
'worker.js',
|
||||
'../external/jpgjs/jpg.js'
|
||||
'../external/jpgjs/jpg.js',
|
||||
'jpx.js'
|
||||
];
|
||||
|
||||
// Load all the files.
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -22,4 +22,5 @@
|
||||
!issue918.pdf
|
||||
!smaskdim.pdf
|
||||
!type4psfunc.pdf
|
||||
!S2.pdf
|
||||
!zerowidthline.pdf
|
||||
|
2549
test/pdfs/S2.pdf
Normal file
2549
test/pdfs/S2.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -410,6 +410,12 @@
|
||||
"link": true,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "S2-eq",
|
||||
"file": "pdfs/S2.pdf",
|
||||
"md5": "d0b6137846df6e0fe058f234a87fb588",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1055",
|
||||
"file": "pdfs/issue1055.pdf",
|
||||
"md5": "3ba56c2e48dce81da8669b1b9cf98ff0",
|
||||
|
@ -22,6 +22,7 @@
|
||||
<script type="text/javascript" src="/src/stream.js"></script>
|
||||
<script type="text/javascript" src="/src/worker.js"></script>
|
||||
<script type="text/javascript" src="/external/jpgjs/jpg.js"></script>
|
||||
<script type="text/javascript" src="/src/jpx.js"></script>
|
||||
<script type="text/javascript" src="driver.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -26,6 +26,7 @@
|
||||
<script type="text/javascript" src="../src/stream.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||
<script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||
<script type="text/javascript" src="../external/jpgjs/jpg.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||
<script type="text/javascript" src="../src/jpx.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||
<script type="text/javascript" src="viewer.js"></script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user