<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments for Geek Scrapbook</title>
	<atom:link href="http://www.geekscrapbook.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekscrapbook.com</link>
	<description>The .Net developer&#039;s everyday how-to guide.</description>
	<lastBuildDate>Mon, 09 Jan 2012 01:50:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>Comment on Turning a WordPress Blog into a Book: Part One by Dave</title>
		<link>http://www.geekscrapbook.com/2011/05/18/turning-a-wordpress-blog-into-a-book-part-one/comment-page-1/#comment-794</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 09 Jan 2012 01:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekscrapbook.com/2011/05/18/turning-a-wordpress-blog-into-a-book-part-one/#comment-794</guid>
		<description>I am going to post the code here for you, but be warned I haven&#039;t done much to document or genericize anything. This worked specifically for my wife&#039;s blog and took some tinkering:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Net;
using System.Web;
using System.Diagnostics;
using System.Threading;

namespace WordPressTools.ConsoleTest {
    class Program {
        static void Main(string[] args) {
            CollectedDocumentInfo docInfo = new CollectedDocumentInfo();
            docInfo.Posts = new List();
            PostInfo currentPost = null;
            using (XmlTextReader loader = new XmlTextReader(File.Open(@&quot;path-to-wordpress-export.xml&quot;, FileMode.Open))) {
                if (loader.ReadToDescendant(&quot;channel&quot;)) {
                    while (loader.Read()) {

                        

                        if (!loader.IsStartElement()) {
                            continue;
                        }

                        if (loader.Name == &quot;title&quot; &amp;&amp; loader.Depth == 2) {
                            docInfo.Title = loader.ReadString();
                        }

                        if (loader.Name == &quot;description&quot; &amp;&amp; loader.Depth == 2) {
                            docInfo.SubTitle = loader.ReadString();
                        }

                        if (loader.Name == &quot;wp:author_display_name&quot; &amp;&amp; loader.Depth == 3) {
                            docInfo.Author = loader.ReadString();
                        }

                        if (loader.Name == &quot;item&quot; &amp;&amp; loader.Depth == 2) {
                            if (currentPost != null &amp;&amp; String.IsNullOrWhiteSpace(currentPost.Content)) {
                                docInfo.Posts.Remove(currentPost);
                            }
                            currentPost = new PostInfo();
                            docInfo.Posts.Add(currentPost);
                        }

                        if (loader.Name == &quot;title&quot; &amp;&amp; loader.Depth == 3) {
                            currentPost.Title = loader.ReadString();
                        }

                        if (loader.Name == &quot;content:encoded&quot; &amp;&amp; loader.Depth == 3) {
                            currentPost.Content = loader.ReadString();
                        }

                        if (loader.Name == &quot;wp:post_date&quot; &amp;&amp; loader.Depth == 3) {
                            currentPost.Date = DateTime.Parse(loader.ReadString());
                        }

                        if (loader.Name == &quot;wp:status&quot; &amp;&amp; loader.Depth == 3) {
                            string status = loader.ReadString();
                            if (status != &quot;publish&quot;) {
                                currentPost.Content = null;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(String.Empty);
            using (StreamWriter sw = new StreamWriter(@&quot;c:\fftex\ff.tex&quot;, false)) {
                sw.WriteLine(@&quot;\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[normalem]{ulem}
% Default margins are too wide all the way around. I reset them here
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{.125in}
\setlength{\textwidth}{6.25in}
\begin{document}
\title{God&#039;s Faithfulness Through Infertility}
\author{Part 1 - (Some name for Part 1)\\Elaine Sheldon}
\maketitle
&quot;&quot;&#039;For I know the plans I have for you,&#039; declares the LORD, &#039;plans to prosper you and not to harm you, plans to give you hope and a future.&quot;&quot; Jeremiah 29:11

&quot;);
                foreach (PostInfo post in docInfo.Posts) {
                    Console.WriteLine(post.Title + &quot; - &quot; + post.Date.ToShortDateString());

                    // ok, I need to go through this post and process the content...


                    post.Title = System.Web.HttpUtility.HtmlDecode(post.Title).Replace(&quot;&amp;&quot;, &quot;\\&amp;&quot;).Replace(&quot;#&quot;, &quot;\\#&quot;);
                    string contentHtml = post.Content;

                    if (File.Exists(panDocInputPath)) {
                        File.Delete(panDocInputPath);
                    }

                    if (File.Exists(panDocOutputPath)) {
                        File.Delete(panDocOutputPath);
                    }

                    File.WriteAllText(panDocInputPath, contentHtml);

                    ProcessStartInfo psiPanDoc = new ProcessStartInfo(panDocPath, panDocInputPath + &quot; -f html -t latex -o &quot; + panDocOutputPath);
                    psiPanDoc.WindowStyle = ProcessWindowStyle.Hidden;

                    Process pPanDoc = Process.Start(psiPanDoc);

                    while (pPanDoc.HasExited) {
                        Thread.Sleep(50);
                    }
                    Thread.Sleep(100);
                    #region remove those image links and download html images to local folder
                    string searchString = @&quot;\includegraphics{&quot;;
                    using (StreamReader texIn = new StreamReader(panDocOutputPath)) {
                        using (StreamWriter texOut = new StreamWriter(fixedOutputPath)) {
                            int line = 0;
                            while (texIn.EndOfStream == false) {
                                string myLine = texIn.ReadLine();

                                string[] linesDerived = myLine.Split(new string[] { &quot;\\\\&quot; }, StringSplitOptions.None);
                                foreach (string lineFound in linesDerived) {
                                    myLine = lineFound;

                                    line++;

                                    if (myLine.StartsWith(&quot;\\href{&quot;) &amp;&amp; myLine.EndsWith(&quot;}}&quot;)) {
                                        myLine = myLine.Substring(myLine.IndexOf(&#039;}&#039;) + 2);
                                        myLine = myLine.Substring(0, myLine.Length - 1);
                                    }

                                    int indexOfGraphics = myLine.IndexOf(searchString);
                                    if (indexOfGraphics &gt; -1) {
                                        int indexToStart = indexOfGraphics + searchString.Length;

                                        string webFile = myLine.Substring(indexToStart);
                                        webFile = webFile.Substring(0, webFile.IndexOf(&#039;}&#039;));
                                        string localFile = &quot;./&quot; + webFile.Substring(webFile.LastIndexOf(&#039;/&#039;) + 1).Replace(&quot;?imgmax=800&quot;, &quot;&quot;).Replace(&quot;%&quot;,&quot;&quot;);

                                        string downloadFile = @&quot;c:\fftex\&quot; + localFile.Substring(2);
                                        try {
                                            if (!File.Exists(downloadFile)) {
                                                WebClient downloader = new WebClient();
                                                downloader.DownloadFile(webFile, downloadFile);
                                            }
                                        }
                                        catch (Exception ex) {
                                            continue;
                                        }
                                        myLine = myLine.Replace(webFile, localFile);
                                    }
                                    texOut.WriteLine(myLine);
                                }
                            }
                        }
                    }
                    #endregion remove those image links

                    string contentLatex = File.ReadAllText(fixedOutputPath);

                    sw.WriteLine(String.Format(@&quot;\section{{{0} - {1}}}

{2}&quot;, post.Title, post.Date.ToShortDateString(), contentLatex));
                }
                sw.Write(@&quot;\end{document}&quot;);
            }
            
            Console.WriteLine(String.Empty);
            Console.WriteLine(&quot;Press enter to exit...&quot;);

            Console.ReadLine();
        }
        static string panDocInputPath = @&quot;c:\pan-in.txt&quot;;
        static string panDocOutputPath = @&quot;c:\pan-out.txt&quot;;
        static string fixedOutputPath = @&quot;c:\pan-out-fixed.txt&quot;;
        static string panDocPath = @&quot;c:\program files (x86)\pandoc\bin\pandoc.exe&quot;;
    }

    class CollectedDocumentInfo {
        public string Title { get; set; }
        public string SubTitle { get; set; }
        public string Author { get; set; }
        public List Posts { get; set; }
    }

    class PostInfo {
        public string Title { get; set; }
        public DateTime Date { get; set; }
        public string Content { get; set; }
    }
}</description>
		<content:encoded><![CDATA[<p>I am going to post the code here for you, but be warned I haven&#8217;t done much to document or genericize anything. This worked specifically for my wife&#8217;s blog and took some tinkering:</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Xml;<br />
using System.IO;<br />
using System.Net;<br />
using System.Web;<br />
using System.Diagnostics;<br />
using System.Threading;</p>
<p>namespace WordPressTools.ConsoleTest {<br />
    class Program {<br />
        static void Main(string[] args) {<br />
            CollectedDocumentInfo docInfo = new CollectedDocumentInfo();<br />
            docInfo.Posts = new List();<br />
            PostInfo currentPost = null;<br />
            using (XmlTextReader loader = new XmlTextReader(File.Open(@&#8221;path-to-wordpress-export.xml&#8221;, FileMode.Open))) {<br />
                if (loader.ReadToDescendant(&#8220;channel&#8221;)) {<br />
                    while (loader.Read()) {</p>
<p>                        if (!loader.IsStartElement()) {<br />
                            continue;<br />
                        }</p>
<p>                        if (loader.Name == &#8220;title&#8221; &amp;&amp; loader.Depth == 2) {<br />
                            docInfo.Title = loader.ReadString();<br />
                        }</p>
<p>                        if (loader.Name == &#8220;description&#8221; &amp;&amp; loader.Depth == 2) {<br />
                            docInfo.SubTitle = loader.ReadString();<br />
                        }</p>
<p>                        if (loader.Name == &#8220;wp:author_display_name&#8221; &amp;&amp; loader.Depth == 3) {<br />
                            docInfo.Author = loader.ReadString();<br />
                        }</p>
<p>                        if (loader.Name == &#8220;item&#8221; &amp;&amp; loader.Depth == 2) {<br />
                            if (currentPost != null &amp;&amp; String.IsNullOrWhiteSpace(currentPost.Content)) {<br />
                                docInfo.Posts.Remove(currentPost);<br />
                            }<br />
                            currentPost = new PostInfo();<br />
                            docInfo.Posts.Add(currentPost);<br />
                        }</p>
<p>                        if (loader.Name == &#8220;title&#8221; &amp;&amp; loader.Depth == 3) {<br />
                            currentPost.Title = loader.ReadString();<br />
                        }</p>
<p>                        if (loader.Name == &#8220;content:encoded&#8221; &amp;&amp; loader.Depth == 3) {<br />
                            currentPost.Content = loader.ReadString();<br />
                        }</p>
<p>                        if (loader.Name == &#8220;wp:post_date&#8221; &amp;&amp; loader.Depth == 3) {<br />
                            currentPost.Date = DateTime.Parse(loader.ReadString());<br />
                        }</p>
<p>                        if (loader.Name == &#8220;wp:status&#8221; &amp;&amp; loader.Depth == 3) {<br />
                            string status = loader.ReadString();<br />
                            if (status != &#8220;publish&#8221;) {<br />
                                currentPost.Content = null;<br />
                            }<br />
                        }<br />
                    }<br />
                }<br />
            }</p>
<p>            Console.WriteLine(String.Empty);<br />
            using (StreamWriter sw = new StreamWriter(@&#8221;c:\fftex\ff.tex&#8221;, false)) {<br />
                sw.WriteLine(@&#8221;\documentclass[11pt]{article}<br />
\usepackage{graphicx}<br />
\usepackage{hyperref}<br />
\usepackage[normalem]{ulem}<br />
% Default margins are too wide all the way around. I reset them here<br />
\setlength{\topmargin}{-.5in}<br />
\setlength{\textheight}{9in}<br />
\setlength{\oddsidemargin}{.125in}<br />
\setlength{\textwidth}{6.25in}<br />
\begin{document}<br />
\title{God&#8217;s Faithfulness Through Infertility}<br />
\author{Part 1 &#8211; (Some name for Part 1)\\Elaine Sheldon}<br />
\maketitle<br />
&#8220;&#8221;&#8216;For I know the plans I have for you,&#8217; declares the LORD, &#8216;plans to prosper you and not to harm you, plans to give you hope and a future.&#8221;" Jeremiah 29:11</p>
<p>&#8220;);<br />
                foreach (PostInfo post in docInfo.Posts) {<br />
                    Console.WriteLine(post.Title + &#8221; &#8211; &#8221; + post.Date.ToShortDateString());</p>
<p>                    // ok, I need to go through this post and process the content&#8230;</p>
<p>                    post.Title = System.Web.HttpUtility.HtmlDecode(post.Title).Replace(&#8220;&amp;&#8221;, &#8220;\\&amp;&#8221;).Replace(&#8220;#&#8221;, &#8220;\\#&#8221;);<br />
                    string contentHtml = post.Content;</p>
<p>                    if (File.Exists(panDocInputPath)) {<br />
                        File.Delete(panDocInputPath);<br />
                    }</p>
<p>                    if (File.Exists(panDocOutputPath)) {<br />
                        File.Delete(panDocOutputPath);<br />
                    }</p>
<p>                    File.WriteAllText(panDocInputPath, contentHtml);</p>
<p>                    ProcessStartInfo psiPanDoc = new ProcessStartInfo(panDocPath, panDocInputPath + &#8221; -f html -t latex -o &#8221; + panDocOutputPath);<br />
                    psiPanDoc.WindowStyle = ProcessWindowStyle.Hidden;</p>
<p>                    Process pPanDoc = Process.Start(psiPanDoc);</p>
<p>                    while (pPanDoc.HasExited) {<br />
                        Thread.Sleep(50);<br />
                    }<br />
                    Thread.Sleep(100);<br />
                    #region remove those image links and download html images to local folder<br />
                    string searchString = @&#8221;\includegraphics{&#8220;;<br />
                    using (StreamReader texIn = new StreamReader(panDocOutputPath)) {<br />
                        using (StreamWriter texOut = new StreamWriter(fixedOutputPath)) {<br />
                            int line = 0;<br />
                            while (texIn.EndOfStream == false) {<br />
                                string myLine = texIn.ReadLine();</p>
<p>                                string[] linesDerived = myLine.Split(new string[] { &#8220;\\\\&#8221; }, StringSplitOptions.None);<br />
                                foreach (string lineFound in linesDerived) {<br />
                                    myLine = lineFound;</p>
<p>                                    line++;</p>
<p>                                    if (myLine.StartsWith(&#8220;\\href{&#8220;) &amp;&amp; myLine.EndsWith(&#8220;}}&#8221;)) {<br />
                                        myLine = myLine.Substring(myLine.IndexOf(&#8216;}&#8217;) + 2);<br />
                                        myLine = myLine.Substring(0, myLine.Length &#8211; 1);<br />
                                    }</p>
<p>                                    int indexOfGraphics = myLine.IndexOf(searchString);<br />
                                    if (indexOfGraphics &gt; -1) {<br />
                                        int indexToStart = indexOfGraphics + searchString.Length;</p>
<p>                                        string webFile = myLine.Substring(indexToStart);<br />
                                        webFile = webFile.Substring(0, webFile.IndexOf(&#8216;}&#8217;));<br />
                                        string localFile = &#8220;./&#8221; + webFile.Substring(webFile.LastIndexOf(&#8216;/&#8217;) + 1).Replace(&#8220;?imgmax=800&#8243;, &#8220;&#8221;).Replace(&#8220;%&#8221;,&#8221;");</p>
<p>                                        string downloadFile = @&#8221;c:\fftex\&#8221; + localFile.Substring(2);<br />
                                        try {<br />
                                            if (!File.Exists(downloadFile)) {<br />
                                                WebClient downloader = new WebClient();<br />
                                                downloader.DownloadFile(webFile, downloadFile);<br />
                                            }<br />
                                        }<br />
                                        catch (Exception ex) {<br />
                                            continue;<br />
                                        }<br />
                                        myLine = myLine.Replace(webFile, localFile);<br />
                                    }<br />
                                    texOut.WriteLine(myLine);<br />
                                }<br />
                            }<br />
                        }<br />
                    }<br />
                    #endregion remove those image links</p>
<p>                    string contentLatex = File.ReadAllText(fixedOutputPath);</p>
<p>                    sw.WriteLine(String.Format(@&#8221;\section{{{0} &#8211; {1}}}</p>
<p>{2}&#8221;, post.Title, post.Date.ToShortDateString(), contentLatex));<br />
                }<br />
                sw.Write(@&#8221;\end{document}&#8221;);<br />
            }</p>
<p>            Console.WriteLine(String.Empty);<br />
            Console.WriteLine(&#8220;Press enter to exit&#8230;&#8221;);</p>
<p>            Console.ReadLine();<br />
        }<br />
        static string panDocInputPath = @&#8221;c:\pan-in.txt&#8221;;<br />
        static string panDocOutputPath = @&#8221;c:\pan-out.txt&#8221;;<br />
        static string fixedOutputPath = @&#8221;c:\pan-out-fixed.txt&#8221;;<br />
        static string panDocPath = @&#8221;c:\program files (x86)\pandoc\bin\pandoc.exe&#8221;;<br />
    }</p>
<p>    class CollectedDocumentInfo {<br />
        public string Title { get; set; }<br />
        public string SubTitle { get; set; }<br />
        public string Author { get; set; }<br />
        public List Posts { get; set; }<br />
    }</p>
<p>    class PostInfo {<br />
        public string Title { get; set; }<br />
        public DateTime Date { get; set; }<br />
        public string Content { get; set; }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C# Method to Add an Image to a PDF by Richard Chang</title>
		<link>http://www.geekscrapbook.com/2009/11/16/c-method-to-add-an-image-to-a-pdf/comment-page-1/#comment-731</link>
		<dc:creator>Richard Chang</dc:creator>
		<pubDate>Tue, 20 Dec 2011 07:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekscrapbook.com/2009/11/16/c-method-to-add-an-image-to-a-pdf/#comment-731</guid>
		<description>Hi,

Thanks for this example with PdfSharp !

So, this can be used to add a bunch of images at the end of a PDF ?
Not sure what you mean by a &quot;Letterhead&quot; generator.
Isn&#039;t a letterhead something at the beginning of each page of the document ?

Any idea of putting some image description text ( above or below each image ) ?
Regards, Rich</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for this example with PdfSharp !</p>
<p>So, this can be used to add a bunch of images at the end of a PDF ?<br />
Not sure what you mean by a &#8220;Letterhead&#8221; generator.<br />
Isn&#8217;t a letterhead something at the beginning of each page of the document ?</p>
<p>Any idea of putting some image description text ( above or below each image ) ?<br />
Regards, Rich</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Turning a WordPress Blog into a Book: Part One by emre</title>
		<link>http://www.geekscrapbook.com/2011/05/18/turning-a-wordpress-blog-into-a-book-part-one/comment-page-1/#comment-388</link>
		<dc:creator>emre</dc:creator>
		<pubDate>Tue, 24 May 2011 02:24:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekscrapbook.com/2011/05/18/turning-a-wordpress-blog-into-a-book-part-one/#comment-388</guid>
		<description>So how did you do it? Could you share the code?</description>
		<content:encoded><![CDATA[<p>So how did you do it? Could you share the code?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on CashTrackerOnline.com Sneak Peek by Dave</title>
		<link>http://www.geekscrapbook.com/2010/09/03/cashtrackeronline-com-sneak-peek/comment-page-1/#comment-180</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 04 Sep 2010 05:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekscrapbook.com/2010/09/03/cashtrackeronline-com-sneak-peek/#comment-180</guid>
		<description>Yeah, plastic blue theme :) There&#039;s definitely a learning curve to them over the regular-old controls that ship with .NET and the AJAX toolkit, but the advantage is how nice they look out-of-the-box once you get the pattern down. Most of that has to do with the DevExpress controls using callbacks to do almost everything, which just works sometimes, but other times I have to take extra steps to make sure another control updates, etc.</description>
		<content:encoded><![CDATA[<p>Yeah, plastic blue theme <img src='http://www.geekscrapbook.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  There&#8217;s definitely a learning curve to them over the regular-old controls that ship with .NET and the AJAX toolkit, but the advantage is how nice they look out-of-the-box once you get the pattern down. Most of that has to do with the DevExpress controls using callbacks to do almost everything, which just works sometimes, but other times I have to take extra steps to make sure another control updates, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on CashTrackerOnline.com Sneak Peek by joseph</title>
		<link>http://www.geekscrapbook.com/2010/09/03/cashtrackeronline-com-sneak-peek/comment-page-1/#comment-179</link>
		<dc:creator>joseph</dc:creator>
		<pubDate>Fri, 03 Sep 2010 19:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekscrapbook.com/2010/09/03/cashtrackeronline-com-sneak-peek/#comment-179</guid>
		<description>ooh, pretty! DevExpress controls FTW :)</description>
		<content:encoded><![CDATA[<p>ooh, pretty! DevExpress controls FTW <img src='http://www.geekscrapbook.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

