Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 12-13-2015, 01:37 PM   #16
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Thank you, I was finally able to tweak ebook-convert flags and generate the debug output!

Actually, all my CSS rules are properly applied and merged with Calibre's, as inspecting processed/stylesheet.css revealed. The structure of the HTML file at this stage in the process is:

Code:
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <title>Table of Contents | Willkommen, bienvenue, benvenuto, bienvendia, bem-vindo, ahlan wa sahlan, добро пожаловать, 환영, 欢迎,welcome!</title>
    <meta content="" name="description"/>
    <meta content="GitBook 2.6.5" name="generator"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link href="stylesheet.css" rel="stylesheet" type="text/css"/>
<link href="page_styles.css" rel="stylesheet" type="text/css"/>
</head>
  <body class="dir">        
<div class="page">
<div class="section">
    <h1 class="calibre">Table of Contents</h1>
    <ol class="calibre1">
        <li class="calibre2">
            <span class="inner">
                        <a href="index.html" class="calibre3 pcalibre1 pcalibre2 pcalibre">Introduction</a>
                <span class="page1">0</span>
            </span>
        </li>
        <li class="calibre2">
            <span class="inner">
                        <a href="quick-start.html" class="calibre3 pcalibre1 pcalibre2 pcalibre">Quick-start</a>
                <span class="page1">1</span>
            </span>
        </li>
    </ol>
</div>
</div>
</body></html>
So, actually, what seems to happen is that when applying a CSS styling to "body" or ".dir" (both cases), the Output Plugin only considers what's inside the body tag, so it doesn't apply the rules.

Back to square one, then: is it possible to instruct Calibre/ebook-converter to apply a background that would extend the whole page? The only option I can think of is to apply that background to ".page", reduce its margins to 0 somehow while adding some padding. Not the best idea ever I'm afraid, though.
chikamichi is offline   Reply With Quote
Old 12-13-2015, 01:46 PM   #17
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
PDF output is generated by a browser (webkit) engine running with CSS 3 columns defined on body. In fact the same engine that powers the calibre viewer. If you can figure out how to convince a browser to show a background behind css3 columns defined on body, you can use it with ebook-convert.
kovidgoyal is offline   Reply With Quote
Advert
Old 12-13-2015, 01:54 PM   #18
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Interesting. What exactly do you mean by "css3 columns defined on body" though?
chikamichi is offline   Reply With Quote
Old 12-13-2015, 01:57 PM   #19
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Were you referring to https://github.com/kovidgoyal/calibr.../pdf_output.ui used for Calibre's UI ?

Edit: Oh, I guess it's actually https://github.com/kovidgoyal/calibr...r/from_html.py

Last edited by chikamichi; 12-13-2015 at 02:03 PM.
chikamichi is offline   Reply With Quote
Old 12-13-2015, 02:28 PM   #20
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
google css3 columns. ANd if you want to find it in the code, look for paged.coffee
kovidgoyal is offline   Reply With Quote
Advert
Old 12-13-2015, 02:32 PM   #21
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Thank you.
chikamichi is offline   Reply With Quote
Old 12-13-2015, 05:05 PM   #22
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Ok, I've been trying to set CSS rules that would affect the entire PDF document (as produced by Calibre's Output Filter leveraging the logic of paged.coffee), but no luck.

I'm not giving up, but meanwhile, if you have any idea how one could instruct the webkit-based renderer to apply CSS rules to a PDF page as a whole/unit, that would be great. Especially, something that would target the whole page. It's kind of disappointing setting a simple background for the PDF document has to be so damn hard a task

Last edited by chikamichi; 12-13-2015 at 06:30 PM.
chikamichi is offline   Reply With Quote
Old 12-13-2015, 11:02 PM   #23
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I know of know way to do that in HTML. But a bit of googling will show you plenty of ways you can postpocess a pdf to add background images, for example pdftk multistamp.
kovidgoyal is offline   Reply With Quote
Old 12-14-2015, 06:08 AM   #24
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Thank you, that's good to know.

I'd rather have ebook-convert handle and automate that operation though, for having the end-user use the CLI in an extra step doesn't fit my use-case.
chikamichi is offline   Reply With Quote
Old 12-14-2015, 06:16 AM   #25
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Extra question: how about extending the current behavior found in https://github.com/kovidgoyal/calibr...r/from_html.py so instead of enforcing a white background (as per line 353), it would first check whether a value has been supplied in the CSS? Something like paged_display.set_background() to be implemented within paged.coffee (at least being able to change the color would be nice; of course it would be even nicer being able to set backgroundImage and backgroundCover properties).

Last edited by chikamichi; 12-14-2015 at 06:43 AM.
chikamichi is offline   Reply With Quote
Old 12-14-2015, 07:12 AM   #26
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
That will not work, the body background color does not apply to margins.
kovidgoyal is offline   Reply With Quote
Old 12-14-2015, 07:53 AM   #27
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by chikamichi View Post
I'd rather have ebook-convert handle and automate that operation though, for having the end-user use the CLI in an extra step doesn't fit my use-case.
What exactly are you doing? I'm guessing you are trying to embed ebook-convert inside some other software.
kovidgoyal is offline   Reply With Quote
Old 12-14-2015, 09:34 AM   #28
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
Quote:
Originally Posted by kovidgoyal View Post
What exactly are you doing? I'm guessing you are trying to embed ebook-convert inside some other software.
The exact context I'm working on is GitBook. It's an open-source project, one can use it their CLI locally, or one can leverage the website itself to benefit from a fully automated process, from writing to hosting books. Basically, one writes markdown+css and gets a fully-fledged book in different format.

In a team I'm working with, I'd like to have non-tech people use GitBook's website to manage some public-facing documentation, so that 1/ rendered documents are all in sync, no matter the format (html, pdf, mobi, etc.) 2/ it becomes easier for translators to follow edits using git/GitHub (for GitBook's website can push to GitHub).

The only "special" use-case I'd have is for the PDF rendering of a document, to have an image as its background (same bg on each page, full-extend, covering margins). Although I can provide CSS styling in GitBook for the body tag of the HTML that's going to be provided to ebook-convert, it eventually gets wiped out for the reasons we demonstrated above (thx again for your insights).
chikamichi is offline   Reply With Quote
Old 12-14-2015, 09:36 AM   #29
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
So why not just use pdftk, make it part of a script that first runs ebook-convert and then calls pdftk?
kovidgoyal is offline   Reply With Quote
Old 12-14-2015, 10:08 AM   #30
chikamichi
Member
chikamichi began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Dec 2015
Device: none
As I said, I'd rather have the non-tech people use a down-to-earth solution like GitBook: "click a button, and it's ready" I'll see whether adding post-processing (using pdftk for instance) to GitBook's workflow is an option, then. Thank you!
chikamichi is offline   Reply With Quote
Reply

Tags
css, html, pdf, structure


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[old thread] filename and library structure /author and titel structure tscamera Library Management 4 05-31-2011 05:44 PM
Interesting behavior of Structure Detection PDF to MOBI tleon Conversion 8 05-04-2011 05:29 PM
description for the lrf structure joblack LRF 2 08-01-2009 03:35 PM
Other Non-Fiction Abelson, H; Sussman G: Structure and Interpretation of Computer Programs. PDF. v1.0 scottdw Other Books 0 07-05-2008 08:43 AM


All times are GMT -4. The time now is 06:37 AM.


MobileRead.com is a privately owned, operated and funded community.