Forum How do I...?

Calibre plugin to convert epub hyperlinks to footnotes

I am using the Prince PDF plugin for Calibre (latest versions). I have azw3 & epub files with endnotes that are formatted as hyperlinks rather than true endnotes.

I need to convert these hyperlinks to real footnotes at the bottom of each page.

Can you confirm if this is possible with Prince PDF please?

If so, what do I type in the Custom Styles window?



To clarify, the input is azw3 or epub with hyperlinks to notes at the end of each book.

The desired output is a pdf with footnotes at the bottom of each page.
If the endnotes are currently hyperlinks to content later in the document this will require using JavaScript to collect that content and insert it inline where the footnote should go and apply the appropriate CSS styling.
Hello there,

Sorry for the bump but since this is 100% my issue, I thought it would be best not to create a new topic.

I just came across Prince today and I'm very much in the same boat as the thread creator: Using the Prince PDF plugin in Calibre, trying to convert an epub file with hyperlinks instead of true endnotes to a PDF that has them as footnotes on the same page.

Prince seems to be the only solution I found that has the capability to handle this properly. A workaround by means of converting epub -> docx -> pdf is unsuitable because there are apparently too many hyperlinks in the file for Word to handle (it goes unresponsive for 45min+ when I try to replace all hyperlinks with footnotes using VBA).

Could you please elaborate on your previous post and provide a sample script, Mike? The solution seems sound but I'm not sure how to realize it.

To clarify, the hyperlinks have the format of /path/to.html#ftn.footnoteid

Thank you so much!
It is actually possible to do a simple version of this purely in CSS using the target-content() function, see the attached example below. This will not capture markup present in the footnote elements however.

I was going to create a JavaScript example to do something similar but along the way I hit an unexpected issue with the DOM API so I might investigate that further before proceeding. :D
  1. footnotes1.html0.6 kB
Actually it wasn't too bad, the JavaScript version is attached.
  1. footnotes2.html0.9 kB
Thank you very much for your reply! I will try to get it to work based on either of your solutions :)

Edited by cony

One minor issue: the footnotes2.html example refers to "a.hash", however on closer inspection Prince is currently returning the .hash value without a leading "#" character, which is incorrect. We will fix this in a future release of Prince, after which it will be necessary to use a.hash.substring(1) to access the ID.
Cony, I’m in the same boat and am trying to go via Word first - would you be willing to share the code you used in VBA? I’m not particularly au fait with the software, and know it didn’t work for you, but would like to give it a go!