mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Editor] Add the possibility to save an updated stamp annotation (bug 1921291)
This commit is contained in:
parent
0308b8075f
commit
c9050be863
9 changed files with 338 additions and 83 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -672,3 +672,4 @@
|
|||
!issue16038.pdf
|
||||
!highlight_popup.pdf
|
||||
!issue18072.pdf
|
||||
!stamps.pdf
|
||||
|
|
BIN
test/pdfs/stamps.pdf
Executable file
BIN
test/pdfs/stamps.pdf
Executable file
Binary file not shown.
|
@ -10578,5 +10578,94 @@
|
|||
"noPrint": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "stamps-editor-save-print",
|
||||
"file": "pdfs/stamps.pdf",
|
||||
"md5": "0f8e16d204d4863be159f77aa8045938",
|
||||
"rounds": 1,
|
||||
"lastPage": 1,
|
||||
"type": "eq",
|
||||
"save": true,
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"pdfjs_internal_editor_0": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [87, 72, 251, 382],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "25R"
|
||||
},
|
||||
"pdfjs_internal_editor_1": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [350, 337, 524, 522],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "34R"
|
||||
},
|
||||
"pdfjs_internal_editor_2": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [82, 608, 234, 735],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "58R"
|
||||
},
|
||||
"pdfjs_internal_editor_3": {
|
||||
"pageIndex": 0,
|
||||
"deleted": true,
|
||||
"id": "37R",
|
||||
"popupRef": "44R"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "stamps-editor-print",
|
||||
"file": "pdfs/stamps.pdf",
|
||||
"md5": "0f8e16d204d4863be159f77aa8045938",
|
||||
"rounds": 1,
|
||||
"lastPage": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"pdfjs_internal_editor_0": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [87, 72, 251, 382],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "25R"
|
||||
},
|
||||
"pdfjs_internal_editor_1": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [350, 337, 524, 522],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "34R"
|
||||
},
|
||||
"pdfjs_internal_editor_2": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"rect": [82, 608, 234, 735],
|
||||
"rotation": 0,
|
||||
"isSvg": false,
|
||||
"structTreeParentId": null,
|
||||
"id": "58R"
|
||||
},
|
||||
"pdfjs_internal_editor_3": {
|
||||
"pageIndex": 0,
|
||||
"deleted": true,
|
||||
"id": "37R",
|
||||
"popupRef": "44R"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4283,6 +4283,7 @@ describe("annotation", function () {
|
|||
value: "Hello PDF.js World !",
|
||||
id: "143R",
|
||||
ref: freeTextRef,
|
||||
oldAnnotation: freeTextDict,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
|
|
@ -2800,7 +2800,7 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("write a new stamp annotation in a non-tagged pdf, save and check that the structure tree", async function () {
|
||||
it("write a new stamp annotation in a non-tagged pdf, save and check the structure tree", async function () {
|
||||
if (isNodeJS) {
|
||||
pending("Cannot create a bitmap from Node.js.");
|
||||
}
|
||||
|
@ -2949,6 +2949,52 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("write an updated stamp annotation in a tagged pdf, save and check the structure tree", async function () {
|
||||
let loadingTask = getDocument(buildGetDocumentParams("stamps.pdf"));
|
||||
let pdfDoc = await loadingTask.promise;
|
||||
pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_1", {
|
||||
annotationType: AnnotationEditorType.STAMP,
|
||||
pageIndex: 0,
|
||||
rect: [72.5, 134.17, 246.49, 318.7],
|
||||
rotation: 0,
|
||||
isSvg: false,
|
||||
structTreeParentId: null,
|
||||
accessibilityData: {
|
||||
type: "Figure",
|
||||
alt: "The Firefox logo",
|
||||
structParent: -1,
|
||||
},
|
||||
id: "34R",
|
||||
});
|
||||
pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_4", {
|
||||
annotationType: AnnotationEditorType.STAMP,
|
||||
pageIndex: 0,
|
||||
rect: [335.1, 394.83, 487.17, 521.47],
|
||||
rotation: 0,
|
||||
isSvg: false,
|
||||
structTreeParentId: null,
|
||||
accessibilityData: {
|
||||
type: "Figure",
|
||||
alt: "An elephant with a red hat",
|
||||
structParent: 0,
|
||||
},
|
||||
id: "58R",
|
||||
});
|
||||
|
||||
const data = await pdfDoc.saveDocument();
|
||||
await loadingTask.destroy();
|
||||
|
||||
loadingTask = getDocument(data);
|
||||
pdfDoc = await loadingTask.promise;
|
||||
const page = await pdfDoc.getPage(1);
|
||||
const tree = await page.getStructTree();
|
||||
|
||||
expect(tree.children[0].alt).toEqual("An elephant with a red hat");
|
||||
expect(tree.children[1].alt).toEqual("The Firefox logo");
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("read content from multiline textfield containing an empty line", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue17492.pdf"));
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue