I’m using MigraDoc to layout PDF documents, which are generated with PDFSharp. I would like to add Alt Text to images.
Intuitively, I would expect that the Image would have a property such as AltText, which is then rendered into the PDF document. But that doesn’t exist. MigraDoc does not seem to support accessibility tagging.
I understand that I can use PDFSharp to generate an accessible PDF using the UAManager:
https://docs.pdfsharp.net/PDFsharp/Topics/PDF-Features/Accessibility.html
But the UAManager can’t be used if the document is laid out using MigraDoc.
What I’ve tried:
- I’ve tried setting the Image.Tag property to the desired Alt Text, but of course that’s not it’s intended use.
- I’ve tried setting the Image.Tag property in MigraDoc to a known string, and then looping through the PDF to find the tagged image. I’m able to find the image, but still there’s no way to set the Alt Text at that point.
- The closest I’ve gotten is using PDFSharp to add the image, rather than MigraDoc. I loop through the PDF to find where the image should be. I use the UAManager to get a StructureBuilder for that page. But, when I try to get the XGraphics, it says “Cannot handle XGraphics objects for pages other than the current page”.
Am I missing something about this whole process?