UTF-8 characters using --footer-left or --footer-right does not render properly #223

Closed
jgrau opened this Issue Feb 9, 2014 · 8 comments

Comments

Projects
None yet
4 participants

jgrau commented Feb 9, 2014

Hi

Inserting text with UTF-8 chars into the footer using the --footer-left or --footer-right option does not seem to produce the correct result. See attached image. Code:

# Initializer
PDFKit.configure do |config|
  config.default_options = {
   :encoding => "UTF-8"
  }
end

# Controller
options = {
    :footer_left => "Special Char Test ÆØÅ"
}
kit = PDFKit.new("Testing special chars in body: ÆØÅ", options)

Ruby: 1.8.7
OS: OSX Mavericks.
wkhtmltopdf: 0.9.9
pdfkit: 0.5.4

All help is greatly appreciated.

screenshot 2014-02-10 00 32 20

I have the same problem and I didn't yet manage to figure out the reason. On a dev server everything works fine and the header/footer renders nicely, even with UTF-8 characters (older Debian Squeeze machine, Ruby 2.1.1, Unicorn). When deployed to the production server (Ubuntu 14.04, Ruby 2.1.1, Passenger) all non-ASCII characters are broken in the header/footer, but the page content is fine. Probably the encoding breaks when the header/footer content is passed to wkhtmltopdf as parameters, but only in some setups?!

PDFKit 0.6.2
wkhtmltopdf 0.12.0 64bit (I also tried 0.12.1rc without success)

Owner

sigmavirus24 commented May 9, 2014

Can everyone give me the output of locale run on the machines producing this behaviour?

This is the output of locale on the system producing the error:

LANG=de_DE.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

I already compared the locale settings with the machine where the error doesn't occur, but the settings are identical.

Owner

sigmavirus24 commented May 13, 2014

So I know that users of upstart have problems with locale not having the right values. Can you tell me what the value of ENV['LANG'] is inside of the process running your server? Even if your console supports UTF-8, it's plausible that the process isn't configured to support it.

@sigmavirus24 You're a genius! 👍 Actually LANG was not set for the server process in the production environment.

In this case I am running Passenger+Nginx installed via the Gem, using a custom init script to start Nginx. Setting e.g. env LANG=en_US.UTF-8 (Upstart script) or export LANG=en_US.UTF-8 (System V-style init script) on top of my Nginx init script did the trick for me.

@jgrau I bet setting LANG also fixes the issue for you.

Owner

sigmavirus24 commented May 14, 2014

@jgrau this seems to not be the problem for you, right? You're running this on OSX, ostensibly not from cron or anything of the like.

Owner

sigmavirus24 commented Aug 7, 2014

@jgrau I'm closing this issue for inactivity but if you have the chance to answer my questions, I'll be happy to reopen it.

allaire commented Jan 22, 2015

That fixed it for me too with the upstart script, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment