The sample file is downloaded to their iPad (or other iOS device) and the prospective customer can read a few pages of your book. When they get to the end of the sample, they are invited to purchase the book:
Apple will automatically create a sample file from your EPUB when you upload your book, using either the first chapter or 5% of the total word count, whichever is more.
If you'd like to offer some other quantity or selection of sample content, you can create a custom sample EPUB file.
First, make a copy of your final EPUB. You obviously don't want to work on the original! Make sure to delete the .iTunesMetadata.plist file if iTunes has unhelpfully and surreptitiously added it to your file.
Next, decide how much of your book you want to offer as a sample. I like to offer enough of the book to get a taste, but not so much that they don't need to buy my book! :)
Eliminate the files that shouldn't be part of your EPUB. For example, you might delete all of the XHTML files from Chapter 2 onward. If you have particularly long chapters, you might not even want to include the entire first chapter. In that case, eliminate the part of the XHTML file that should not be included in the sample. In this case, make sure that the code in the remaining file still validates (e.g., has all of the appropriate closing tags).
The next step is to go through the XHTML files that will be included and search for IMG to see which image files you'll need to keep. Then go through your OEBPS folder and actually eliminate the image files that are not used in the sample. Repeat this step for any other extra files (audios, video, pdfs) that may not be a part of the sample.
Since you've removed both XHTML files and media files, you'll have to remove their declarations from the
<manifest>in the content.opf file. I keep my images folder open, gather the declarations for the "good" images at the top of the manifest, and then delete the rest with one fell swoop.
Don't forget to remove references to the non-included XHTML files in the
Next, get rid of all the links that refer to documents not included in the sample. For example, you might have a TOC that links to every chapter in your book.
Here's what the code looks like in my book:
<p class="TOC-Header-3"><a href="EPUBwCS55-body-1.html#toc_marker-2-1-8">Columns</a></p>
And of course, each entry may have a different class, a different destination, and a different title.
I use GREP to quickly remove the links. And the links end up looking like this:
You can't have any links to files that are outside of your sample EPUB.
Hmm. Now that I think about it, it makes more sense to make the links remain, but go to the final page. I haven't tested it (and it may be two weeks before my next books is live on the iBookstore), but this is the GREP I will use:
(That lovely thing says "find a single link and remember the clickable text and then replace it with a link that goes to the buy button at the end of the book but keep the clickable text the same." Don't you love GREP?)
And here's how my code will look:
<p class="TOC-Header-3"><a href="EPUBwCS55-body-1.html#com_apple_itunes_epub_end0000">Columns</a></p>
Notice that I'm changing all the links from the deleted files to the same target "EPUBwCS55-body-1.html#com_apple_itunes_epub_end0000".
Finally, the hardest part is to adjust the toc.ncx file so that the Table of Contents items in the non-included chapters appear in gray—so the prospective customer knows what will be available in the full book—but don't generate errors in EpubCheck (as the actual links would).
Here's a part of the toc.ncx file from my recently published “From InDesign CS 5.5 to EPUB and Kindle”:
But the "EPUBwCS55-body-6.html" document is beyond the scope of the sample. Change it as follows:
where “EPUBwCS55-body-1.html" is the last available file in your sample EPUB, and “com_apple_itunes_epub_end0000” ends in a unique, sequential number. Start with 0001 and increase by one for each grayed out link.
You'll also, at the end of the final document in your Sample EPUB, have to create a bunch of a tags whose id is equal to each of the com links you created:
Make sure you have as many ids as you do numbered coms in your toc.ncx file.
Any link that has the com_apple_itunes_epub_end0000 link will appear in gray in the navigational TOC.
Once, for Barcelona, Catalonia, by Matthew Tree, I grayed out some interior items because I wanted to include the afterward. It worked fine, though it might feel a little confusing to someone paging through the sample.
I usually have to run EpubCheck about six times to catch all of the missing bits. It probably won't take you as many passes, but I recommend you use it to make sure you've caught all the changes.
Once you've zipped your Sample EPUB up, you can attach it to your ebook in the Assets panel of the iTunes Producer window:
If you've got any suggestions for how to choose the content for a Sample, I'd love to hear what strategies you've used or considered.