PDF and UTF-8 database

Author Message

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; 

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:16:07
Script start
Timing: Jan 31 2025 01:16:07
Module start 'layout'
Timing: Jan 31 2025 01:16:07
Module start 'content'
Timing: Jan 31 2025 01:16:08
Module end 'content'
Timing: Jan 31 2025 01:16:08
Script end

Main resources:

Total runtime0.7216 sec
Peak memory usage8,192.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.1250151.2109
Module start 'layout' 0.00530.0048 739.3359220.6719
Module start 'content' 0.01000.7107 960.00784,405.6797
Module end 'content' 0.72070.0008 5,365.68757.8750
Script end 0.7216  5,373.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.5138160.0002
Check MTime0.00130.1794160.0001
Mysql Total
Database connection0.00110.151510.0011
Mysqli_queries0.639388.5954540.0118
Looping result0.00050.0742520.0000
Template Total0.658891.320.3294
Template load0.00240.326920.0012
Template processing0.656490.967420.3282
Template load and register function0.00150.206810.0015
states
state_id_array0.00400.547810.0040
state_identifier_array0.00090.123520.0004
Override
Cache load0.00200.2812200.0001
Sytem overhead
Fetch class attribute can translate value0.00170.235420.0008
Fetch class attribute name0.00190.256830.0006
XML
Image XML parsing0.00210.291020.0010
class_abstraction
Instantiating content class attribute0.00000.001130.0000
General
dbfile0.00280.3914150.0002
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs