Create Live Index for ePub

This script  creates an index which will operate in the same way when exported for Epub or for PDF.  The page links are active and when clicked will go to the requested page. If the index was created by InDesign using the indexing features of the application, normal export of the document to Epub will not export the index as the index markers have no equivalent in an Epub representation. This script avoids this problem by creating a clone of the index which is text based.  The script copies the index to the host file system and then creates a new layer with a non printing attribute. It then places the file from the file system in new pages at the end on the document on the new layer. Since the cloned index is an exact copy but is text based, it will be exported to an Epub while it will not be exported to PDF as the layer is non printing.  Exports to ePub ignore the non printing attribute so the new index is exported to ePub. The script then creates text anchors on each page of the document and proceeds to link the text anchors with the page numbers in the index. The result is an index with hyperlinks to pages in the resulting ePub which are live and clickable.