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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 7;
use lib 't/lib'; # Needed for 'make test' from project dir
use TestData;
use PDFAPI2Mock; # provide dummy PDF::API2. obviously a real PDF::API2 or
# PDF::Builder installation will be needed in order to run
BEGIN {
use_ok('PDF::Table');
}
require_ok('PDF::Table');
my ( $pdf, $page, $tab, @data );
$pdf = PDF::API2->new();
$page = $pdf->page();
$tab = PDF::Table->new($pdf,$page);
@data = ( [ 'r1c1', 'r1c2', 'r1c3' ], ['r2c1', undef, 'r2c3'] );
$tab->table( $pdf, $page, \@data, %TestData::required,
column_props => [
{ background_color => 'red' },
],
cell_props => [
[],
[{colspan=>2}]
]
);
#Check first row text placement
ok(
$pdf->match(
[ [qw(translate 12 686)], [qw(text r1c1)] ],
[ [qw(translate 112 686)], [qw(text r1c2)] ],
[ [qw(translate 212 686)], [qw(text r1c3)] ],
),
'text placement in first row'
) or note explain $pdf;
ok(
$pdf->match(
[ [qw(translate 12 667)], [qw(text r2c1)] ],
),
'text placement r2c1'
) or note explain $pdf;
ok(
$pdf->match(
[ [qw(translate 212 667)], [qw(text r2c3)] ],
),
'text placement r2c3'
) or note explain $pdf;
ok(
$pdf->match(
[ [qw(rect 10 681 100 19)], [qw(fillcolor red)] ],
),
'r1c1 background box'
) or note explain $pdf;
ok(
$pdf->match(
[ [qw(rect 10 662 200 19)], [qw(fillcolor red)] ],
),
'r2c1 colspan background box'
) or note explain $pdf;
1;
|