Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 09-16-2009, 11:50 AM   #31
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
Quote:
Originally Posted by Jellby View Post
Well, I decided on using it mainly because it was so easy to install (it's on the official repositories) even on my oldest system, a Mandriva 2005.
OK, the problem turned out to be incredibly simple. I did successfully install xmlstarlet from the Ubuntu repositories. The problem was that this version uses "xmlstarlet" for the executable rather than just "xml". So I just set up a symbolic link, and now it works.

I don't have a lot of time to experiment today. I'm a little worried about no author style: would that mean that nothing in the original's CSS would be maintained? That's hardly a good compromise.

I've been meaning to play around with pacify too, ahi... just don't have a lot of time this week, and am juggling other projects.

Last edited by frabjous; 09-16-2009 at 11:52 AM.
frabjous is offline   Reply With Quote
Old 09-16-2009, 11:58 AM   #32
ahi
Wizard
ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.
 
Posts: 1,790
Karma: 507333
Join Date: May 2009
Device: none
Quote:
Originally Posted by frabjous View Post
I don't have a lot of time to experiment today. I'm a little worried about no author style: would that mean that nothing in the original's CSS would be maintained? That's hardly a good compromise.

I've been meaning to play around with pacify too, ahi... just don't have a lot of time this week, and am juggling other projects.
I'm overbusy myself... no worries.

The approach I intend to take in pacify, is to import only minimal formatting, and dress the output (whether LaTeX or HTML) with predefined templates (or, I suppose, optionally a user provided one).

However that's not really an option, unless you know what elements and classes the document uses. With pacify, I know that, because I basically (re)generate the HTML... but if the source HTML is to be faithfully preserved, intricacies may be impossible to address other than on a document by document basis (via a custom user-provided CSS stylesheet).

Of course... well formatted ePubs should have their paragraphs inside <P> tags and headers inside <Hx> tags... that much is easy enough to style. The problems start only if there are quotations, poems, tables, pictures, et cetera in there... most of which could be handled in a variety of different ways in HTML.

- Ahi
ahi is offline   Reply With Quote
Advert
Old 09-16-2009, 10:19 PM   #33
ahi
Wizard
ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.ahi ought to be getting tired of karma fortunes by now.
 
Posts: 1,790
Karma: 507333
Join Date: May 2009
Device: none
.....
ahi is offline   Reply With Quote
Old 09-18-2009, 03:11 PM   #34
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I've updated the script in post #11 again. I think it's a bit cleaner now, and two main improvements:

- It will use pdftk if available to set the author and title metadata of the PDF.

- It has another option, -S, equivalent to -s but with a higher priority. The stylesheet specified with -s is overriden (if there are conflicts) by the book-specific .css, if any. The stylesheet specified with -S will override anything (use !important to override the "author" styles, as usual).
Jellby is online now   Reply With Quote
Old 09-18-2009, 08:02 PM   #35
acidzebra
Liseuse Lover
acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.
 
acidzebra's Avatar
 
Posts: 869
Karma: 1035404
Join Date: Jul 2008
Location: Netherlands
Device: PRS-505
Quote:
Originally Posted by Jellby View Post
I've updated the script in post #11 again. I think it's a bit cleaner now, and two main improvements:

- It will use pdftk if available to set the author and title metadata of the PDF.

- It has another option, -S, equivalent to -s but with a higher priority. The stylesheet specified with -s is overriden (if there are conflicts) by the book-specific .css, if any. The stylesheet specified with -S will override anything (use !important to override the "author" styles, as usual).
Great script, some notes:

- I had to softlink /usr/bin/xmlstarlet to a /usr/bin/xml which the script seems to think is the name of the xmlstartlet program? (I'm on stock FC10, xmlstarlet from standard package repos). No big headache though.

- If I use the -S option it won't load my specified stylesheet, instead trying to load default.css - if that doesn't exist it throws an error (circumvented by renaming my style sheet default.css)

- the generated bookmarks seem odd at times.For some Calibre-generated epubs I got a multilevel TOC like
- <book name>
---<author>
------produced by calibre (version)

Other than that, it looks rather spiffy



I had some issues with it ignoring my css and defaulting to the book CSS, but forcing lots of !importants everywhere seems to solve it. Still, I would expect -S to override everything as per your previous post, but that doesn't seem to happen always.

Last edited by acidzebra; 09-18-2009 at 08:44 PM. Reason: I'm an idiot who should use the !important attribute in CSS
acidzebra is offline   Reply With Quote
Advert
Old 09-19-2009, 06:04 AM   #36
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by acidzebra View Post
I had to softlink /usr/bin/xmlstarlet to a /usr/bin/xml which the script seems to think is the name of the xmlstartlet program? (I'm on stock FC10, xmlstarlet from standard package repos). No big headache though.
In Mandriva it's called xml, I guess I could add a check to use xmlstartlet if xml does not exist.

Quote:
If I use the -S option it won't load my specified stylesheet, instead trying to load default.css - if that doesn't exist it throws an error (circumvented by renaming my style sheet default.css)
The script will always try to load "default.css" as a default stylesheet, unless you use the -s option. I recommend placing the file in ~/.epub2pdf/default.css and forgetting about it. You can make it an empty file, if you don't want any rules applied by default.

Quote:
the generated bookmarks seem odd at times.For some Calibre-generated epubs I got a multilevel TOC like
- <book name>
---<author>
------produced by calibre (version)
I see... That's due to the way Prince generates the bookmarks. It can be changed with CSS (see Prince docs), but I don't think there is a universal solution. If the book includes a prince-style, that's where it should do whatever needed to have the right bookmarks. If you have a lot of these Calibre files, it should be possible to add some rules to your default stylesheet disabling the bookmarks for those title items, something like:

[code].calibretitle, .calibreauthor, .calibreversion {
prince-bookmark-level: none;
}[/quote]

... using the correct class names, of course. If you show me a sample file, I'll tell you

Quote:
I had some issues with it ignoring my css and defaulting to the book CSS, but forcing lots of !importants everywhere seems to solve it. Still, I would expect -S to override everything as per your previous post, but that doesn't seem to happen always.
I probably wasn't clear enough. Prince considers three kinds of stylesheet, but we are only concerned about "User" and "Author". "Author" is whatever stylesheets specified in the XHTML+CSS source of the ePUB, which are supposed to be applied by ePUB readers. "User" is what you give in the Prince command-line, that includes stylesheets passed with -s and -S options, and the prince-style included in the book, if any (because epub2pdf passes this stylesheet as a command-line argument to Prince).

Normally, "Author" styles override "User" styles, but rules with !important change this ("User" rules with !important are stronger than "Author" rules, with or without !important). So if you want to override "Author" styles, you can just have !important in the stylesheet given with -s (or ~/.epub2pdf/default.css).

When the priority of conflicting rules is the same, the last one to be declared takes precedence. So, if your default.css and the book's prince-style are in conflict, the latter wins, because it is passed to the Prince command-line last. Usually you could override it with !important in your default.css, but if it already has !important in the prince-style, it won't do anything. This is the role of the -S option, it passes the stylesheet to the command-line after the prince-style, so it can override !important rules there. In fact, it's only needed in this case, since in all other cases you can override rules with the -s option.

Another problem is, as Frabjous commented above, that if you specify a font-family (or any other property) for the body element, but the book's stylesheets have another font-family for lower elements (p, div...), the latter take precedende, no matter how !important your rules are. If you want to change it you have to define the font family for these p or div elements (and maybe with the correct class names) in your default.css.
Jellby is online now   Reply With Quote
Old 12-23-2009, 05:28 AM   #37
ahsin_111
Junior Member
ahsin_111 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2009
Device: none
Not able to remove watermark [:(]

Quote:
Originally Posted by Jellby View Post
I've tried Prince XML and it's quite easy and powerful, at least at first sight. As a test, I've done the conversion of The Picture of Dorian Gray, and the result is attached.

All that was needed was this user css:

pdf_output.css
Code:
@page {
  size: 9cm 12cm;
  margin: 5mm 1mm 1mm 1mm;
  @top-left {
    border-bottom: solid 0.2pt #000;
    margin-bottom: 1mm;
    content: "";
  }
  @top-center {
    font-size: 60%;
    font-style: italic;
    border-bottom: solid 0.2pt #000;
    margin-bottom: 1mm;
    content: string(chaptitle);
  }
  @top-right {
    font-size: 50%;
    border-bottom: solid 0.2pt #000;
    margin-bottom: 1mm;
    content: counter(page) "/" counter(pages);
  }
}

@page:first {
  margin: 1mm 1mm 1mm 1mm;
  @top-left {
    border-size: 0;
    margin: 0;
    content: normal;
  }
  @top-center {
    border-size: 0;
    margin: 0;
    content: normal;
  }
  @top-right {
    border-size: 0;
    margin: 0;
    content: normal;
  }
}

@page title {
  margin: 1mm 1mm 1mm 1mm;
  @top-left {
    border-size: 0;
    margin: 0;
    content: normal;
  }
  @top-center {
    border-size: 0;
    margin: 0;
    content: normal;
  }
  @top-right {
    border-size: 0;
    margin: 0;
    content: normal;
  }
}

/* specific code for this image */
@page cover {
  size: 7.98cm 12cm;
  margin: 0 -2.01cm; /* make the virtual width 12cm */
}

body {
  font-size: 9.9pt;
  font-family: serif;
  text-align: justify;
  prince-image-resolution: 166dpi;
  hyphens: auto;
  prince-text-replace: " – " "—"       /*replace em-dashes*/
                       "st" "s\FEFFt"; /*disable st ligatures*/
}

body.cover {
  page: cover;
}

div.header {
  string-set: chaptitle content();
}

div.title, div.edition {
  page: title;
}
div.edition {
  float: bottom;
}

p.logo {
  display: none;
}

div.toc a {
  text-decoration: none;
}
div.toc a::after {
  content: leader('. ') target-counter(attr(href), page);
}

h1 {
  prince-bookmark-level: 1
}
(I also modified the main font.css file, to use FreeSans, and FreeSerif as default fonts for all conversions.)

And then on the directory with the ePUB files uncompressed, I ran:

Code:
prince OEBPS/Cover.xhtml OEBPS/Title.xhtml OEBPS/Contents.xhtml OEBPS/Preface.xhtml OEBPS/Chapter-*.xhtml -s pdf_output.css -o test.pdf
The only modification in the .xhtml was adding a "class=cover" in the body of Cover.xhtml, which I'll be probably adding in future ePUBs. Note how I changed back, on the fly, from "space-endash-space" no "emdash" The "st" ligatures are probably a fancy of the FreeSerif font, which I didn't want here.

Now I have to separate the "universal" stuff from the settings and classes particular to this ebook or to my coding style. I'd like to place the latter in a separate css file in the ePUB, and maybe use some metadata container for it, then a converter could use this for automatically convert the ePUB to PDF...

By the way, the logo watermark in the first page is quite easy to remove if you output the PDF with --no-compress (the pdf can later be compressed with pdftk).

Hii
I am not able to remove the logo watermark from the first page... How you have done it.
Thanks
ahsin_111 is offline   Reply With Quote
Old 12-23-2009, 06:19 AM   #38
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by ahsin_111 View Post
I am not able to remove the logo watermark from the first page... How you have done it.
pdftk file.pdf output tmp.pdf uncompress
(do some magic[*] with tmp.pdf)
pdftk tmp.pdf output file.pdf compress

[*] The magic boils down to searching for:

Code:
stream
0.2314 0.0471 0.3765 rg
...
h
f
and turning that last "f" into "%f", this only disables the filling of the logo, so it becomes invisible.
Jellby is online now   Reply With Quote
Old 12-31-2009, 12:46 AM   #39
ahsin_111
Junior Member
ahsin_111 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2009
Device: none
Thanksss alot

Awesome!!!

Thanks a alot







Quote:
Originally Posted by Jellby View Post
pdftk file.pdf output tmp.pdf uncompress
(do some magic[*] with tmp.pdf)
pdftk tmp.pdf output file.pdf compress

[*] The magic boils down to searching for:

Code:
stream
0.2314 0.0471 0.3765 rg
...
h
f
and turning that last "f" into "%f", this only disables the filling of the logo, so it becomes invisible.
ahsin_111 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating XML book listing with Calibre JTAL604622 Library Management 5 06-01-2010 02:57 PM
Question about creating PDFs (resolved - my error, d'oh) Prince Hal PDF 19 03-02-2010 11:30 PM
Software for creating image-based PDFs 301verbs Workshop 2 06-13-2009 12:51 PM
Mobile reader being able to display A4 pdfs Mononofu Which one should I buy? 10 01-17-2009 07:22 AM
Creating media.xml manually pepak Sony Reader 5 11-28-2008 10:26 AM


All times are GMT -4. The time now is 03:54 AM.


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