@@ -47,28 +47,28 @@ const loadingTask = pdfjsLib.getDocument({
47
47
cMapPacked : CMAP_PACKED ,
48
48
enableXfa : ENABLE_XFA ,
49
49
} ) ;
50
- loadingTask . promise . then ( function ( pdfDocument ) {
50
+ ( async function ( ) {
51
+ const pdfDocument = await loadingTask . promise ;
51
52
// Document loaded, retrieving the page.
52
- return pdfDocument . getPage ( PAGE_TO_VIEW ) . then ( function ( pdfPage ) {
53
- // Creating the page view with default parameters.
54
- const pdfPageView = new pdfjsViewer . PDFPageView ( {
55
- container,
56
- id : PAGE_TO_VIEW ,
57
- scale : SCALE ,
58
- defaultViewport : pdfPage . getViewport ( { scale : SCALE } ) ,
59
- eventBus,
60
- // We can enable text/annotation/xfa/struct-layers, as needed.
61
- textLayerFactory : ! pdfDocument . isPureXfa
62
- ? new pdfjsViewer . DefaultTextLayerFactory ( )
63
- : null ,
64
- annotationLayerFactory : new pdfjsViewer . DefaultAnnotationLayerFactory ( ) ,
65
- xfaLayerFactory : pdfDocument . isPureXfa
66
- ? new pdfjsViewer . DefaultXfaLayerFactory ( )
67
- : null ,
68
- structTreeLayerFactory : new pdfjsViewer . DefaultStructTreeLayerFactory ( ) ,
69
- } ) ;
70
- // Associate the actual page with the view, and draw it.
71
- pdfPageView . setPdfPage ( pdfPage ) ;
72
- return pdfPageView . draw ( ) ;
53
+ const pdfPage = await pdfDocument . getPage ( PAGE_TO_VIEW ) ;
54
+ // Creating the page view with default parameters.
55
+ const pdfPageView = new pdfjsViewer . PDFPageView ( {
56
+ container,
57
+ id : PAGE_TO_VIEW ,
58
+ scale : SCALE ,
59
+ defaultViewport : pdfPage . getViewport ( { scale : SCALE } ) ,
60
+ eventBus,
61
+ // We can enable text/annotation/xfa/struct-layers, as needed.
62
+ textLayerFactory : ! pdfDocument . isPureXfa
63
+ ? new pdfjsViewer . DefaultTextLayerFactory ( )
64
+ : null ,
65
+ annotationLayerFactory : new pdfjsViewer . DefaultAnnotationLayerFactory ( ) ,
66
+ xfaLayerFactory : pdfDocument . isPureXfa
67
+ ? new pdfjsViewer . DefaultXfaLayerFactory ( )
68
+ : null ,
69
+ structTreeLayerFactory : new pdfjsViewer . DefaultStructTreeLayerFactory ( ) ,
73
70
} ) ;
74
- } ) ;
71
+ // Associate the actual page with the view, and draw it.
72
+ pdfPageView . setPdfPage ( pdfPage ) ;
73
+ return pdfPageView . draw ( ) ;
74
+ } ) ( ) ;
0 commit comments