in reply to Re^2: Write special chars to PDF. UTF8?
in thread Write special chars to PDF. UTF8?
Try using decode() for the pdf
poj#!/perl use strict; use warnings; use CGI; use CGI::Carp 'fatalsToBrowser'; use PDF::API2; use Encode; my $cgi = new CGI; my $f1 = $cgi->param('f1'); my $f2 = decode('UTF-8', $f1 ); open OUT,'>','c:/temp/web/pdf.txt' or die; # change path to suit print OUT "$f1 $f2"; close OUT; my $pdf = PDF::API2->new()->mediabox('A4'); my $text = $pdf->page->text; my $font1 = $pdf->corefont('Arial'); $text->font($font1, 36); $text->translate(100,500); $text->text("f1 = $f1"); $text->translate(100,600); $text->text("f2 = $f2"); $pdf->saveas('c:/temp/web/utf8_test1.pdf'); # change path to suit print <<EOF; Content-Type: text/html; charset=UTF-8\n <!DOCTYPE html> <html lang='en-NZ'> <head> <title>Test UTF-8</title> <meta charset="UTF-8"> </head><body> $f1 $f2 <form method="post"> Input: <input type="text" name="f1" value="$f1"><br> <input type="submit" name="submit" value="Submit"> </form></body></html> EOF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Write special chars to PDF. UTF8?
by tel2 (Pilgrim) on Feb 14, 2016 at 23:18 UTC |