- 论坛徽章:
- 0
|
用PDF::Create模块对PDF文件写入中文时是乱码,有谁知道写入PDF时是用什么编码才能显示中文(我基本上每种编码都试了,还是乱码)。代码如下:#!/usr/bin/perl
use PDF::Create;
my $pdf = new PDF::Create('filename' => 'd:/sample.pdf');
my $root = $pdf->new_page('MediaBox' => $pdf->get_page_size('a4'));
my $f1 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'gb2312',
'BaseFont' => 'Helvetica');
my $f2 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'uft8',
'BaseFont' => 'Times-Roman');
my $toc = $pdf->new_outline('Title' => 'Sample Document');
my $page = $root->new_page;
$toc->new_outline('Title' => 'Page 1', 'Destination' => $page);
$a='写入的pdf的中文是乱码';
$page->stringc($f2, 20, 300, 300, "$a");
$pdf->close; |
谢! |
|