@@ -629,39 +629,48 @@ const isValidExplicitDest = _isValidExplicitDest.bind(
629629class PDFDocumentLoadingTask {
630630 static #docId = 0 ;
631631
632- constructor ( ) {
633- this . _capability = Promise . withResolvers ( ) ;
634- this . _transport = null ;
635- this . _worker = null ;
632+ /**
633+ * @private
634+ */
635+ _capability = Promise . withResolvers ( ) ;
636636
637- /**
638- * Unique identifier for the document loading task.
639- * @type {string }
640- */
641- this . docId = `d${ PDFDocumentLoadingTask . #docId++ } ` ;
637+ /**
638+ * @private
639+ */
640+ _transport = null ;
642641
643- /**
644- * Whether the loading task is destroyed or not.
645- * @type {boolean }
646- */
647- this . destroyed = false ;
642+ /**
643+ * @private
644+ */
645+ _worker = null ;
648646
649- /**
650- * Callback to request a password if a wrong or no password was provided.
651- * The callback receives two parameters: a function that should be called
652- * with the new password, and a reason (see {@link PasswordResponses}).
653- * @type {function }
654- */
655- this . onPassword = null ;
647+ /**
648+ * Unique identifier for the document loading task.
649+ * @type {string }
650+ */
651+ docId = `d${ PDFDocumentLoadingTask . #docId++ } ` ;
656652
657- /**
658- * Callback to be able to monitor the loading progress of the PDF file
659- * (necessary to implement e.g. a loading bar).
660- * The callback receives an {@link OnProgressParameters} argument.
661- * @type {function }
662- */
663- this . onProgress = null ;
664- }
653+ /**
654+ * Whether the loading task is destroyed or not.
655+ * @type {boolean }
656+ */
657+ destroyed = false ;
658+
659+ /**
660+ * Callback to request a password if a wrong or no password was provided.
661+ * The callback receives two parameters: a function that should be called
662+ * with the new password, and a reason (see {@link PasswordResponses}).
663+ * @type {function }
664+ */
665+ onPassword = null ;
666+
667+ /**
668+ * Callback to be able to monitor the loading progress of the PDF file
669+ * (necessary to implement e.g. a loading bar).
670+ * The callback receives an {@link OnProgressParameters} argument.
671+ * @type {function }
672+ */
673+ onProgress = null ;
665674
666675 /**
667676 * Promise for document loading task completion.
@@ -699,6 +708,16 @@ class PDFDocumentLoadingTask {
699708 this . _worker ?. destroy ( ) ;
700709 this . _worker = null ;
701710 }
711+
712+ /**
713+ * Attempt to fetch the raw data of the PDF document, when e.g.
714+ * - An exception was thrown during document initialization.
715+ * - An `onPassword` callback is delaying initialization.
716+ * @returns {Promise<Uint8Array> }
717+ */
718+ async getData ( ) {
719+ return this . _transport . getData ( ) ;
720+ }
702721}
703722
704723/**
0 commit comments