This commit is contained in:
wangjinlei
2024-07-17 09:23:45 +08:00
parent edf9deeb1a
commit 881ac3e056
1001 changed files with 41032 additions and 5452 deletions

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
* @group barcode
* @group 1d
* @group html
* @group comparable
*/
// include 1D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
* @group barcode
* @group 1d
* @group png
*/
// include 1D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
* @group barcode
* @group 1d
* @group svg
* @group comparable
*/
// include 1D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.000
* @group barcode
* @group 1d
* @group svg
* @group comparable
*/
// include 1D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group datamatrix
* @group html
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group datamatrix
* @group png
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group datamatrix
* @group svg
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group datamatrix
* @group svg
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group pdf417
* @group html
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group pdf417
* @group png
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group pdf417
* @group svg
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,10 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group pdf417
* @group svg
* @group comparable
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group qrcode
* @group html
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group qrcode
* @group png
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group qrcode
* @group svg
*/
// include 2D barcode class (search for installation path)

View File

@@ -37,6 +37,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.009
* @group barcode
* @group qrcode
* @group svg
*/
// include 2D barcode class (search for installation path)

View File

@@ -212,6 +212,14 @@ define('K_THAI_TOPCHARS', true);
*/
define('K_TCPDF_CALLS_IN_HTML', true);
/**
* List of TCPDF methods that are allowed to be called using HTML syntax.
* Note: each method name must end with surrounded with | (pipe) character.
* The constant K_TCPDF_CALLS_IN_HTML must be set to true.
* IMPORTANT: For security reason, disable this feature if you are allowing user HTML content.
*/
define('K_ALLOWED_TCPDF_TAGS', '|AddPage|Rect|SetDrawColor|write1DBarcode|');
/**
* If true and PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution.
*/

View File

@@ -22,6 +22,10 @@
* @abstract TCPDF - Example: Default Header and Footer
* @author Nicola Asuni
* @since 2008-03-04
* @group header
* @group footer
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,10 @@
* @abstract TCPDF - Example: Removing Header and Footer
* @author Nicola Asuni
* @since 2008-03-04
* @group header
* @group footer
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,10 @@
* @abstract TCPDF - Example: Custom Header and Footer
* @author Nicola Asuni
* @since 2008-03-04
* @group header
* @group footer
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Cell stretching
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Multicell
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: WriteHTML and RTL support
* @author Nicola Asuni
* @since 2008-03-04
* @group html
* @group rtl
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -224,6 +227,20 @@ $html = '<h1>Image alignments on HTML table</h1>
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// create some HTML content
$html = '<h1>Embedded Images</h1>
<table cellpadding="1" cellspacing="1" border="1" style="text-align:center;">
<tr><td>src="@..." </td><td><img src="@DATA1@" border="0" height="41" width="41" /></td></tr>
<tr><td>src="data..."</td><td><img src="@DATA2@" border="0" height="41" width="41" /></td></tr>
</table>';
$data = base64_encode(file_get_contents("images/logo_example.png"));
$html = str_replace("@DATA1@", "@" . $data, $html);
$html = str_replace("@DATA2@", "data:image/png;base64," . $data, $html);
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// reset pointer to the last page
$pdf->lastPage();

View File

@@ -22,6 +22,10 @@
* @abstract TCPDF - Example: Two independent columns with WriteHTMLCell()
* @author Nicola Asuni
* @since 2008-03-04
* @group column
* @group cell
* @group html
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Include external UTF-8 text file
* @author Nicola Asuni
* @since 2008-03-04
* @group unicode
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -75,7 +77,7 @@ $pdf->setFont('freeserif', '', 12);
// add a page
$pdf->AddPage();
// get esternal file content
// get external file content
$utf8text = file_get_contents('data/utf8test.txt', false);
// set color for text

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Test Image
* @author Nicola Asuni
* @since 2008-03-04
* @group image
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Text on multiple columns
* @author Nicola Asuni
* @since 2008-03-04
* @group column
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Colored Table
* @author Nicola Asuni
* @since 2008-03-04
* @group table
* @group color
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Graphic Functions
* @author Nicola Asuni
* @since 2008-03-04
* @group drawing
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Graphic Transformations
* @author Nicola Asuni
* @since 2008-03-04
* @group drawing
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Javascript Form and user rights (only works on Adobe Acrobat)
* @author Nicola Asuni
* @since 2008-03-04
* @group javascript
* @group form
* @group pdf
*/
@@ -70,7 +73,7 @@ if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
// IMPORTANT: disable font subsetting to allow users editing the document
$pdf->setFontSubsetting(false);
// set font
// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+
$pdf->setFont('helvetica', '', 10, '', false);
// add a page

View File

@@ -23,6 +23,9 @@
* @abstract TCPDF - Example: Bookmarks (Table of Content)
* @author Nicola Asuni
* @since 2008-03-04
* @group toc
* @group bookmark
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Document Encryption / Security
* @author Nicola Asuni
* @since 2008-03-04
* @group security
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Two independent columns with MultiCell
* @author Nicola Asuni
* @since 2008-03-04
* @group column
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: RTL document with Persian language
* @author Nicola Asuni
* @since 2008-03-06
* @group rtl
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Non unicode with alternative config file
* @author Nicola Asuni
* @since 2008-03-04
* @group unicode
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -23,6 +23,9 @@
* @abstract TCPDF - Example: Two columns composed by MultiCell of different heights
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group column
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: WriteHTML text flow.
* @author Nicola Asuni
* @since 2008-03-04
* @group html
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: CMYK colors.
* @author Nicola Asuni
* @since 2008-03-04
* @group color
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Page Groups.
* @author Nicola Asuni
* @since 2008-03-04
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Object Visibility and Layers
* @author Nicola Asuni
* @since 2008-03-04
* @group drawing
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Object Transparency
* @author Nicola Asuni
* @since 2008-03-04
* @group drawing
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,7 @@
* @abstract TCPDF - Example: Text Rendering Modes and Text Clipping
* @author Nicola Asuni
* @since 2008-03-04
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: 1D Barcodes.
* @author Nicola Asuni
* @since 2008-03-04
* @group barcode
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: changing page formats
* @author Nicola Asuni
* @since 2008-03-04
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Set PDF viewer display preferences.
* @author Nicola Asuni
* @since 2008-06-09
* @group viewer
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Colour gradients
* @author Nicola Asuni
* @since 2008-06-09
* @group color
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Pie Chart
* @author Nicola Asuni
* @since 2008-06-09
* @group drawing
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: EPS/AI image
* @author Nicola Asuni
* @since 2008-06-09
* @group image
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Mixed font types
* @author Nicola Asuni
* @since 2008-06-24
* @group font
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Clipping
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Line styles with cells and multicells
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Annotations
* @author Nicola Asuni
* @since 2008-08-08
* @group annotation
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Spot colors.
* @author Nicola Asuni
* @since 2008-09-12
* @group color
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: CID-0 CJK unembedded font
* @author Nicola Asuni
* @since 2008-09-15
* @group font
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: HTML justification
* @author Nicola Asuni
* @since 2008-10-18
* @group html
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Booklet mode (double-sided pages)
* @author Nicola Asuni
* @since 2008-10-28
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Annotation - FileAttachment
* @author Nicola Asuni
* @since 2008-12-07
* @group annotation
* @group attachment
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Test Image with alpha channel
* @author Nicola Asuni
* @since 2008-12-23
* @group image
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Disk caching
* @author Nicola Asuni
* @since 2009-01-02
* @group cache
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Move, copy and delete pages
* @author Nicola Asuni
* @since 2009-01-02
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Bookmarks and Table of Content
* @author Nicola Asuni
* @since 2008-03-04
* @group toc
* @group bookmark
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: text Hyphenation
* @author Nicola Asuni
* @since 2009-02-28
* @group text
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Transactions
* @author Nicola Asuni
* @since 2009-03-19
* @group transaction
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: HTML tables and table headers
* @author Nicola Asuni
* @since 2009-03-20
* @group html
* @group table
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -2,7 +2,7 @@
//============================================================+
// File name : example_049.php
// Begin : 2009-04-03
// Last Update : 2014-12-10
// Last Update : 2024-03-18
//
// Description : Example 049 for TCPDF class
// WriteHTML with TCPDF callback functions
@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: WriteHTML with TCPDF callback functions
* @author Nicola Asuni
* @since 2008-03-04
* @group html
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -76,36 +78,36 @@ $pdf->AddPage();
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
IMPORTANT:
If you are printing user-generated content, tcpdf tag can be unsafe.
You can disable this tag by setting to false the K_TCPDF_CALLS_IN_HTML
constant on TCPDF configuration file.
If you are printing user-generated content, the tcpdf tag should be considered unsafe.
This tag is disabled by default by the K_TCPDF_CALLS_IN_HTML constant on TCPDF configuration file.
Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.
For security reasons, the parameters for the 'params' attribute of TCPDF
tag must be prepared as an array and encoded with the
serializeTCPDFtagParameters() method (see the example below).
For security reasons, the content of the TCPDF tag must be prepared and encoded with the serializeTCPDFtag() method (see the example below).
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
$html = '<h1>Test TCPDF Methods in HTML</h1>
<h2 style="color:red;">IMPORTANT:</h2>
<span style="color:red;">If you are using user-generated content, the tcpdf tag can be unsafe.<br />
You can disable this tag by setting to false the <b>K_TCPDF_CALLS_IN_HTML</b> constant on TCPDF configuration file.</span>
<span style="color:red;">If you are using user-generated content, the tcpdf tag should be considered unsafe.<br />
Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.<br />
This feature is disabled by default by the <b>K_TCPDF_CALLS_IN_HTML</b> constant on TCPDF configuration file.</span>
<h2>write1DBarcode method in HTML</h2>';
$params = $pdf->serializeTCPDFtagParameters(array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
$html .= '<tcpdf method="write1DBarcode" params="'.$params.'" />';
$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
$html .= '<tcpdf data="'.$data.'" />';
$params = $pdf->serializeTCPDFtagParameters(array('CODE 128', 'C128', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
$html .= '<tcpdf method="write1DBarcode" params="'.$params.'" />';
$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 128', 'C128', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
$html .= '<tcpdf data="'.$data.'" />';
$html .= '<tcpdf method="AddPage" /><h2>Graphic Functions</h2>';
$data = $pdf->serializeTCPDFtag('AddPage');
$html .= '<tcpdf data="'.$data.'" /><h2>Graphic Functions</h2>';
$params = $pdf->serializeTCPDFtagParameters(array(0));
$html .= '<tcpdf method="SetDrawColor" params="'.$params.'" />';
$data = $pdf->serializeTCPDFtag('SetDrawColor', array(0));
$html .= '<tcpdf data="'.$data.'" />';
$params = $pdf->serializeTCPDFtagParameters(array(50, 50, 40, 10, 'DF', array(), array(0,128,255)));
$html .= '<tcpdf method="Rect" params="'.$params.'" />';
$data = $pdf->serializeTCPDFtag('Rect', array(50, 50, 40, 10, 'DF', array(), array(0,128,255)));
$html .= '<tcpdf data="'.$data.'" />';
// output the HTML content

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: 2D barcodes.
* @author Nicola Asuni
* @since 2008-03-04
* @group barcode
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Full page background
* @author Nicola Asuni
* @since 2009-04-16
* @group background
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -40,7 +43,7 @@ class MYPDF extends TCPDF {
$this->setAutoPageBreak(false, 0);
// set bacground image
$img_file = K_PATH_IMAGES.'image_demo.jpg';
$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$this->Image($img_file, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0);
// restore auto-page-break status
$this->setAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content
@@ -124,7 +127,7 @@ $auto_page_break = $pdf->getAutoPageBreak();
$pdf->setAutoPageBreak(false, 0);
// set bacground image
$img_file = K_PATH_IMAGES.'image_demo.jpg';
$pdf->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$pdf->Image($img_file, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0);
// restore auto-page-break status
$pdf->setAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Certification Signature (experimental)
* @author Nicola Asuni
* @since 2009-05-07
* @group security
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -87,7 +89,7 @@ $info = array(
// set document signature
$pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info);
// set font
// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+
$pdf->setFont('helvetica', '', 12);
// add a page

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Javascript example.
* @author Nicola Asuni
* @since 2009-09-02
* @group javascript
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: XHTML Forms
* @author Nicola Asuni
* @since 2009-09-07
* @group html
* @group form
* @group pdf
*/
// Include the main TCPDF library (search for installation path).
@@ -69,7 +72,7 @@ if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
// IMPORTANT: disable font subsetting to allow users editing the document
$pdf->setFontSubsetting(false);
// set font
// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+
$pdf->setFont('helvetica', '', 10, '', false);
// add a page

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: XHTML Forms
* @author Nicola Asuni
* @since 2009-10-21
* @group html
* @group form
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Crop marks and color registration bars
* @author Nicola Asuni
* @since 2010-03-26
* @group color
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Cell vertical alignments
* @author Nicola Asuni
* @since 2008-03-04
* @group cell
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: SVG Image
* @author Nicola Asuni
* @since 2010-05-02
* @group svg
* @group image
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: Table Of Content using HTML templates.
* @author Nicola Asuni
* @since 2010-05-06
* @group toc
* @group html
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Advanced page settings.
* @author Nicola Asuni
* @since 2010-05-17
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,9 @@
* @abstract TCPDF - Example: XHTML + CSS
* @author Nicola Asuni
* @since 2010-05-25
* @group html
* @group css
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: XObject Template
* @author Nicola Asuni
* @since 2010-08-25
* @group object
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: Text stretching and spacing (tracking)
* @author Nicola Asuni
* @since 2010-09-29
* @group text
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: No-write page regions
* @author Nicola Asuni
* @since 2010-10-14
* @group page
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -22,6 +22,8 @@
* @abstract TCPDF - Example: PDF/A-1b mode
* @author Nicola Asuni
* @since 2011-09-28
* @group A-1b
* @group pdf
*/
// Include the main TCPDF library (search for installation path).

View File

@@ -14,10 +14,12 @@
* @abstract TCPDF - Example: PDF/A-1b mode
* @author Nicola Asuni
* @since 2021-03-26
* @group A-1b
* @group pdf
*/
// Load the autoloader, move one folder back from examples
require_once __DIR__ . '/../vendor/autoload.php';
// 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, true);

View File

@@ -0,0 +1,223 @@
<?php
//============================================================+
// File name : example_067.php
// Begin : 2022-01-07
// Last Update : 2022-01-07
//
// Description : Example 067 for TCPDF class
// HTML tables with !important in style
//
// 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: HTML tables and table headers
* @author Nicola Asuni
* @since 2009-03-20
* @group html
* @group table
* @group pdf
*/
// 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('Owen Leibman');
$pdf->setTitle('TCPDF Example 067');
$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.' 067', 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('helvetica', 'B', 20);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0);
$pdf->setFont('helvetica', '', 8);
// -----------------------------------------------------------------------------
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: 1px dotted red;">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: 1px dashed blue !important;">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: 1px hair black !important;">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: dashed green">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: solid yellow !important">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
// At medium thickness, which is what you get with only one
// setting for style, everything looks the same.
// Included just for completeness.
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" style="border: dashed">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
// -----------------------------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_067.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -85,6 +85,8 @@ echo '<'.'?'.'xml version="1.0" encoding="UTF-8"'.'?'.'>';
<li>Text stretching and spacing (tracking/kerning): [<a href="example_063.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>No-write page regions: [<a href="example_064.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>PDF/A-1b (ISO 19005-1:2005) document: [<a href="example_065.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>Using WriteHTMLCell: [<a href="example_066.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>Shorthand border styles including !important: [<a href="example_067.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
</ol>
<h2>Barcodes</h2>