mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #18031 from Snuffleupagus/issue-18030
[api-minor] Expose the /Desc-attribute of file attachments in the viewer (issue 18030)
This commit is contained in:
commit
16dbf5dcfd
7 changed files with 48 additions and 12 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -54,6 +54,7 @@
|
|||
!issue17056.pdf
|
||||
!issue17679.pdf
|
||||
!issue17679_2.pdf
|
||||
!issue18030.pdf
|
||||
!issue14953.pdf
|
||||
!issue15367.pdf
|
||||
!issue15372.pdf
|
||||
|
|
BIN
test/pdfs/issue18030.pdf
Normal file
BIN
test/pdfs/issue18030.pdf
Normal file
Binary file not shown.
|
@ -4005,7 +4005,7 @@ describe("annotation", function () {
|
|||
const fileSpecRef = Ref.get(19, 0);
|
||||
const fileSpecDict = new Dict();
|
||||
fileSpecDict.set("Type", Name.get("Filespec"));
|
||||
fileSpecDict.set("Desc", "");
|
||||
fileSpecDict.set("Desc", "abc");
|
||||
fileSpecDict.set("EF", embeddedFileDict);
|
||||
fileSpecDict.set("UF", "Test.txt");
|
||||
|
||||
|
@ -4035,6 +4035,7 @@ describe("annotation", function () {
|
|||
expect(data.annotationType).toEqual(AnnotationType.FILEATTACHMENT);
|
||||
expect(data.file.filename).toEqual("Test.txt");
|
||||
expect(data.file.content).toEqual(stringToBytes("Test attachment"));
|
||||
expect(data.file.description).toEqual("abc");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1475,11 +1475,28 @@ describe("api", function () {
|
|||
const pdfDoc = await loadingTask.promise;
|
||||
const attachments = await pdfDoc.getAttachments();
|
||||
|
||||
const attachment = attachments["foo.txt"];
|
||||
expect(attachment.filename).toEqual("foo.txt");
|
||||
expect(attachment.content).toEqual(
|
||||
const { filename, content, description } = attachments["foo.txt"];
|
||||
expect(filename).toEqual("foo.txt");
|
||||
expect(content).toEqual(
|
||||
new Uint8Array([98, 97, 114, 32, 98, 97, 122, 32, 10])
|
||||
);
|
||||
expect(description).toEqual("");
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets attachments, with /Desc", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue18030.pdf"));
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const attachments = await pdfDoc.getAttachments();
|
||||
|
||||
const { filename, content, description } = attachments["empty.pdf"];
|
||||
expect(filename).toEqual("Empty page.pdf");
|
||||
expect(content instanceof Uint8Array).toEqual(true);
|
||||
expect(content.length).toEqual(2357);
|
||||
expect(description).toEqual(
|
||||
"SHA512: 06bec56808f93846f1d41ff0be4e54079c1291b860378c801c0f35f1d127a8680923ff6de59bd5a9692f01f0d97ca4f26da178ed03635fa4813d86c58a6c981a"
|
||||
);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue