Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core/base_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class BaseStream {
return false;
}

get isImageStream() {
return false;
}

get canAsyncDecodeImageFromBuffer() {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/ccitt_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class CCITTFaxStream extends DecodeStream {
this.buffer[this.bufferLength++] = c;
}
}

get isImageStream() {
return true;
}
}

export { CCITTFaxStream };
2 changes: 1 addition & 1 deletion src/core/decode_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class DecodeStream extends BaseStream {

class StreamsSequenceStream extends DecodeStream {
constructor(streams, onError = null) {
streams = streams.filter(s => s instanceof BaseStream);
streams = streams.filter(s => s instanceof BaseStream && !s.isImageStream);

let maybeLength = 0;
for (const stream of streams) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Page {
async getContentStream() {
const content = await this.pdfManager.ensure(this, "content");

if (content instanceof BaseStream) {
if (content instanceof BaseStream && !content.isImageStream) {
return content;
}
if (Array.isArray(content)) {
Expand Down
4 changes: 4 additions & 0 deletions src/core/jbig2_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class Jbig2Stream extends DecodeStream {
return true;
}

get isImageStream() {
return true;
}

async decodeImage(bytes, _decoderOptions) {
if (this.eof) {
return this.buffer;
Expand Down
4 changes: 4 additions & 0 deletions src/core/jpeg_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ class JpegStream extends DecodeStream {
decoder?.close();
}
}

get isImageStream() {
return true;
}
}

export { JpegStream };
4 changes: 4 additions & 0 deletions src/core/jpx_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class JpxStream extends DecodeStream {
get canAsyncDecodeImageFromBuffer() {
return this.stream.isAsync;
}

get isImageStream() {
return true;
}
}

export { JpxStream };
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,4 @@
!bitmap-trailing-7fff-stripped-harder.pdf
!bitmap-trailing-7fff-stripped.pdf
!bitmap.pdf
!bomb_giant.pdf
Binary file added test/pdfs/bomb_giant.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13922,5 +13922,12 @@
"rounds": 1,
"type": "eq",
"useWasm": false
},
{
"id": "bomb_giant_contents_image_stream",
"file": "pdfs/bomb_giant.pdf",
"md5": "e515a9abb11ab74332e57e371bfae61e",
"rounds": 1,
"type": "eq"
}
]
Loading