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 45 46 47 48 49
| use strict;
use warnings;
use Config::IniFiles;
use PDF::API2;
my @repertoire; ## repertoire prod ##
my @fichier; ## test.lst test1.lst ##
my $cfg = Config::IniFiles->new( -file => $ARGV[0] );
foreach ('REP_PROD') {
push @repertoire, $cfg->val('repertoire', $_);
}
foreach ('Fic_1','FIC_2') {
push @fichier, $cfg->val('fichier', $_) if $cfg->val('fichier', $_);;
}
my $file=$fichier[0];;
(my $file_out=$file)=~s/\.lst$/.pdf/;
my %options = (
header => 1, # Include header on all pages
footer => 1, # Include footer on all pages
line_numbers => 1, # Print line numbers
page_width => 595, # A4
page_height => 842, # A4
left_margin => 48, # 0.75"
right_margin => 48, # 0.75"
top_margin => 60, #
bottom_margin => 60, #
font_face => 'Courier', # Monospaged text
font_size => 9, # Text size = 9 points
perl_syntax => 1, # Perform Perl syntax highlighting
icon_scale => 0.5, # Icon scaling (%age)
);
$options{title}=$file;
my $pdf=PDF::API2->new(%options);
open(IN, '<', $file);
foreach my $line (<IN> )
{
$pdf->print($line);
}
close(IN);
[B]open(OUT, '>', $file_out);[/B]
print OUT $pdf->{pdf}->stringify;
close(OUT); |
Partager