Pages to ePub observations and hints


Pages to ePub observations and hints
I've been experimenting with exporting ePubs. Here are some things I have have found that may help others.
These observations are based on Pages v4.1 and iBooks v2.0.1
These truths might be invalidated when new versions of Pages and/or iBooks appear.
There may be subtle distinctions and/or situations where these observations don't work as described. Or maybe for some of them, I have gotten close to the truth but not fully realized it completely yet. Experiment with them at your will.
1. Pages does not and will not insert any "page breaks" (or css causing that effect) in an ePub file per se. When exporting to ePub, Pages ignores any and all page breaks or section breaks you insert into a Pages document. Instead, it splits what it considers to be chapters each into separate xhtml files within the created ePub container. It seems that iBooks is hardcoded to automatically display each xhtml file beginning on a new "page."
2. According to Apple's "ePub Best Practices" document, Pages considers chapters to be delimited by instances of text of the style "Chapter Name". I have found that changing the name of that style does not effect the resulting ePub. Therefore, it is not the style's name that informs pages to use it as the chapter delimiter. Instead, I have found that Pages will look at all the styles you have marked as to be included in the TOC (hereafter called "TOC-included-styles"). Whichever one of these happens to be used first in the document, will be the style that Pages will use to parse chapters, unless the first TOC-included-style used is named "Chapter Number". In this case, that instance of "Chapter Number" is skipped over when considering the style to use as chapter delimiter, and the next TOC-included-style found will be used.
3. Unlike "Chapter Name", the style named "Chapter Number" is required be to named "Chapter Number". This style further affects the splitting of the xhtml files, and therefore, iBook's rendering of "page breaks". An exported ePub will normally be split into xhtml files at the first character of all instances of "Chapter Name". A document that also includes any "Chapter Number" instances will be split at the first character of those instances. The rule, in plain english, would be: split into xhtml files at instances of 'Chapter Name', but if any particular 'Chapter Name' instance has a 'Chapter Number' instance before it, back up and make the split immediately before that 'Chapter Number'. If a "Chapter Name" instance has more than one instance of "Chapter Number" before it, the split will happen at the earliest instance of "Chapter Number" until a previous "Chapter Name" is found. If the last "Chapter Name" instance in a document has any "Chapter Number" instances after it, there will be no split at those "Chapter Number" instances. Any other styles in between any of these instances are preserved, so you could have a new page in iBooks with a chapter number, followed by some text, then the chapter's name.  If you rename the  "Chapter Number" style to something else, it is then considered like any other style and has no affect on resulting ePub structure.
4. If you insert a TOC into your Pages document, it is ignored for ePub export. The TOC created in an ePub will include whatever styles are checked in the Document->TOC inspector. The ePub TOCs as generated by Pages seem to have only two levels of indentation. The high level is the chapter level, as described above, whatever TOC-included-style appears first in the document will be the chapter delimiter and be the least indented level of the TOC. All other TOC-included-styles, no matter what they are named or how they are configured in Pages, will be placed at indent level two in the resulting ePub's TOC. So, a style does not need to be named "Heading" to be included in the ePub TOC, it just needs to be a TOC-included-style.
5. You can add however many images you want to a chapter, but if the combined file size of the images in that chapter add to more than 1Mb, then the resulting ePub will not display any of the images which cause the size of that chapter to surpass 1Mb.
6. There is talk that a "magic" resolution for images is 600x860 in order to have them occupy a full "page" in the resulting ePub. I have found that any image whose pixel resolution fills the iBooks page viewport will do that, if the image is also set to cause wrap-with-clear-space on the left and/or right. The iBooks viewport seems to be 368x569 pixels when the iPad is held in landscape orientation. So in other words, no matter how large your image is, when viewing on the iPad in landscape mode, it will be at the most 368x569 physical iPad pixels. Therefore it seems to me, if you only wanted to view a book in landscape mode, you could make all your images exactly 368x569, and not larger, making the resultant ePub file as small as possible. But you'd probably want to design the book for portrait mode as well. In portrait mode, the viewport seems to be 547x???. Where I have not taken the time to deduce the exact vertical viewport dimension, but I know it is close to 780px, either way, the image can be smaller than 600x860. iBooks will shrink any image larger than the viewport at hand (portrait or landscape) to fit the viewport. If the aspect ratio of the image differs greatly from the viewport, the image will appear "letterboxed" because the aspect ratio of the image is maintained as it is shrunk to fit the page's viewport.
7. The margins of your Pages document, whether they be document-wide margins, or margins within a section, don't seem to affect the resulting ePub. The document-wide-margins and the layout-margins (in a section) can be set to zero. The on-the-ruler margins can be at the edges of the "paper." Extranious tabs on the rulers can affect things. I find it is best to drag all tab stops off the rulers.
8. Tables are problematic. They are not good constructs to put in ePubs. Pages will dimension tables/columns width based on percentages. So if the overall width of your table drawn in Pages happens to be 50% the width of the "paper", then in iBooks on the iPad, the table will be 50% of the width of iPad's page viewport. An 8.5x11 "sheet" of paper shown in Pages is typically defined as 612 pixels wide* (change your Pages ruler units preferences to Points to verify, the Document inspector will show the page size in pixels). So if you draw your table half the width of that sheet, you get a table 306px wide in Pages. That's pretty good, you can fit a bit of text in a table that wide. But now you export to ePub, and since the iPad's (landscape) viewport is only 368 pixels wide, your resulting table is 50% of that, or 184px wide. Since the size of the text hasn't changed much, now everything is wrapping and going crazy. Column widths are also generated as percentages of the table's width, so a column that fits its content nicely in Pages is now too narrow in the ePub. Confusion ensues. Incidentally, the above assumes your document left and right margins are set to zero, if not, the percentage of width is calculated between the margins, not the edges of the page. What you can do is make the table 100% of the width of the page, in that case the resulting table in the ePub will always be 100% of the width of the page viewport on the iPad. For a bit of left and right margin, you can throw in an empty column to the left and an empty column to the right of your table's content, then shut off the border lines for those side columns so they aren't seen. This won't solve your problems, but might take some of the pain away. If a user cranks the font size up as high as it will go on the iPad, no table remains standing.
* if you do any measuring with on-screen rulers, make sure you set Page's zoom to 100% first, as it defaults to 125%!
9. If you want to get a clue as to how your book will flow on the iPad (in landscape mode for example), you can temporarily set your document's Page Size to be 368x569 pixels (will all margins set to zero). You set Page Size and Margins in pixels (in inspector) by first changing the ruler units to Points in Page's settings. Be careful though, it's an approximate result, not exact WYSIWYG, the words won't end up exactly where you see them.
10. If you have read thus far, you probably already know that the first (on-screen) page of a Pages document can be used to automatically create the ePub's cover image upon export. As mentioned elsewhere on the 'net, floating images can be used on this first page (if they are used elsewhere they are ignored). I have found that shapes, specifically floating shapes can be used on the first page as well. You can even use background shapes! This unlocks the door to creating some truly nice covers with a minimum of work. I have here attached an image of a cover I created in just a couple of minutes without using Photoshop or any other image editor, just Pages. I will describe below how it is done
All the objects on the first page (shown above) is set to floating or background, therefore, you need to move the inline text to the next page. You can do this by inserting a section break. You can see it in the upper left corner. That forces all the text to be shuttled off to next page, out of the way.
First I created the swirly pattern background. To do so, create a box shape on the page and immediately set its Placement properties to "in background". Keep "background objects selectable" and resize it to cover the entire page. Remove any border or shadow from it. Then set its Fill to any seamless pattern you like. Keep the pattern pixel dimensions small so as not to create a large ePub. This particular swirly pattern I created very quickly for free at patterncooler dot com. Set the fill properties to "Tile" so that your pattern is tiled throughout the whole box shape. Now you can uncheck "background objects selectable" so that you can work on top of it without disturbing it.
The size of the pattern repeat itself is important to consider. The book cover will be seen in two places: on iBook's bookshelf (small), and opposite the table of contents in the book itself if the iPad is held in landscape mode. If the size of the repeat is too small, then you cant really make out the pattern in the bookshelf icon because the whole cover has been shrunk down, if the repeat is too large, it might look nice on the bookshelf but funny opposite the TOC. You'll have to experiment, but the repeat used in this example is a good compromise.
Next the brown spine down the left hand side is another box shape. This one's placement is set to "floating". Stretch it to the edges of the page. I filled this one with a subtle gradient to give it a slightly 3 dimensional look. Remember that iBooks will overlay shade an indentation along the left edge to appear as a crease. So dont make it too dark. Remove any border from this box, but give it a shadow on the right, just enought to make it appear affixed on the book. I used shadow settings of Offset 1pt, Blur 6pt, Opacity 75% at an angle of 323. Too much offset or blur ruins the effect. You want it to appear as a very thin layer adhesed to the "book". As for colors, use the eyedropper on the color inspector to pick colors from the background pattern, this will make it "work together" if you are color challenged.
The stitching on the right edge of the spine shape is a simple line shape 2 pts wide. Properties are: dotted, with a very slight shadow (2,4,85%,315). You can use the "bring forward" or "send backward" commands if the stack order gets mixed up.
Next add the Title and Author boxes. They are simple floating box shapes with color fill, and simple black border of 3px. Page's pop-up alignment guides will help you center them in the page. There is no shadow for these boxes as they (here) are supposed to mimic a printed and not a physical adhesion. Instead of a line border, you can also apply Page's "picture frame borders. I went crazy with those, but ultimately came back to the simple line border.
If you want to make these "adhesions" there are lots of nice paper textures on the 'net you can use as fill.
Finally you see there is a slight highlight on the top edge of the book and slight shadow along the right and bottom edge. These make the cover seem to have rounded edges, they give it a 3D appearance. To create the right hand "round over" draw a line-shape the height of the page. Make it 5px wide, and give it shadow properties of 5,4,50%,142. Next you have to move it so that it is slightly off the paper and thus not seen, but close enough that it's shadow is still seen. To move it, you can use a combination of the mouse, the arrow buttons on the keyboard, and/or the position inspector pane. In my example, the page is 600px wide, and the line sits at the 601px location. Be careful about moving shapes off the page, as you can "lose" them. Oddly enough, there is no way to see and/or find shapes that are "off page" (that I know of anyway). If you lose a shape off the page, you have to draw selection boxes blindly, until you stumble upon the shape again. It seems a way to hide content if one so desired.
For the bottom edge of the book, do the same thing with a horizontal line. Shadow angle in my example is the same 142 degrees.
For the top edge, do the same except make the shadow color white. (5,5,50%,270). This shape is hard to select once you have it offscreen. If you want to select it, you might have to move the background and right edge shadow out of the way first. Then draw a small box at the top right corner of the page until you hit it.
And one last detail, you might notice my page size is 600x860px (8.333in x 11.944in). This is because I think this aspect ratio is shaped more like a novel than than 8.5x11in (612x792px). The latter is squarer, and more the shape of a text book.
I hope this stuff has been useful to you.
Thank you for sharing such an informative post! I'd like to offer one small correction.
My company publishes children's picture storybooks in print. These are edge to edge full color pages for those who may not be familiar with this format. Our early ePub's were always disappointing in that we could not duplicate the print format without showing considerable white margins on an e-reader. We have since solved that problem in order to achieve the maximum image size. There will always be some amount of white margin in ePub format, but our image output now nearly fills the screen of any e-reader.
The 600X860 resolution is correct in order to achieve a wall to wall ePub image. The image must be created at that resolution for insertion into the document, and the page setup must also be set at the same dimension, which in inches is 8.333X11.944. You cannot, for example, use a smaller size image and drag it with constrained proportions to fill the viewport at the 600X860 resolution. The exported ePub file recognizes the portion of the image that is beyond the margins of the viewport and it will show up in an e-reader with a large white bottom margin.
Dragging a smaller image than the 600X860 resolution to fill the viewport with unconstrained proportions will work, but of course distorts the image. So, create your images at 600X860, insert them into your doc, export to ePub and you will be happy, happy, happy!
Read More: The other 8 answers