Geht doch einfach so:
1
2
3
4
5
6
7
8
9
10
11
12
use PDF::API2;
use utf8;
my $pdf = PDF::API2->new();
my $page = $pdf->page();
$page->mediabox('A4');
my $font = $pdf->corefont('Helvetica');
my $text = $page->text();
$text->font($font, 20);
$text->translate(200, 700);
$text->text('1 €');
$pdf->saveas('new.pdf');
Du musst das € als UTF8 ausgeben und die richtigen Schrift einbinden.
Das € muss auch in der Schrift drin sein! Type 1-Schriften haben sowas nicht, aber TrueType oder OpenType.
So gehts mit einer Type 1-Schrift:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use 5.010;
use PDF::API2;
use utf8;
my $pdf = PDF::API2->new();
my $page = $pdf->page();
$page->mediabox('A4');
my $font1
= $pdf->psfont(
'/Bibliothek/Fonts/Type 1/Adobe/hvbo____.pfb',
-pfmfile => '/Bibliothek/Fonts/Type 1/Adobe/hvbo____.pfm'
);
my $font2 = $pdf->psfont(
'/Bibliothek/Fonts/XeroxPhaser/eurofont/_2bi____.pfb',
-pfmfile => '/Bibliothek/Fonts/XeroxPhaser/eurofont/_2bi____.pfm'
);
my $text = $page->text();
$text->font($font1, 20);
$text->translate(200, 700);
$text->text('1');
$text->font($font2, 20);
$text->text('€');
$pdf->saveas('new-t1.pdf');
Auch hier ist das Euro drin.
Editiert von GwenDragon: PDF entfernt
Anhänge
Last edited: 2015-06-23 19:04:19 +0200 (CEST)