Thread PDF::API2 und Euro-Zeichen (7 answers)
Opened by chebureck at 2015-06-23 16:31

GwenDragon
 2015-06-23 17:01
#181415 #181415
User since
2005-01-17
14510 Artikel
Admin1
[Homepage]
user image
Geht doch einfach so:
Code (perl): (dl )
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:
Code (perl): (dl )
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
#!/usr/bin/perl

use strict; 
use warnings;

use 5.010;

use PDF::API2;
use utf8;

my $pdf = PDF::API2->new();
my $page = $pdf->page();
$page->mediabox('A4');

# Helevetica Bold Oblique
my $font1 # = $pdf->corefont('Helvetica-Oblique');
         = $pdf->psfont(
            '/Bibliothek/Fonts/Type 1/Adobe/hvbo____.pfb',             
            -pfmfile => '/Bibliothek/Fonts/Type 1/Adobe/hvbo____.pfm'
         );
# Euro Sans Bold Italic
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)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread PDF::API2 und Euro-Zeichen