Leser: 1
|< 1 2 >| | 12 Einträge, 2 Seiten |
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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
use strict;
use PDF::Report;
use XML::DOM;
my $pdf = new PDF::Report(
PageSize => 'a4',
PageOrientation => 'portrait'
);
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("test.xml");
$pdf->newpage(1);
my $nodes = $doc->getElementsByTagName ("preis");
my $n = $nodes->getLength;
for (my $i = 0; $i < $n; $i++)
{
my $node = $nodes->item($i);
my $text = $node->getAttributeNode ("text")->getValue;
$pdf->setSize(30);
$pdf->setFont('Helvetica-bold');
$pdf->setAddTextPos(107,85);
$pdf->setAlign("center");
$pdf->addText($text.chr(0x80),
undef,
undef);
}
open(PDF, "> $0.pdf") or die "Error opening $0.pdf: $!\n";
print PDF $pdf->Finish();
close(PDF);
exit(0);
1
2
3
4
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<aktion>
<preis x="100" y="58.82" type="Helvetica-bold" size="8.82" align="right" text="Unsere Werbung ist gut"/>
</aktion>
1
2
3
4
5
6
7
8
9
10
use Tie::File;
my $file = 'path/to/xml.file';
my @lines = ();
tie(@lines,'Tie::File',$file,autochomp => 0) or die $file.": ".$!;
foreach(@lines){
$_ =~ s/\r?\n/\n/g;
}
untie @lines;
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
|< 1 2 >| | 12 Einträge, 2 Seiten |