Support providing a filename unconditionally, when passing binary data to PDFViewerApplication.open

Previously this was only supported in Firefox, however when merging PDFs the `PDFViewerApplication.onSaveAndLoad` method will provide a `filename` unconditionally.
This commit is contained in:
Jonas Jenwald 2026-05-10 13:51:33 +02:00
parent e86e9d9465
commit 0763c69b6a

View File

@ -1220,11 +1220,12 @@ const PDFViewerApplication = {
const workerParams = AppOptions.getAll(OptionKind.WORKER);
Object.assign(GlobalWorkerOptions, workerParams);
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
if (args.data && isPdfFile(args.filename)) {
this._contentDispositionFilename = args.filename;
}
} else if (args.url) {
if (args.data && isPdfFile(args.filename)) {
this._contentDispositionFilename = args.filename;
} else if (
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
args.url
) {
// The Firefox built-in viewer always calls `setTitleUsingUrl`, before
// `initPassiveLoading`, and it never provides an `originalUrl` here.
this.setTitleUsingUrl(