32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-10-31 18:52:35 +00:00
This commit is contained in:
nicolaasuni 2009-04-25 10:54:01 +02:00
parent 6ab6c9fb0d
commit 48f009ea40
16 changed files with 865 additions and 575 deletions

View File

@ -1,3 +1,8 @@
4.6.005 (2009-04-25)
- Points (pt) conversion in getHTMLUnitToUnits() was fixed.
- Default tcpdf.pem certificate file was added.
- Experimental support for signing document was added but it is not yet completed (some help is needed - I think that the calculation of the ByteRange is OK and the problem is on the signature calculation).
4.6.004 (2009-04-23)
- Method deletePage() was added to delete pages (see example n. 44).

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 4.6.004
Release date: 2009-04-23
Version: 4.6.005
Release date: 2009-04-25
Author: Nicola Asuni
Copyright (c) 2001-2009:

View File

@ -45,7 +45,7 @@
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

File diff suppressed because it is too large Load Diff

View File

@ -1368,7 +1368,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -96,7 +96,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -507,7 +507,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:17 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:53 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -88,7 +88,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:12 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:48 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -65,7 +65,7 @@ Source Location: /tcpdf.php<br /><br />
</div><br /><br />
<h2>Page Details:</h2>
This is a PHP class for generating PDF documents without requiring external extensions.<br /><br /><br /><p>TCPDF project (http://www.tcpdf.org) was originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br /> &lt;h3&gt;TCPDF main features are:&lt;/h3&gt; <ul><li>no external libraries are required for the basic functions;</li><li>supports all ISO page formats;</li><li>supports UTF-8 Unicode and Right-To-Left languages;</li><li>supports document encryption;</li><li>includes methods to publish some XHTML code;</li><li>includes graphic (geometric) and transformation methods;</li><li>includes bookmarks;</li><li>includes Javascript and forms support;</li><li>includes a method to print various barcode formats;</li><li>supports TrueTypeUnicode, TrueType, Type1 and CID-0 fonts;</li><li>supports custom page formats, margins and units of measure;</li><li>includes methods for page header and footer management;</li><li>supports automatic page break;</li><li>supports automatic page numbering and page groups;</li><li>supports automatic line break and text justification;</li><li>supports JPEG and PNG images whitout GD library and all images supported by GD: GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM;</li><li>supports stroke and clipping mode for text;</li><li>supports clipping masks;</li><li>supports Grayscale, RGB and CMYK colors and transparency;</li><li>supports links and annotations;</li><li>supports page compression (requires zlib extension);</li><li>supports PDF user's rights.</li></ul> Tools to encode your unicode fonts are on fonts/utils directory.&lt;/p&gt;</p><br /><br /><br />
This is a PHP class for generating PDF documents without requiring external extensions.<br /><br /><br /><p>TCPDF project (http://www.tcpdf.org) was originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br /> &lt;h3&gt;TCPDF main features are:&lt;/h3&gt; <ul><li>no external libraries are required for the basic functions;</li><li>supports all ISO page formats;</li><li>supports custom page formats, margins and units of measure;</li><li>supports UTF-8 Unicode and Right-To-Left languages;</li><li>supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li><li>supports document encryption;</li><li>includes methods to publish some XHTML code;</li><li>includes graphic (geometric) and transformation methods;</li><li>includes Javascript and forms support;</li><li>includes a method to print various barcode formats: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS;</li><li>includes methods to set Bookmarks and print a Table of Content;</li><li>includes methods to move and delete pages;</li><li>includes methods for automatic page header and footer management;</li><li>supports automatic page break;</li><li>supports automatic page numbering and page groups;</li><li>supports automatic line break and text justification;</li><li>supports JPEG and PNG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)</li><li>supports stroke and clipping mode for text;</li><li>supports clipping masks;</li><li>supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li><li>supports several annotations, including links, text and file attachments;</li><li>supports page compression (requires zlib extension);</li><li>supports text hyphenation.</li><li>supports transactions to UNDO commands.</li></ul> Tools to encode your unicode fonts are on fonts/utils directory.&lt;/p&gt;</p><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
@ -73,7 +73,7 @@ This is a PHP class for generating PDF documents without requiring external exte
<td><b>author:</b>&nbsp;&nbsp;</td><td>Nicola Asuni</td>
</tr>
<tr>
<td><b>version:</b>&nbsp;&nbsp;</td><td>4.6.004</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>4.6.005</td>
</tr>
<tr>
<td><b>copyright:</b>&nbsp;&nbsp;</td><td>2002-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</td>
@ -92,19 +92,19 @@ This is a PHP class for generating PDF documents without requiring external exte
<br /><br />
<h4>Includes:</h4>
<div class="tags">
require_once(dirname(__FILE__).'/config/tcpdf_config.php') [line 131]<br />
main configuration file<br /><br />require_once(dirname(__FILE__).'/htmlcolors.php') [line 143]<br />
html colors table<br /><br />require_once(dirname(__FILE__).'/unicode_data.php') [line 138]<br />
require_once(dirname(__FILE__).'/config/tcpdf_config.php') [line 135]<br />
main configuration file<br /><br />require_once(dirname(__FILE__).'/htmlcolors.php') [line 147]<br />
html colors table<br /><br />require_once(dirname(__FILE__).'/unicode_data.php') [line 142]<br />
unicode data<br /><br /></div>
<br /><br />
<br /><br />
<hr />
<a name="definePDF_PRODUCER"></a>
<h3>PDF_PRODUCER <span class="smalllinenumber">[line 149]</span></h3>
<h3>PDF_PRODUCER <span class="smalllinenumber">[line 153]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>PDF_PRODUCER = 'TCPDF 4.6.004 (http://www.tcpdf.org)'</code>
<code>PDF_PRODUCER = 'TCPDF 4.6.005 (http://www.tcpdf.org)'</code>
</td></tr></table>
</td></tr></table>
@ -115,7 +115,7 @@ unicode data<br /><br /></div>
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:12 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:48 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -237,7 +237,7 @@ Unicode Include file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:17 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:53 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -875,6 +875,12 @@
<div>
<h2>s</h2>
<dl>
<dt><b>$sign</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sign">TCPDF::$sign</a><br>&nbsp;&nbsp;&nbsp;&nbsp;If true enables document signing</dd>
<dt><b>$signature_data</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$signature_data">TCPDF::$signature_data</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature data</dd>
<dt><b>$signature_max_lenght</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$signature_max_lenght">TCPDF::$signature_max_lenght</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature max lenght</dd>
<dt><b>$spot_colors</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$spot_colors">TCPDF::$spot_colors</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Array of Spot colors</dd>
<dt><b>$state</b></dt>
@ -896,9 +902,9 @@
<dt><b>SetAutoPageBreak</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetAutoPageBreak">TCPDF::SetAutoPageBreak()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetBarcode">TCPDF::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set document barcode.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file barcodes.php, method <a href="com-tecnick-tcpdf/TCPDFBarcode.html#methodsetBarcode">TCPDFBarcode::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the barcode.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetBarcode">TCPDF::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set document barcode.</dd>
<dt><b>SetBooklet</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetBooklet">TCPDF::SetBooklet()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the booklet mode for double-sided pages.</dd>
<dt><b>setBuffer</b></dt>
@ -1013,6 +1019,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetRightMargin">TCPDF::SetRightMargin()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Defines the right margin. The method can be called before creating the first page.</dd>
<dt><b>setRTL</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetRTL">TCPDF::setRTL()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Enable or disable Right-To-Left language mode</dd>
<dt><b>setSignature</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetSignature">TCPDF::setSignature()</a></dd>
<dt><b>SetSubject</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetSubject">TCPDF::SetSubject()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Defines the subject of the document.</dd>
<dt><b>setTableHeader</b></dt>
@ -1352,7 +1360,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -1024,6 +1024,12 @@
<div>
<h2>s</h2>
<dl>
<dt><b>$sign</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sign">TCPDF::$sign</a><br>&nbsp;&nbsp;&nbsp;&nbsp;If true enables document signing</dd>
<dt><b>$signature_data</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$signature_data">TCPDF::$signature_data</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature data</dd>
<dt><b>$signature_max_lenght</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$signature_max_lenght">TCPDF::$signature_max_lenght</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature max lenght</dd>
<dt><b>$spot_colors</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$spot_colors">TCPDF::$spot_colors</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Array of Spot colors</dd>
<dt><b>$state</b></dt>
@ -1045,9 +1051,9 @@
<dt><b>SetAutoPageBreak</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetAutoPageBreak">TCPDF::SetAutoPageBreak()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetBarcode">TCPDF::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set document barcode.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file barcodes.php, method <a href="com-tecnick-tcpdf/TCPDFBarcode.html#methodsetBarcode">TCPDFBarcode::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the barcode.</dd>
<dt><b>setBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetBarcode">TCPDF::setBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set document barcode.</dd>
<dt><b>SetBooklet</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetBooklet">TCPDF::SetBooklet()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the booklet mode for double-sided pages.</dd>
<dt><b>setBuffer</b></dt>
@ -1162,6 +1168,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetRightMargin">TCPDF::SetRightMargin()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Defines the right margin. The method can be called before creating the first page.</dd>
<dt><b>setRTL</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetRTL">TCPDF::setRTL()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Enable or disable Right-To-Left language mode</dd>
<dt><b>setSignature</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodsetSignature">TCPDF::setSignature()</a></dd>
<dt><b>SetSubject</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodSetSubject">TCPDF::SetSubject()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Defines the subject of the document.</dd>
<dt><b>setTableHeader</b></dt>
@ -1375,7 +1383,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -35,7 +35,7 @@
<a href="#Post-parsing">Post-parsing</a><br>
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:17 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:53 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -58,7 +58,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.1</a><br />
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -58,7 +58,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.1</a><br />
<div class="credit">
<hr />
Documentation generated on Thu, 23 Apr 2009 10:53:11 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Sat, 25 Apr 2009 10:53:47 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

294
tcpdf.php
View File

@ -2,9 +2,9 @@
//============================================================+
// File name : tcpdf.php
// Begin : 2002-08-03
// Last Update : 2009-04-23
// Last Update : 2009-04-25
// Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org
// Version : 4.6.004
// Version : 4.6.005
// License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2009 Nicola Asuni - Tecnick.com S.r.l.
@ -35,27 +35,29 @@
//
// Main features:
// * no external libraries are required for the basic functions;
// * supports all ISO page formats;
// * supports UTF-8 Unicode and Right-To-Left languages;
// * supports all ISO page formats;
// * supports custom page formats, margins and units of measure;
// * supports UTF-8 Unicode and Right-To-Left languages;
// * supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
// * supports document encryption;
// * includes methods to publish some XHTML code;
// * includes graphic (geometric) and transformation methods;
// * includes bookmarks;
// * includes Javascript and forms support;
// * includes a method to print various barcode formats;
// * supports TrueTypeUnicode, TrueType, Type1 and CID-0 fonts;
// * supports custom page formats, margins and units of measure;
// * includes methods for page header and footer management;
// * includes a method to print various barcode formats: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS;
// * includes methods to set Bookmarks and print a Table of Content;
// * includes methods to move and delete pages;
// * includes methods for automatic page header and footer management;
// * supports automatic page break;
// * supports automatic page numbering and page groups;
// * supports automatic line break and text justification;
// * supports JPEG and PNG images whitout GD library and all images supported by GD: GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM;
// * supports JPEG and PNG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)
// * supports stroke and clipping mode for text;
// * supports clipping masks;
// * supports Grayscale, RGB, CMYK, Spot colors and transparency;
// * supports links and annotations;
// * supports page compression (requires zlib extension);
// * supports PDF user's rights.
// * supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;
// * supports several annotations, including links, text and file attachments;
// * supports page compression (requires zlib extension);
// * supports text hyphenation.
// * supports transactions to UNDO commands.
//
// -----------------------------------------------------------
// THANKS TO:
@ -92,28 +94,30 @@
* TCPDF project (http://www.tcpdf.org) was originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* <h3>TCPDF main features are:</h3>
* <ul>
* <li>no external libraries are required for the basic functions;</li>
* <li>supports all ISO page formats;</li>
* <li>supports UTF-8 Unicode and Right-To-Left languages;</li>
* <li>supports document encryption;</li>
* <li>includes methods to publish some XHTML code;</li>
* <li>includes graphic (geometric) and transformation methods;</li>
* <li>includes bookmarks;</li>
* <li>includes Javascript and forms support;</li>
* <li>includes a method to print various barcode formats;</li>
* <li>supports TrueTypeUnicode, TrueType, Type1 and CID-0 fonts;</li>
* <li>supports custom page formats, margins and units of measure;</li>
* <li>includes methods for page header and footer management;</li>
* <li>supports automatic page break;</li>
* <li>supports automatic page numbering and page groups;</li>
* <li>supports automatic line break and text justification;
* <li>supports JPEG and PNG images whitout GD library and all images supported by GD: GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM;</li>
* <li>supports stroke and clipping mode for text;</li>
* <li>supports clipping masks;</li>
* <li>supports Grayscale, RGB and CMYK colors and transparency;</li>
* <li>supports links and annotations;</li>
* <li>supports page compression (requires zlib extension);</li>
* <li>supports PDF user's rights.</li>
* <li>no external libraries are required for the basic functions;</li>
* <li>supports all ISO page formats;</li>
* <li>supports custom page formats, margins and units of measure;</li>
* <li>supports UTF-8 Unicode and Right-To-Left languages;</li>
* <li>supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li>
* <li>supports document encryption;</li>
* <li>includes methods to publish some XHTML code;</li>
* <li>includes graphic (geometric) and transformation methods;</li>
* <li>includes Javascript and forms support;</li>
* <li>includes a method to print various barcode formats: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS;</li>
* <li>includes methods to set Bookmarks and print a Table of Content;</li>
* <li>includes methods to move and delete pages;</li>
* <li>includes methods for automatic page header and footer management;</li>
* <li>supports automatic page break;</li>
* <li>supports automatic page numbering and page groups;</li>
* <li>supports automatic line break and text justification;</li>
* <li>supports JPEG and PNG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/www/formats.html)</li>
* <li>supports stroke and clipping mode for text;</li>
* <li>supports clipping masks;</li>
* <li>supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
* <li>supports several annotations, including links, text and file attachments;</li>
* <li>supports page compression (requires zlib extension);</li>
* <li>supports text hyphenation.</li>
* <li>supports transactions to UNDO commands.</li>
* </ul>
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
@ -122,7 +126,7 @@
* @copyright 2002-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
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 4.6.004
* @version 4.6.005
*/
/**
@ -146,14 +150,14 @@ if (!class_exists('TCPDF', false)) {
/**
* define default PDF document producer
*/
define('PDF_PRODUCER', 'TCPDF 4.6.004 (http://www.tcpdf.org)');
define('PDF_PRODUCER', 'TCPDF 4.6.005 (http://www.tcpdf.org)');
/**
* This is a PHP class for generating PDF documents without requiring external extensions.<br>
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* @name TCPDF
* @package com.tecnick.tcpdf
* @version 4.6.004
* @version 4.6.005
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1261,8 +1265,28 @@ if (!class_exists('TCPDF', false)) {
* @since 4.5.037 (2009-04-07)
*/
protected $cache_size_UTF8StringToArray = 0;
/**
* If true enables document signing
* @access protected
* @since 4.6.005 (2009-04-24)
*/
protected $sign = false;
/**
* Signature data
* @access protected
* @since 4.6.005 (2009-04-24)
*/
protected $signature_data = array();
/**
* Signature max lenght
* @access protected
* @since 4.6.005 (2009-04-24)
*/
protected $signature_max_lenght = 5120;
//------------------------------------------------------------
// METHODS
//------------------------------------------------------------
@ -1369,7 +1393,8 @@ if (!class_exists('TCPDF', false)) {
$this->fgcolor = array('R' => 0, 'G' => 0, 'B' => 0);
$this->bgcolor = array('R' => 255, 'G' => 255, 'B' => 255);
$this->extgstates = array();
// user's rights
// user's rights
$this->sign = false;
$this->ur = false;
$this->ur_document = '/FullSave';
$this->ur_annots = '/Create/Delete/Modify/Copy/Import/Export';
@ -4910,6 +4935,67 @@ if (!class_exists('TCPDF', false)) {
if ($dest != 'F') {
$name = preg_replace('/[\s]+/', '_', $name);
$name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $name);
}
if ($this->sign) {
// *** apply digital signature to the document (NOT WORKING) ***
// get the document content
$pdfdoc = $this->getBuffer();
// remove last newline
$pdfdoc = substr($pdfdoc, 0, -1);
// Remove the original buffer
if (isset($this->diskcache) AND $this->diskcache) {
// remove buffer file from cache
unlink($this->buffer);
}
unset($this->buffer);
// remove filler space
$tmppos = strpos($pdfdoc, '/ByteRange[0 ********** ********** **********]') + 58;
$pdfdoc = substr($pdfdoc, 0, $tmppos).substr($pdfdoc, $tmppos + $this->signature_max_lenght);
// define the ByteRange
$byte_range = array();
$byte_range[0] = 0;
$byte_range[1] = $tmppos - 1;
$byte_range[2] = $byte_range[1] + $this->signature_max_lenght;
$byte_range[3] = strlen($pdfdoc) - $byte_range[1];
// replace the ByteRange
$byterange = sprintf('/ByteRange[0 %010u %010u %010u]', $byte_range[1], $byte_range[2], $byte_range[3]);
$pdfdoc = str_replace('/ByteRange[0 ********** ********** **********]', $byterange, $pdfdoc);
// write the document to a temporary folder
$tempdoc = tempnam(K_PATH_CACHE, 'tmppdf_');
$f = fopen($tempdoc, 'wb');
if (!$f) {
$this->Error('Unable to create temporary file: '.$tempdoc);
}
$pdfdoc_lenght = strlen($pdfdoc);
fwrite($f, $pdfdoc, $pdfdoc_lenght);
fclose($f);
// get digital signature.
// IS THE FOLLOWING PROCEDURE CORRECT? THE SIGNED DOCUMENTS ARE NOT VALID!
$tempsign = tempnam(K_PATH_CACHE, 'tmpsig_');
if (empty($this->signature_data['extracerts'])) {
openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED);
} else {
openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED, $this->signature_data['extracerts']);
}
unlink($tempdoc);
// read signature
$signature = file_get_contents($tempsign, false, null, $pdfdoc_lenght);
unlink($tempsign);
// extract signature
$signature = substr($signature, (strpos($signature, "%%EOF\n\n------") + 13));
$tmparr = explode("\n\n", $signature);
$signature = $tmparr[1];
unset($tmparr);
// decode signature
$signature = base64_decode(trim($signature));
// convert signature to hex
$signature = current(unpack('H*', $signature));
$signature = str_pad($signature, $this->signature_max_lenght, '0');
// Add signature to the document
$pdfdoc = substr($pdfdoc, 0, $byte_range[1]).$signature.substr($pdfdoc, (0 - $byte_range[3]));
$this->diskcache = false;
$this->buffer = &$pdfdoc;
$this->bufferlen = strlen($pdfdoc);
}
switch($dest) {
case 'I': {
@ -4996,7 +5082,16 @@ if (!class_exists('TCPDF', false)) {
unlink($this->buffer);
}
foreach (array_keys(get_object_vars($this)) as $val) {
if ($destroyall OR (($val != 'internal_encoding') AND ($val != 'state') AND ($val != 'bufferlen') AND ($val != 'buffer') AND ($val != 'diskcache'))) {
if ($destroyall OR (
($val != 'internal_encoding')
AND ($val != 'state')
AND ($val != 'bufferlen')
AND ($val != 'buffer')
AND ($val != 'diskcache')
AND ($val != 'sign')
AND ($val != 'signature_data')
AND ($val != 'signature_max_lenght')
)) {
if (!$preserve_objcopy OR ($val != 'objcopy')) {
unset($this->$val);
}
@ -6117,7 +6212,6 @@ if (!class_exists('TCPDF', false)) {
$v = $this->n_ocg_view.' 0 R';
$as = '<</Event /Print /OCGs ['.$p.' '.$v.'] /Category [/Print]>> <</Event /View /OCGs ['.$p.' '.$v.'] /Category [/View]>>';
$this->_out('/OCProperties <</OCGs ['.$p.' '.$v.'] /D <</ON ['.$p.'] /OFF ['.$v.'] /AS ['.$as.']>>>>');
$this->_putuserrights();
}
/**
@ -6232,7 +6326,8 @@ if (!class_exists('TCPDF', false)) {
//Catalog
$this->_newobj();
$this->_out('<<');
$this->_putcatalog();
$this->_putcatalog();
$this->_putuserrights();
$this->_out('>>');
$this->_out('endobj');
//Cross-ref
@ -9067,57 +9162,58 @@ if (!class_exists('TCPDF', false)) {
/*
* Enable Write permissions for PDF Reader.
* (EXPERIMENTAL - ONLY WORKS WITH SOME ACROBAT READER VERSIONS)
* TO BE COMPLETED
* (EXPERIMENTAL - NOT WORKING)
* @access protected
* @author Nicola Asuni
* @since 2.9.000 (2008-03-26)
*/
protected function _putuserrights() {
if (!$this->ur) {
protected function _putuserrights() {
if (!$this->sign) {
return;
}
$this->_out('/Perms');
$this->_out('<<');
$this->_out('/UR3');
$this->_out('<<');
$this->_out('<<');
$this->_out('/Type/Sig');
$this->_out('/Filter/Adobe.PPKLite');
$this->_out('/SubFilter/adbe.pkcs7.detached');
$this->_out('/Name(TCPDF)');
$this->_out('/ByteRange[0 0 0 0]');
$this->_out('/Contents<>');
$this->_out('/M '.$this->_datastring('D:'.date('YmdHis')));
$this->_out('/Reference');
$this->_out('[');
$this->_out('<<');
$this->_out('/Type/SigRef');
$this->_out('/TransformMethod/UR3');
$this->_out('/TransformParams');
$this->_out('<<');
$this->_out('/Type/TransformParams');
$this->_out('/V/2.2');
if (!$this->empty_string($this->ur_document)) {
$this->_out('/Document['.$this->ur_document.']');
}
if (!$this->empty_string($this->ur_annots)) {
$this->_out('/Annots['.$this->ur_annots.']');
}
if (!$this->empty_string($this->ur_form)) {
$this->_out('/Form['.$this->ur_form.']');
}
if (!$this->empty_string($this->ur_signature)) {
$this->_out('/Signature['.$this->ur_signature.']');
}
$this->_out('>>');
$this->_out('>>');
$this->_out(']');
$this->_out('/ByteRange[0 ********** ********** **********]');
$this->_out('/Contents<>'.str_repeat(' ', $this->signature_max_lenght));
if ($this->ur) {
$this->_out('/Reference');
$this->_out('[');
$this->_out('<<');
$this->_out('/Type/SigRef');
$this->_out('/TransformMethod/UR3');
$this->_out('/TransformParams');
$this->_out('<<');
$this->_out('/Type/TransformParams');
$this->_out('/V/2.2');
if (!$this->empty_string($this->ur_document)) {
$this->_out('/Document['.$this->ur_document.']');
}
if (!$this->empty_string($this->ur_annots)) {
$this->_out('/Annots['.$this->ur_annots.']');
}
if (!$this->empty_string($this->ur_form)) {
$this->_out('/Form['.$this->ur_form.']');
}
if (!$this->empty_string($this->ur_signature)) {
$this->_out('/Signature['.$this->ur_signature.']');
}
$this->_out('>>');
$this->_out('>>');
$this->_out(']');
}
$this->_out('/M '.$this->_datastring('D:'.date('YmdHisO')));
$this->_out('>>');
$this->_out('>>');
}
/*
* Set User's Rights for PDF Reader
* Set User's Rights for PDF Reader
* (EXPERIMENTAL - NOT WORKING)
* Check the PDF Reference 8.7.1 Transform Methods,
* Table 8.105 Entries in the UR transform parameters dictionary
* @param boolean $enable if true enable user's rights on PDF reader
@ -9139,8 +9235,39 @@ if (!class_exists('TCPDF', false)) {
$this->ur_document = $document;
$this->ur_annots = $annots;
$this->ur_form = $form;
$this->ur_signature = $signature;
}
$this->ur_signature = $signature;
if ($this->ur) {
$this->setSignature();
}
}
/*
* Enable document signature (requires the OpenSSL Library).
* (EXPERIMENTAL - NOT WORKING)
* The digital signature improve document authenticity and integrity and allows o enable extra features on Acrobat Reader.
* @param mixed $signing_cert signing certificate (string or filename prefixed with 'file://')
* @param mixed $private_key private key (string or filename prefixed with 'file://')
* @param string $private_key_password password
* @param string $extracerts specifies the name of a file containing a bunch of extra certificates to include in the signature which can for example be used to help the recipient to verify the certificate that you used.
* @access public
* @author Nicola Asuni
* @since 4.6.005 (2009-04-24)
*/
public function setSignature($signing_cert='', $private_key='', $private_key_password='', $extracerts='') {
// to create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.pem -out tcpdf.pem
$this->sign = true;
$this->signature_data = array();
if (strlen($signing_cert) == 0) {
$signing_cert = 'file://'.dirname(__FILE__).'/tcpdf.pem';
}
if (strlen($private_key) == 0) {
$private_key = $signing_cert;
}
$this->signature_data['signcert'] = $signing_cert;
$this->signature_data['privkey'] = $private_key;
$this->signature_data['password'] = $private_key_password;
$this->signature_data['extracerts'] = $extracerts;
}
/*
* Create a new page group.
@ -12683,8 +12810,11 @@ if (!class_exists('TCPDF', false)) {
$retval = ($value * 12) / $k;
break;
}
case 'px':
case 'pt': {
$retval = $value / $k;
break;
}
case 'px': {
$retval = $this->pixelsToUnits($value);
break;
}