Subject: | Bug - PDF::EasyPDF |
Date: | Tue, 5 Dec 2006 16:42:22 +1100 |
To: | bug-PDF-EasyPDF [...] rt.cpan.org |
From: | bigcroc [...] aapt.net.au |
Hey :)
Love the simplicity of EasyPDF, but you forgot something - in a PDF file,
strings for text objects are delimited by () parentheses. When the text
function is called with a string containing parentheses, the produced PDF is
flagged as corrupted by Acrobat Reader.
The solution for this is to use the escape characters \( and \) to replace
parentheses characters - here's a mod to EasyPDF.pm that does the job:
...
sub text {
my $self = shift;
my ($x,$y,$text) = @_;
$text =~ s/\(/\\\(/; #change
$text =~ s/\)/\\\)/; #change
...
- The two REGEX operations substitute all ( with \( and all ) with \).
I've tested it in a variety of situations, it's extremely straightforward anyway
- so if you could patch that into the module and re-upload to CPAN or whatever,
I'm sure you'd save some people some grief - I know I spent 2 hours trying to
find the bug in my script before I opened up the PDF in a plaintext editor and
saw the () delimited strings. XD.
Hope this message finds you and is of use.
--
Anthony Carapetis
mailto:bigcroc@aapt.net.au