Open polizoto opened 1 year ago
I receive the "'Figure' element on a single page with no bounding box" (accessibility) error for every image in my PDF.
I am trying to loop through each image, capture its width and height, and set the /Bbox.
/Bbox
I have tried using the following code:
pdfDoc.context.enumerateIndirectObjects().forEach(object => { const pdfObject = object[1] if (!(pdfObject instanceof PDFRawStream)) return const { dict } = pdfObject const type = dict.get(PDFName.of('Type')) if (type === PDFName.of('XObject')) { const subtype = dict.get(PDFName.of('Subtype')) if (subtype === PDFName.of('Image')) { const width = dict.get(PDFName.of('Width')) const height = dict.get(PDFName.of('Height')) pdfObject.dict.set(PDFName.of('BBox'), new PDFArray([new PDFNumber(0), new PDFNumber(0), new PDFNumber(width), new PDFNumber(height)]) ) } } })
The error persists in the PDF after I try to set the Bounding Box.
What I would expect is for the Missing Bounding Box Error to go away.
Sample PDF:
How to Freeze Your Credit - NerdWallet.pdf
1.17.1
Node
No response
Note: I am checking the PDF using the PAC 2021 (accessibility) checker.
What were you trying to do?
I receive the "'Figure' element on a single page with no bounding box" (accessibility) error for every image in my PDF.
I am trying to loop through each image, capture its width and height, and set the
/Bbox
.How did you attempt to do it?
I have tried using the following code:
What actually happened?
The error persists in the PDF after I try to set the Bounding Box.
What did you expect to happen?
What I would expect is for the Missing Bounding Box Error to go away.
How can we reproduce the issue?
Sample PDF:
How to Freeze Your Credit - NerdWallet.pdf
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response