1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Add support for "GoToE" actions with destinations (issue 17056)

This shouldn't be very common in practice, since "GoToE" actions themselves seem quite uncommon; see PR 15537.
This commit is contained in:
Jonas Jenwald 2023-10-03 08:01:55 +02:00
parent da4fdc76a3
commit bf9c33e60f
7 changed files with 62 additions and 19 deletions

View file

@ -67,7 +67,7 @@ class DownloadManager {
/**
* @returns {boolean} Indicating if the data was opened.
*/
openOrDownloadData(element, data, filename) {
openOrDownloadData(element, data, filename, dest = null) {
const isPdfData = isPdfFile(filename);
const contentType = isPdfData ? "application/pdf" : "";
@ -93,6 +93,9 @@ class DownloadManager {
"?file=" +
encodeURIComponent(blobUrl + "#" + filename);
}
if (dest) {
viewerUrl += `#${escape(dest)}`;
}
try {
window.open(viewerUrl);

View file

@ -132,7 +132,7 @@ class DownloadManager {
/**
* @returns {boolean} Indicating if the data was opened.
*/
openOrDownloadData(element, data, filename) {
openOrDownloadData(element, data, filename, dest = null) {
const isPdfData = isPdfFile(filename);
const contentType = isPdfData ? "application/pdf" : "";
@ -143,7 +143,10 @@ class DownloadManager {
this.#openBlobUrls.set(element, blobUrl);
}
// Let Firefox's content handler catch the URL and display the PDF.
const viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename);
let viewerUrl = blobUrl + "?filename=" + encodeURIComponent(filename);
if (dest) {
viewerUrl += `#${escape(dest)}`;
}
try {
window.open(viewerUrl);