@@ -30,6 +30,7 @@ import {
30
30
stringToPDFString ,
31
31
stringToUTF8String ,
32
32
unreachable ,
33
+ UNSUPPORTED_FEATURES ,
33
34
Util ,
34
35
warn ,
35
36
} from "../shared/util.js" ;
@@ -225,16 +226,35 @@ class Page {
225
226
return shadow ( this , "rotate" , rotate ) ;
226
227
}
227
228
229
+ /**
230
+ * @private
231
+ */
232
+ _onSubStreamError ( handler , reason , objId ) {
233
+ if ( this . evaluatorOptions . ignoreErrors ) {
234
+ // Error(s) when reading one of the /Contents sub-streams -- sending
235
+ // unsupported feature notification and allow parsing to continue.
236
+ handler . send ( "UnsupportedFeature" , {
237
+ featureId : UNSUPPORTED_FEATURES . errorContentSubStream ,
238
+ } ) ;
239
+ warn ( `getContentStream - ignoring sub-stream (${ objId } ): "${ reason } ".` ) ;
240
+ return ;
241
+ }
242
+ throw reason ;
243
+ }
244
+
228
245
/**
229
246
* @returns {Promise<BaseStream> }
230
247
*/
231
- getContentStream ( ) {
248
+ getContentStream ( handler ) {
232
249
return this . pdfManager . ensure ( this , "content" ) . then ( content => {
233
250
if ( content instanceof BaseStream ) {
234
251
return content ;
235
252
}
236
253
if ( Array . isArray ( content ) ) {
237
- return new StreamsSequenceStream ( content ) ;
254
+ return new StreamsSequenceStream (
255
+ content ,
256
+ this . _onSubStreamError . bind ( this , handler )
257
+ ) ;
238
258
}
239
259
// Replace non-existent page content with empty content.
240
260
return new NullStream ( ) ;
@@ -307,7 +327,7 @@ class Page {
307
327
renderInteractiveForms,
308
328
annotationStorage,
309
329
} ) {
310
- const contentStreamPromise = this . getContentStream ( ) ;
330
+ const contentStreamPromise = this . getContentStream ( handler ) ;
311
331
const resourcesPromise = this . loadResources ( [
312
332
"ColorSpace" ,
313
333
"ExtGState" ,
@@ -417,7 +437,7 @@ class Page {
417
437
sink,
418
438
combineTextItems,
419
439
} ) {
420
- const contentStreamPromise = this . getContentStream ( ) ;
440
+ const contentStreamPromise = this . getContentStream ( handler ) ;
421
441
const resourcesPromise = this . loadResources ( [
422
442
"ExtGState" ,
423
443
"Font" ,
0 commit comments