Heiner Wurbs
|
Wednesday 23 August 2006 5:20:16 am
Hi ! I have a 3.8.3 UTF-8 database and the pdf creation looks like described in this bug: http://ez.no/community/bugs/pdf_content_pdf_problem_with_utf_8_and_or_german_umlauts
Special characters like ÄÖÜ and so on are destroyed. Whats the problem ?
Greetings heiner
|
Valentin Doroschuk
|
Wednesday 23 August 2006 5:42:13 am
The problem is
PDF uses WinAnsiEncoding (by default),
If you have UTf-8 db/site,
and if you try to create PDF with UTF-8 symbols
this symbols will be shown like latin1 and special chars will be destroyed.
There is a quick fix: We should convert text from UTF-8 to latin before executing pdf lib.
Index: settings/pdf.ini
===================================================================
--- settings/pdf.ini (revision 16510)
+++ settings/pdf.ini (working copy)
@@ -16,6 +16,7 @@
BottomMargin=100
LeftMargin=80
RightMargin=80
+OutputCharset=iso-8859-15
[Header]
Page=all
Index: lib/ezpdf/classes/ezpdf.php
===================================================================
--- lib/ezpdf/classes/ezpdf.php (revision 16510)
+++ lib/ezpdf/classes/ezpdf.php (working copy)
@@ -329,6 +329,15 @@
$text = str_replace( array( ' ', "\n", "\t" ), '', $text );
+ include_once( 'lib/ezi18n/classes/eztextcodec.php' );
+ $httpCharset = eZTextCodec::httpCharset();
+ $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
+ ? $config->variable( 'PDFGeneral', 'OutputCharset' )
+ : 'iso-8859-15';
+ $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
+ // Convert current text to $outputCharset (by default iso-8859-15)
+ $text =& $codec->convertString( $text );
+
$this->PDF->ezText( $text );
eZDebug::writeNotice( 'Execute text in PDF, length: "'. strlen( $text ) .'"', 'eZPDF::modify' );
} break;
|