Skip to content

Commit

Permalink
Allow StreamsSequenceStream to skip sub-streams that are not actual…
Browse files Browse the repository at this point in the history
… Streams (issue 18973)

This extends PR 13796 to also handle the case where sub-streams contain invalid data, i.e. anything that isn't a Stream, however please note that in these cases there's no guarantee that we'll render the page "correctly".

Note that Adobe Reader, i.e. the PDF reference implementation, cannot render the last page of the referenced PDF document.
  • Loading branch information
Snuffleupagus committed Oct 29, 2024
1 parent 93961e2 commit 48a1858
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/decode_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class DecodeStream extends BaseStream {

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

let maybeLength = 0;
for (const stream of streams) {
maybeLength +=
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue18973.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/user-attachments/files/17550758/doc1520828609.pdf
9 changes: 9 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,15 @@
"firstPage": 3,
"type": "eq"
},
{
"id": "issue18973",
"file": "pdfs/issue18973.pdf",
"md5": "b9bbd312269862bf39bb2a31023a9d02",
"link": true,
"rounds": 1,
"firstPage": 45,
"type": "eq"
},
{
"id": "issue9262",
"file": "pdfs/issue9262_reduced.pdf",
Expand Down

0 comments on commit 48a1858

Please sign in to comment.