Forum How do I...?

cover image

codrut
I am using prince for personal purposes, I am converting my epub files (which I own) to pdf such that I can read them on my e-ink reader which supports only pdf (Quaderno). I have learned to unpack my epub files and I manually convert them to pdf using prince. Everything is fine but the cover image. For example the cover.xhtml contains the following:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>The Book of Five Rings</title>
.............
</head>

<body>
<div style="text-align: center; padding: 0pt; margin: 0pt;">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 1313 2000" width="100%"><image height="2000" width="1313" xlink:href="../Images/cover.jpg"/></svg>
</div>
</body>
</html>

running prince will result in a cover where there are margins to the left, right and top.

How can I make the image to fill as much as possible from the cover page?

  1. cover.jpg597.5 kB
  2. cover.pdf602.6 kB
    pdf file
  3. cover.xhtml0.6 kB
mikeday
You can reduce the page margins with this CSS rule:
@page {
    margin: 0
}
codrut
Wow! It worked. Thank you so much!
codrut
The next question would be how to apply the css rule only to one of the files. For example

prince cover.xhtml -s style.css ch1.xhtml ch2.xhtml... -o book.pdf

would apply the rules from style.css to all of the files passed as arguments.
mikeday
This can't be done on the command-line yet, you would need to link to the style sheet from the file itself, or if that's not possible perhaps add the link dynamically using JavaScript.