Hello! I'm part of the Archive of Our Own development team, and we'd like to use Calibre's command line interface to offer MOBI downloads of our users' stories. Our users strongly prefer MOBI files with no left or right margins at all, but we're having trouble achieving that. If it's relevant, you can see our planned implementation of Calibre in
this pull request. The process amounts to the following:
First, we create an HTML file. Here's
a Gist with an example HTML file.
Then we convert that HTML file to MOBI using the following command:
Code:
ebook-convert input_file output_file --input-encoding="utf-8" --use-auto-toc --title="story title" --authors="authors" --comments="story summary" --tags="tag" --pubdate="date" --chapter="//h:body/h:div[@id='chapters']/h:h2[@class='toc-heading'] | //h:body/h:div[@id='chapters']/h:div[@class='meta group']/h:h2[@class='heading'] | //h:body/h:div[@id='preface' or @id='afterword']/h:h2[@class='toc-heading']" --mobi-ignore-margins --remove-paragraph-spacing --extra-css=".meta dt { font-weight: bold; }"
We've tried adding the following CSS to the HTML file's stylesheet without any luck:
Code:
@page, html, body, div, p, blockquote { margin-right: 0; margin-left: 0; }
We tried specifying 0pt as well, since we know Calibre uses pts for margins.
We also tried including the above CSS with the
--extra-css option, removing the
--mobi-ignore-margins option, and using
--margin-left="0" and
--margin-right="0".
We even tried completely removing the CSS that's in the HTML file, just in case one of our styles was to blame.
Finally, I used the KindleImport plugin for Sigil to compare a MOBI file that didn't have margins with the MOBI file we were generating using Calibre. The file without margins had margin attributes (
leftmargin="0" bottommargin="0" topmargin="0" rightmargin="0") added to the body tag, so I added those to our HTML file's template. Unfortunately, it didn't help, and when I examined the resultant MOBI file using Sigil, the margin attributes had been removed from the body element.
For reference, I've attached a MOBI file without margins (without_margins.mobi), which we produced using our old system, and one with margins that we produced using Calibre (with_margins.mobi). We've tried versions 3.27.1 and 3.28.0 of Calibre, but we just can't seem to make the margins go away.
We'd be very grateful for any help you can provide!
Thanks,
Sarken