Pdf/writer unicode support?

Hi,

Does the pdf/writer support unicode? When i render a pdf with swedish or
german names, it displays some garbled text. Is this a font issue?

Thanks,
/franee

On 12/8/06, Francis S. [email protected] wrote:

Does the pdf/writer support unicode? When i render a pdf with swedish or
german names, it displays some garbled text. Is this a font issue?

PDF::Writer’s documentation is very clear about this: PDF does not
support UTF-8, and that’s probably what you’re trying to use. Use
substitution character maps instead (the example code in The Ruby
Way
2nd Edition talks about how to use this). UTF-16 support will be
added to PDF::Writer at some point in the future.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

Austin Z. wrote:

On 12/8/06, Francis S. [email protected] wrote:

Does the pdf/writer support unicode? When i render a pdf with swedish or
german names, it displays some garbled text. Is this a font issue?

PDF::Writer’s documentation is very clear about this: PDF does not
support UTF-8, and that’s probably what you’re trying to use. Use
substitution character maps instead (the example code in The Ruby
Way
2nd Edition talks about how to use this). UTF-16 support will be
added to PDF::Writer at some point in the future.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

Ok i’ll check on that. Thanks for the fast reply:)

Francis S. wrote:

Austin Z. wrote:

On 12/8/06, Francis S. [email protected] wrote:

Does the pdf/writer support unicode? When i render a pdf with swedish or
german names, it displays some garbled text. Is this a font issue?

PDF::Writer’s documentation is very clear about this: PDF does not
support UTF-8, and that’s probably what you’re trying to use. Use
substitution character maps instead (the example code in The Ruby
Way
2nd Edition talks about how to use this). UTF-16 support will be
added to PDF::Writer at some point in the future.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

Ok i’ll check on that. Thanks for the fast reply:)

when i add any of these strings direct to pdf, it displays perfectly
well. “Straße”, “öffnen”, “Østergade 4. 1,tv”

but when i pull up the same strings in the db, it gets garbled. any idea
why?

Hi Austin,

Austin Z. wrote:

I’ll be getting back to PDF::Writer development
in the new year and one of the things I want to …

I’ve been using PDF::Writer, very happily, to produce PDFs. Now I’ve
been
given a requirement to include the XML file that the PDF documents are
based
on into the PDF file itself. Any chance you’re interested in
PDF::Writer
having that capability? I’d be interested in helping with / doing the
work.

Thanks for all the work you’ve already done. It’s a great tool!

Best regards,
Bill

On 12/8/06, Francis S. [email protected] wrote:

added to PDF::Writer at some point in the future.

but when i pull up the same strings in the db, it gets garbled. any idea
why?

That I can’t answer. If you’re using MySQL, it’s partially because
MySQL is dumber than dirt 99% of the time. You need to make sure
you’re encoding things properly and you may need to use iconv to
switch encodings around, or build your substitution character maps to
reflect what’s actually stored in your database (which is easier than
it sounds).

I’ll be getting back to PDF::Writer development in the new year and
one of the things I want to allow for is multiple instances of the
same font with different character maps. That will go a long way
toward delaying the need for UTF-16 support (because that’s very
hard to do).

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

when i add any of these strings direct to pdf, it displays perfectly
well. “Straße”, “öffnen”, “Østergade 4. 1,tv”

but when i pull up the same strings in the db, it gets garbled. any idea
why?

Make sure everything is in UTF-8. Here are some places to check:

—database.yml—
development:
adapter: mysql
database: 123
username: 123
password: 123
host: localhost
encoding: utf8

—class ApplicationController—
def set_charset
@headers[“Content-Type”] ||= “text/html; charset=UTF-8”
end

—your database tables—
make sure they are set to UTF-8

Austin Z. wrote:

On 12/10/06, Taylor S. [email protected] wrote:

when i add any of these strings direct to pdf, it displays perfectly
well. “Stra�e”, “�ffnen”, “�stergade 4. 1,tv”

but when i pull up the same strings in the db, it gets garbled. any idea
why?
Make sure everything is in UTF-8. Here are some places to check:

Except that this is probably exactly why the OP is having problems
with PDF::Writer and the strings being garbled. PDF::Writer does not
AND WILL NEVER support UTF-8 (it will support UTF-16). You will need
to use iconv to convert from UTF-8 to a suitable single-byte encoding
in order to print in PDF::Writer.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

yeah my db is set to utf-8. That is probably the reason why it gets
garbled on pdf/writer. I’ll check out iconv and will let you know of the
results.

Thanks for all the inputs guys:)

Finally fixed the problem.

I used this:
require ‘iconv’

ic_ignore = Iconv.new(‘ISO-8859-15//IGNORE//TRANSLIT’, ‘UTF-8’)

ic_ignore.iconv(‘string from db with utf-8 encoding’)

Thanks for all the help guys:)

On 12/10/06, Taylor S. [email protected] wrote:

when i add any of these strings direct to pdf, it displays perfectly
well. “Straße”, “öffnen”, “Østergade 4. 1,tv”

but when i pull up the same strings in the db, it gets garbled. any idea
why?
Make sure everything is in UTF-8. Here are some places to check:

Except that this is probably exactly why the OP is having problems
with PDF::Writer and the strings being garbled. PDF::Writer does not
AND WILL NEVER support UTF-8 (it will support UTF-16). You will need
to use iconv to convert from UTF-8 to a suitable single-byte encoding
in order to print in PDF::Writer.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

On 12/11/06, mati [email protected] wrote:

Austin Z. wrote:

with PDF::Writer and the strings being garbled. PDF::Writer does not
AND WILL NEVER support UTF-8 (it will support UTF-16). You will need
Pardon me if this is common knowledge, but is there any particular
reason to dismiss UTF-8? Because from what I can tell, pretty much
everything (at least in Europe) seems to be moving towards UTF-8, a
trend which imho is already long overdue. And how is UTF-16 any better
than UTF-8?

It’s actually supported by the underlying specification. UTF-8 isn’t.
I’m not going to convert your data for you. I might do so in Ruby
1.9.1 when I can depend on the encoding attached to the strings, but
not before.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

Austin Z. wrote:

with PDF::Writer and the strings being garbled. PDF::Writer does not
AND WILL NEVER support UTF-8 (it will support UTF-16). You will need

Pardon me if this is common knowledge, but is there any particular
reason to dismiss UTF-8? Because from what I can tell, pretty much
everything (at least in Europe) seems to be moving towards UTF-8, a
trend which imho is already long overdue. And how is UTF-16 any better
than UTF-8?