Calibre (and produce and publish)

I have set up Produce and Publish to export ebooks with Calibre.

After the e-pub is made, I need to open the Ebook in Calibre Ebook edit and add the front cover and generate the TOC (Clicking on generate TOC from major headings work perfect).

I am pretty sure that this can be done from the command line, but I can not figure out from where the conversion is run).

.... any help is welcome... even if you have to bill me... or need help with something in return.

Produce & Publish - likely you are talking about the Produce & Publish Plone Client Connector - does nothing ebook related. The conversion is carried out on the Produce & Publish Server which wraps the ebook-convert binary. If you can accomplish your goal yourself with ebook-convert then it should be possible to do the same through the PP server and its API. Most supported converters support arbitrary command line options to be passed through the Python API to the REST endpoint of the PP server.


Looking at the pp.server code: is this what the 'cmd_options' is for ?

So in theory, it should be possible to use:



ebook-convert in.html out.epub -cover=/path/to/cover.jpg

( cover has to be an image in calibre convert, it can not be html )

The pdf() method

accepts on the API level the cmd_options parameter (which is just a string).

This parameter is not used and not fetch from the request...feel free to add it in your fork.

However the parameter is passed through the Python API

down to the converter level


1 Like

I think I got it now.

For later reference:

Typical parameters for the cover will be:

" --remove-first-image --cover=%s" % cover

where cover is path to an image

Typical TOC (table of contents) would be something like:

" --level1-toc=//h:h1 --level2-toc=//h:h2  --level3-toc=//h:h3"

the language can be set with:

" --language=%s" % language

resulting in something like this:

ebook-convert "/path/to/var/queue/af523db3-87b3-4e40-a3d5-e4391fcafa44/index.html" 
--remove-first-image --cover=http://mysite/page/@@images/image --level1-toc=//h:h1 
--level2-toc=//h:h2  --level3-toc=//h:h3 --language=no