@@ -469,8 +469,7 @@ class BaseViewer {
469
469
}
470
470
const pagesCount = pdfDocument . numPages ;
471
471
const firstPagePromise = pdfDocument . getPage ( 1 ) ;
472
-
473
- const annotationStorage = pdfDocument . annotationStorage ;
472
+ // Rendering (potentially) depends on this, hence fetching it immediately.
474
473
const optionalContentConfigPromise = pdfDocument . getOptionalContentConfig ( ) ;
475
474
476
475
this . _pagesCapability . promise . then ( ( ) => {
@@ -521,7 +520,6 @@ class BaseViewer {
521
520
id : pageNum ,
522
521
scale,
523
522
defaultViewport : viewport . clone ( ) ,
524
- annotationStorage,
525
523
optionalContentConfigPromise,
526
524
renderingQueue : this . renderingQueue ,
527
525
textLayerFactory,
@@ -1244,11 +1242,14 @@ class BaseViewer {
1244
1242
/**
1245
1243
* @param {HTMLDivElement } pageDiv
1246
1244
* @param {PDFPage } pdfPage
1245
+ * @param {AnnotationStorage } [annotationStorage] - Storage for annotation
1246
+ * data in forms.
1247
1247
* @param {string } [imageResourcesPath] - Path for image resources, mainly
1248
1248
* for annotation icons. Include trailing slash.
1249
1249
* @param {boolean } renderInteractiveForms
1250
1250
* @param {IL10n } l10n
1251
1251
* @param {boolean } [enableScripting]
1252
+ * @param {Promise<boolean> } [hasJSActionsPromise]
1252
1253
* @returns {AnnotationLayerBuilder }
1253
1254
*/
1254
1255
createAnnotationLayerBuilder (
@@ -1258,21 +1259,22 @@ class BaseViewer {
1258
1259
imageResourcesPath = "" ,
1259
1260
renderInteractiveForms = false ,
1260
1261
l10n = NullL10n ,
1261
- enableScripting = false
1262
+ enableScripting = false ,
1263
+ hasJSActionsPromise = null
1262
1264
) {
1263
1265
return new AnnotationLayerBuilder ( {
1264
1266
pageDiv,
1265
1267
pdfPage,
1266
- annotationStorage,
1268
+ annotationStorage :
1269
+ annotationStorage || this . pdfDocument ?. annotationStorage ,
1267
1270
imageResourcesPath,
1268
1271
renderInteractiveForms,
1269
1272
linkService : this . linkService ,
1270
1273
downloadManager : this . downloadManager ,
1271
1274
l10n,
1272
1275
enableScripting,
1273
- hasJSActionsPromise : enableScripting
1274
- ? this . pdfDocument . hasJSActions ( )
1275
- : Promise . resolve ( false ) ,
1276
+ hasJSActionsPromise :
1277
+ hasJSActionsPromise || this . pdfDocument ?. hasJSActions ( ) ,
1276
1278
} ) ;
1277
1279
}
1278
1280
0 commit comments