logoalt Hacker News

bookman10yesterday at 4:11 PM1 replyview on HN

Not yet and it's a little messy now to be honest.

The pipeline itself is in node.js and uses mostly pdf-lib (https://pdf-lib.js.org/) and ebook-convert (https://manual.calibre-ebook.com/generated/en/ebook-convert....)

For epubs, I split the book into chapters and run ebook-convert on each chapter individually, adding an extra page if needed to make the number of pages even. Then I combine all the chapters and do a custom scheme for numbering (because you don't want numbers on blank pages, you want the numbering to start at chapter 1, etc)

For html books from Project Gutenberg for example, I make sure they have text in <p> and chapters in <h2>. Then do a similar logic with ebook-convert.

For pdf books, I just use pdf-lib to draw the pages directly.

I also shift odd pages to the right and even pages to the left so there is a larger inner margin than outer margin.

If you're looking to do custom books, I would just use ebook-convert by itself, it just won't be quite as pretty though because it lacks those improvements.


Replies

poulpy123yesterday at 4:23 PM

Thanks for the explanation!