shairontoledo / rghost

RGhost is a document creation and conversion API. It uses the Ghostscript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents. Support(PDF,PS,GIF,TIF,PNG,JPG,etc)
http://rghost.rubyforge.org
MIT License
186 stars 46 forks source link

Iconv::IllegalSequence when printing € char #15

Closed abruneel closed 13 years ago

abruneel commented 13 years ago

Hi,

I'm creating a pdf document with your wonderfull tool.

I'm french and I have to print some prices on my documents. So I need to print the prices in Euro with '€' character. But when doing so I have an Iconv error or 'â¬' printed instead.

I tried to change, in rghost configuration, the font encoding and charset convert but nothing changed.

Is this an issue or a configuration problem from me?

ps: I tried with several fonts too.

Thanks for your time.

shairontoledo commented 13 years ago

Hi, Have you ever tried generate the encoding test with your string?

RGhost::Config.encode_test("your string").render :pdf, :filename => "/tmp/foo.pdf"

And also try disable the iconv before create your document.

RGhost::Config::GS[:charset_convert]=nil

abruneel commented 13 years ago

Hi, I tried what you said but it either made an error (with the charset_convert) or print me 'â¬' instead of '€'.

A colleague of mine found where this come form!

The ISO-8859-1 doesn't contain the '€' character; it has been added in the ISO-8859-15.

I juste had to add this line in the configuration : RGhost::Config::GS[:charset_convert]=lambda {|text| Iconv::iconv('ISO-8859-15','"UTF-8//TRANSLIT1', text)}

Thanks for your help.

cmager commented 13 years ago

Hi,

i ran into the same issue, but can't get it work. The Euro symbol won't be displayed and all other special characters like German äöü, too. I'm always getting this error: "\xE4" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

what i have tried so far:

1) RGhost::Config::GS[:charset_convert]=nil 2) RGhost::Config::GS[:charset_convert]=lambda {|text| Iconv::iconv('ISO-8859-15','UTF-8//TRANSLIT1', text).first.to_s} and some other combinations 3) doc = Document.new(..., :font_encoding => "UTF-8") 4) adding # encoding: UTF-8 to the .rb file 5) text_var.force_encdoding("UTF-8") to all variables i want to assign to the output PDF

i'd be really glad if somebody could help me. i'm running ruby 1.9.2 and rails 3.1.1. thx, Christian.

shairontoledo commented 13 years ago

can you wrap up this code in a file and send it to me in pvt? shairon.toledo at gmail