-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special chars in header and footer #106
Comments
Same problem here. The content prints correct accents but texts into the header and footer removes those characters. I print the content of $command variable in "protected function executeCommand($command)" (Knp\Snappy\AbstractGenerator) and looks right:
If I execute this code from console works but from the browser remove characters with accents. I am using php-fpm and apache. Maybe is a requirement we are missing into some configuration into this bundle or KnpLabs/snappy. |
hm OK, I thing I got the issue.
|
Same result using setlocale(LC_CTYPE, "en_US.UTF-8") and setlocale(LC_ALL, "en_US.UTF-8"). I try it within web/app_dev.php and within executeCommand() method, before execute the command. I got this result executing "locale" on my terminal: [root@798e56631c3b /]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL= |
@micayael could you try |
Thanks for your reply @akovalyov I do this on RHEL7
And now I have this:
But still not working. Anyway, the weird thing is that the output command is right:
When I execute from terminal the PDF is correct but from browser removes the accent characters
|
Is there any solution for this? |
seems such issue come from there https://github.com/KnpLabs/snappy/blob/e3364520431fcce40f3b5051630fd97c0e08b15b/src/Knp/Snappy/AbstractGenerator.php#L428
try to add |
Hi guys, I don't know if this solution can fix with your issues but I prefered the the header-html and footer-html options to the header and footer ones. If it could help... |
@mathieumuller how do you use page numbers configuration within the html? (footer-right: 'Página [page] de [toPage]'). Because is there where I use accents. |
@micayael below is an example of how I use the page numbers in the footer-html according to the wkhtmltopdf doc. As you can see, you have to use a little js script to fill html elements representing your [page] and [toPage] values.
|
@mathieumuller thanks. It works @pilot I have this values ¨¨¨ and I try to use also setlocale(LC_CTYPE, "en_US.UTF-8"); within the controller for example but its the same. The LC_ALL variable when I execute "locale" on the terminal sould be nothing? "LC_ALL=" |
@micayael what server do you use? What default charset is set for the webserver? |
@akovalyov , thanks for reply. I use a docker with RHEL7.1, php-fpm and apache. # locale -a
C
en_US.utf8
POSIX # locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL= The default chartset that you said sould be from apache or php-fpm? |
@micayael could you add |
@akovalyov I add it but is the same, no accents. Could be php-fpm configuration? |
@micayael could you share your docker/docker-compose config so that I can take a look? I am really interested to find and resolve the issue since we don't really have an answer for this particular trouble and I'd be happy to finally resolve it. If you don't want to share config here - you can drop me a line on the email you can find in my profile ;) |
@akovalyov thanks. I just sent you the dockerfile via email. Let me know if you need something else. I am really interested too. |
OK, finally I have a possible solution for this issue. |
Hi, we're experiencing same issue with 'UTF-8' chars using PDF export function. We have tried all solutions you commented but we're still having this issue. I'm almost sure its related to server locale configuration. I read this about 'escapeshellarg' command "If escapeshellarg() function removes your accents (like á, a with an 'accute') from the given string, ensure your LC_ALL variable is correct. If using it via web, you need to restart Apache or the corresponding web server after setting LC_ALL with a export LC_ALL=es_ES.utf8 (for example) from your shell." We're using ubuntu 12.04 with es_ES.UTF-8 encoding |
@gonzaloplaza what does |
I know this is a recurring issue but without more details about installed locales, value of |
I also facing this issue on ubuntu |
I found the solution for footer and header, when you create your pdf object add the local like this : $pdf = new Pdf(
array(
'orientation' => ($paysage > 0) ? 'landscape' : 'portrait', // -O, --orientation <orientation>
'footer-html' => 'https://'.$footer_page, // --footer-right "Page [page] of [toPage]"
'footer-font-size' => '8', // --footer-font-size 8
'commandOptions' => array(
'procEnv' => array(
// Check the output of 'locale' on your system to find supported languages
'LANG' => 'en_US.utf-8', // this line do the local change for display accents and spécials characters
),
),
)
); |
Hi,
I am trying to generate a pdf with an header containing french special chars (é, è, à...)using the 'header-left' or 'header-right' options. To make sure that my document is right encoded I've added the 'encoding' option set to 'UTF-8' but my special chars are not displayed at all in my header. Does anyone have an idea?
Thanks in advance...
The text was updated successfully, but these errors were encountered: