I've read all similar questions here, and most of the answers suggest using
calibre for this task, however, I'm trying to improve the output. Here I explain:
I've extracted text from a PDF using
pdftohtml (part of Poppler) using -c and -s options. I got an HTML that contains text and surprisingly text is correctly un-wrapped, so the main problem of extracting text from PDFs is gone. If I feed this Html to calibre (specifically to
ebook-convert) I get a dirty epub with the following problems that need to be solved:
- the title of the document repeats at header of every page -> it should be removed
- page numbers were in the pdf and appear in the epub, that make no sense -> they should be removed
- footnotes appear as normal text -> they should be recognized as footnotes and properly linked
- text is "dirty": there are many different classes for
<p>paragraphs, with "
absolute position" attributes, leading to messy text: sentences are in the correct order, but the different settings for every class make the text rendered slightly under, above, before or after (a few pixels) the place where it should be -> all the classes should be removed and replaced only with
<b> and <i>when needed
- titles appear in bold, and are somehow recognized by calibre heuristic conversion, however, this process is not always correctly performed
- additionally, no table of contents is created, and should be
Is there any software or library that performs these tasks? I'm not a developer, but I'd rather code something than editing every book by hand. I can't believe that in 2021 there's not a program that does that, since open source world is so vast and rich with every kind of tools. I think that what I'm explaining is a very common need, and that thousands of people have felt the same need. Looking forward to hear your suggestions.