UTF-8 String to PDF using PDF::Writer

Hi

I just can’t seem to figure this out.

I know that PDF doesn’t support UTF-8 so I’m trying to use Iconv to
convert the string from UTF-8 to MacRoman (or anything that will
work). This doesn’t seem to be working though. Is there a better/
correct way to do this? The string is stored as UTF-8 in MySQL and
displays properly on the web (<?xml version="1.0" encoding="utf-8"?>).

The main problem seems to be smart quotes do not come across I get
strange symbols, everything else seems to work.

My latest attempt.

def create_pdf
# creates a PDF version of an authors listing. Pass a listing
object as the methods parameter. AJ
#
pdfOfListing = PDF::Writer.new # defaults to a US Letter,
portrait, PDF version 1.3 document. AJ
pdfOfListing.compressed
pdfOfListing.select_font(‘Times-Roman’, {:encoding =>
‘MacRomanEncoding’})
pdfOfListing.text(Iconv.conv(“UTF-8”, “MacRoman”,
chapter.chapter_body), :font_size => 12, :justification => :left))
send_data(pdfOfListing.render, :filename =>
listing.title_of_work , :type => “application/pdf” )
end

Thanks
Andrew J.

On 9/25/06, Andrew J. [email protected] wrote:

The main problem seems to be smart quotes do not come across I get
strange symbols, everything else seems to work.

Use substitution maps. Look in the source for the manual (it’s
documented in the manual, but it’s not as clear as I’d like) and see
where I do substitutions for the copyright character. It’s in the
first 10k or so of source, and it’s pretty clear.

You can do any substitution you’d like at all.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * You are in a maze of twisty little passages, all alike. // halo • statue
* [email protected]