Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2010, 08:47 AM   #16
omk3
Wizard
omk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five words
 
omk3's Avatar
 
Posts: 1,454
Karma: 37243
Join Date: Dec 2009
Location: Europe
Device: pocketbook 360, kindle 4
You are so right, thank you!!!! I removed the comments and it is now on page one (and it is only 1kb of size)


(also any other comments on my code or structure would be much appreciated - without taking up much of your time of course)

However, the mystery is not solved yet for me, because all the comments were actually copied from Jellby's cover of "The Prince and the Pauper", and this cover was on page one all right.... I really don't understand why they would behave differently. I had kept the commented code because I thought I might need it if I wanted to edit the cover, but I can see now that it is best to keep the cover.xhtml as small as possible. But...again...why did Jellby's cover work fine and mine didn't, when it was actually only a copy of his? Oh well...
omk3 is offline   Reply With Quote
Old 01-22-2010, 10:23 AM   #17
omk3
Wizard
omk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five words
 
omk3's Avatar
 
Posts: 1,454
Karma: 37243
Join Date: Dec 2009
Location: Europe
Device: pocketbook 360, kindle 4
A book full of x's

Okay, here is a dummy version of the book, with every small character replaced with x's (not very beautiful, but the best I could come up with to keep size and everything else as true to the original as possible). Scrambled the cover, and only included the first 4 stories.

I kept the comments on the cover page, so that you see it on page 2 or 3. If I remove the comments, it goes to page 1 as intended, as pdurrant said. But the question remains, why does this really happen?

So if you want to read a lot of x's, here it is

Comments on my code and structure are very welcome.

[EDIT] It was validated, and ADE displays it okay, put epubreader seems to have a problem with things like &xxxxx;which are remnants of apostrophes I would guess... This problem exists only for the dummy book of course, not the original one.
Attached Files
File Type: epub dummy_book.epub (277.4 KB, 159 views)

Last edited by omk3; 01-22-2010 at 10:27 AM.
omk3 is offline   Reply With Quote
Advert
Old 01-22-2010, 11:58 AM   #18
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: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Stupidly enough (on the part of Adobe), it seems pagination depends on the compression level of the files! I've just uncompressed your book and recreated it in two versions:

A) No compression (level 0). The cover is in pages 2-3, and the book is 56 pages long.

B) Maximum compression (level 9). The cover is in page 1, and the book is 14 pages long.

This makes the "page" numbers even more arbitrary than before
Attached Files
File Type: epub dummy_book-0.epub (277.4 KB, 165 views)
File Type: epub dummy_book-9.epub (204.9 KB, 155 views)
Jellby is offline   Reply With Quote
Old 01-22-2010, 12:18 PM   #19
omk3
Wizard
omk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five words
 
omk3's Avatar
 
Posts: 1,454
Karma: 37243
Join Date: Dec 2009
Location: Europe
Device: pocketbook 360, kindle 4
Unbelievable! Thank you so much Jellby! I would never have guessed.

So Adobe uses the compressed size instead of the actual size of the files to determine pages.... What can I say...

What do you use for zipping, by the way? I just used UltimateZip with no compression, so that I would have no problems with the mimetype file. It does not seem to offer many levels of compression, just "fast", "normal", etc. I tried with normal compression and got the cover on page 1, and 56 pages of book...

So to anyone else having the same problem: Either keep your cover page <=1kb or compress!

for answering what to me was a great mystery!

Was the rest of my code okay? I'd like to hear any corrections from you ePub pros!
omk3 is offline   Reply With Quote
Old 01-22-2010, 12:22 PM   #20
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,827
Karma: 921169
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
Quote:
Originally Posted by Jellby View Post
Stupidly enough (on the part of Adobe), it seems pagination depends on the compression level of the files! I've just uncompressed your book and recreated it in two versions:

A) No compression (level 0). The cover is in pages 2-3, and the book is 56 pages long.

B) Maximum compression (level 9). The cover is in page 1, and the book is 14 pages long.

This makes the "page" numbers even more arbitrary than before
wow, that's... pretty crazy. i'm glad it's all sorted out now, and i've learned a thing or two as well in this thread. the epub kings save the day again ! nicely done, jellby and pdurrant.
zelda_pinwheel is offline   Reply With Quote
Advert
Old 01-22-2010, 12:39 PM   #21
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: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by omk3 View Post
What do you use for zipping, by the way?
I use just the standard "zip" command in Linux, which is Info-ZIP, it seems.

Quote:
Was the rest of my code okay? I'd like to hear any corrections from you ePub pros!
It seems you have your first paragraph wrapped in a <div> and the rest of the chapter in another <div>:

Code:
<div class="firstp">
<p>First paragraph of the story</p>
</div>
<div class="body">
<p>Rest of the story</p>
<p>...</p>
</div>
I don't think that's really useful, you could get the same with:

Code:
<p class="firstp">First paragraph of the story</p>
<p>Rest of the story</p>
<p>...</p>
which looks cleaner to me. And then, are you sure you meant "text-indent: 10%" in the first paragraph? Books usually have no indent in the first paragraph. Anyway, you could simply write:

Code:
p
{
margin-bottom: 0;
margin-top: 0;
text-indent: 1em;
}

p.firstp
{
text-indent: 10%;
}
Jellby is offline   Reply With Quote
Old 01-22-2010, 12:52 PM   #22
omk3
Wizard
omk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five wordsomk3 can name that ebook in five words
 
omk3's Avatar
 
Posts: 1,454
Karma: 37243
Join Date: Dec 2009
Location: Europe
Device: pocketbook 360, kindle 4
Thank you and you're right, the <div> tags were not really useful. I had doubts about them myself, but thought I might need them later in ways I could not predict. If p.anything overrules simple p, then obviously I don't need them at all. I also had some small poems in later stories, which need different handling too. I had them in <div class="poem"> tags, but I guess <p class="poem"> would suffice. What would I need a <div> tag for, then, I wonder... I'll probably find out with experience.

About the indents, I was not at all sure how to format the book, so to avoid experimenting well into next year, I just copied the formatting of the original paper book, which actually had deeper indents for the first paragraphs, along with the titles. It surprised me too, but it looked okay.

Jellby, Pdurrant and Zelda, have I told you you have been fantastic? I'm so happy to be here among you
omk3 is offline   Reply With Quote
Old 01-22-2010, 01:20 PM   #23
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: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by omk3 View Post
If p.anything overrules simple p, then obviously I don't need them at all.
It does. More specific selectors override less specific ones, much like "div.firstp p" overrides a bare "p".

Quote:
I also had some small poems in later stories, which need different handling too. I had them in <div class="poem"> tags, but I guess <p class="poem"> would suffice. What would I need a <div> tag for, then, I wonder... I'll probably find out with experience.
Poems are a nasty dusty beast

For simple poems, you don't need much, indeed. But when you start having different indents and long lines (which you'd like to wrap nicely), things start to get complicated. My personal way of dealing with poems is something like:

Code:
<div class="poetry">
<div class="stanza">
<p>How doth the little crocodile</p>
<p class="indented">Improve his shining tail,</p>
<p>And pour the waters of the Nile</p>
<p class="indented">On every golden scale!</p>
</div>

<div class="stanza">
<p>How cheerfully he seems to grin,</p>
<p class="indented">How neatly spread his claws,</p>
<p>And welcome little fishes in</p>
<p class="indented">With gently smiling jaws!</p>
</div>
</div>
with:

Code:
div.poetry {
  margin: 1em 0 1em 2em;
  font-style: italic;
}
div.stanza {
  margin: 0.5em 0;
  page-break-inside: avoid;
}
div.poetry p {
  margin: 0;
  text-align: left;
  padding-left: 5em; 
  text-indent: -5em;
}
div.poetry p.indented {
  margin-left: 1.5em;
}
The combination of margins, paddings, and text-indent allows me to indent the whole poetry block, have additional indent for the "indented" class (I have also "indented2", "indented3", etc. if needed), and let the wrapped portions of a line (if it gets wrapped) be further indented (ideally they would be right-aligned, with a "[" before them, but that's simply not possible with CSS). Sometimes I think I should use <div> instead of <p> in poetry, but <p> is shorter
Jellby is offline   Reply With Quote
Old 01-22-2010, 01:56 PM   #24
Peter Sorotokin
speaking for myself
Peter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it is
 
Posts: 139
Karma: 2166
Join Date: Feb 2008
Location: San Francisco Bay Area
Device: PRS-505
Quote:
Originally Posted by omk3 View Post
So Adobe uses the compressed size instead of the actual size of the files to determine pages.... What can I say...
This is all documented in EPUB Best Practices Guide (http://www.adobe.com/devnet/digitalpublishing/):

When page map is not available in the document, Adobe Digital Editions will synthesize a page-map based on the document content. The approach used is the following:
1. Determine a compressed byte length of each resource which is referenced in the spine, subtracting any known encryption overhead (IV size)
2. Assume that there is a page for each 1024 bytes in each resource, rounding up to the nearest whole number of pages for each resource
3. To map page breaks into a resource, use the number of pages for the resource as determined in step 2, count the number of Unicode characters in the resource; distribute synthetic page breaks in the resource evenly between the characters by dividing the number of characters by the number of pages; if the number of characters don’t divide evenly among the pages, round the number of characters per page up and let the last “page” contain less characters than the rest.

It may be "obvious" to you that uncompressed size should be used, but it would not work reliably. Compressed size is better because it is the only reliable number about the resource without expensive decompression and sometimes decryption (and decryption may not even be possible in some cases).
Peter Sorotokin is offline   Reply With Quote
Old 01-22-2010, 02:10 PM   #25
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
There is a discrepancy between step 2 and 3. In 2 you say bytes and in 3 you say unicode characters. I believe 3 is right but they are not always the same number. I think ADE looks at the coding to figure out what to do and probably uses a formula for UTF-8.
DaleDe is offline   Reply With Quote
Old 01-22-2010, 02:30 PM   #26
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: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Peter Sorotokin View Post
This is all documented in EPUB Best Practices Guide (http://www.adobe.com/devnet/digitalpublishing/):
Of course, I had read it some time ago, but it didn't register in my head

Quote:
It may be "obvious" to you that uncompressed size should be used, but it would not work reliably.
What is obvious to me is that page numbers are not reliable anyway Just like for paper books, page numbers are only useful if you refer to a specific particular edition of a book, or if you keep them for your own private use, like estimating how long it will take you to read a book or finish a chapter.

But... doesn't the zip file store (or isn't it "easy" to get) the uncompressed size of the files? I think I usually see the uncompressed size in GUI zip apps, and it doesn't seem like they really uncompress the files. Or maybe is it because I strip all permissions and such when zipping?

Quote:
Originally Posted by DaleDe View Post
There is a discrepancy between step 2 and 3. In 2 you say bytes and in 3 you say unicode characters.
But step 2 refers to the compressed size, and there are no characters there, only bytes. With the compressed size you calculate the number of pages. Then, after you uncompress the resource (file), you can place the pagebreaks by distributing the characters.
Jellby is offline   Reply With Quote
Old 01-22-2010, 02:34 PM   #27
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
Quote:
Originally Posted by Jellby View Post
Of course, I had read it some time ago, but it didn't register in my head

But step 2 refers to the compressed size, and there are no characters there, only bytes. With the compressed size you calculate the number of pages. Then, after you uncompress the resource (file), you can place the pagebreaks by distributing the characters.
How can that work? It you already used step two to figure the total then how can you use the uncompressed to get to the same number. The zipped file includes all of the images as well which are not counted in the page sizes. This needs fixing I think.

Dale
DaleDe is offline   Reply With Quote
Old 01-22-2010, 02:50 PM   #28
Peter Sorotokin
speaking for myself
Peter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it is
 
Posts: 139
Karma: 2166
Join Date: Feb 2008
Location: San Francisco Bay Area
Device: PRS-505
Quote:
Originally Posted by DaleDe View Post
There is a discrepancy between step 2 and 3. In 2 you say bytes and in 3 you say unicode characters. I believe 3 is right but they are not always the same number. I think ADE looks at the coding to figure out what to do and probably uses a formula for UTF-8.
There is no discrepancy. To determine number of pages allocated to a resource, its compressed size in bytes is used. To place page boundaries inside the resource Unicode characters are used.
Peter Sorotokin is offline   Reply With Quote
Old 01-22-2010, 02:56 PM   #29
Peter Sorotokin
speaking for myself
Peter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it isPeter Sorotokin knows what time it is
 
Posts: 139
Karma: 2166
Join Date: Feb 2008
Location: San Francisco Bay Area
Device: PRS-505
Quote:
Originally Posted by Jellby View Post
What is obvious to me is that page numbers are not reliable anyway Just like for paper books, page numbers are only useful if you refer to a specific particular edition of a book, or if you keep them for your own private use, like estimating how long it will take you to read a book or finish a chapter.
That's true, of course. And in addition to compression ratio there are many other variables, for instance UTF-8 vs UTF-16 encoding, entity references, DOS/UNIX linebreaking, whitespace.

Quote:
But... doesn't the zip file store (or isn't it "easy" to get) the uncompressed size of the files?
It does, except when it does not. Sometimes there is just zero there. And if a resource is encrypted, it is not stored anywhere.

Quote:
I think I usually see the uncompressed size in GUI zip apps, and it doesn't seem like they really uncompress the files. Or maybe is it because I strip all permissions and such when zipping?
It is there most of the times. But some common toools don't put it there (e.g. I think Java Zip implementation sometimes omits it, but I may be mistaken).
Peter Sorotokin is offline   Reply With Quote
Old 01-23-2010, 03:35 AM   #30
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: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by DaleDe View Post
How can that work? It you already used step two to figure the total then how can you use the uncompressed to get to the same number.
Simple: by forcing it

First, with the compressed size, you calculate the number of pages. Now the number of pages is fixed, and you place the pagebreaks in the uncompressed file so that you get the fixed number. There's no specification on the page length here, they'll be as long as needed to get the number of pages you calculated before.
Jellby is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert to EPUB without Cover Page? Handyman1 Calibre 14 10-17-2010 10:18 AM
ePub Page Numbering Using Page-map Dark123 Calibre 2 06-16-2010 07:15 AM
ePub Suppress Cover Page daveps Calibre 3 02-10-2010 10:12 AM
ePub Cover Page Timoleon ePub 10 11-06-2009 11:22 AM
EPUB=>Mobi: Start/open at cover page - how to? Skydog Calibre 6 10-16-2009 09:43 PM


All times are GMT -4. The time now is 12:44 PM.


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