File: header.pl

package info (click to toggle)
libpdf-table-perl 1%3A0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 216 kB
  • sloc: perl: 999; makefile: 2
file content (55 lines) | stat: -rwxr-xr-x 1,101 bytes parent folder | download
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
50
51
52
53
54
55
#!/usr/bin/env perl
use warnings;
use strict;
use diagnostics;

#Please use TABSTOP=4 for best view
use PDF::API2;
use PDF::Table;

my $pdftable = new PDF::Table;
my $pdf      = new PDF::API2( -file => "headers.pdf" );
my $page     = $pdf->page();
$pdf->mediabox('A4');

# A4 as defined by PDF::API2 is h=842 w=545 for portrait

# some data to layout
my $some_data = [
	[ 'HeaderA', 'HeaderB' ],
	[ 'foo',     'bar' ],
	[ 'one',     'two' ],
	[ 'thr',     'four score and seven years ago our fathers brought forth' ],
	[ 'fiv',     'six' ],
	[ 'sev',     'abcdefghijklmnopqrstuvwxyz' ],
];

# build the table layout
$pdftable->table(

	# required params
	$pdf,
	$page,
	$some_data,
	x       => 10,
	w       => 220,
	start_y => 700,
	next_y  => 700,
	start_h => 62,
	next_h  => 62,

	# some optional params
	border          => 0,
	font_size       => 20,
	font_underline  => [3 ,2],
	max_word_length => 13,
	header_props    => {
		background_color => 'yellow',
		repeat           => 1
	},
	cell_props => [
		[], [ { background_color => 'red' }, { background_color => 'blue' } ],
	],
);

$pdf->saveas();