<?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"
	>
<channel>
	<title>Comments on: Working with UTF-8 in PDF::Writer and Ruby on Rails</title>
	<atom:link href="http://www.peterkrantz.com/2007/utf8-in-pdf-writer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/</link>
	<description>A blog about technology, visualization, music and unmanned vehicle experiments</description>
	<pubDate>Sat, 06 Sep 2008 01:41:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Rails PDF Plugin unter Rails2.1 &#124; Code Schubser</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2308</link>
		<dc:creator>Rails PDF Plugin unter Rails2.1 &#124; Code Schubser</dc:creator>
		<pubDate>Tue, 19 Aug 2008 16:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2308</guid>
		<description>[...] übrigens im PDF Dokument mit UTF-8 arbeiten will, sollte mal bei Peter Krantz [...]</description>
		<content:encoded><![CDATA[<p>[...] übrigens im PDF Dokument mit UTF-8 arbeiten will, sollte mal bei Peter Krantz [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gpm</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2306</link>
		<dc:creator>gpm</dc:creator>
		<pubDate>Thu, 14 Aug 2008 00:41:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2306</guid>
		<description>The PDF::Writer newsgroup brings this up briefly (http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/ff2b849a9fc39a2b).  It sounds like you need to convert to UTF-16 and specify a UxFEFF BOM before text string (or, as i understand it, the string must start with the bytes 254 then 255).

I tried adding this to the solution here (http://pastie.org/252651) but it looks like the pdf is still rendering latin characters with the 254 and 255 bytes being rendered and prepended to everything.

Please post if you get this working!  Another alternative is to move over to prawn, which appears to support UTF-8 out of the box.</description>
		<content:encoded><![CDATA[<p>The PDF::Writer newsgroup brings this up briefly (http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/ff2b849a9fc39a2b).  It sounds like you need to convert to UTF-16 and specify a UxFEFF BOM before text string (or, as i understand it, the string must start with the bytes 254 then 255).</p>
<p>I tried adding this to the solution here (http://pastie.org/252651) but it looks like the pdf is still rendering latin characters with the 254 and 255 bytes being rendered and prepended to everything.</p>
<p>Please post if you get this working!  Another alternative is to move over to prawn, which appears to support UTF-8 out of the box.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2300</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Thu, 31 Jul 2008 20:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2300</guid>
		<description>Are there any ideas or techniques floating around here about how to do this if one is &lt;i&gt;&lt;b&gt;not&lt;/b&gt;&lt;/i&gt; only using Latin characters with diacritics?  I have japanese utf-8 that has to go into PDF::Writer.  Maybe I need to learn how to manipulate strings at a lower level or understand unicode more thoroughly, but here's what I've got so far -   

Currently in PDF::Writer:
Iconv.conv('utf-16BE', 'utf-8', 'ローラー') ==&#62;  0í0ü0é0ü

While irb:
Iconv.conv('utf-16BE', 'utf-8', 'ローラー') ==&#62; "0\3550\3740\3510\374"</description>
		<content:encoded><![CDATA[<p>Are there any ideas or techniques floating around here about how to do this if one is <i><b>not</b></i> only using Latin characters with diacritics?  I have japanese utf-8 that has to go into PDF::Writer.  Maybe I need to learn how to manipulate strings at a lower level or understand unicode more thoroughly, but here&#8217;s what I&#8217;ve got so far -   </p>
<p>Currently in PDF::Writer:<br />
Iconv.conv(&#8217;utf-16BE&#8217;, &#8216;utf-8&#8242;, &#8216;ローラー&#8217;) ==&gt;  0í0ü0é0ü</p>
<p>While irb:<br />
Iconv.conv(&#8217;utf-16BE&#8217;, &#8216;utf-8&#8242;, &#8216;ローラー&#8217;) ==&gt; &#8220;0\3550\3740\3510\374&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2280</link>
		<dc:creator>Boris</dc:creator>
		<pubDate>Tue, 24 Jun 2008 13:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2280</guid>
		<description>I also ran into the recursion error "stack level too deep" and resolved it like this:

alias_method :old_add_text, :add_text unless method_defined?(:old_add_text)

This prevents the method to be overridden more often than once.

Cheers,
boris</description>
		<content:encoded><![CDATA[<p>I also ran into the recursion error &#8220;stack level too deep&#8221; and resolved it like this:</p>
<p>alias_method :old_add_text, :add_text unless method_defined?(:old_add_text)</p>
<p>This prevents the method to be overridden more often than once.</p>
<p>Cheers,<br />
boris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BuGo</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2263</link>
		<dc:creator>BuGo</dc:creator>
		<pubDate>Thu, 15 May 2008 15:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2263</guid>
		<description>Am i the only one who gets :

stack level too deep

?</description>
		<content:encoded><![CDATA[<p>Am i the only one who gets :</p>
<p>stack level too deep</p>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik L. Underbjerg</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2247</link>
		<dc:creator>Erik L. Underbjerg</dc:creator>
		<pubDate>Wed, 23 Apr 2008 14:35:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2247</guid>
		<description>Brilliant! This was just what I needed :-)</description>
		<content:encoded><![CDATA[<p>Brilliant! This was just what I needed <img src='http://www.peterkrantz.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kikito and fjuan</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2236</link>
		<dc:creator>kikito and fjuan</dc:creator>
		<pubDate>Fri, 28 Mar 2008 15:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2236</guid>
		<description>We love you</description>
		<content:encoded><![CDATA[<p>We love you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kai</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2166</link>
		<dc:creator>Kai</dc:creator>
		<pubDate>Fri, 21 Dec 2007 13:48:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2166</guid>
		<description>&lt;code&gt;
def add_text(x, y, text, *args)
  old_add_text(x,y,ICONV_CONVERTER.iconv(text), *args)
end
&lt;/code&gt;

does not work with Time objects. The trick is to call iconv with text.to_s instead of just text. Then you are able to print dates (for example to put Time.now in the page footer).</description>
		<content:encoded><![CDATA[<p><pre><code>
def add_text(x, y, text, *args)
  old_add_text(x,y,ICONV_CONVERTER.iconv(text), *args)
end
</code></pre></p>
<p>does not work with Time objects. The trick is to call iconv with text.to_s instead of just text. Then you are able to print dates (for example to put Time.now in the page footer).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2137</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Thu, 06 Dec 2007 18:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2137</guid>
		<description>I want to add that its better to use the method "add_text" instead of "text" because SimpleTable uses "add_text" and "text" uses "add_text" internally.</description>
		<content:encoded><![CDATA[<p>I want to add that its better to use the method &#8220;add_text&#8221; instead of &#8220;text&#8221; because SimpleTable uses &#8220;add_text&#8221; and &#8220;text&#8221; uses &#8220;add_text&#8221; internally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2136</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Thu, 06 Dec 2007 16:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comment-2136</guid>
		<description>I have a small question: Why is the converter a constant?</description>
		<content:encoded><![CDATA[<p>I have a small question: Why is the converter a constant?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
