Discussion:
No umlaut in PDF files
Thomas Weidner
2007-09-04 13:24:57 UTC
Permalink
Hy,

*) I expect that Zend_Pdf uses it's own encoding.

*) Zend_Pdf is not related to Zend_Locale or the I18N core.
Locales do not include informations about the encoding which shall be used.

But anyway... when using other characters than ASCII, like in your case,
everyone is anounced to use UTF-8.
When you have any issue with Zend_Pdf it's better to write directly to the
fw-formats list where Zend_Pdf is related to.

Greetings
Thomas
I18N Team Leader

----- Original Message -----
From: "dashmz" <dashmz-S0/***@public.gmane.org>
To: <fw-i18n-***@public.gmane.org>
Sent: Wednesday, August 29, 2007 4:03 PM
Subject: [fw-i18n] No umlaut in PDF files
Hi there,
ä-ö-ü-ß) are not displayed. There isn't even a "?" or any cryptic letters,
it is just not displayed.
It doesn't matter if I draw the letters myself or get them out of a
database.
<?php
require_once 'Zend/Locale.php';
$locale = new Zend_Locale('de_DE'); // German language _ Germany
?>
How can I handle to get correct umlauts in PDF?
Greetings
Rainer Hihn
Willie Alberty
2007-09-04 19:26:03 UTC
Permalink
when creating PDF files with the zend framework, umlauts (these
letters: ä-ö-ü-ß) are not displayed. There isn't even a "?" or any
cryptic letters, it is just not displayed.
It doesn't matter if I draw the letters myself or get them out of a
database.
The current text drawing subsystem for Zend_Pdf interprets strings
using the character encoding method specified by the host system's
"current locale" (not related to Zend_Locale), typically one of the
ISO-8859 sets. It then converts these strings to ISO-8859-1 (Latin-1)
for drawing.

When drawing text using characters outside of the US-ASCII range
(character codes > 127), you may get different results depending on
the character encoding used to save your PHP source, and the default
character encoding used by the system's current locale. This is the
reason Unicode is so important... it eliminates all of these headaches.

The best solution to this problem today is to explicitly specify the
character encoding method used by the string when calling
Zend_Pdf_Page::drawText(). For example:

$text = "These characters -- ü ï ë -- go here!";
$pdfPage->drawText($text, 72, 72, 'utf-8');

--

Willie Alberty, Owner
Spenlen Media
willie-***@public.gmane.org

http://www.spenlen.com/
Alexander Veremyev
2007-09-04 19:55:22 UTC
Permalink
Yes, Zend_Pdf text drawing method has on optional parameter, which specifies string encoding:
---------------------------------
$page->drawText($outputString1, $x, $y, 'UTF-8');
.....
$page->drawText($outputString2, $x, $y, 'Windows-1252');
---------------------

Only Latin1 character set is supported by "internal" PDF fonts and only Latin1 character set is supported by current implementation of TrueType fonts processing. But strings with these characters may be supplied using any appropriate encoding.


With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Tuesday, September 04, 2007 5:25 PM
Subject: [fw-formats] Re: [fw-i18n] No umlaut in PDF files
Hy,
*) I expect that Zend_Pdf uses it's own encoding.
*) Zend_Pdf is not related to Zend_Locale or the I18N core.
Locales do not include informations about the encoding which
shall be used.
But anyway... when using other characters than ASCII, like in
your case, everyone is anounced to use UTF-8.
When you have any issue with Zend_Pdf it's better to write
directly to the fw-formats list where Zend_Pdf is related to.
Greetings
Thomas
I18N Team Leader
----- Original Message -----
Sent: Wednesday, August 29, 2007 4:03 PM
Subject: [fw-i18n] No umlaut in PDF files
Hi there,
when creating PDF files with the zend framework, umlauts
ä-ö-ü-ß) are not displayed. There isn't even a "?" or any
cryptic letters,
it is just not displayed.
It doesn't matter if I draw the letters myself or get them out of a
database.
<?php
require_once 'Zend/Locale.php';
$locale = new Zend_Locale('de_DE'); // German language _ Germany
?>
How can I handle to get correct umlauts in PDF?
Greetings
Rainer Hihn
Loading...