WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Image alt text not being converted to alt tags in PDF/UA

Open brendan-ward opened this issue 2 years ago • 5 comments

Thank you for this library, it has been very helpful for our work!

We are creating PDFs that contain a lot of map images using variant="pdf/ua-1".

Within our HTML, we are assigning these alt tags in the normal way for HTML.

<img src="..." alt="My image" />

However, these seem to be missing Alt tags when converted to PDF/UA, and so they are failing accessibility checks.

I don't quite follow how these are converted into tags in PDF/UA, but it seems like it should be possible in theory to retain the alt tag when processing the image and convert it into the associated alt tag in PDF/UA.

I didn't see examples to clarify if there was another way to properly tag images.

Possibly related: #1838

brendan-ward avatar May 05 '23 17:05 brendan-ward

Hi!

Yes, unfortunately, many things are not handled with PDF/UA support yet.

I don't quite follow how these are converted into tags in PDF/UA, but it seems like it should be possible in theory to retain the alt tag when processing the image and convert it into the associated alt tag in PDF/UA.

Tags are set in the stream.py file and structured in the pdfua.py file, where you have ElementTree elements (ie. HTML tags transformed into Python objects) and thus alt attributes. By changing these two functions, it should be possible to put the alt attributes into correct PDF tags.

liZe avatar May 06 '23 08:05 liZe

+1 interested also for the "alt" on image during PDF export

Tomefa avatar Jun 13 '23 09:06 Tomefa

+1 interested also for the "alt" on image during PDF export

If someone wants to add the feature, I’ll be happy to help! The previous comment already contains useful tips.

liZe avatar Jun 18 '23 13:06 liZe