/
usr
/
share
/
doc
/
php-tcpdf
/
examples
/
/usr/share/doc/php-tcpdf/examples
mkdir
upload
Name
Size
Mode
Actions
barcodes/
-
0755
rm
config/
-
0755
rm
data/
-
0755
rm
images/
-
0755
rm
lang/
-
0755
rm
example_001.php
3958
0644
edit
dl
rm
example_002.php
2399
0644
edit
dl
rm
example_003.php
3485
0644
edit
dl
rm
example_004.php
4246
0644
edit
dl
rm
example_005.php
6387
0644
edit
dl
rm
example_006.php
13688
0644
edit
dl
rm
example_007.php
9710
0644
edit
dl
rm
example_008.php
2868
0644
edit
dl
rm
example_009.php
4893
0644
edit
dl
rm
example_010.php
4423
0644
edit
dl
rm
example_011.php
3896
0644
edit
dl
rm
example_012.pdf
13214
0644
edit
dl
rm
example_012.php
7831
0644
edit
dl
rm
example_013.php
6795
0644
edit
dl
rm
example_014.php
6217
0644
edit
dl
rm
example_015.php
5632
0644
edit
dl
rm
example_016.php
5159
0644
edit
dl
rm
example_017.php
9874
0644
edit
dl
rm
example_018.php
4672
0644
edit
dl
rm
example_019.php
2950
0644
edit
dl
rm
example_020.php
5424
0644
edit
dl
rm
example_021.php
5562
0644
edit
dl
rm
example_022.php
4367
0644
edit
dl
rm
example_023.php
3224
0644
edit
dl
rm
example_024.php
3938
0644
edit
dl
rm
example_025.php
3359
0644
edit
dl
rm
example_026.php
5119
0644
edit
dl
rm
example_027.php
11303
0644
edit
dl
rm
example_028.php
3402
0644
edit
dl
rm
example_029.php
3804
0644
edit
dl
rm
example_030.php
5988
0644
edit
dl
rm
example_031.php
2902
0644
edit
dl
rm
example_032.php
2750
0644
edit
dl
rm
example_033.php
4162
0644
edit
dl
rm
example_034.php
2817
0644
edit
dl
rm
example_035.php
3509
0644
edit
dl
rm
example_036.php
2833
0644
edit
dl
rm
example_037.php
5209
0644
edit
dl
rm
example_038.php
2767
0644
edit
dl
rm
example_039.php
4073
0644
edit
dl
rm
example_040.php
3223
0644
edit
dl
rm
example_041.php
2741
0644
edit
dl
rm
example_042.php
3371
0644
edit
dl
rm
example_043.php
2551
0644
edit
dl
rm
example_044.php
3489
0644
edit
dl
rm
example_045.php
4216
0644
edit
dl
rm
example_046.php
5879
0644
edit
dl
rm
example_047.php
3167
0644
edit
dl
rm
example_048.php
8720
0644
edit
dl
rm
example_049.php
4570
0644
edit
dl
rm
example_050.php
6415
0644
edit
dl
rm
example_051.php
4304
0644
edit
dl
rm
example_052.php
4186
0644
edit
dl
rm
example_053.php
3341
0644
edit
dl
rm
example_054.php
4446
0644
edit
dl
rm
example_055.php
3512
0644
edit
dl
rm
example_056.php
4379
0644
edit
dl
rm
example_057.php
8891
0644
edit
dl
rm
example_058.php
3195
0644
edit
dl
rm
example_059.php
6696
0644
edit
dl
rm
example_060.php
3318
0644
edit
dl
rm
example_061.php
9935
0644
edit
dl
rm
example_062.php
4184
0644
edit
dl
rm
example_063.php
4573
0644
edit
dl
rm
example_064.php
14513
0644
edit
dl
rm
example_065.php
3580
0644
edit
dl
rm
example_066.php
2892
0644
edit
dl
rm
index.php
10486
0644
edit
dl
rm
tcpdf_include.php
1466
0644
edit
dl
rm
Edit:
/usr/share/doc/php-tcpdf/examples/example_006.php
(13688B)
<?php //============================================================+ // File name : example_006.php // Begin : 2008-03-04 // Last Update : 2013-05-14 // // Description : Example 006 for TCPDF class // WriteHTML and RTL support // // Author: Nicola Asuni // // (c) Copyright: // Nicola Asuni // Tecnick.com LTD // www.tecnick.com // info@tecnick.com //============================================================+ /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf * @abstract TCPDF - Example: WriteHTML and RTL support * @author Nicola Asuni * @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). require_once('tcpdf_include.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->setCreator(PDF_CREATOR); $pdf->setAuthor('Nicola Asuni'); $pdf->setTitle('TCPDF Example 006'); $pdf->setSubject('TCPDF Tutorial'); $pdf->setKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->setHeaderMargin(PDF_MARGIN_HEADER); $pdf->setFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->setFont('dejavusans', '', 10); // add a page $pdf->AddPage(); // writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='') // writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true) // create some HTML content $html = '<h1>HTML Example</h1> Some special characters: < € € € & è è © > \\slash \\\\double-slash \\\\\\triple-slash <h2>List</h2> List example: <ol> <li><img src="images/logo_example.png" alt="test alt attribute" width="30" height="30" border="0" /> test image</li> <li><b>bold text</b></li> <li><i>italic text</i></li> <li><u>underlined text</u></li> <li><b>b<i>bi<u>biu</u>bi</i>b</b></li> <li><a href="http://www.tecnick.com" dir="ltr">link to http://www.tecnick.com</a></li> <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> <li>SUBLIST <ol> <li>row one <ul> <li>sublist</li> </ul> </li> <li>row two</li> </ol> </li> <li><b>T</b>E<i>S</i><u>T</u> <del>line through</del></li> <li><font size="+3">font + 3</font></li> <li><small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal</li> </ol> <dl> <dt>Coffee</dt> <dd>Black hot drink</dd> <dt>Milk</dt> <dd>White cold drink</dd> </dl> <div style="text-align:center">IMAGES<br /> <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" /> </div>'; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // output some RTL HTML content $html = '<div style="text-align:center">The words “<span dir="rtl">מזל [mazel] טוב [tov]</span>” mean “Congratulations!”</div>'; $pdf->writeHTML($html, true, false, true, false, ''); // test some inline CSS $html = '<p>This is just an example of html code to demonstrate some supported CSS inline styles. <span style="font-weight: bold;">bold text</span> <span style="text-decoration: line-through;">line-trough</span> <span style="text-decoration: underline line-through;">underline and line-trough</span> <span style="color: rgb(0, 128, 64);">color</span> <span style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);">background color</span> <span style="font-weight: bold;">bold</span> <span style="font-size: xx-small;">xx-small</span> <span style="font-size: x-small;">x-small</span> <span style="font-size: small;">small</span> <span style="font-size: medium;">medium</span> <span style="font-size: large;">large</span> <span style="font-size: x-large;">x-large</span> <span style="font-size: xx-large;">xx-large</span> </p>'; $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Print a table // add a page $pdf->AddPage(); // create some HTML content $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>'; $html = '<h2>HTML TABLE:</h2> <table border="1" cellspacing="3" cellpadding="4"> <tr> <th>#</th> <th align="right">RIGHT align</th> <th align="left">LEFT align</th> <th>4A</th> </tr> <tr> <td>1</td> <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> <td>4B</td> </tr> <tr> <td>'.$subtable.'</td> <td bgcolor="#0000FF" color="yellow" align="center">A2 € € € & è è<br/>A2 € € € & è è</td> <td bgcolor="#FFFF00" align="left"><font color="#FF0000">Red</font> Yellow BG</td> <td>4C</td> </tr> <tr> <td>1A</td> <td rowspan="2" colspan="2" bgcolor="#FFFFCC">2AA<br />2AB<br />2AC</td> <td bgcolor="#FF0000">4D</td> </tr> <tr> <td>1B</td> <td>4E</td> </tr> <tr> <td>1C</td> <td>2C</td> <td>3C</td> <td>4F</td> </tr> </table>'; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // Print some HTML Cells $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>'; $pdf->setFillColor(255,255,0); $pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'L', true); $pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 1, true, 'C', true); $pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'R', true); // reset pointer to the last page $pdf->lastPage(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Print a table // add a page $pdf->AddPage(); // create some HTML content $html = '<h1>Image alignments on HTML table</h1> <table cellpadding="1" cellspacing="1" border="1" style="text-align:center;"> <tr><td><img src="images/logo_example.png" border="0" height="41" width="41" /></td></tr> <tr style="text-align:left;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="top" /></td></tr> <tr style="text-align:center;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="middle" /></td></tr> <tr style="text-align:right;"><td><img src="images/logo_example.png" border="0" height="41" width="41" align="bottom" /></td></tr> <tr><td style="text-align:left;"><img src="images/logo_example.png" border="0" height="41" width="41" align="top" /></td></tr> <tr><td style="text-align:center;"><img src="images/logo_example.png" border="0" height="41" width="41" align="middle" /></td></tr> <tr><td style="text-align:right;"><img src="images/logo_example.png" border="0" height="41" width="41" align="bottom" /></td></tr> </table>'; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Print all HTML colors // add a page $pdf->AddPage(); $textcolors = '<h1>HTML Text Colors</h1>'; $bgcolors = '<hr /><h1>HTML Background Colors</h1>'; foreach(TCPDF_COLORS::$webcolor as $k => $v) { $textcolors .= '<span color="#'.$v.'">'.$v.'</span> '; $bgcolors .= '<span bgcolor="#'.$v.'" color="#333333">'.$v.'</span> '; } // output the HTML content $pdf->writeHTML($textcolors, true, false, true, false, ''); $pdf->writeHTML($bgcolors, true, false, true, false, ''); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Test word-wrap // create some HTML content $html = '<hr /> <h1>Various tests</h1> <a href="#2">link to page 2</a><br /> <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>'; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // Test fonts nesting $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'; $html2 = '<small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal'; $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>.'; $html = $html1.'<br />'.$html2.'<br />'.$html3.'<br />'.$html3.'<br />'.$html2; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // test pre tag // add a page $pdf->AddPage(); $html = <<<EOF <div style="background-color:#880000;color:white;"> Hello World!<br /> Hello </div> <pre style="background-color:#336699;color:white;"> int main() { printf("HelloWorld"); return 0; } </pre> <tt>Monospace font</tt>, normal font, <tt>monospace font</tt>, normal font. <br /> <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> <br /> <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> EOF; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // test custom bullet points for list // add a page $pdf->AddPage(); $html = <<<EOF <h1>Test custom bullet image for list items</h1> <ul style="font-size:14pt;list-style-type:img|png|4|4|images/logo_example.png"> <li>test custom bullet image</li> <li>test custom bullet image</li> <li>test custom bullet image</li> <li>test custom bullet image</li> <ul> EOF; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_006.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
Save
cmd:
run