28 require_once(
'tcpdf_include.php');
35 $pdf->SetAuthor(
'Nicola Asuni');
36 $pdf->SetTitle(
'TCPDF Example 006');
37 $pdf->SetSubject(
'TCPDF Tutorial');
38 $pdf->SetKeywords(
'TCPDF, PDF, example, test, guide');
62 if (@file_exists(dirname(__FILE__).
'/lang/eng.php')) {
63 require_once(dirname(__FILE__).
'/lang/eng.php');
64 $pdf->setLanguageArray(
$l);
70 $pdf->SetFont(
'dejavusans',
'', 10);
80 Some special characters: < € € € & è è © > \\slash \\\\double-slash \\\\\\triple-slash 84 <li><img src="images/logo_example.png" alt="test alt attribute" width="30" height="30" border="0" /> test image</li> 85 <li><b>bold text</b></li> 86 <li><i>italic text</i></li> 87 <li><u>underlined text</u></li> 88 <li><b>b<i>bi<u>biu</u>bi</i>b</b></li> 89 <li><a href="http://www.tecnick.com" dir="ltr">link to http://www.tecnick.com</a></li> 90 <li>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<br />Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</li> 101 <li><b>T</b>E<i>S</i><u>T</u> <del>line through</del></li> 102 <li><font size="+3">font + 3</font></li> 103 <li><small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal</li> 107 <dd>Black hot drink</dd> 109 <dd>White cold drink</dd> 111 <div style="text-align:center">IMAGES<br /> 112 <img src="images/logo_example.png" alt="test alt attribute" width="100" height="100" border="0" /><img src="images/tcpdf_box.svg" alt="test alt attribute" width="100" height="100" border="0" /><img src="images/logo_example.jpg" alt="test alt attribute" width="100" height="100" border="0" /> 116 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
120 $html =
'<div style="text-align:center">The words “<span dir="rtl">מזל [mazel] טוב [tov]</span>” mean “Congratulations!”</div>';
121 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
124 $html =
'<p>This is just an example of html code to demonstrate some supported CSS inline styles. 125 <span style="font-weight: bold;">bold text</span> 126 <span style="text-decoration: line-through;">line-trough</span> 127 <span style="text-decoration: underline line-through;">underline and line-trough</span> 128 <span style="color: rgb(0, 128, 64);">color</span> 129 <span style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);">background color</span> 130 <span style="font-weight: bold;">bold</span> 131 <span style="font-size: xx-small;">xx-small</span> 132 <span style="font-size: x-small;">x-small</span> 133 <span style="font-size: small;">small</span> 134 <span style="font-size: medium;">medium</span> 135 <span style="font-size: large;">large</span> 136 <span style="font-size: x-large;">x-large</span> 137 <span style="font-size: xx-large;">xx-large</span> 140 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
152 $subtable =
'<table border="1" cellspacing="6" cellpadding="4"><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>';
154 $html =
'<h2>HTML TABLE:</h2> 155 <table border="1" cellspacing="3" cellpadding="4"> 158 <th align="right">RIGHT align</th> 159 <th align="left">LEFT align</th> 164 <td bgcolor="#cccccc" align="center" colspan="2">A1 ex<i>amp</i>le <a href="http://www.tcpdf.org">link</a> column span. One two tree four five six seven eight nine ten.<br />line after br<br /><small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla<ol><li>first<ol><li>sublist</li><li>sublist</li></ol></li><li>second</li></ol><small color="#FF0000" bgcolor="#FFFF00">small small small small small small small small small small small small small small small small small small small small</small></td> 168 <td>'.$subtable.
'</td> 169 <td bgcolor="#0000FF" color="yellow" align="center">A2 € € € & è è<br/>A2 € € € & è è</td> 170 <td bgcolor="#FFFF00" align="left"><font color="#FF0000">Red</font> Yellow BG</td> 175 <td rowspan="2" colspan="2" bgcolor="#FFFFCC">2AA<br />2AB<br />2AC</td> 176 <td bgcolor="#FF0000">4D</td> 191 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
195 $html =
'<span color="red">red</span> <span color="green">green</span> <span color="blue">blue</span><br /><span color="red">red</span> <span color="green">green</span> <span color="blue">blue</span>';
197 $pdf->SetFillColor(255,255,0);
199 $pdf->writeHTMLCell(0, 0,
'',
'',
$html,
'LRTB', 1, 0,
true,
'L',
true);
200 $pdf->writeHTMLCell(0, 0,
'',
'',
$html,
'LRTB', 1, 1,
true,
'C',
true);
201 $pdf->writeHTMLCell(0, 0,
'',
'',
$html,
'LRTB', 1, 0,
true,
'R',
true);
213 $html =
'<h1>Image alignments on HTML table</h1> 214 <table cellpadding="1" cellspacing="1" border="1" style="text-align:center;"> 215 <tr><td><img src="images/logo_example.png" border="0" height="41" width="41" /></td></tr> 216 <tr style="text-align:left;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="top" /></td></tr> 217 <tr style="text-align:center;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="middle" /></td></tr> 218 <tr style="text-align:right;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="bottom" /></td></tr> 219 <tr><td style="text-align:left;"><img src="images/logo_example.png" border="0" height="41" width="41" align="top" /></td></tr> 220 <tr><td style="text-align:center;"><img src="images/logo_example.png" border="0" height="41" width="41" align="middle" /></td></tr> 221 <tr><td style="text-align:right;"><img src="images/logo_example.png" border="0" height="41" width="41" align="bottom" /></td></tr> 225 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
240 $textcolors .=
'<span color="#'.$v.
'">'.$v.
'</span> ';
241 $bgcolors .=
'<span bgcolor="#'.$v.
'" color="#333333">'.$v.
'</span> ';
254 <h1>Various tests</h1> 255 <a href="#2">link to page 2</a><br /> 256 <font face="courier"><b>thisisaverylongword</b></font> <font face="helvetica"><i>thisisanotherverylongword</i></font> <font face="times"><b>thisisaverylongword</b></font> thisisanotherverylongword <font face="times">thisisaverylongword</font> <font face="courier"><b>thisisaverylongword</b></font> <font face="helvetica"><i>thisisanotherverylongword</i></font> <font face="times"><b>thisisaverylongword</b></font> thisisanotherverylongword <font face="times">thisisaverylongword</font> <font face="courier"><b>thisisaverylongword</b></font> <font face="helvetica"><i>thisisanotherverylongword</i></font> <font face="times"><b>thisisaverylongword</b></font> thisisanotherverylongword <font face="times">thisisaverylongword</font> <font face="courier"><b>thisisaverylongword</b></font> <font face="helvetica"><i>thisisanotherverylongword</i></font> <font face="times"><b>thisisaverylongword</b></font> thisisanotherverylongword <font face="times">thisisaverylongword</font> <font face="courier"><b>thisisaverylongword</b></font> <font face="helvetica"><i>thisisanotherverylongword</i></font> <font face="times"><b>thisisaverylongword</b></font> thisisanotherverylongword <font face="times">thisisaverylongword</font>';
259 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
262 $html1 =
'Default <font face="courier">Courier <font face="helvetica">Helvetica <font face="times">Times <font face="dejavusans">dejavusans </font>Times </font>Helvetica </font>Courier </font>Default';
263 $html2 =
'<small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal';
264 $html3 =
'<font size="10" color="#ff7f50">The</font> <font size="10" color="#6495ed">quick</font> <font size="14" color="#dc143c">brown</font> <font size="18" color="#008000">fox</font> <font size="22"><a href="http://www.tcpdf.org">jumps</a></font> <font size="22" color="#a0522d">over</font> <font size="18" color="#da70d6">the</font> <font size="14" color="#9400d3">lazy</font> <font size="10" color="#4169el">dog</font>.';
269 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
278 <div
style=
"background-color:#880000;color:white;">
282 <pre style=
"background-color:#336699;color:white;">
284 printf(
"HelloWorld");
288 <tt>Monospace
font</tt>, normal
font, <tt>monospace font</tt>, normal font.
290 <div style=
"background-color:#880000;color:white;">DIV LEVEL 1<div style=
"background-color:#008800;color:white;">DIV LEVEL 2</div>DIV LEVEL 1</div>
292 <span style=
"background-color:#880000;color:white;">SPAN LEVEL 1 <span style=
"background-color:#008800;color:white;">SPAN LEVEL 2</span> SPAN LEVEL 1</span>
296 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
306 <h1>Test custom bullet
image for list items</h1>
307 <ul style=
"font-size:14pt;list-style-type:img|png|4|4|images/logo_example.png">
308 <li>test custom bullet
image</li>
309 <li>test custom bullet
image</li>
310 <li>test custom bullet
image</li>
311 <li>test custom bullet
image</li>
316 $pdf->writeHTML(
$html,
true,
false,
true,
false,
'');
326 $pdf->Output(
'example_006.pdf',
'I');
const PDF_MARGIN_BOTTOM
Bottom margin.
const PDF_MARGIN_LEFT
Left margin.
const PDF_MARGIN_HEADER
Header margin.
const PDF_HEADER_STRING
Header description string.
const PDF_FONT_SIZE_MAIN
Default main font size.
const PDF_FONT_SIZE_DATA
Default data font size.
const PDF_FONT_NAME_MAIN
Default main font name.
static $webcolor
Array of WEB safe colors static.
PHP class for generating PDF documents without requiring external extensions.
const PDF_HEADER_LOGO_WIDTH
Header logo image width in user units.
const PDF_HEADER_LOGO
Deafult image logo used be the default Header() method.
const PDF_UNIT
Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch].
const PDF_IMAGE_SCALE_RATIO
Ratio used to adjust the conversion of pixels to user units.
const PDF_PAGE_ORIENTATION
Page orientation (P=portrait, L=landscape).
const PDF_MARGIN_RIGHT
Right margin.
const PDF_HEADER_TITLE
Header title.
const PDF_FONT_NAME_DATA
Default data font name.
const PDF_CREATOR
Document creator.
const PDF_PAGE_FORMAT
Page format.
const PDF_FONT_MONOSPACED
Default monospaced font name.
const PDF_MARGIN_TOP
Top margin.
const PDF_MARGIN_FOOTER
Footer margin.
const EOF
How fgetc() reports an End Of File.