<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PowerShell.cz &#187; Kindle</title>
	<atom:link href="http://powershell.cz/category/kindle/feed/" rel="self" type="application/rss+xml" />
	<link>http://powershell.cz</link>
	<description>Get-World &#124; ConvertTo-PowerShell</description>
	<lastBuildDate>Mon, 07 May 2012 15:09:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>How to work with KindleGen</title>
		<link>http://powershell.cz/2011/01/07/how-to-work-with-kindlegen/</link>
		<comments>http://powershell.cz/2011/01/07/how-to-work-with-kindlegen/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 23:22:53 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[Kindle]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=21</guid>
		<description><![CDATA[In previous post I showed you the result of my experiment with KindleGen. In this post I’ll describe the workflow I used to generate the file. KindleGen utility First of all you need to download KindleGen utility and unpack it to whatever folder you want. I put it to my Dropbox folder to be able <a href="http://powershell.cz/2011/01/07/how-to-work-with-kindlegen/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://powershell.cz/?p=8">previous post</a> I showed you the <a href="http://www.powershell.cz/files/PowerShellP.mobi">result</a> of my experiment with <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&amp;docId=1000234621">KindleGen</a>. In this post I’ll describe the workflow I used to generate the file.</p>
<p><strong>KindleGen utility</strong></p>
<p>First of all you need to download <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&amp;docId=1000234621">KindleGen utility</a> and unpack it to whatever folder you want. I put it to my Dropbox folder to be able to run it on all my computers and then I set an alias for kindlegen.exe file.</p>
<p class="code">PS C:\&gt; Set-Alias -Name kg -Value Dropbox:\Utilities\KindleGen\kindlegen.exe</p>
<p>Amazon provides two samples so can check folders <em>Sample</em> and <em>MultimediaSample</em> for general info.</p>
<p><strong>Starting point – CHM file</strong></p>
<p>As a source I used PowerShell help file located in C:\WINDOWS\help\WindowsPowerShellHelp.chm. <a href="http://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help">CHM</a> is “just” a bunch of HTML pages compiled together. You can see it’s structure for example via 7-Zip.</p>
<p><a href="http://www.powershell.cz/images/HowtoworkwithKindleGen_B670/image.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.powershell.cz/images/HowtoworkwithKindleGen_B670/image_thumb.png" border="0" alt="image" width="235" height="275" /></a></p>
<p>For us are important those files/folders:</p>
<ul>
<li><em>html folder</em> – contains all topics from CHM file &#8211; one HTML page per topic.</li>
<li><em>local folder</em> – contains “support” files – pictures used in help, CSS file and JS file.</li>
<li>PowerShell_GPSplusC.hhc – <a href="http://msdn.microsoft.com/en-us/library/ms524242(v=VS.85).aspx">table of contents</a> for CHM file.</li>
</ul>
<p>You can grab all of those to your drive by using <em>hh.exe</em> utility.</p>
<p class="code">PS C:\&gt; Get-Command hh.exe | fl<br />
Name            : hh.exe<br />
CommandType     : Application<br />
Definition      : C:\WINDOWS\hh.exe<br />
Extension       : .exe<br />
Path            : C:\WINDOWS\hh.exe<br />
FileVersionInfo : File:             C:\WINDOWS\hh.exe<br />
InternalName:     HH 1.41<br />
OriginalFilename: HH.exe<br />
FileVersion:      5.2.3790.2453 (srv03_sp1_qfe.050525-1536)<br />
FileDescription:  MicrosoftR HTML Help Executable<br />
Product:          HTML Help<br />
ProductVersion:   5.2.3790.2453<br />
Debug:            False<br />
Patched:          False<br />
PreRelease:       False<br />
PrivateBuild:     False<br />
SpecialBuild:     False<br />
Language:         English (United States)</p>
<p>Simply run this command:</p>
<p class="code">PS C:\&gt; hh.exe –decompile hlp c:\windows\help\WindowsPowerShellHelp.chm</p>
<p>and you will see files/folders mentioned above in new hlp folder. You can then check it’s contents to be familiar with the structure.</p>
<p><strong>Let’s build the structure</strong></p>
<p>Now you need to create four files.</p>
<ol>
<li>.OPF file – Open Packaging Format file is XML based file and defines “structure” of your final book. More can be found is <a href="http://www.idpf.org/doc_library/epub/OPF_2.0_latest.htm">OPF specification</a>. In <em>Sample</em> folder of KindleGen installation you can check <em>Guide.opf</em> file as it contains also comments to all elements. I used it as a starting point also. Biggest advantage is that it contains information about mandatory elements of the file. Most important elements are: <em>&lt;manifest&gt;</em> – contains list of all files you’ll include in final book. <em>&lt;spine&gt;</em> – ordered (in a way of linear reading) list of HTML files. <em>&lt;metadata&gt;</em> – some general info about final book. As I included cover, it has to be mentioned here.</li>
<li>.NCX file – Navigation Control file for XML is table of contents. In <em>Sample</em> folder you’ll see some nesting of elements but I found that for my case I was OK with just two levels – chapter and section. On my Kindle I don’t care about five levels as it’s in source CHM file.</li>
<li>toc.html – Table of contents as it will be shown visually on Kindle. I just used simple <em>&lt;ul&gt;</em> tags to show really basic outline. You can see the picture of my TOC below.</li>
<li>about.html – some short info about the book.</li>
</ol>
<p>Two mentioned HTML files <a href="http://www.idpf.org/2007/opf/OPF_2.0_final_spec.html#Section2.6">are not mandatory</a> but I found useful to include them.</p>
<p><a href="http://www.powershell.cz/images/HowtoworkwithKindleGen_B670/image_3.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.powershell.cz/images/HowtoworkwithKindleGen_B670/image_thumb_3.png" border="0" alt="image" width="381" height="277" /></a></p>
<p>As a resume let’s see what we have now.</p>
<p class="code">Dropbox:\PowerShell\Scripts\Help2Kindle\PowerShellP&gt; ls</p>
<p class="code">Mode                LastWriteTime     Length Name<br />
&#8212;-                &#8212;&#8212;&#8212;&#8212;-     &#8212;&#8212; &#8212;-<br />
d&#8212;-            4.1.11  10:27 PM            html<br />
d&#8212;-            3.1.11   8:19 PM            local<br />
-a&#8212;            4.1.11  11:57 AM        810 about.html<br />
-a&#8212;            5.1.11   4:41 PM       6616 cover.gif<br />
-a&#8212;            4.1.11   5:19 PM     109400 PowerShellP.ncx<br />
-a&#8212;            5.1.11   4:49 PM      94708 PowerShellP.opf<br />
-a&#8212;            4.1.11   4:58 PM      44067 toc.html</p>
<p>We can go to generate our final MOBI file.</p>
<p class="code">Dropbox:\PowerShell\Scripts\Help2Kindle\PowerShellP&gt; kg .\PowerShellP.opf<br />
***********************************************<br />
* Amazon.com kindlegen(Windows) V1.1 build 99 *<br />
* A command line e-book compiler              *<br />
* Copyright Amazon.com 2010                   *<br />
***********************************************<br />
opt version: try to minimize (default)<br />
Info(prcgen): Added metadata dc:Title        &#8220;PowerShell Help&#8221;<br />
Info(prcgen): Added metadata dc:Date         &#8220;2011-01-05&#8243;<br />
Info(prcgen): Added metadata dc:Creator      &#8220;@makovec&#8221;<br />
Info(prcgen): Added metadata dc:Publisher    &#8220;PowerShell.cz&#8221;<br />
Info(prcgen): Added metadata dc:Subject      &#8220;PowerShell Help&#8221;<br />
Info(prcgen): Added metadata dc:Description  &#8220;Help files provided with PowerShell.&#8221;<br />
Info(prcgen): Parsing files  0000457<br />
Info(prcgen): Resolving hyperlinks<br />
Info(prcgen): Resolving start reading location<br />
Info(prcgen): Added metadata Start reading   &#8220;65BE&#8221;<br />
Info(prcgen): Building table of content     URL: Dropbox:\PowerShell\Scripts\Help2Kindle\PowerShellP\PowerShellP.ncx<br />
Info(prcgen): Computing UNICODE ranges used in the book<br />
Info(prcgen): Found UNICODE range: Basic Latin [20..7E]<br />
Info(prcgen): Found UNICODE range: Letter-like Symbols [2100..214F]<br />
Info(prcgen): Found UNICODE range: General Punctuation &#8211; Windows 1252 [2026..2026]<br />
Info(prcgen): Found UNICODE range: Latin-1 Supplement [A0..FF]<br />
Info(prcgen): Building MOBI file, record count:   0001927<br />
Info(prcgen): Compiling HTML Parser restart information<br />
Info(prcgen): Final stats &#8211; text compressed to (in % of original size):  038.49%<br />
Info(prcgen): The document identifier is: &#8220;PowerShell_Help&#8221;<br />
Info(prcgen): The file format version is V6<br />
Info(prcgen): Saving MOBI file<br />
Info(prcgen): MOBI File successfully generated!</p>
<p>And the file is there:</p>
<p class="code">Dropbox:\PowerShell\Scripts\Help2Kindle\PowerShellP&gt; ls *.mobi</p>
<p class="code">Mode                LastWriteTime     Length Name<br />
&#8212;-                &#8212;&#8212;&#8212;&#8212;-     &#8212;&#8212; &#8212;-<br />
-a&#8212;            6.1.11  11:59 PM    4598551 PowerShellP.mobi</p>
<p><strong> </strong></p>
<p><strong>Some notes</strong></p>
<ul>
<li>I manually modified some HTML files. There were missing some tag’s parameters and KindleGen generated warning. It was not critical but I wanted nice output just with info messages.</li>
<li>I found out that (in my opinion) is not necessary to create chapters/sections with deep nesting. Maybe – as the only exception – is the toc.html file itself where it should be useful to see the structure. But I decided that it’s not that important for me.</li>
<li>You need to put ordered file names into <em>&lt;spin&gt;</em> tag in OPF file. Otherwise you content will be sorted by file name which is not so useful.</li>
<li>Use <em>Sample</em> folder as a starting point. It’s pretty well described.</li>
<li>Cover image size should be 800&#215;600.</li>
</ul>
<p>That’s enough of theory for now. Today we didn’t play with PowerShell so much so next time I’ll dedicate whole post to techniques I used during whole process (generating of files, TOC order, etc.)</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/01/07/how-to-work-with-kindlegen/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PowerShell help on Kindle</title>
		<link>http://powershell.cz/2011/01/05/powershell-help-on-kindle/</link>
		<comments>http://powershell.cz/2011/01/05/powershell-help-on-kindle/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 19:32:40 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[Kindle]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=8</guid>
		<description><![CDATA[I bought my Kindle few months ago. As I am reading whole day during every possible break I have the Kindle still with me. Last week I was checking new book from Don Jones &#8211; Learn Windows PowerShell in a Month of Lunches. As I ordered it in MEAP I like Kindle feature to add <a href="http://powershell.cz/2011/01/05/powershell-help-on-kindle/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I bought my Kindle few months ago. As I am reading whole day during every possible break I have the Kindle still with me. Last week I was checking new book from Don Jones &#8211; <a href="http://www.manning.com/jones/">Learn Windows PowerShell in a Month of Lunches</a>. As I ordered it in <a href="http://www.manning.com/about/meap.html">MEAP</a> I like Kindle feature to add my own notes “directly” to the book. What I am missing – is PowerShell <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So I decided to move help files to Kindle to be able check anything I need.</p>
<p>Amazon provides command line tool named KindleGen and I recommend you to download it together with Kindle Previewer (both located at <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&amp;docId=1000234621">Amazon Kindle&#8217;s Publishing Program</a> page). With KindleGen you’ll receive also two samples so you can find how it works.</p>
<p>As a source I used CHM file provided with PowerShell (you can access it from ISE by pressing F1 key).</p>
<p><a href="http://www.powershell.cz/images/PowerShellhelponKindle_9B3B/image.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.powershell.cz/images/PowerShellhelponKindle_9B3B/image_thumb.png" border="0" alt="image" width="335" height="311" /></a></p>
<p>I simply extracted HTML files from that file (by running <span style="font-family: cou;">hh.exe –decompile hlp c:\windows\help\WindowsPowerShellHelp.chm</span>) and then process those files with KindleGen. As a result I received nice MOBI file <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You can download the result from <a href="http://www.powershell.cz/files/PowerShellP.mobi" target="_blank">this location</a>.</p>
<p><a href="http://www.powershell.cz/images/PowerShellhelponKindle_9B3B/screen_shot1040.gif"><img style="display: inline; border-width: 0px;" title="screen_shot-1040" src="http://www.powershell.cz/images/PowerShellhelponKindle_9B3B/screen_shot1040_thumb.gif" border="0" alt="screen_shot-1040" width="320" height="419" /></a></p>
<p>As this was really funny work and whole process of the file creation is not described anywhere (AFAIK) I plan some blog posts in the near future to show how to work with KindleGen itself and also to show how I used PowerShell to help me with some conversion/copy&amp;pasting/generating XHTML.</p>
<p>Please note that my influence to this book was only the conversion from CHM to MOBI. All the texts inside were created by people from PowerShell team (except to Preface &#8211; I added it just for clarification) and all kudos needs to be send to Redmond.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/01/05/powershell-help-on-kindle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

