1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

[api-minor] Attempt to support fetching the raw data of the PDF document from the PDFDocumentLoadingTask-instance (issue 15085)

The new API-functionality will allow a PDF document to be downloaded in the viewer e.g. while the PasswordPrompt is open, or in cases when document initialization failed.
Normally the raw data of the PDF document would be accessed via the `PDFDocumentProxy.prototype.getData` method, however in these cases the `PDFDocumentProxy`-instance isn't available.
This commit is contained in:
Jonas Jenwald 2025-03-09 14:50:43 +01:00
parent d1d88cc09e
commit 9e8d4e4d46
3 changed files with 92 additions and 30 deletions

View file

@ -1153,7 +1153,9 @@ const PDFViewerApplication = {
async download() {
let data;
try {
data = await this.pdfDocument.getData();
data = await (this.pdfDocument
? this.pdfDocument.getData()
: this.pdfLoadingTask.getData());
} catch {
// When the PDF document isn't ready, simply download using the URL.
}