Accessibility-compliant table of contents

InDesign creates hyperlinks for the table-of-contents (TOC) entries when a TOC is generated. These hyperlinks are hidden, they don't appear in the Hyperlinks panel. They become active when the document is exported to PDF. Click a TOC entry in the PDF and the viewer jumps to the linked page.

Those TOC hyperlinks use page destinations. This is a problem for screen readers, because the page destinations cause readers to start reading from the top of the page no matter where on the page the referenced heading is.

To deal with this problem, the script changes the page destinations of TOC hyperlinks to text destinations. In the exported PDF the screen reader then starts reading from the referenced header.

If the document contains TOC bookmarks, they too are converted to target text destinations rather than page destinations.

Use

The script has no interface.

In a single-document publication, open the document. In a book project, open the book, then open the table of contents from the book panel. Then run the script from InDesign's Scripts panel.

In a book project the script saves and closes all the documents.

Troubleshooting

In order to find a TOC item's source in the text, the script matches the TOC entry with the headings on the relevant page. That means that the heading's content must be exactly the same as the TOC entry's content. But that's not always the case: when it generates the TOC, InDesign strips various items from the heading, such as index and footnote markers, text anchors, and probably some others; text variables are converted to text; and, finally, there's an option to remove forced line breaks (aka soft returns) from TOC entries.

The script considers these differences, but there may be items that aren't accounted for. If that happens the script shows a warning. Please write to me (contact link below) and send me your file and I'll update the script.


Version history

7 Dec. 2024: Posted.


Useful script? Saved you lots of time?

Consider making a donation. To make a donation, please click the button below. This is Paypal's payment system; you don't need a Paypal account to use it: you can use several types/brands of credit and debit card.

Peter Kahrel's paypal account

Download the scripts

Back to script index

Installing and running scripts

Questions, comments? Get in touch