1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

[Editor] Add the ability to create/update the structure tree when saving a pdf containing newly added annotations (bug 1845087)

When there is no tree, the tags for the new annotions are just put under the root element.
When there is a tree, we insert the new tags at the right place in using the value
of structTreeParentId (added in PR #16916).
This commit is contained in:
Calixte Denizet 2023-09-11 17:51:22 +02:00
parent 7f8de83e96
commit a8573d4e1b
8 changed files with 613 additions and 14 deletions

View file

@ -1639,7 +1639,7 @@ class MarkupAnnotation extends Annotation {
}
static async createNewAnnotation(xref, annotation, dependencies, params) {
const annotationRef = annotation.ref || xref.getNewTemporaryRef();
const annotationRef = (annotation.ref ||= xref.getNewTemporaryRef());
const ap = await this.createNewAppearanceStream(annotation, xref, params);
const buffer = [];
let annotationDict;
@ -1652,6 +1652,9 @@ class MarkupAnnotation extends Annotation {
} else {
annotationDict = this.createNewDict(annotation, xref, {});
}
if (Number.isInteger(annotation.parentTreeId)) {
annotationDict.set("StructParent", annotation.parentTreeId);
}
buffer.length = 0;
await writeObject(annotationRef, annotationDict, buffer, xref);