mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[api-minor] Add partial support for the "GoToE" action (issue 8844)
*Please note:* The referenced issue is the only mention that I can find, in either GitHub or Bugzilla, of "GoToE" actions. Hence why I've purposely settled for a very simple, and partial, "GoToE" implementation to avoid complicating things initially.[1] In particular, this patch only supports "GoToE" actions that references the /EmbeddedFiles-dict in the PDF document. See https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2048909 --- [1] Usually I always prefer having *real-world* test-cases to work with, whenever I'm implementing new features.
This commit is contained in:
parent
8c59cc72a3
commit
ce66fefbff
8 changed files with 97 additions and 3 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -49,6 +49,7 @@
|
|||
!issue7426.pdf
|
||||
!issue7439.pdf
|
||||
!issue7847_radial.pdf
|
||||
!issue8844.pdf
|
||||
!issue14953.pdf
|
||||
!issue15367.pdf
|
||||
!issue15372.pdf
|
||||
|
|
BIN
test/pdfs/issue8844.pdf
Normal file
BIN
test/pdfs/issue8844.pdf
Normal file
Binary file not shown.
|
@ -15,6 +15,7 @@
|
|||
|
||||
import {
|
||||
AnnotationMode,
|
||||
AnnotationType,
|
||||
createPromiseCapability,
|
||||
FontType,
|
||||
ImageKind,
|
||||
|
@ -1536,6 +1537,7 @@ describe("api", function () {
|
|||
|
||||
expect(outline[4]).toEqual({
|
||||
action: null,
|
||||
attachment: undefined,
|
||||
dest: "Händel -- Halle🎆lujah",
|
||||
url: null,
|
||||
unsafeUrl: undefined,
|
||||
|
@ -1562,6 +1564,7 @@ describe("api", function () {
|
|||
|
||||
expect(outline[1]).toEqual({
|
||||
action: "PrevPage",
|
||||
attachment: undefined,
|
||||
dest: null,
|
||||
url: null,
|
||||
unsafeUrl: undefined,
|
||||
|
@ -1588,6 +1591,7 @@ describe("api", function () {
|
|||
|
||||
expect(outline[0]).toEqual({
|
||||
action: null,
|
||||
attachment: undefined,
|
||||
dest: null,
|
||||
url: null,
|
||||
unsafeUrl: undefined,
|
||||
|
@ -2155,6 +2159,23 @@ describe("api", function () {
|
|||
]);
|
||||
});
|
||||
|
||||
it("gets annotations containing GoToE action (issue 8844)", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue8844.pdf"));
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const pdfPage = await pdfDoc.getPage(1);
|
||||
const annotations = await pdfPage.getAnnotations();
|
||||
|
||||
expect(annotations.length).toEqual(1);
|
||||
expect(annotations[0].annotationType).toEqual(AnnotationType.LINK);
|
||||
|
||||
const { filename, content } = annotations[0].attachment;
|
||||
expect(filename).toEqual("man.pdf");
|
||||
expect(content instanceof Uint8Array).toEqual(true);
|
||||
expect(content.length).toEqual(4508);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets text content", async function () {
|
||||
const defaultPromise = page.getTextContent();
|
||||
const parametersPromise = page.getTextContent({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue