View Single Post
Old 01-28-2011, 04:19 AM   #1
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
SVG & Layout fun - need some - new issue on the same theme

I've been working on scanning and converting some of my favorite paper books that aren't available as ebooks, and some formatting one would think should be simple is really quite challenging.

Anyway challenge of the day is chapter headings with large images. The book has a squarish image at the beginning of every chapter - the image pretty much goes to the page borders and takes up about ~60% of the page. Below that are a Chapter header and 1-2 paragraphs.

I'm trying to future-proof my epubs and use decent sized images that can scale across multiple devices. The obvious answer seemed to be SVG. The problem I'm having is inserting an SVG image which will always be nailed to the top of the page border, and try to include the Chapter header and at least 2 lines of text no matter the aspect ratio of the page. It seems i can have only one or the other - an SVG which is scalable and remains nailed to the top of the page, but pushes text away in landscape-ish views, or an SVG that slides away from the top of the page when the width is narrowed.

Ideal Requirements:
  • Width of the image should be 100% of the page width in portrait mode, ~60% of the height
  • As the aspect ratio changes that should change to allow for the header and a few lines of text.
  • In portrait views the image should always be at the top of the page with equal margins on the three sides - that's another issue is that ADE doesn't seem to center it perfectly....

I've attached an epub book that displays three different examples, all manipulating the height of the SVG view box. There is a div with a red border around it so you can see how resizing/viewbox parameters stretches the div (seems like ADE prefers SVG wrapped in Divs as well).

Ideally I'd like something close to example 1, but without the image floating down the page and increasing whitespace as the width narrows.

Here's the SVG/html code I'm using in case you don't need to download the example epub:
Spoiler:
Code:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Width 100 and Height 70</title>
  <link href="../Styles/Stylesheet.css" rel="stylesheet" type="text/css" />
  
<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }
</style>
</head>

<body class="calibre">
  <div class="chapterpic">
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" height="60%" version="1.1" viewBox="0 0 876 857" width="100%">
      <metadata id="metadata7">image/svg+xml</metadata>

      <g id="layer1">
        <image height="876" id="image3144" width="857" xlink:href="../Images/testimage.png"></image>
      </g>
    </svg>
  </div>

  <h2 class="calibre23" id="heading_id_2">Ex. 1:Width 100%, Height 70%</h2>

  <p class="calibre24"><span class="font2">This setting provides the best balance between both portrait and landscape views, and seems to display well in ADE and QT based renderers. &nbsp;Unfortunately as the width gets narrower the image will not stay nailed to the top of the page, and white space also increases at the bottom of the image as well.</span></p>

  <p class="calibre24"><span class="font2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vulputate, eros eget blandit iaculis, nulla sem pulvinar diam, eu vehicula est nibh ut tellus. Fusce in ligula metus. Proin hendrerit velit sit amet diam vestibulum id sodales urna aliquet.</span></p>
</body>
</html>
Attached Files
File Type: epub SVG_Issue.epub (87.8 KB, 341 views)

Last edited by ldolse; 02-02-2011 at 08:57 AM.
ldolse is offline   Reply With Quote