1
|
<?php
|
2
|
/**
|
3
|
* Pdf Advanced table - Example
|
4
|
* Copyright (c), Interpid, http://www.interpid.eu
|
5
|
*/
|
6
|
|
7
|
require_once __DIR__ . '/../autoload.php';
|
8
|
|
9
|
use Interpid\PdfLib\Table;
|
10
|
use Interpid\PdfLib\Pdf;
|
11
|
|
12
|
// Pdf extends FPDF
|
13
|
$pdf = new Pdf();
|
14
|
|
15
|
// use the default FPDF configuration
|
16
|
$pdf->SetAuthor('Interpid');
|
17
|
$pdf->SetMargins(20, 20, 20);
|
18
|
$pdf->SetAutoPageBreak(true, 20);
|
19
|
|
20
|
$pdf->SetFont('helvetica', '', 11);
|
21
|
$pdf->SetTextColor(200, 10, 10);
|
22
|
$pdf->SetFillColor(254, 255, 245);
|
23
|
|
24
|
// add a page
|
25
|
$pdf->AddPage();
|
26
|
|
27
|
// Create the Advanced Table Object and inject the PDF Tablet
|
28
|
$table = new Table($pdf);
|
29
|
|
30
|
// Set the styles for the advanced table
|
31
|
$table->setStyle('base', 11, '', [0, 0, 77], 'helvetica');
|
32
|
$table->setStyle('p', null, null);
|
33
|
$table->setStyle('b', null, 'B');
|
34
|
$table->setStyle('i', null, 'I');
|
35
|
$table->setStyle('bi', null, 'BI');
|
36
|
$table->setStyle('u', null, 'U');
|
37
|
$table->setStyle('h', null, 'B', '203,0,48');
|
38
|
$table->setStyle('s', 8, null);
|
39
|
$table->setStyle('title', 14, null, [102, 0, 0], null, 'h');
|
40
|
$table->setStyle('h1', 16, null, null, null, 'h');
|
41
|
$table->setStyle('h2', 14, null, null, null, 'h');
|
42
|
$table->setStyle('h3', 12, null, null, null, 'h');
|
43
|
$table->setStyle('h4', 11, null, null, null, 'h');
|
44
|
$table->setStyle('super', 8, null, [255, 102, 153]);
|
45
|
|
46
|
//Initialize the table, 3 columns with the specified widths
|
47
|
$table->initialize([50, 50, 40]);
|
48
|
|
49
|
$row = [
|
50
|
'I am cell 1',
|
51
|
'I am cell 2',
|
52
|
[
|
53
|
'TEXT' => 'I am cell 3',
|
54
|
'TEXT_ALIGN' => 'R'
|
55
|
],
|
56
|
];
|
57
|
|
58
|
//add the row to the table
|
59
|
$table->addRow($row);
|
60
|
|
61
|
$row = [
|
62
|
'I am cell 1',
|
63
|
'I am cell 2',
|
64
|
];
|
65
|
|
66
|
$table->addRow($row);
|
67
|
|
68
|
$table->addRow($row);
|
69
|
|
70
|
$table->addPageBreak();
|
71
|
|
72
|
$table->addRow($row);
|
73
|
|
74
|
$table->close();
|
75
|
|
76
|
$pdf->output();
|