Fixing a PDF Accessibility Issue (Alternative desc

2019-01-26 20:30发布

问题:

Currently, I am working on a program that converts an html page into a PDF using the iText Library.

The Checker that I am using is PAC3 -->PDF Accessibility Checker 3 which is described by the following link (https://section508.gov/blog/check-pdf).

One of the issues is the “Alternate description missing for an Annotation” An excerpt from the following link explains it:

  • http://www.uottawa.ca/respect/sites/www.uottawa.ca.respect/files/fss-fixing-accessibility-errors-in-pdfs.pdf

Alternative description missing for an annotation This usually happens when the link is not clear enough. To fix this error, add alternative text to the link tags. To add the alternative text, please do the following;

  • In the tag tree, select the tag for the link, and select Properties from the options menu.
  • In the Touchup Properties dialog box, select the Tag Tab.
  • Type alternate text for the link, and click close

I have been trying to use iText to fix this problem, but googling, looking at the source and reading the documentation does not help.

Does anybody have any suggestions on how to either write the HTML or use the itext problem to get rid of the “Alternate description missing for an Annotation”

Thank you for your help

回答1:

You did not specify whether you using old code (XMLWorker, HTMLWorker) or new iText code (pdfHTML).

This of course impacts the proposed solution.

In my answer I am going to assume you are using pdfHTML

There are several options:

  • edit the incoming HTML using a library like JSoup
  • convert the incoming HTML to iText IElement objects, and edit those, setting properties where needed
  • write your own custom TagWorker that handles all instances of a specific tag, and write custom logic to deal with the missing annotations.

An example of a custom tag worker can be found here: https://developers.itextpdf.com/content/itext-7-examples/converting-html-pdf/pdfhtml-custom-tagworker-example



标签: html pdf itext