mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the functionality of the webViewerDownloadOrSave
function into a new PDFViewerApplication
method instead
Given that this relies on accessing properties on the `PDFDocumentProxy`-instance, it seems more appropriate for this code to live in `PDFViewerApplication`.
This commit is contained in:
parent
e6e2809825
commit
958ea2be8b
1 changed files with 10 additions and 12 deletions
22
web/app.js
22
web/app.js
|
@ -1060,6 +1060,14 @@ const PDFViewerApplication = {
|
|||
});
|
||||
},
|
||||
|
||||
downloadOrSave(options) {
|
||||
if (this.pdfDocument?.annotationStorage.size > 0) {
|
||||
this.save(options);
|
||||
} else {
|
||||
this.download(options);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* For PDF documents that contain e.g. forms and javaScript, we should only
|
||||
* trigger the fallback bar once the user has interacted with the page.
|
||||
|
@ -2712,21 +2720,11 @@ function webViewerPresentationMode() {
|
|||
function webViewerPrint() {
|
||||
PDFViewerApplication.triggerPrinting();
|
||||
}
|
||||
function webViewerDownloadOrSave(sourceEventType) {
|
||||
if (
|
||||
PDFViewerApplication.pdfDocument &&
|
||||
PDFViewerApplication.pdfDocument.annotationStorage.size > 0
|
||||
) {
|
||||
PDFViewerApplication.save({ sourceEventType });
|
||||
} else {
|
||||
PDFViewerApplication.download({ sourceEventType });
|
||||
}
|
||||
}
|
||||
function webViewerDownload() {
|
||||
webViewerDownloadOrSave("download");
|
||||
PDFViewerApplication.downloadOrSave({ sourceEventType: "download" });
|
||||
}
|
||||
function webViewerSave() {
|
||||
webViewerDownloadOrSave("save");
|
||||
PDFViewerApplication.downloadOrSave({ sourceEventType: "save" });
|
||||
}
|
||||
function webViewerFirstPage() {
|
||||
if (PDFViewerApplication.pdfDocument) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue