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
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
|
* 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.
|
* trigger the fallback bar once the user has interacted with the page.
|
||||||
@ -2712,21 +2720,11 @@ function webViewerPresentationMode() {
|
|||||||
function webViewerPrint() {
|
function webViewerPrint() {
|
||||||
PDFViewerApplication.triggerPrinting();
|
PDFViewerApplication.triggerPrinting();
|
||||||
}
|
}
|
||||||
function webViewerDownloadOrSave(sourceEventType) {
|
|
||||||
if (
|
|
||||||
PDFViewerApplication.pdfDocument &&
|
|
||||||
PDFViewerApplication.pdfDocument.annotationStorage.size > 0
|
|
||||||
) {
|
|
||||||
PDFViewerApplication.save({ sourceEventType });
|
|
||||||
} else {
|
|
||||||
PDFViewerApplication.download({ sourceEventType });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function webViewerDownload() {
|
function webViewerDownload() {
|
||||||
webViewerDownloadOrSave("download");
|
PDFViewerApplication.downloadOrSave({ sourceEventType: "download" });
|
||||||
}
|
}
|
||||||
function webViewerSave() {
|
function webViewerSave() {
|
||||||
webViewerDownloadOrSave("save");
|
PDFViewerApplication.downloadOrSave({ sourceEventType: "save" });
|
||||||
}
|
}
|
||||||
function webViewerFirstPage() {
|
function webViewerFirstPage() {
|
||||||
if (PDFViewerApplication.pdfDocument) {
|
if (PDFViewerApplication.pdfDocument) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user