-
Notifications
You must be signed in to change notification settings - Fork 275
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Accessibility tags allow blind and low vision screen reader users the ability to access the information on PDFs. On download, the PDF needs to preserve the accessibility tags (and their order), the alternative text in images, and the title of the document. Without the tags a blind screen reader user cannot access the information in a human-readable way (if at all) on a digital PDF.
Bug:
A PDF with accessibility tags that is flattened and downloaded using unipdf loses some accessibility features such as accessibility tags and alternative text for images
.
Expected Behavior
Accessibility tags (in order) and alt text for images are preserved on download
How to test
You can test if a PDF has accessibility tags a few ways.
- Use the free tool PAC
- Use the adobe acrobat reader free version to see if PDF is tagged (image attached)
- Use adobe acrobat pro paid version and run accessibility checker (image attached)
Attachments
Attached you'll find:
- PDF with accessibility tags (accessibility-pdf.pdf)
- the output of the file on download with the tags removed (output.pdf)
- an image of where to find if the document is tagged with adobe acrobat free
- an image of what tags look like in adobe acrobat pro
adobe acrobat pro

adobe acrobat free

pdf with accessibility tags
pdf downloaded using unipdf (with lost accessibility tags)
Code
pdfReader, err :=pdf.NewPdfReader(bytes.NewReader(data))
if err != nil {
return nil, err
}
acroForm := pdfReader.AcroForm
if acroForm == nil {
return nil, errors.New("no form data present in pdf template")
}
w := &pdfFieldWriter{}
w.SetFields(acroForm.Fields)
w.LoadFieldOptions()
truPdf := pdfcore.PdfObjectBool(true)
acroForm.NeedAppearances = &truPdf
w.Write(FieldOptionTypes.ReservationNumber, issuance.ReservationNumber)
w.Write(FieldOptionTypes.Comment, issuance.Comment)
// this returns pdf with lost accessibility tags
return pdfReader.ToBytes(), nil
gunnsth
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request