Project

General

Profile

Problem with PdfTable and PageBreak » example_test.php

Marco Steindl, 07/17/2014 10:01 AM

 
1
<?php
2
/**
3
* Pdf Advanced Table - Example
4
* Copyright (c) 2005-2013, Andrei Bintintan, http://www.interpid.eu
5
*/
6

    
7
// include pdf class
8
require_once ("classes/pdf.php");
9

    
10
/**
11
 * mypdf extends pdf class, it is used to draw the header and footer
12
 */
13
require_once ("mypdf-table.php");
14

    
15
// Tag Based Multicell Class
16
require_once ("classes/pdftable.php");
17

    
18
// define some background colors
19
$aBgColor1 = array (
20
		234,
21
		255,
22
		218 
23
);
24
$aBgColor2 = array (
25
		165,
26
		250,
27
		220 
28
);
29
$aBgColor3 = array (
30
		255,
31
		252,
32
		249 
33
);
34

    
35
// create the pdf object and do some initialization
36
$oPdf = new myPdf ();
37
$oPdf->Open ();
38
$oPdf->SetAutoPageBreak ( true, 20 );
39
$oPdf->SetMargins ( 20, 20, 20 );
40

    
41
$oPdf->AddFont ( 'dejavusans', '', 'DejaVuSans.ttf', true );
42
$oPdf->AddFont ( 'dejavusans', 'I', 'DejaVuSans-Oblique.ttf', true );
43
$oPdf->AddFont ( 'dejavusans', 'B', 'DejaVuSans-Bold.ttf', true );
44
$oPdf->AddFont ( 'dejavusans', 'BI', 'DejaVuSans-BoldOblique.ttf', true );
45
$oPdf->AddFont ( 'dejavuserif', '', 'DejaVuSerif.ttf', true );
46
$oPdf->AddFont ( 'dejavuserif', 'B', 'DejaVuSerif-Bold.ttf', true );
47
$oPdf->AddFont ( 'dejavuserif', 'BI', 'DejaVuSerif-BoldItalic.ttf', true );
48

    
49
$oPdf->AddPage ();
50
$oPdf->AliasNbPages ();
51

    
52
/**
53
 * Create the pdf Table object
54
 * Alternative you can use the Singleton Instance
55
 * 
56
 * @example : $oTable = PdfTable::getInstance($oPdf);
57
 */
58
$oTable = new PdfTable ( $oPdf );
59

    
60
/**
61
 * Set the tag styles
62
 */
63
$oTable->setStyle ( "p", "dejavusans", "", 9, "130,0,30" );
64
$oTable->setStyle ( "b", "dejavusans", "", 9, "80,80,260" );
65
$oTable->setStyle ( "t1", "dejavuserif", "", 10, "0,151,200" );
66
$oTable->setStyle ( "bi", "dejavusans", "BI", 12, "0,0,120" );
67

    
68
// $oMulticell = $oTable->getMulticellInstance ();
69
// $oMulticell->multiCell ( 0, 4, "<p>This <b>tFPDF Add On</b> allows the creation of <b>complex Table</b> in the pdf document.
70
// The functionality is exactly the same as for <b href='http://www.interpid.eu/fpdf-addons/fpdf-table'>Fpdf Advanced Table</b>,it is based on tFpdf class and has UTF8 support.</p>" );
71

    
72
// $oPdf->Ln ( 10 );
73

    
74
$sTxt1 = "<p><pb>tFpdf</pb> base class is used and UTF8 characters are supported\n<pb>Examples:</pb> Σ ε φ ά η т а р и с ж  ن م ا ی ن د گ ا ن  کم</p>";
75

    
76
// Initialize the table class, 5 columns with the specified widths
77
$oTable->initialize ( array (
78
		20,
79
		30,
80
		80 
81
) );
82

    
83
$aHeader = array (
84
		array (
85
				'TEXT' => "123"
86
		),
87
		array (
88
				'TEXT' => '12345' 
89
		),
90
		array (
91
				'TEXT' => 'sddfdsfsdfsdsfghgfhgfh fghfhgfhgfdfhfghfghffghgj' 
92
		)
93
);
94

    
95
// add the header line
96
$oTable->addHeader ( $aHeader );
97

    
98
for ( $i=0;$i<=300;$i++){
99
$oTable->addRow ( $aHeader );
100
}
101

    
102
// close the table
103
$oTable->close ();
104

    
105
// send the pdf to the browser
106
$oPdf->Output ();
(2-2/4)