<?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>AJ</title>
	<atom:link href="http://aniljava.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://aniljava.com</link>
	<description></description>
	<lastBuildDate>Thu, 17 Jun 2010 05:11:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Goulet Pen : Highly Recommended</title>
		<link>http://aniljava.com/2010/06/goulet-pen-highly-recommended/</link>
		<comments>http://aniljava.com/2010/06/goulet-pen-highly-recommended/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 05:11:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[clairefontane]]></category>
		<category><![CDATA[Goulet pen]]></category>
		<category><![CDATA[rhodia]]></category>

		<guid isPermaLink="false">http://aniljava.com/?p=31</guid>
		<description><![CDATA[I ordered a dozen of Clairefontaine clothbound basic notebooks and a Rhodia Webnotebook on saturday morning. Brian took the order over the phone and did the express shipping the same day. My notebooks arrived on Monday in Dallas.
If i had ordered these notebooks from Ebay or Amazon, i would have stuck with their 1-3 business [...]]]></description>
			<content:encoded><![CDATA[<p>I ordered a dozen of <a href="http://www.gouletpens.com/Basic_Clothbound_Notebook_p/c791460.htm">Clairefontaine clothbound basic notebooks</a> and a <a href="http://www.gouletpens.com/Rhodia_Webnotebook_p/r118060.htm">Rhodia Webnotebook</a> on saturday morning. Brian took the order over the phone and did the express shipping the same day. My notebooks arrived on Monday in Dallas.</p>
<p>If i had ordered these notebooks from Ebay or Amazon, i would have stuck with their 1-3 business days and other BS. Like Goulet pen, i always recommend preaching for small businesses which always guarantees a dedicated individuals' touch behind every order you place.</p>
<p>This is also my first experience with Rhodia Webnotebook, Brian suggested me this to replace Moleskines. I use pilot pens for most of time, and the Rhodia does not bleed with it.</p>
<p>For any considering a stable source for your writing indulgences, I highly recommend <a href="http://www.gouletpens.com">Goulet Pen Company</a>.</p>
<div id="attachment_32" class="wp-caption aligncenter" style="width: 610px"><a href="http://aniljava.com/wp-content/uploads/2010/06/DSC_0031.jpg"><img class="size-full wp-image-32 " title="Rhodia Webnotebooks and Clairefontaine basics" src="http://aniljava.com/wp-content/uploads/2010/06/DSC_0031.jpg" alt="" width="600" height="600" /></a><p class="wp-caption-text">Rhodia webnotebook on top and Clairefontaine basic at bottom.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://aniljava.com/2010/06/goulet-pen-highly-recommended/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert any e-book to PDF for iPad</title>
		<link>http://aniljava.com/2010/05/convert-any-e-book-to-pdf-for-ipad/</link>
		<comments>http://aniljava.com/2010/05/convert-any-e-book-to-pdf-for-ipad/#comments</comments>
		<pubDate>Tue, 25 May 2010 04:22:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://aniljava.com/?p=22</guid>
		<description><![CDATA[Most of the e-books are tied to their publishing house, and their propriety reading software. It is quite troublesome to use them in different environment, for example ubuntu or iPad that supports only PDF. 
Below is a three step process that converts the e-books that can be opened in any computer into image-only pdf. The [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the e-books are tied to their publishing house, and their propriety reading software. It is quite troublesome to use them in different environment, for example ubuntu or iPad that supports only PDF. </p>
<p>Below is a three step process that converts the e-books that can be opened in any computer into image-only pdf. The post is written with developer in mind, specially some one who can set path, compile and run a simple java program.</p>
<p>Before starting, we need to make sure whether the e-book reader allows contentious navigation or not. Most of the e-book reader does with the use of arrow or space key for a page at a time. The code below is tested with the software that allowed page scrolling with space.</p>
<p>Actual conversion process would be like.</p>
<ol>
<li>Scroll a page.</li>
<li>Take a snapshot of the screen and work on the snapshot now to extract only the required portion / or save and use Photo shop automation to do this.</li>
<li>Stitch the processed images to a single pdf using Acrobat pro or java iText library.</li>
</ol>
<p>The code below is divided into three parts, if you feel comfortable looking at the entire code please scroll to bottom.</p>
<p>Scrolling the page.</p>
<p>[code lang='java']<br />
private void pressSpace() throws Exception {<br />
Robot r = new Robot();<br />
r.keyPress(KeyEvent.VK_SPACE);<br />
}<br />
private void click(int x, int y, int times) throws Exception {<br />
Robot r = new Robot();<br />
r.mouseMove(x, y);<br />
for (int i = 0; i &lt; times; i++) {</p>
<p>r.mousePress(InputEvent.BUTTON1_MASK);<br />
r.mouseRelease(InputEvent.BUTTON1_MASK);<br />
Thread.sleep(100);<br />
}<br />
}</p>
<p>..<br />
click(500, 500, 2); // Adjust to somewhere near center.<br />
pressSpace();<br />
click(500, 500, 2);<br />
..<br />
[/code]</p>
<p>Getting the snapshot and extracting the required portion out of it.</p>
<p>[code lang='java']<br />
    private BufferedImage getImage(int sX, int sY, int eX, int eY) throws Exception {<br />
        Robot r = new Robot();<br />
        BufferedImage img = r.createScreenCapture(new Rectangle(sX, sY, (eX - sX), (eY - sY)));<br />
        return img;<br />
    }</p>
<p>    private void save(BufferedImage img, String fileName) throws Exception {<br />
        JPEGImageWriter writer = (JPEGImageWriter) ImageIO.getImageWritersByFormatName("jpeg").next();<br />
        ImageWriteParam iwp = writer.getDefaultWriteParam();<br />
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);<br />
        iwp.setCompressionQuality(1);</p>
<p>        FileImageOutputStream output = new FileImageOutputStream(new File(fileName));<br />
        writer.setOutput(output);<br />
        IIOImage iimage = new IIOImage(img, null, null);</p>
<p>        writer.write(null, iimage, iwp);<br />
        writer.reset();<br />
    }</p>
<p>..<br />
        save(getImage(527, 55, 1389, 1067), pageNumber); // With some dummy coordinates for start and end.<br />
..<br />
[/code]</p>
<p>Stitching the final image. Can be done using Adobe pro or using code below</p>
<p>[code lang = 'java']<br />
        Document document = new Document(new com.itextpdf.text.Rectangle(862,1012));<br />
        document.setMargins(0, 0, 0, 0);<br />
        PdfWriter.getInstance(document, new FileOutputStream("book.pdf"));<br />
        document.open();</p>
<p>        JPEGProducer p = new JPEGProducer();</p>
<p>        for (int i = 0; i < (550 ) ; i++) {<br />
            Image image = p.getImage(527, 55, 1389, 1067);</p>
<p>            document.add(com.itextpdf.text.Image.getInstance(image, null));<br />
            p.click(500, 500, 2);<br />
            p.pressSpace();<br />
            p.click(100, 100, 2);</p>
<p>        }<br />
        document.close();<br />
[/code]</p>
<p>Below is the complete source code. Make sure you put iText library in path for this code to compile and run.</p>
<p>[code lang='java']</p>
<p>import java.awt.Image;<br />
import java.awt.Rectangle;<br />
import java.awt.Robot;<br />
import java.awt.event.InputEvent;<br />
import java.awt.event.KeyEvent;<br />
import java.awt.image.BufferedImage;<br />
import java.io.File;<br />
import java.io.FileOutputStream;</p>
<p>import javax.imageio.IIOImage;<br />
import javax.imageio.ImageIO;<br />
import javax.imageio.ImageWriteParam;<br />
import javax.imageio.stream.FileImageOutputStream;</p>
<p>import com.itextpdf.text.Document;<br />
import com.itextpdf.text.pdf.PdfWriter;<br />
import com.sun.imageio.plugins.jpeg.JPEGImageWriter;</p>
<p>public class JPEGProducer {</p>
<p>    private void click(int x, int y, int times) throws Exception {<br />
        Robot r = new Robot();<br />
        r.mouseMove(x, y);<br />
        for (int i = 0; i < times; i++) {</p>
<p>            r.mousePress(InputEvent.BUTTON1_MASK);<br />
            r.mouseRelease(InputEvent.BUTTON1_MASK);<br />
            Thread.sleep(100);<br />
        }</p>
<p>    }</p>
<p>    private BufferedImage getImage(int sX, int sY, int eX, int eY) throws Exception {<br />
        Robot r = new Robot();<br />
        BufferedImage img = r.createScreenCapture(new Rectangle(sX, sY, (eX - sX), (eY - sY)));<br />
        return img;<br />
    }</p>
<p>    private void pressSpace() throws Exception {<br />
        Robot r = new Robot();<br />
        r.keyPress(KeyEvent.VK_SPACE);<br />
    }</p>
<p>    private void save(BufferedImage img, String fileName) throws Exception {<br />
        JPEGImageWriter writer = (JPEGImageWriter) ImageIO.getImageWritersByFormatName("jpeg").next();<br />
        ImageWriteParam iwp = writer.getDefaultWriteParam();<br />
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);<br />
        iwp.setCompressionQuality(1);</p>
<p>        FileImageOutputStream output = new FileImageOutputStream(new File(fileName));<br />
        writer.setOutput(output);<br />
        IIOImage iimage = new IIOImage(img, null, null);</p>
<p>        writer.write(null, iimage, iwp);<br />
        writer.reset();<br />
    }</p>
<p>    public static void main(String[] args) throws Exception {</p>
<p>        Thread.sleep(8000);//Enough to activate the reader in screen.</p>
<p>        Document document = new Document(new com.itextpdf.text.Rectangle(862, 1012));<br />
        document.setMargins(0, 0, 0, 0);<br />
        PdfWriter.getInstance(document, new FileOutputStream("book.pdf"));<br />
        document.open();</p>
<p>        JPEGProducer p = new JPEGProducer();</p>
<p>        for (int i = 0; i < (45 + 581 + 8 + 6 + 15 + 67 + 2 + 11 + 16); i++) {<br />
            Image image = p.getImage(527, 55, 1389, 1067);</p>
<p>            document.add(com.itextpdf.text.Image.getInstance(image, null));<br />
            p.click(500, 500, 2);<br />
            p.pressSpace();<br />
            p.click(100, 100, 2);</p>
<p>        }<br />
        document.close();</p>
<p>    }</p>
<p>}<br />
[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://aniljava.com/2010/05/convert-any-e-book-to-pdf-for-ipad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
