[Koha-bugs] [Bug 2246] Label printing doesn't work with Unicode characters

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Sep 28 08:43:55 CEST 2011


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2246

wajasu <matted-34813 at mypacks.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matted-34813 at mypacks.net

--- Comment #12 from wajasu <matted-34813 at mypacks.net> 2011-09-28 06:43:55 UTC ---
Improvement
With hopes of getting diacritics ( u dieresis and such) printing for my barcode
labels, I dug into
/home/koha344/koha/intranet/cgi-bin/labels/label-create-pdf.pl

I found that if I set the utf8 flag off for the $line string, it would end up
sending FC instead of C3BC in the PDF.  So for the "standard PDF encodings that
we currently allow (Helvitica, Courier, etc) the single byte maps to those
common foreign characters just fine.  It worked for me!  

Here is the "utf8::downgrade($line);" that I used from this section of code. I
am running perl 5.12.1 (that I built), with the latest cpan modules pulled as
of Sept 2011, and koha 3.4.4. (your wide character fix in PDF.pm helped). It
seems to get through my latest version of PDF::Reuse, that I have installed.

sub _print_text {
    my $label_text = shift;
    foreach my $text_line (@$label_text) {
        my $pdf_font = $pdf->Font($text_line->{'font'});
        my $line = "BT /$pdf_font $text_line->{'font_size'} Tf
$text_line->{'text_llx'} $text_line->{'text_lly'} Td ($text_line->{'line'}) Tj
 ET";

        utf8::downgrade($line);  # This forces the utf8 flag off so the single
byte will pass thru for regular PDFEncoding etc.
                                 # (So now my basic diacritics in the standard
character sets will not get double encoded. Yeah!
                                 # Note: This is not meant to deal with the
case where we want to use unicode with TTF - truetype fonts.

        $pdf->Add($line);
    }
}

This bug is log overdue, and it might be possible for someone to test and patch
it, since I might not be able to get it done before Oct 8th 2011 for the 3.6
release.

Note: I didn't want to loose this info.  I also tried this fix in my production
3.0.2 environment.  I had to add the PDF.pm patch for wide chars, to get a PDF
to be generated.  Once I added the downgrade line in 3.0.2, my
create-label-pdf.pl hung, with some recursion error and cpu at 100%.  So I gave
up on 3.0.2.  The PDF:Reuse in that version might be the factor, or something
else.
I'm going to grab koha 3.4.5 and try the fix on that. We can't wait till next
year for this, can we?

I also coded it with a TTF truetype font, but was missing the description
lines, so I didn't have time to figure out the drawing logic.  We would need to
add a way to select a font path, or upload one, and store it in the database.
Also, this fix might be usable for other create-*-pdf.pl scripts (like patron
cards).

This is a partial fix if we need to support other languages.

-- 
Configure bugmail: http://bugs.koha-community.org/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.


More information about the Koha-bugs mailing list