<?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>Thomas Lynema&#039;s Weblog &#187; tip</title> <atom:link href="http://lynema.org/tag/tip/feed" rel="self" type="application/rss+xml" /><link>http://lynema.org</link> <description>Discover Goal, Work/Play, Achieve Goal, Repeat</description> <lastBuildDate>Sat, 17 Dec 2011 18:10:23 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Printing a PDF in Java With PDFRenderer</title><link>http://lynema.org/2010/12/29/printing-a-pdf-in-java-with-pdfrenderer</link> <comments>http://lynema.org/2010/12/29/printing-a-pdf-in-java-with-pdfrenderer#comments</comments> <pubDate>Wed, 29 Dec 2010 22:46:49 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Software Development]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[PDF]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.org/?p=203</guid> <description><![CDATA[Printing is not an easy task.  It is easy to get tied into intricate details of environment specific configuration settings such as margins and paper size. Therefore, printing a PDF without a library is not recommended unless you have a lot of time or are really interested in that sort of thing.  There are two [...]]]></description> <content:encoded><![CDATA[<p>Printing is not an easy task.  It is easy to get tied into intricate details of environment specific configuration settings such as margins and paper size. Therefore, printing a PDF without a library is not recommended unless you have a lot of time or are really interested in that sort of thing.  There are two libraries that can perform this task already.   One will be exampled today, and another tomorrow.</p><p>Today&#8217;s library is PDFRenderer <a
href="https://pdf-renderer.dev.java.net/">https://pdf-renderer.dev.java.net/</a>.   This library was released by Sun a couple of years ago.   Note that this example does not map a FileChannel object as some examples do.  Using a FileChannel made the file not able to be deleted until garbage collection was run.  See the bug in the code comments for more details.</p><pre class="brush: java; title: ; notranslate">
try
{
File f = null;
RandomAccessFile fis = null;
FileChannel fc = null;
ByteBuffer bb = null;
String printer = YOUR_PRINTER_NAME;
PrintService printService = PrintHelper.getPrintService(printer);

f = YOUR_PDF_FILE;
//Read only access would work too
fis = new RandomAccessFile(f, &quot;rw&quot;);
fc = fis.getChannel();
bb = ByteBuffer.allocate((int)fc.size());
fc.read(bb);
﻿﻿﻿﻿﻿﻿﻿﻿

//Do not map the file to a ByteBuffer as the examples show.
// There is a reason why in java bug #474038
// http://bugs.sun.com/view_bug.do?bug_id=4724038
//fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
//bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());

PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
PDFPrintPage pages = new PDFPrintPage(pdfFile);
// Create Print Job
PrinterJob pjob = PrinterJob.getPrinterJob();
pjob.setPrintService(printService);

PageFormat pf = PrinterJob.getPrinterJob().defaultPage();

pf.setOrientation(PageFormat.PORTRAIT);

Paper paper = new Paper();

//This is to fix an error in PDF-Renderer
//View http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/ for details
//Printing a PDF is also possible by sending the bytes directly to the printer, but
//  the printer would have to support it.

paper.setImageableArea(0,0,paper.getWidth() * 2,paper.getHeight());

pf.setPaper(paper);

pjob.setJobName(f.getName());

Book book = new Book();
book.append(pages, pf, pdfFile.getNumPages());
pjob.setPageable(book);
pjob.print();

}
catch (FileNotFoundException e)
{
//do your error action
}
catch (IOException e)
{
//do your error action
}
catch (PrinterException e)
{
//do your error action
}
finally
{
try
{
if (fc != null)
{
fc.close();
fc = null;
}
}
catch (IOException e)
{
log.error(e);
//handle error here
}
try
{
if (fis != null)
{
fis.close();
fis = null;
}
}
catch (IOException e)
{
//handle error here
}
if (bb != null)
{
bb.clear();
}
}
</pre><p>Because this library has the bug that makes it not want to print in half size when printing a portrait-oriented PDF,  I cannot recommend using this library unless you find it is the only thing that will do the job.    Such obvious bugs that have been around for over a year point to unmaintained code or some other upstream issues.  Tune in tomorrow for another library that is maintained that will get the job done as well.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2010/12/29/printing-a-pdf-in-java-with-pdfrenderer/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Remote Control of an OS X Box</title><link>http://lynema.org/2008/08/10/remote-control-of-an-os-x-box</link> <comments>http://lynema.org/2008/08/10/remote-control-of-an-os-x-box#comments</comments> <pubDate>Sun, 10 Aug 2008 17:53:22 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[osx]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.com/2008/08/10/remote-control-of-an-os-x-box</guid> <description><![CDATA[You&#8217;re trying to connect to an OS X box and your vnc viewer just doesn&#8217;t seem to work. Then, after many a google serch, you discover that OS X&#8217;s remote access protocol is incompatible with most VNC servers.  Tuning to Apple for help yeilds a solution, for a small(large) fee. Thankfully, there is a better [...]]]></description> <content:encoded><![CDATA[<p>You&#8217;re trying to connect to an OS X box and your vnc viewer just doesn&#8217;t seem to work. Then, after many a google serch, you discover that OS X&#8217;s remote access protocol is incompatible with most VNC servers.  Tuning to Apple for help yeilds a solution, <a
href="http://www.apple.com/remotedesktop/">for a small(large) fe</a>e.</p><p>Thankfully, there is a better way.  There is a <a
href="http://sourceforge.net/projects/osxvnc/">free VNC server for OS X</a> called Vine.  Download it and install the server.  Now you should be able to connect through a typical VNC client.</p><p>Remember, if you use tightVNC to connect, use the F8 key to <a
href="http://ubuntuforums.org/archive/index.php/t-352591.html">bring up the menu that allows you to switch to fullscreen and disconnect the sessio</a>n.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/08/10/remote-control-of-an-os-x-box/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>When the Power Goes Out</title><link>http://lynema.org/2008/08/05/when-the-power-goes-out</link> <comments>http://lynema.org/2008/08/05/when-the-power-goes-out#comments</comments> <pubDate>Wed, 06 Aug 2008 01:35:45 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.com/2008/08/05/when-the-power-goes-out</guid> <description><![CDATA[The storms that went through yesterday had an interesting effect on the available wifi networks in the area.   It wasn&#8217;t so much the storms that caused this, it was more the lack of power in the area when the lightning started striking.   Here is what the wireless situation looks like with and without power: A [...]]]></description> <content:encoded><![CDATA[<p>The storms that went through yesterday had an interesting effect on the available wifi networks in the area.   It wasn&#8217;t so much the storms that caused this, it was more the lack of power in the area when the lightning started striking.   Here is what the wireless situation looks like with and without power:</p><div
id="attachment_143" class="wp-caption aligncenter" style="width: 319px"><a
href="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi4.jpg"><img
class="size-full wp-image-143" title="poweroutwifi4" src="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi4.jpg" alt="Before power goes out" width="309" height="392" /></a><p
class="wp-caption-text">Before power goes out</p></div><p>A UPS on internet equipment is something that I haven&#8217;t seen in too many places.  Apparently, not many people in my complex have heard of it either.</p><div
id="attachment_146" class="wp-caption aligncenter" style="width: 319px"><a
href="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi2.jpg"><img
class="size-full wp-image-146" title="poweroutwifi2" src="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi2.jpg" alt="Power just went out" width="309" height="392" /></a><p
class="wp-caption-text">Power just went out</p></div><p>And finally, I win.  The <a
title="Xpower" href="2006/07/09/the-xantrex-xpower-400" target="_self">Xantrax Xpower 400</a> actually kept the Internet up for over 8 hours after the power outage.</p><div
id="attachment_144" class="wp-caption aligncenter" style="width: 319px"><a
href="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi3.jpg"><img
class="size-full wp-image-144" title="poweroutwifi3" src="http://lynema.com/wp-content/uploads/2008/08/poweroutwifi3.jpg" alt="I stand alone" width="309" height="392" /></a><p
class="wp-caption-text">I stand alone</p></div><p>Of course, the server didn&#8217;t do as well, and I had to turn it down after 20 minutes.  It&#8217;s tough to have 99% uptime off of home DSL.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/08/05/when-the-power-goes-out/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Fixing this error: 	You either don&#8217;t have a PayPal account or your PayPal account is not linked to your eBay account</title><link>http://lynema.org/2008/08/01/fixing-this-error-you-either-dont-have-a-paypal-account-or-your-paypal-account-is-not-linked-to-your-ebay-account</link> <comments>http://lynema.org/2008/08/01/fixing-this-error-you-either-dont-have-a-paypal-account-or-your-paypal-account-is-not-linked-to-your-ebay-account#comments</comments> <pubDate>Fri, 01 Aug 2008 23:50:09 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.com/2008/08/01/fixing-this-error-you-either-dont-have-a-paypal-account-or-your-paypal-account-is-not-linked-to-your-ebay-account</guid> <description><![CDATA[Some content is taken from http://forums.ebay.co.uk/thread.jspa?threadID=1200182458. I tried to link my ebay account to my paypal account and it would just simply not work. After going through the prompts many times, it would still say that there was no association. There is a fix in an odd location. Go to account settings -> addresses Click [...]]]></description> <content:encoded><![CDATA[<p>Some content is taken from <a
href="http://forums.ebay.co.uk/thread.jspa?threadID=1200182458">http://forums.ebay.co.uk/thread.jspa?threadID=1200182458</a>.</p><p>I tried to link my ebay account to my paypal account and it would just simply not work.  After going through the prompts many times, it would still say that there was no association.  There is a fix in an odd location.</p><p>Go to account settings -> addresses<br
/> Click on all addresses<br
/> Then click on add paypal addresses</p><p>This gives yet another paypal login.  After login, I was greeted with a message thanking me for creating a paypal account.  Hmmm.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/08/01/fixing-this-error-you-either-dont-have-a-paypal-account-or-your-paypal-account-is-not-linked-to-your-ebay-account/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Discovering Dependant Dlls in Windows</title><link>http://lynema.org/2008/07/24/discovering-dependant-dlls-in-windows</link> <comments>http://lynema.org/2008/07/24/discovering-dependant-dlls-in-windows#comments</comments> <pubDate>Thu, 24 Jul 2008 14:08:15 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Life]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[tip]]></category> <category><![CDATA[windows]]></category><guid
isPermaLink="false">http://lynema.com/2008/07/24/discovering-dependant-dlls-in-windows</guid> <description><![CDATA[Sometime, you just don&#8217;t know which dll files to register.  Enlighten yourself with dependancy walker .]]></description> <content:encoded><![CDATA[<p>Sometime, you just don&#8217;t know which dll files to register.  Enlighten yourself with <a
title="http://www.dependencywalker.com/" href="http://www.dependencywalker.com/">dependancy walker</a> .</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/07/24/discovering-dependant-dlls-in-windows/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Liberate Your Fonts</title><link>http://lynema.org/2008/07/14/liberate-your-fonts</link> <comments>http://lynema.org/2008/07/14/liberate-your-fonts#comments</comments> <pubDate>Mon, 14 Jul 2008 21:50:30 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.com/2008/07/14/liberate-your-fonts</guid> <description><![CDATA[They&#8217;ve been out for over a year, but I just stumbled upon them this week.  Redhat release some very high quality and non-encumbered fonts.   Most distibutions will have them in a package named liberated-fonts.  They are substitues for some very popular fonts such asTimes New Roman, Thorndale, Nimbus Roman, and Bitstream Vera Serif.  Check em [...]]]></description> <content:encoded><![CDATA[<p>They&#8217;ve been out for over a year, but I just stumbled upon them this week.  Redhat release some very high quality and non-encumbered fonts.   Most distibutions will have them in a package named liberated-fonts.  They are substitues for some very popular fonts such asTimes New Roman, Thorndale, Nimbus Roman, and Bitstream Vera Serif.  Check em out at <a
href="https://www.redhat.com/promo/fonts/">https://www.redhat.com/promo/fonts/</a>.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/07/14/liberate-your-fonts/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Slick Favicon Website</title><link>http://lynema.org/2008/07/13/slick-favicon-website</link> <comments>http://lynema.org/2008/07/13/slick-favicon-website#comments</comments> <pubDate>Sun, 13 Jul 2008 20:44:03 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[tip]]></category> <category><![CDATA[web]]></category><guid
isPermaLink="false">http://lynema.com/?p=133</guid> <description><![CDATA[Check out http://www.favicon.cc/ for your various favicon needs.]]></description> <content:encoded><![CDATA[<p>Check out <a
href="http://www.favicon.cc/">http://www.favicon.cc/</a> for your various favicon needs.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/07/13/slick-favicon-website/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>What To Do When All of Gnome&#8217;s MIME Enteries Break</title><link>http://lynema.org/2008/07/13/what-to-do-when-all-of-gnomes-mime-enteries-break</link> <comments>http://lynema.org/2008/07/13/what-to-do-when-all-of-gnomes-mime-enteries-break#comments</comments> <pubDate>Sun, 13 Jul 2008 05:34:40 +0000</pubDate> <dc:creator>lyz</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[gnome]]></category> <category><![CDATA[tip]]></category><guid
isPermaLink="false">http://lynema.com/2008/07/13/what-to-do-when-all-of-gnomes-mime-enteries-break</guid> <description><![CDATA[When double clicking on apps don&#8217;t seem to open the correct program anymore on almost every file, there is most likely an issue with the MIME database.  The MIME database tells the desktop environment which program should open a file.  Try this to re-associate things. update-mime-database ~/.local/share/mime This tip was found after searching the net [...]]]></description> <content:encoded><![CDATA[<p>When double clicking on apps don&#8217;t seem to open the correct program anymore on almost every file, there is most likely an issue with the MIME database.  The MIME database tells the desktop environment which program should open a file.  Try this to re-associate things.</p><p>update-mime-database ~/.local/share/mime</p><p>This tip was found after searching the net and landing on <a
href="http://prematureoptimization.org/blog/archives/63">this page</a>.</p> ]]></content:encoded> <wfw:commentRss>http://lynema.org/2008/07/13/what-to-do-when-all-of-gnomes-mime-enteries-break/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic (User agent is rejected)
Database Caching 8/17 queries in 0.006 seconds using disk: basic

Served from: lynema.org @ 2012-02-04 09:38:17 -->
