Wednesday, February 29, 2012

FREE BOOK and $50 Giftcard Drawing Mar 1-3

Launch Promo: One (1) $50 Amazon Giftcard

5 easy steps:
  1. Go to http://amzn.to/zhK30L and download the book FREE before Saturday 11:59 pm Pacific Time (March 3, 2012)
  2. Go to the "Contact Me" sidebar on this blog, or the "Contact" page of my publisher  http://www.amigabooks.com/contact/  and fill in the contact form.
  3. Include your e-mail address
  4. Include your Amazon Order ID#
  5. Include the answer to this question: Who is the first character listed in the "Cast of Characters" section?
Note: you may enter this drawing if you downloaded the book before Saturday 11:59 pm PST, March 3, 2012.

All e-mails need to be sent before the cut-off Sunday 1:00 am March 4. One entry per purchase. Results will be posted next week. Good luck!

Thank you for your interest in Michal's Window! And please visit my Author's page at Amazon.

Friday, February 24, 2012

Michal's Window Launch Giveaway $50 Giftcard

Don't forget to enter the Giveaway. Send e-mail or use the "Contact Me" in the right side bar or go to http://www.amigabooks.com and contact me there.

Download Michal's Window here at Amazon: http://amzn.to/zhK30L

You don't need a Kindle to read it. Download Free Kindle Apps that run on PC, Mac, iPhone, iPad, Blackberry, Android, etc... http://amzn.to/yBeO0l

Thanks for your interest. The drawing ends Sunday, March 4, 2012 at 1:00 am.

Download 99c BOOK and Enter $50 Giveaway

Launch Promo: $50 Amazon Giftcard

5 easy steps:
  1. Go to http://amzn.to/xMkZ9f and download the book before Saturday 11:59 pm March 3, 2012
  2. Go to the "Contact Me" sidebar on this blog, or the "Contact" page of my publisher  http://www.amigabooks.com/contact/  and fill in the contact form.
  3. Include your e-mail address
  4. Include your Amazon Order ID#
  5. Include the answer to this question: Who is the first character listed in the "Cast of Characters" section?
Note: you may enter this contest if you downloaded the book before Saturday 11:59 pm, March 3, 2012.

All e-mails need to be sent before the cut-off Sunday 1:00 am March 4. One entry per person. I will sort all e-mail addresses and generate a random number.

Thank you for your interest in Michal's Window!

Michal's Window is LIVE today!

Michal's Window is available at Amazon at this link. http://is.gd/RPJ4E7


Launch Promo! $50 Amazon Giftcard


Everyone who buys or downloads for FREE (yes, that's right, FREE promo TBA) in the next week can enter my $50 Amazon Giftcard giveaway. Send me e-mail in the "Contact Me" form on the right sidebar.


Giveaway ends Sunday, March 4th , 1:00 am Pacific Time


Include:


  • YOUR email address [so I can get back to you]
  • Subject field: Launch Giveaway [so I can easily find your e-mail]
  • Message field: Amazon Order # and the answer to this question found in the "Cast of Characters". Who is the first character named?

Wednesday, February 22, 2012

Kindle Formatting 7: Using KindleGen Alone

I figured out that my previously posted OPF file was not setup to use Kindlegen to create the table of contents. I did not have the "toc.htm" file in the manifest. There was also the problem of overloading the "toc" for both the table of contents and the toc.ncx item. I changed the toc.ncx to id="toc1" and deleted the "Hard Bookmarks" inside the document.htm for table of contents. This allowed Kindlegen to place my Table of Contents where it wanted, which was right after the Cover. Changed items are in red. I hope this helps anyone that is stumped. I no longer have to go through the extra step of using Calibre. This eliminates the pesky blank pages Calibre automatically puts in before each Part and Chapter heading. Because of the flowing nature of e-readers blank pages can cause readers to be confused, thinking the book has ended.

Note: Start, Cover, and TOC points work on Kindle on PC, iPad, and the emulators to "Part 1" where I put the named bookmark. Start does not work on Kindle Fire. On Kindle Fire "start" points to the beginning of the Table of Contents.

Here are the fragments of the OPF file that I changed. Now the Table of Contents for Kindle on PC is active.
---------------

<manifest>
<item href="Michals-jpg-kindle.jpg" id="my-cover-image" media-type="image/jpeg" />
<item id="toc1" media-type="application/x-dtbncx+xml" href="toc.ncx"></item>
<item id="toc" media-type="text/x-oeb1-document" href="toc.htm"></item>
<item id="item1" media-type="text/x-oeb1-document" href="MichalsWindow.htm"></item>
</manifest>

<spine toc="toc1">
<itemref idref="toc"/>
<itemref idref="item1"/>

</spine>

<tours></tours>

<guide>
<reference type="toc" title="Table of Contents" href="toc.htm"/>

<reference type="start" title="Startup Page" href="MichalsWindow.htm%23start"></reference>

</guide>

</package>

Monday, February 20, 2012

Kindle Formatting 6: Using Kindlegen and Calibre to form .mobi file

Again, read Helen Hanson's excellent explanation http://www.helenhanson.com/?p=1376 on how to use Kindlegen


See that .mobi file? This is the file you will load into Calibre to allow it to generate the Table of Contents for you. This is why we REMOVED the Table of Contents from our Word document. Otherwise we will end up with TWO Table of Contents, and only the Calibre one will work correctly with Kindle on PC and iPad. Interestingly enough, the Kindlegen one does work with Kindle Previewer. What I mean is that when you say "Go To Table of Contents" on the Kindle Previewer, it works for the Kindle versions, but not for iPad and iPod. For Kindle on PC, the menu item to go to "Table of Contents" is disabled on the non-Calibre version.

Using Calibre should be straightforward, but I will include some instructions in case it is not self-evident.

You load your .mobi file into Calibre, and do a Mobi to Mobi conversion. Fill in and fix anything you want. Check "Force use of auto-generated Table of Contents"
Type in Title of Table of Contents
Check "Put generated Table of Contents at start instead of end"

In Structure Detection add in "Detect Chapters at (Xpath Expression) [I added "cast" and "note"] This helps Calibre determine what is automatically a table of content entry

//*[((name()='h1' or name()='h2') and re:test(., '\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue|cast|note)(\s+|$))', 'i')) or @class = 'chapter']

Hit "Okay" and there you go. Go to Path: click to open and file your .mobi file. This is the file you will upload to Amazon.

Check it with Kindle Previewer and any other Kindle apps. Make sure you can "go to start", "go to cover", "go to table of contents" and use the NCX View [which requires double-clicking]

And you should be good to go. Ask me any questions if anything is unclear.

Kindle Formatting 5: Preparing the OPF file

NOTE: There is an error in this OPF file that causes the Table of Contents to not be recognized. Please see #7 in this series where I explain where the entries should go.
------
Related thread in Amazon Forum.

Helen Hanson http://www.helenhanson.com/?p=1318 does a great explanation of the OPF file.

Everyone's file will be different because of content. In this example, YOURFILENAME=mynovel and YOURCOVER=mycover [make sure these two files are in your sandbox. Move the toc.ncx and this opf file which is named YOURFILENAME.opf or mynovel.opf into the sandbox]

The toc.htm will not be found. I could not figure out how to do this, so before we move on, delete your table of contents from YOURFILENAME.htm. Simple delete all rows starting with <p class=MsoToc1 ...
Or go into your mynovel.docx and delete the Table of Contents and regenerate the mynovel.htm. This is probably better since the entire purpose of this exercise is to be able to keep changing mynovel.docx and regenerate mynovel.htm without having to regenerate the toc.ncx file. This allows you to fix typos, etc.


<?xml version="1.0" encoding="utf-8"?>
<package unique-identifier="uid">
<metadata>
<dc-metadata xmlns:dc="http://purl.org/metadata/dublin_core" xmlns:oebpackage="http://openebook.org/namespaces/oeb-package/1.0/">

<dc:Title>YOUR TITLE</dc:Title>
<dc:Language>en-us</dc:Language>
<dc:Identifier id="uid"></dc:Identifier>
<dc:Creator>YOUR NAME</dc:Creator>
<dc:Publisher>YOUR PUBLISHER</dc:Publisher>
<dc:Subject BASICCode="FIC027050">Romance/Historical</dc:Subject>
<dc:Description>YOUR PRODUCT DESCRIPTION</dc:Description>

<dc:Date>YOUR PUB DATE</dc:Date>

</dc-metadata>

<x-metadata>
/* <output encoding="Windows-1252" content-type="text/x-oeb1-document"></output> */
<output encoding="utf-8" content-type="text/x-oeb1-document"></output>
<EmbeddedCover>YOURCOVER.jpg</EmbeddedCover>

<SRP Currency="USD">0.99</SRP>
<Demo>YOURFILENAMESample.prc</Demo>
</x-metadata>

<meta name="cover" content="my-cover-image" />

</metadata>

<manifest>
<item href="YOURCOVER.jpg" id="my-cover-image" media-type="image/jpeg" />
<item id="toc" media-type="application/x-dtbncx+xml" href="toc.ncx"></item>
<item id="item1" media-type="text/x-oeb1-document" href="YOURFILENAME.htm"></item>
</manifest>

<spine toc="toc">

<itemref idref="item1"/>

</spine>

<tours></tours>

<guide>
<reference type="toc" title="Table of Contents" href="toc.htm"/>

<reference type="cover" title="Cover Image" href="YOURFILENAME.htm%23cover"></reference>
<reference type="toc" title="Table of Contents" href="YOURFILENAME.htm%23toc"></reference>
<reference type="start" title="Startup Page" href="YOURFILENAME.htm%23start"></reference>

</guide>

</package>

Kindle Formatting 4: Michal's Window toc.ncx


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">

<head>

<!-- The following four metadata items are required for all NCX documents,
including those conforming to the relaxed constraints of OPS 2.0 --> <meta name="dtb:uid" content="123456789X"/> <!-- same as in .opf -->

<meta name="dtb:depth" content="1"/> <!-- 1 or higher -->
<meta name="dtb:totalPageCount" content="0"/> <!-- must be 0 -->
<meta name="dtb:maxPageNumber" content="0"/> <!-- must be 0 -->
</head>

<docTitle>
<text>Michal’s Window</text>
</docTitle>
<navMap>
<navPoint id="navPoint-1" playOrder="1">

<navLabel>
<text>Part I</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288502"/>
</navPoint>

<navPoint id="navPoint-2" playOrder="2">

<navLabel>
<text>Chapter 1</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288503"/>
</navPoint>

<navPoint id="navPoint-3" playOrder="3">

<navLabel>
<text>Chapter 2</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288504"/>
</navPoint>

<navPoint id="navPoint-4" playOrder="4">

<navLabel>
<text>Chapter 3</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288505"/>
</navPoint>

<navPoint id="navPoint-5" playOrder="5">

<navLabel>
<text>Chapter 4</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288506"/>
</navPoint>

<navPoint id="navPoint-6" playOrder="6">

<navLabel>
<text>Chapter 5</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288507"/>
</navPoint>

<navPoint id="navPoint-7" playOrder="7">

<navLabel>
<text>Chapter 6</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288508"/>
</navPoint>

<navPoint id="navPoint-8" playOrder="8">

<navLabel>
<text>Chapter 7</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288509"/>
</navPoint>

<navPoint id="navPoint-9" playOrder="9">

<navLabel>
<text>Part II</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288510"/>
</navPoint>

<navPoint id="navPoint-10" playOrder="10">

<navLabel>
<text>Chapter 8</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288511"/>
</navPoint>

<navPoint id="navPoint-11" playOrder="11">

<navLabel>
<text>Chapter 9</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288512"/>
</navPoint>

<navPoint id="navPoint-12" playOrder="12">

<navLabel>
<text>Chapter 10</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288513"/>
</navPoint>

<navPoint id="navPoint-13" playOrder="13">

<navLabel>
<text>Chapter 11</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288514"/>
</navPoint>

<navPoint id="navPoint-14" playOrder="14">

<navLabel>
<text>Chapter 12</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288515"/>
</navPoint>

<navPoint id="navPoint-15" playOrder="15">

<navLabel>
<text>Chapter 13</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288516"/>
</navPoint>

<navPoint id="navPoint-16" playOrder="16">

<navLabel>
<text>Chapter 14</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288517"/>
</navPoint>

<navPoint id="navPoint-17" playOrder="17">

<navLabel>
<text>Chapter 15</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288518"/>
</navPoint>

<navPoint id="navPoint-18" playOrder="18">

<navLabel>
<text>Chapter 16</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288519"/>
</navPoint>

<navPoint id="navPoint-19" playOrder="19">

<navLabel>
<text>Chapter 17</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288520"/>
</navPoint>

<navPoint id="navPoint-20" playOrder="20">

<navLabel>
<text>Chapter 18</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288521"/>
</navPoint>

<navPoint id="navPoint-21" playOrder="21">

<navLabel>
<text>Chapter 19</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288522"/>
</navPoint>

<navPoint id="navPoint-22" playOrder="22">

<navLabel>
<text>Chapter 20</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288523"/>
</navPoint>

<navPoint id="navPoint-23" playOrder="23">

<navLabel>
<text>Chapter 21</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288524"/>
</navPoint>

<navPoint id="navPoint-24" playOrder="24">

<navLabel>
<text>Chapter 22</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288525"/>
</navPoint>

<navPoint id="navPoint-25" playOrder="25">

<navLabel>
<text>Chapter 23</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288526"/>
</navPoint>

<navPoint id="navPoint-26" playOrder="26">

<navLabel>
<text>Chapter 24</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288527"/>
</navPoint>

<navPoint id="navPoint-27" playOrder="27">

<navLabel>
<text>Chapter 25</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288528"/>
</navPoint>

<navPoint id="navPoint-28" playOrder="28">

<navLabel>
<text>Chapter 26</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288529"/>
</navPoint>

<navPoint id="navPoint-29" playOrder="29">

<navLabel>
<text>Chapter 27</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288530"/>
</navPoint>

<navPoint id="navPoint-30" playOrder="30">

<navLabel>
<text>Chapter 28</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288531"/>
</navPoint>

<navPoint id="navPoint-31" playOrder="31">

<navLabel>
<text>Chapter 29</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288532"/>
</navPoint>

<navPoint id="navPoint-32" playOrder="32">

<navLabel>
<text>Chapter 30</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288533"/>
</navPoint>

<navPoint id="navPoint-33" playOrder="33">

<navLabel>
<text>Part III</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288534"/>
</navPoint>

<navPoint id="navPoint-34" playOrder="34">

<navLabel>
<text>Chapter 31</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288535"/>
</navPoint>

<navPoint id="navPoint-35" playOrder="35">

<navLabel>
<text>Chapter 32</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288536"/>
</navPoint>

<navPoint id="navPoint-36" playOrder="36">

<navLabel>
<text>Chapter 33</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288537"/>
</navPoint>

<navPoint id="navPoint-37" playOrder="37">

<navLabel>
<text>Chapter 34</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288538"/>
</navPoint>

<navPoint id="navPoint-38" playOrder="38">

<navLabel>
<text>Chapter 35</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288539"/>
</navPoint>

<navPoint id="navPoint-39" playOrder="39">

<navLabel>
<text>Chapter 36</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288540"/>
</navPoint>

<navPoint id="navPoint-40" playOrder="40">

<navLabel>
<text>Chapter 37</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288541"/>
</navPoint>

<navPoint id="navPoint-41" playOrder="41">

<navLabel>
<text>Chapter 38</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288542"/>
</navPoint>

<navPoint id="navPoint-42" playOrder="42">

<navLabel>
<text>Chapter 39</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288543"/>
</navPoint>

<navPoint id="navPoint-43" playOrder="43">

<navLabel>
<text>Chapter 40</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288544"/>
</navPoint>

<navPoint id="navPoint-44" playOrder="44">

<navLabel>
<text>Chapter 41</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288545"/>
</navPoint>

<navPoint id="navPoint-45" playOrder="45">

<navLabel>
<text>Chapter 42</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288546"/>
</navPoint>

<navPoint id="navPoint-46" playOrder="46">

<navLabel>
<text>Chapter 43</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288547"/>
</navPoint>

<navPoint id="navPoint-47" playOrder="47">

<navLabel>
<text>Chapter 44</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288548"/>
</navPoint>

<navPoint id="navPoint-48" playOrder="48">

<navLabel>
<text>Chapter 45</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288549"/>
</navPoint>

<navPoint id="navPoint-49" playOrder="49">

<navLabel>
<text>Chapter 46</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288550"/>
</navPoint>

<navPoint id="navPoint-50" playOrder="50">

<navLabel>
<text>Chapter 47</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288551"/>
</navPoint>

<navPoint id="navPoint-51" playOrder="51">

<navLabel>
<text>Chapter 48</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288552"/>
</navPoint>

<navPoint id="navPoint-52" playOrder="52">

<navLabel>
<text>Chapter 49</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288553"/>
</navPoint>

<navPoint id="navPoint-53" playOrder="53">

<navLabel>
<text>Part IV</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288554"/>
</navPoint>

<navPoint id="navPoint-54" playOrder="54">

<navLabel>
<text>Chapter 50</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288555"/>
</navPoint>

<navPoint id="navPoint-55" playOrder="55">

<navLabel>
<text>Chapter 51</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288556"/>
</navPoint>

<navPoint id="navPoint-56" playOrder="56">

<navLabel>
<text>Chapter 52</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288557"/>
</navPoint>

<navPoint id="navPoint-57" playOrder="57">

<navLabel>
<text>Chapter 53</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288558"/>
</navPoint>

<navPoint id="navPoint-58" playOrder="58">

<navLabel>
<text>Epilogue</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288559"/>
</navPoint>

<navPoint id="navPoint-59" playOrder="59">

<navLabel>
<text>Cast</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288560"/>
</navPoint>

<navPoint id="navPoint-60" playOrder="60">

<navLabel>
<text>Note</text>
</navLabel>

<content src="MichalsWindow.htm#_Toc317288561"/>
</navPoint>

</navMap>

Kindle Formatting 3: Using Java to create the toc.ncx entries

The toc.ncx file is used by Kindles to navigate. The java file NcxGenTOC.java is shown below:

The three arguments I used were:

  • toc-input.txt [a snippet where I copied the MsoToc1 lines from mynovel.htm for input. I suppose you COULD use mynovel.htm, but you will have to remove the first entry because it is the text "Table of Contents". You'll see what I mean when you bring mynovel.htm into Notepad++
  • mynovel
  • mynovel.htm
The output files are used to cut and paste into the real toc.ncx file.
  • toc-ncx.txt
  • toc-html.txt [unused because I use Calibre later]
Take the toc-ncx.txt file and cut/paste its contents into the space of your ncx template that you created in Step 2.

Import this Java code into your Eclipse Workspace and run it with Configuration: toc-input.txt, mynovel, mynovel.htm

import java.io.*;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/** Generate Table Of Contents files, toc-ncx.txt and toc-html.txt for cut/paste into toc.ncx and toc.htm for KindleGen (beware of special characters like "smart quotes" that need to be corrected manually */ 


public final class NcxGenTOC {


/** Requires three arguments - file with cut/paste of MsoToc1 entries, and document title, document html filename */ 


public static void main(String... aArgs) throws IOException { 
String inFileName = aArgs[0];
String docTitle = aArgs[1];
String htmlFileName = aArgs[2];
NcxGenTOC test = new NcxGenTOC( inFileName, docTitle, htmlFileName ); test.convert();
}


/** Constructor. */
NcxGenTOC(String aFileName, String aDocTitle, String aHtmlFileName){ 
fFileName = aFileName; 
fDocTitle = aDocTitle;
fHtmlFileName = aHtmlFileName;
}


/** Generate the cut/paste files */


void convert() throws IOException {
String header = new String();
String headerRaw;
String refPt = new String();
StringBuilder line = new StringBuilder();
StringBuilder htmlLine = new StringBuilder();
log("creating output file.");


Writer out = new OutputStreamWriter(new FileOutputStream(outfile), encoding); 
Writer htmlOut = new OutputStreamWriter(new FileOutputStream(tocHtml), encoding);  
log("Reading from file: " + fFileName);


String text = new String();
String NL = System.getProperty("line.separator"); 
Scanner scanner = new Scanner(new FileInputStream(fFileName), "UTF-8"); 


out.write("<docTitle>" + NL);
line.append("<text>");
line.append(fDocTitle);
line.append("</text>");
out.write(line + NL);
out.write("</docTitle>" + NL);
out.write("<navMap>" + NL);
Pattern tocRef = Pattern.compile("\"([^\"]*)\"");
Pattern tocHead = Pattern.compile("\">[^(\">)^(</)]*</");
String contentSrc = new String("<content src=\"");
String navPointStart = new String ("<navPoint id=\"navPoint-");
String navPointPlay = new String ("\" playOrder=\"");
String navPointEnd = new String ("\">");


Integer i = 0;
try {
while (scanner.hasNextLine()){
text = scanner.nextLine();


// Specific for MSFT Word generated entries, tweak as needed
if(text.startsWith("<div class="MsoToc1">")) {
i++;
log(i.toString() + ": " + text);


line.setLength(0);
line.append(navPointStart);
line.append(i.toString());
line.append(navPointPlay);
line.append(i.toString());
line.append(navPointEnd + NL);
out.write(line + NL);


Matcher mH = tocHead.matcher(text);
while (mH.find()) {
headerRaw = new String(mH.group(0));
header = headerRaw.substring(2,headerRaw.length()-2);
//strip the first and last two characters
log(header);
line.setLength(0);
line.append("<navLabel>" + NL);
line.append("<text>");
line.append(header);
line.append("</text>" + NL);
line.append("</navLabel>" + NL);
out.write(line + NL);
} //end while


Matcher mR = tocRef.matcher(text);
while (mR.find()) {
line.setLength(0);
line.append(contentSrc);
line.append(fHtmlFileName);
refPt = mR.group(1);
log(refPt);
line.append(refPt);
line.append("\"/>" + NL);
line.append("</navPoint>" + NL);
out.write(line + NL);
} //end while


htmlLine.setLength(0);
htmlLine.append("<a href=\"");
htmlLine.append(fHtmlFileName);
htmlLine.append(refPt);
htmlLine.append("\">");
htmlLine.append(header);
htmlLine.append("</a><br />");
htmlOut.write(htmlLine + NL);
} //end if
} //end while
} //end try
finally {
scanner.close();
out.write("</navMap>" + NL);
out.close();
htmlOut.close();
}
log("Files written: " + outfile + " and " + tocHtml);
} // end convert
// PRIVATE
private final String fFileName;
private final String fDocTitle;
private final String fHtmlFileName;
String encoding = "UTF-8";
String outfile = "toc-ncx.txt";
String tocHtml = "toc-html.txt";
private void log(String aMessage){
System.out.println(aMessage);
}
}

Kindle Formatting 2: Extracting the TOC

Prepare to Generate toc.ncx

Extract the toc entries from mynovel.htm


Copy and paste this and save into a text file called “toc-input.txt”

Prepare a skeleton ncx file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">

<head>

<!-- The following four metadata items are required for all NCX documents,
including those conforming to the relaxed constraints of OPS 2.0 --> <meta name="dtb:uid" content="123456789X"/> <!-- same as in .opf -->

<meta name="dtb:depth" content="1"/> <!-- 1 or higher -->
<meta name="dtb:totalPageCount" content="0"/> <!-- must be 0 -->
<meta name="dtb:maxPageNumber" content="0"/> <!-- must be 0 -->
</head>

<!-- your output from the Java code goes here -->

</ncx>

Kindle Formatting 1: Preparing Word Document

Microsoft Word Used: Office 2010, Version 14.0.6112.5000 (32-bit)


Clean Up the Word Document

Go to File à Options à Proofing à Autocorrect Options and make sure “Straight quotes” with “Smart quotes” is ticked.



Go through your document and “Find/Replace” a single quote ( ' ) with a single quote ( ' ), and a double quote ( " ) with a double quote ( " ). Trust me, it works.
Now, go through your document and find every place you have a contraction like ‘tis or ‘66 and fix them. Type a’tis and delete the “a”. Yep, it’s a pain, but hopefully you don’t have that many contractions.

You want to fix all of these smart quotes before you start editing HTML, because you do not want curly quotes in HTML tags.

Replace all double spaces by single spaces. Go to “Find/Replace” and space twice in the Find box, and once in the Replace box. Modern typography does not require a double space at the end of the sentence.

Go ahead and remove all page numbers, headers and footers that will not be in the Kindle file.

General Table of Contents without Page Numbers

Uncheck the “Show page numbers” and make sure “Use hyperlinks instead of page numbers” is checked.

Insert the Kindle Required Markers

Kindle requires two markers “toc” for Table of Contents, and “start” for the beginning of the text
Put your cursor right before the “T” in the Table of Contents and Go to the Insert Tab, and hit bookmark. Add “toc”
Now put your cursor right before the first letter of either your “Part 1” or “Chapter 1” and insert bookmark. Add “start”.
Because of a bug in KindleGen [Amazon.com kindlegen(Windows) V2.3 build 36043] we will end up deleting the Table of Contents and using Calibre to generate it. But for now, leave it in so you can use the Bookmark.

Generate HTM

Create a sandbox folder or directory
Place the following documents in your sandbox.
•         Word doc, mynovel.docx [Word 2010 format]
•         Cover image, mycover.jpg [sized to approx. 800x600]
Eventually, two other files will also be placed in the sandbox: toc.ncx and mynovel.opf. But let’s not worry about these yet.
Save the Word file in the sandbox as type "Web Page, Filtered" .htm file to strip most of MSFT encoding. You'll notice an additional folder added where any images you might have will be stored (mynovel_files). Don't worry about the presence of the "toc.htm" file in the picture below. It does not get used because I haven't figured out how to include it in the source file. I use Calibre later on to generate the Table of Contents, however we need the Word generated TOC tags to generate the required toc.ncx file.

Download and install Notepad++ from http://notepad-plus-plus.org/
Download and install Calibre from http://calibre-ebook.com/
Congratulations. Take a break and have a cup of coffee.


Friday, February 10, 2012

Guest Post on Alpha Males

Why kind of man do you like to read about in a novel? Is he the same kind of man you'd pick as a husband or boyfriend? Do you enjoy quirky and unique characters or will a male who doesn't fit the "Alpha" stereotype leave you lackluster and yawning?

Please see my Guest Post on Angela Quarles' Romance Blog.