Subject: | Patch for iso-8859-1 content |
The current CVS version of the Handler seems to support ASCII content only, current PDFLib supports latin1 content though. With the attached patch, UTF-8 content is mapped to ISO-8859-1 which PDFLib unterstands and uses.
Index: AxPoint.pm
===================================================================
RCS file: /home/cvs/XML-Handler-AxPoint/lib/XML/Handler/AxPoint.pm,v
retrieving revision 1.34
diff -u -r1.34 AxPoint.pm
--- AxPoint.pm 2002/07/02 18:51:15 1.34
+++ AxPoint.pm 2003/03/27 14:06:54
@@ -1,9 +1,10 @@
-# $Id: AxPoint.pm,v 1.34 2002/07/02 18:51:15 matt Exp $
+# $Id: $
package XML::Handler::AxPoint;
use strict;
use XML::SAX::Writer;
+use Text::Iconv;
use File::Spec;
use File::Basename;
use PDFLib 0.11;
@@ -56,7 +57,7 @@
XML::SAX::Writer::Exception->throw({ Message => 'Unknown option for Output' });
}
- $self->{Encoder} = XML::SAX::Writer::NullConverter->new;
+ $self->{Encoder} = Text::Iconv->new('utf-8', 'ISO-8859-1');
# create PDF and set defaults
$self->{pdf} = PDFLib->new();
@@ -231,8 +232,8 @@
if (exists($el->{Attributes}{"{}y"})) {
$self->{logo}{y} = $el->{Attributes}{"{}y"}{Value};
}
- $self->{logo}{x} ||= 0;
- $self->{logo}{y} ||= 0;
+ $self->{logo}{x} ||= 0;
+ $self->{logo}{y} ||= 0;
$self->{logo}{scale} ||= 1.0;
$self->gathered_text; # reset
}
@@ -342,10 +343,9 @@
}
elsif ($parent->{LocalName} eq 'slideset') {
my $title = $self->gathered_text;
-
$self->push_bookmark(
$self->{pdf}->add_bookmark(
- text => $title,
+ text => $title,
level => 2,
parent_of => $self->top_bookmark,
open => 1,
@@ -473,7 +473,7 @@
push @{$self->{cache}}, ["slide_characters", $chars];
}
- $self->{gathered_text} .= $chars->{Data};
+ $self->{gathered_text} .= $self->{Encoder}->convert($chars->{Data});
}
sub invalid_parent {
@@ -1568,7 +1568,7 @@
my $text = $self->gathered_text;
$self->push_bookmark(
$self->{pdf}->add_bookmark(
- text => $text,
+ text => $self->{Encoder}->convert($text),
level => 3,
parent_of => $self->top_bookmark,
)
@@ -1644,7 +1644,7 @@
$self->{gathered_text} .= $chars->{Data};
my $name = $self->{SlideCurrent}->{LocalName};
- my $text = $chars->{Data};
+ my $text = $self->{Encoder}->convert($chars->{Data});
return unless $text && $self->{bb};
my $leftover = $self->{bb}->print($text);
if ($leftover) {