1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Search for destinations in both /Names and /Dests dictionaries (issue 19474)

Currently we only use either one of them, preferring the NameTree when it's available.
This commit is contained in:
Jonas Jenwald 2025-02-12 13:47:13 +01:00
parent c69282a64f
commit 33cba30bdb
4 changed files with 65 additions and 33 deletions

View file

@ -533,6 +533,7 @@
!transparent.pdf
!issue19326.pdf
!issue13931.pdf
!issue19474.pdf
!xobject-image.pdf
!issue15441.pdf
!issue6605.pdf

BIN
test/pdfs/issue19474.pdf Normal file

Binary file not shown.

View file

@ -1261,6 +1261,19 @@ describe("api", function () {
await loadingTask.destroy();
});
it("gets destinations, from /Names (NameTree) respectively /Dests dictionary", async function () {
const loadingTask = getDocument(buildGetDocumentParams("issue19474.pdf"));
const pdfDoc = await loadingTask.promise;
const destinations = await pdfDoc.getDestinations();
expect(destinations).toEqual({
A: [{ num: 1, gen: 0 }, { name: "Fit" }],
B: [{ num: 4, gen: 0 }, { name: "Fit" }],
C: [{ num: 5, gen: 0 }, { name: "Fit" }],
});
await loadingTask.destroy();
});
it("gets a destination, from /Names (NameTree) dictionary", async function () {
const loadingTask = getDocument(buildGetDocumentParams("issue6204.pdf"));
const pdfDoc = await loadingTask.promise;
@ -1320,6 +1333,22 @@ describe("api", function () {
await loadingTask.destroy();
});
it("gets a destination, from /Names (NameTree) respectively /Dests dictionary", async function () {
const loadingTask = getDocument(buildGetDocumentParams("issue19474.pdf"));
const pdfDoc = await loadingTask.promise;
const destA = await pdfDoc.getDestination("A");
expect(destA).toEqual([{ num: 1, gen: 0 }, { name: "Fit" }]);
const destB = await pdfDoc.getDestination("B");
expect(destB).toEqual([{ num: 4, gen: 0 }, { name: "Fit" }]);
const destC = await pdfDoc.getDestination("C");
expect(destC).toEqual([{ num: 5, gen: 0 }, { name: "Fit" }]);
await loadingTask.destroy();
});
it("gets non-string destination", async function () {
let numberPromise = pdfDocument.getDestination(4.3);
let booleanPromise = pdfDocument.getDestination(true);