5

Is it possible to determine programatically whether a PDF is "tagged" (for accessibility)? I'm using PHP, and would like (if possible) to simply read a PDF file and return true if tagged, false if not.

I've looked at FPDF and TCPDF, but it isn't clear to me whether either can extract this information.

2 Answers 2

6

In the official ISO PDF-1.7 specification (in the copy available for free from the Adobe website), I read on page 574:

"A Tagged PDF document shall also contain a mark information dictionary (see Table 321) with a value of true for the Marked entry."

To me that means...

  1. ...you'll have to parse the PDF structure and
  2. ...look for the document catalogue
  3. ...where there should be a MarkInfo entry
  4. ...specifying a mark information dictionary
  5. ...which should contain a key named Marked with a boolean value of true for tagged PDF.
3
  • That seems to always appear as "<</Marked true>>", findable by searching the PDF as a string. Thanks ! Commented May 27, 2012 at 20:19
  • @Terrill Thomson: Yes, it may work for 95% or more of all tagged PDFs. But don't rely on just grepping for that string if you need high reliability. (Also, one could easily create such a PDF which declares itself as tagged this way, but in practice doesn't 'keep the promise' and does fail all compliance checks... Commented May 27, 2012 at 21:34
  • 1
    @TerrillThompson: The document catalog can be compressed. Commented May 28, 2012 at 12:06
3

Perhaps you can go further with this (check all PDF_get_xx functions). You will also need this as reference.

Based on this:

Characteristics of a properly tagged PDF:

    - The PDF file includes a logical reading order for its content
    - Images are given correct alternate descriptions
    - Tables are correctly tagged to represent the table structure
    - Form-fields are authored to promote their utility to screen-readers
    - Represents text as Unicode to clear up composition irregularities such as soft
      and hard hyphens

you might get further.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.