View Single Post
Old 05-21-2023, 03:23 AM   #1
gonzalo_diaz
Junior Member
gonzalo_diaz began at the beginning.
 
Posts: 5
Karma: 10
Join Date: May 2023
Device: Kindle
EPUB links to PDF page numbers

Hello,

I wrote a book originally in EPUB flowable format, and now I am working on converting in to a PDF version.

At the end, the book has a custom alphabetical list of subjects. In the EPUB version, besides each item there is a link to the corresponding document and anchor, for example:

Alphabetical index

Subject A .......<a href="chapter1.xhtml#suba">Go</a>
Subject B .......<a href="chapter2.xhtml#subb">Go</a>

When converting to PDF, the "Go" hyperlinks are kept, and still point correctly to the right page. But I would like to change each Go for the actual page number resulting from the PDF conversion.

Alphabetical index

Subject A ....... page 1
Subject B ....... page 5

Is that possible? I plan to offer a printed version of the book's PDF, and the "Go" hyperlinks aren't that useful.

I see that, after the conversion from EPUB to PDF, Calibre "knows" the right page numbers, and stores them in anchors that look like, for example

<a href="#p20"></a>

But you can't specify that in the original EPUB to PDF Search & Replace page.

You can take the resulting PDF and do a second PDF to PDF conversion, in which you can do a regex replacement of the resulting of these <a href="#p20"> ... tags, but that type of conversion destroys the books format.

So, is there any wey to achieve this "link to page number" effect in one step?

I am pretty good with programming, HTML and JavaScript.
Thanks in advance for any comment or answer.
gonzalo_diaz is offline   Reply With Quote