Attach (recommended) or Link to PDF file
Any PDF, e.g. the default compressed.tracemonkey-pldi-09.pdf of the viewer (the steps create the image).
Web browser and its version
Chromium 153
Operating system and its version
macOS 26.5
PDF.js version
6.4.299 (generic viewer from the pdfjs-dist release)
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
- Open a PDF in the viewer, add an image ("Add image"), click "Alt text" on it, enter a description (e.g. "A castle") and save the dialog.
- Download the PDF and open the downloaded file.
- Double-click the image to edit it, click "Alt text": the description "A castle" is shown. Check "Mark as decorative" and save the dialog.
- Download the PDF again.
What is the expected behavior?
The PDF is saved, with the image marked as decorative (or without its alt text).
What went wrong?
Saving fails, the console shows:
Error when saving the document: TypeError: Cannot set properties of undefined (setting 'structParent')
at StampEditor.serialize (pdf.mjs:26653:51)
at get serializable (pdf.mjs:6960:64)
at WorkerTransport.saveDocument
annotationStorage.serializable throws from then on, so no other change in the document can be saved either.
In StampEditor.serialize, accessibilityData is only set for a non-decorative image with an alt text:
if (!decorative && altText) {
serialized.accessibilityData = { type: "Figure", alt: altText };
}
if (this.annotationElementId) {
...
if (changes.isSameAltText) {
delete serialized.accessibilityData;
} else {
serialized.accessibilityData.structParent = this._initialData.structParent ?? -1;
}
For an existing image whose alt text changed to decorative (or was removed), serialized.accessibilityData is undefined when structParent is set.
Link to a viewer
No response
Additional context
We use PDF.js' editors in an editor for PDFs in OpenCloud (opencloud-eu/web-extensions#618), where the failing serialization meant that later changes weren't recognized at all.
Attach (recommended) or Link to PDF file
Any PDF, e.g. the default
compressed.tracemonkey-pldi-09.pdfof the viewer (the steps create the image).Web browser and its version
Chromium 153
Operating system and its version
macOS 26.5
PDF.js version
6.4.299 (generic viewer from the
pdfjs-distrelease)Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
What is the expected behavior?
The PDF is saved, with the image marked as decorative (or without its alt text).
What went wrong?
Saving fails, the console shows:
annotationStorage.serializablethrows from then on, so no other change in the document can be saved either.In
StampEditor.serialize,accessibilityDatais only set for a non-decorative image with an alt text:For an existing image whose alt text changed to decorative (or was removed),
serialized.accessibilityDataisundefinedwhenstructParentis set.Link to a viewer
No response
Additional context
We use PDF.js' editors in an editor for PDFs in OpenCloud (opencloud-eu/web-extensions#618), where the failing serialization meant that later changes weren't recognized at all.