Subversion Repositories Applications.annuaire

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
296 aurelien 1
<?php
2
//============================================================+
3
// File name   : example_054.php
4
// Begin       : 2009-09-07
5
// Last Update : 2010-08-08
6
//
7
// Description : Example 054 for TCPDF class
8
//               XHTML Forms
9
//
10
// Author: Nicola Asuni
11
//
12
// (c) Copyright:
13
//               Nicola Asuni
14
//               Tecnick.com s.r.l.
15
//               Via Della Pace, 11
16
//               09044 Quartucciu (CA)
17
//               ITALY
18
//               www.tecnick.com
19
//               info@tecnick.com
20
//============================================================+
21
 
22
/**
23
 * Creates an example PDF TEST document using TCPDF
24
 * @package com.tecnick.tcpdf
25
 * @abstract TCPDF - Example: XHTML Forms
26
 * @author Nicola Asuni
27
 * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
28
 * @link http://tcpdf.org
29
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
30
 * @since 2009-09-07
31
 */
32
 
33
require_once('../config/lang/eng.php');
34
require_once('../tcpdf.php');
35
 
36
// create new PDF document
37
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
38
 
39
// set document information
40
$pdf->SetCreator(PDF_CREATOR);
41
$pdf->SetAuthor('Nicola Asuni');
42
$pdf->SetTitle('TCPDF Example 054');
43
$pdf->SetSubject('TCPDF Tutorial');
44
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
45
 
46
// set default header data
47
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 054', PDF_HEADER_STRING);
48
 
49
// set header and footer fonts
50
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
51
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
52
 
53
// set default monospaced font
54
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
55
 
56
//set margins
57
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
58
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
59
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
60
 
61
//set auto page breaks
62
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
63
 
64
//set image scale factor
65
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
66
 
67
//set some language-dependent strings
68
$pdf->setLanguageArray($l);
69
 
70
// ---------------------------------------------------------
71
 
72
// IMPORTANT: disable font subsetting to allow users editing the document
73
$pdf->setFontSubsetting(false);
74
 
75
// set font
76
$pdf->SetFont('helvetica', '', 10, '', false);
77
 
78
// add a page
79
$pdf->AddPage();
80
 
81
// create some HTML content
82
$html = <<<EOD
83
<h1>XHTML Form Example</h1>
84
<form method="post" action="http://localhost/printvars.php" enctype="multipart/form-data">
85
<label for="name">name:</label> <input type="text" name="name" value="" size="20" maxlength="30" /><br />
86
<label for="password">password:</label> <input type="password" name="password" value="" size="20" maxlength="30" /><br /><br />
87
<label for="infile">file:</label> <input type="file" name="userfile" size="20" /><br /><br />
88
<input type="checkbox" name="agree" value="1" checked="checked" /> <label for="agree">I agree </label><br /><br />
89
<input type="radio" name="radioquestion" id="rqa" value="1" /> <label for="rqa">one</label><br />
90
<input type="radio" name="radioquestion" id="rqb" value="2" checked="checked"/> <label for="rqb">two</label><br />
91
<input type="radio" name="radioquestion" id="rqc" value="3" /> <label for="rqc">three</label><br /><br />
92
<label for="selection">select:</label>
93
<select name="selection" size="0">
94
	<option value="0">zero</option>
95
	<option value="1">one</option>
96
	<option value="2">two</option>
97
	<option value="3">three</option>
98
</select><br /><br />
99
<label for="selection">select:</label>
100
<select name="multiselection" size="2" multiple="multiple">
101
	<option value="0">zero</option>
102
	<option value="1">one</option>
103
	<option value="2">two</option>
104
	<option value="3">three</option>
105
</select><br /><br /><br />
106
<label for="text">text area:</label><br />
107
<textarea cols="40" rows="3" name="text">line one
108
line two</textarea><br />
109
<br /><br /><br />
110
<input type="reset" name="reset" value="Reset" />
111
<input type="submit" name="submit" value="Submit" />
112
<input type="button" name="print" value="Print" onclick="print()" />
113
<input type="hidden" name="hiddenfield" value="OK" />
114
<br />
115
</form>
116
EOD;
117
 
118
// output the HTML content
119
$pdf->writeHTML($html, true, 0, true, 0);
120
 
121
// reset pointer to the last page
122
$pdf->lastPage();
123
 
124
// ---------------------------------------------------------
125
 
126
//Close and output PDF document
127
$pdf->Output('example_054.pdf', 'I');
128
 
129
//============================================================+
130
// END OF FILE
131
//============================================================+