32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-22 12:55:10 +00:00
This commit is contained in:
nicolaasuni 2010-10-19 17:46:03 +02:00
parent 7eb4f30e7b
commit 43926c7bde
24 changed files with 823 additions and 510 deletions

View File

@ -1,3 +1,7 @@
5.9.006 (2010-10-16)
- Support for AES 256 bit encryption was added (see example n. 16).
- Method getNumLines() was fixed for the empty string case.
5.9.005 (2010-10-18)
- Method addPageRegion() was changed to accept regions starting exactly from the top of the page.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 5.9.005
Release date: 2010-10-18
Version: 5.9.006
Release date: 2010-10-19
Author: Nicola Asuni
Copyright (c) 2002-2010:
@ -39,7 +39,7 @@ Main Features:
* 1D and 2D barcodes: 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, QR-Code, PDF417;
* Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* automatic page header and footer management;
* document encryption and digital signature certifications;
* document encryption up to 256 bit and digital signature certifications;
* transactions to UNDO commands;
* PDF annotations, including links, text and file attachments;
* text rendering modes (fill, stroke and clipping);

View File

@ -65,7 +65,7 @@
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -1004,7 +1004,7 @@ $code)</code>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -5552,7 +5552,7 @@ $frame)</code>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

File diff suppressed because it is too large Load Diff

View File

@ -300,7 +300,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -1378,7 +1378,7 @@ $type)</code>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -18704,7 +18704,7 @@ This is a PHP class containing Unicde data for TCPDF library<br /><br /><br /><b
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:31:05 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:57 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -106,7 +106,7 @@ PHP class to creates array representations for 2D barcodes to be used with TCPDF
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -106,7 +106,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -543,7 +543,7 @@ Configuration file for TCPDF.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:31:05 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:57 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -98,7 +98,7 @@ Array of WEB safe colors.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -158,7 +158,7 @@ Class to create PDF417 barcode arrays for TCPDF class.<br /><br /><p>PDF417 (ISO
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -481,7 +481,7 @@ string $string, [int $split_length = 1])</code>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:59 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:51 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -75,7 +75,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>all standard page formats, custom page formats, custom margins and units of measure;</li><li>UTF-8 Unicode and Right-To-Left languages;</li><li>TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li><li>font subsetting;</li><li>methods to publish some XHTML + CSS code, Javascript and Forms;</li><li>images, graphic (geometric figures) and transformation methods;</li><li>supports JPEG, PNG and SVG 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>1D and 2D barcodes: 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, QR-Code, PDF417;</li><li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li><li>automatic page header and footer management;</li><li>document encryption and digital signature certifications;</li><li>transactions to UNDO commands;</li><li>PDF annotations, including links, text and file attachments;</li><li>text rendering modes (fill, stroke and clipping);</li><li>multiple columns mode;</li><li>no-write page regions;</li><li>bookmarks and table of content;</li><li>text hyphenation;</li><li>text stretching and spacing (tracking/kerning);</li><li>automatic page break, line break and text alignments including justification;</li><li>automatic page numbering and page groups;</li><li>move and delete pages;</li><li>page compression (requires php-zlib extension);</li><li>XOBject Templates;</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>all standard page formats, custom page formats, custom margins and units of measure;</li><li>UTF-8 Unicode and Right-To-Left languages;</li><li>TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;</li><li>font subsetting;</li><li>methods to publish some XHTML + CSS code, Javascript and Forms;</li><li>images, graphic (geometric figures) and transformation methods;</li><li>supports JPEG, PNG and SVG 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>1D and 2D barcodes: 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, QR-Code, PDF417;</li><li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li><li>automatic page header and footer management;</li><li>document encryption up to 256 bit and digital signature certifications;</li><li>transactions to UNDO commands;</li><li>PDF annotations, including links, text and file attachments;</li><li>text rendering modes (fill, stroke and clipping);</li><li>multiple columns mode;</li><li>no-write page regions;</li><li>bookmarks and table of content;</li><li>text hyphenation;</li><li>text stretching and spacing (tracking/kerning);</li><li>automatic page break, line break and text alignments including justification;</li><li>automatic page numbering and page groups;</li><li>move and delete pages;</li><li>page compression (requires php-zlib extension);</li><li>XOBject Templates;</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">
@ -83,7 +83,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>5.9.005</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>5.9.006</td>
</tr>
<tr>
<td><b>copyright:</b>&nbsp;&nbsp;</td><td>2002-2010 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>
@ -112,7 +112,7 @@ main configuration file<br /><br /><p>(define the K_TCPDF_EXTERNAL_CONFIG consta
<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 5.9.005 (http://www.tcpdf.org)'</code>
<code>PDF_PRODUCER = 'TCPDF 5.9.006 (http://www.tcpdf.org)'</code>
</td></tr></table>
</td></tr></table>
@ -123,7 +123,7 @@ main configuration file<br /><br /><p>(define the K_TCPDF_EXTERNAL_CONFIG consta
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:31:00 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:52 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -103,7 +103,7 @@ Unicode data class for TCPDF library.<br /><br /><br /><br />
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:31:05 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:57 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -570,13 +570,13 @@
<dt><b>getBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetBarcode">TCPDF::getBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Get current barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file 2dbarcodes.php, method <a href="com-tecnick-tcpdf/TCPDF2DBarcode.html#methodgetBarcodeArray">TCPDF2DBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file barcodes.php, method <a href="com-tecnick-tcpdf/TCPDFBarcode.html#methodgetBarcodeArray">TCPDFBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBarcodeArray">QRcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file pdf417.php, method <a href="com-tecnick-tcpdf/PDF417.html#methodgetBarcodeArray">PDF417::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file 2dbarcodes.php, method <a href="com-tecnick-tcpdf/TCPDF2DBarcode.html#methodgetBarcodeArray">TCPDF2DBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBarcodeArray">QRcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBitStream</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBitStream">QRcode::getBitStream()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a stream of bits.</dd>
<dt><b>getBorderMode</b></dt>
@ -743,6 +743,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetPathPaintOperator">TCPDF::getPathPaintOperator()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Get the Path-Painting Operators.</dd>
<dt><b>getPDFData</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetPDFData">TCPDF::getPDFData()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the PDF data.</dd>
<dt><b>getRandomSeed</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetRandomSeed">TCPDF::getRandomSeed()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a string containing random data to be used as a seed for encryption methods.</dd>
<dt><b>getRawCharWidth</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetRawCharWidth">TCPDF::getRawCharWidth()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the length of the char in user unit for the current font.</dd>
<dt><b>getRemainder</b></dt>
@ -1985,6 +1987,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_escape">TCPDF::_escape()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Add &quot;\&quot; before &quot;\&quot;, &quot;(&quot; and &quot;)&quot;</dd>
<dt><b>_escapetext</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_escapetext">TCPDF::_escapetext()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;THIS METHOD IS DEPRECATED</dd>
<dt><b>_fixAES256Password</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_fixAES256Password">TCPDF::_fixAES256Password()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert password for AES-256 encryption mode</dd>
<dt><b>_freadint</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_freadint">TCPDF::_freadint()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Read a 4-byte (32 bit) integer from file.</dd>
<dt><b>_generateencryptionkey</b></dt>
@ -2021,6 +2025,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_newobj">TCPDF::_newobj()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Begin a new object and return the object number.</dd>
<dt><b>_objectkey</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_objectkey">TCPDF::_objectkey()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute encryption key depending on object number where the encrypted data is stored.</dd>
<dt><b>_OEvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_OEvalue">TCPDF::_OEvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute OE value (used for encryption)</dd>
<dt><b>_out</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_out">TCPDF::_out()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Output a string to the document.</dd>
<dt><b>_outCurve</b></dt>
@ -2096,7 +2102,7 @@
<dt><b>_putxobjects</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_putxobjects">TCPDF::_putxobjects()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Output Form XObjects Templates.</dd>
<dt><b>_RC4</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_RC4">TCPDF::_RC4()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the input text exrypted using RC4 algorithm and the specified key.</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_RC4">TCPDF::_RC4()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the input text encrypted using RC4 algorithm and the specified key.</dd>
<dt><b>_setGDImageTransparency</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_setGDImageTransparency">TCPDF::_setGDImageTransparency()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the transparency for the given GD image.</dd>
<dt><b>_textstring</b></dt>
@ -2105,6 +2111,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_toJPEG">TCPDF::_toJPEG()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert the loaded image to a JPEG and then return a structure for the PDF creator.</dd>
<dt><b>_toPNG</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_toPNG">TCPDF::_toPNG()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert the loaded image to a PNG and then return a structure for the PDF creator.</dd>
<dt><b>_UEvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_UEvalue">TCPDF::_UEvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute UE value (used for encryption)</dd>
<dt><b>_Uvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_Uvalue">TCPDF::_Uvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute U value (used for encryption)</dd>
<dt><b>__construct</b></dt>
@ -2124,7 +2132,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -134,6 +134,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_escape">TCPDF::_escape()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Add &quot;\&quot; before &quot;\&quot;, &quot;(&quot; and &quot;)&quot;</dd>
<dt><b>_escapetext</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_escapetext">TCPDF::_escapetext()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;THIS METHOD IS DEPRECATED</dd>
<dt><b>_fixAES256Password</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_fixAES256Password">TCPDF::_fixAES256Password()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert password for AES-256 encryption mode</dd>
<dt><b>_freadint</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_freadint">TCPDF::_freadint()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Read a 4-byte (32 bit) integer from file.</dd>
<dt><b>_generateencryptionkey</b></dt>
@ -170,6 +172,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_newobj">TCPDF::_newobj()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Begin a new object and return the object number.</dd>
<dt><b>_objectkey</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_objectkey">TCPDF::_objectkey()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute encryption key depending on object number where the encrypted data is stored.</dd>
<dt><b>_OEvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_OEvalue">TCPDF::_OEvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute OE value (used for encryption)</dd>
<dt><b>_out</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_out">TCPDF::_out()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Output a string to the document.</dd>
<dt><b>_outCurve</b></dt>
@ -245,7 +249,7 @@
<dt><b>_putxobjects</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_putxobjects">TCPDF::_putxobjects()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Output Form XObjects Templates.</dd>
<dt><b>_RC4</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_RC4">TCPDF::_RC4()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the input text exrypted using RC4 algorithm and the specified key.</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_RC4">TCPDF::_RC4()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the input text encrypted using RC4 algorithm and the specified key.</dd>
<dt><b>_setGDImageTransparency</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_setGDImageTransparency">TCPDF::_setGDImageTransparency()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Set the transparency for the given GD image.</dd>
<dt><b>_textstring</b></dt>
@ -254,6 +258,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_toJPEG">TCPDF::_toJPEG()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert the loaded image to a JPEG and then return a structure for the PDF creator.</dd>
<dt><b>_toPNG</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_toPNG">TCPDF::_toPNG()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Convert the loaded image to a PNG and then return a structure for the PDF creator.</dd>
<dt><b>_UEvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_UEvalue">TCPDF::_UEvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute UE value (used for encryption)</dd>
<dt><b>_Uvalue</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_Uvalue">TCPDF::_Uvalue()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Compute U value (used for encryption)</dd>
<dt><b>__construct</b></dt>
@ -771,13 +777,13 @@
<dt><b>getBarcode</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetBarcode">TCPDF::getBarcode()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Get current barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file 2dbarcodes.php, method <a href="com-tecnick-tcpdf/TCPDF2DBarcode.html#methodgetBarcodeArray">TCPDF2DBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file barcodes.php, method <a href="com-tecnick-tcpdf/TCPDFBarcode.html#methodgetBarcodeArray">TCPDFBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBarcodeArray">QRcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file pdf417.php, method <a href="com-tecnick-tcpdf/PDF417.html#methodgetBarcodeArray">PDF417::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file 2dbarcodes.php, method <a href="com-tecnick-tcpdf/TCPDF2DBarcode.html#methodgetBarcodeArray">TCPDF2DBarcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Return an array representations of barcode.</dd>
<dt><b>getBarcodeArray</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBarcodeArray">QRcode::getBarcodeArray()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a barcode array which is readable by TCPDF</dd>
<dt><b>getBitStream</b></dt>
<dd>in file qrcode.php, method <a href="com-tecnick-tcpdf/QRcode.html#methodgetBitStream">QRcode::getBitStream()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a stream of bits.</dd>
<dt><b>getBorderMode</b></dt>
@ -944,6 +950,8 @@
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetPathPaintOperator">TCPDF::getPathPaintOperator()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Get the Path-Painting Operators.</dd>
<dt><b>getPDFData</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetPDFData">TCPDF::getPDFData()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the PDF data.</dd>
<dt><b>getRandomSeed</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetRandomSeed">TCPDF::getRandomSeed()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a string containing random data to be used as a seed for encryption methods.</dd>
<dt><b>getRawCharWidth</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#methodgetRawCharWidth">TCPDF::getRawCharWidth()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns the length of the char in user unit for the current font.</dd>
<dt><b>getRemainder</b></dt>
@ -2157,7 +2165,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -33,9 +33,13 @@
<table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">
<a href="#Post-parsing">Post-parsing</a><br>
<a name="tcpdf.php"></a>
<h1>tcpdf.php</h1>
<h2>Warnings:</h2><br>
<b>Warning on line 11406</b> - Unknown tag "@seed" used<br>
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:31:05 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:57 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -68,7 +68,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -68,7 +68,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Mon, 18 Oct 2010 21:30:58 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 19 Oct 2010 17:45:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>

View File

@ -2,7 +2,7 @@
//============================================================+
// File name : example_016.php
// Begin : 2008-03-04
// Last Update : 2010-08-08
// Last Update : 2010-10-19
//
// Description : Example 016 for TCPDF class
// Document Encryption / Security
@ -53,12 +53,13 @@ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',
If you don't set any password, the document will open as usual.
If you set a user password, the PDF viewer will ask for it before displaying the document.
The master (owner) password, if different from the user one, can be used to get full access.
The master (owner) password, if different from the user one, can be used to get full document access.
Possible encryption modes are:
- 0 = RSA 40 bit
- 1 = RSA 128 bit
- 2 = AES 128 bit
0 = RSA 40 bit
1 = RSA 128 bit
2 = AES 128 bit
3 = AES 256 bit
NOTES:
- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt

364
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 5.9.005
// Version : 5.9.006
// Begin : 2002-08-03
// Last Update : 2010-10-18
// Last Update : 2010-10-19
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -48,7 +48,7 @@
// * 1D and 2D barcodes: 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, QR-Code, PDF417;
// * Grayscale, RGB, CMYK, Spot Colors and Transparencies;
// * automatic page header and footer management;
// * document encryption and digital signature certifications;
// * document encryption up to 256 bit and digital signature certifications;
// * transactions to UNDO commands;
// * PDF annotations, including links, text and file attachments;
// * text rendering modes (fill, stroke and clipping);
@ -112,7 +112,7 @@
* <li>1D and 2D barcodes: 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, QR-Code, PDF417;</li>
* <li>Grayscale, RGB, CMYK, Spot Colors and Transparencies;</li>
* <li>automatic page header and footer management;</li>
* <li>document encryption and digital signature certifications;</li>
* <li>document encryption up to 256 bit and digital signature certifications;</li>
* <li>transactions to UNDO commands;</li>
* <li>PDF annotations, including links, text and file attachments;</li>
* <li>text rendering modes (fill, stroke and clipping);</li>
@ -134,7 +134,7 @@
* @copyright 2002-2010 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 5.9.005
* @version 5.9.006
*/
/**
@ -146,14 +146,14 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
/**
* define default PDF document producer
*/
define('PDF_PRODUCER', 'TCPDF 5.9.005 (http://www.tcpdf.org)');
define('PDF_PRODUCER', 'TCPDF 5.9.006 (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 5.9.005
* @version 5.9.006
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1880,7 +1880,7 @@ class TCPDF {
}
$this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
// set file ID for trailer
$this->file_id = md5(microtime().__FILE__.'TCPDF'.$orientation.$unit.$format.$encoding.uniqid(''.rand()));
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
// get default graphic vars
$this->default_graphic_vars = $this->getGraphicVars();
}
@ -6325,6 +6325,10 @@ class TCPDF {
* @since 4.5.011
*/
public function getNumLines($txt, $w=0, $reseth=false, $autopadding=true, $cellpadding='', $border=0) {
if ($txt === '') {
// empty string
return 1;
}
// adjust internal padding
$prev_cell_padding = $this->cell_padding;
$prev_lasth = $this->lasth;
@ -11392,19 +11396,62 @@ class TCPDF {
// ENCRYPTION METHODS ----------------------------------
/**
* Returns a string containing random data to be used as a seed for encryption methods.
* @seed string starting seed value
* @return string containing random data
* @author Nicola Asuni
* @since 5.9.006 (2010-10-19)
* @access protected
*/
protected function getRandomSeed($seed='') {
$seed .= microtime();
if (function_exists('openssl_random_pseudo_bytes')) {
$seed .= openssl_random_pseudo_bytes(512);
}
$seed .= uniqid('', true);
$seed .= rand();
$seed .= getmypid();
$seed .= __FILE__;
$seed .= $this->bufferlen;
if (isset($_SERVER['REMOTE_ADDR'])) {
$seed .= $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$seed .= $_SERVER['HTTP_USER_AGENT'];
}
if (isset($_SERVER['HTTP_ACCEPT'])) {
$seed .= $_SERVER['HTTP_ACCEPT'];
}
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
$seed .= $_SERVER['HTTP_ACCEPT_ENCODING'];
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$seed .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
$seed .= $_SERVER['HTTP_ACCEPT_CHARSET'];
}
$seed .= rand();
$seed .= uniqid('', true);
$seed .= microtime();
return $seed;
}
/**
* Compute encryption key depending on object number where the encrypted data is stored.
* This is used for all strings and streams without crypt filter specifier.
* @param int $n object number
* @return int object key
* @access protected
* @author Nicola Asuni
* @since 2.0.000 (2008-01-02)
*/
protected function _objectkey($n) {
$objkey = $this->encryptdata['key'].pack('VXxx', $n);
if ($this->encryptdata['mode'] == 2) {
if ($this->encryptdata['mode'] == 2) { // AES-128
// AES padding
$objkey .= "\x73\x41\x6C\x54";
$objkey .= "\x73\x41\x6C\x54"; // sAlT
}
$objkey = substr($this->_md5_16($objkey), 0, (($this->encryptdata['Length'] / 8) + 5));
$objkey = substr($objkey, 0, 16);
@ -11415,6 +11462,7 @@ class TCPDF {
* Encrypt the input string.
* @param int $n object number
* @param string $s data string to encrypt
* @return encrypted string
* @access protected
* @author Nicola Asuni
* @since 5.0.005 (2010-05-11)
@ -11424,15 +11472,19 @@ class TCPDF {
return $s;
}
switch ($this->encryptdata['mode']) {
case 0: // RC4 40 bit
case 1: { // RC4 128 bit
case 0: // RC4-40
case 1: { // RC4-128
$s = $this->_RC4($this->_objectkey($n), $s);
break;
}
case 2: { // AES 128 bit
case 2: { // AES-128
$s = $this->_AES($this->_objectkey($n), $s);
break;
}
case 3: { // AES-256
$s = $this->_AES($this->encryptdata['key'], $s);
break;
}
}
return $s;
}
@ -11461,16 +11513,13 @@ class TCPDF {
}
// V is a code specifying the algorithm to be used in encrypting and decrypting the document
$out .= ' /V '.$this->encryptdata['V'];
if ($this->encryptdata['V'] == 1) {
if (isset($this->encryptdata['Length']) AND !empty($this->encryptdata['Length'])) {
// The length of the encryption key, in bits. The value shall be a multiple of 8, in the range 40 to 256
$out .= ' /Length '.$this->encryptdata['Length'];
} else {
$out .= ' /Length 40';
} elseif (($this->encryptdata['V'] == 2) OR ($this->encryptdata['V'] == 3)) {
if (isset($this->encryptdata['Length']) AND !empty($this->encryptdata['Length'])) {
// The length of the encryption key, in bits. The value shall be a multiple of 8, in the range 40 to 128
$out .= ' /Length '.$this->encryptdata['Length'];
} else {
$out .= ' /Length 40';
}
} elseif ($this->encryptdata['V'] == 4) {
}
if ($this->encryptdata['V'] >= 4) {
if (!isset($this->encryptdata['StmF']) OR empty($this->encryptdata['StmF'])) {
$this->encryptdata['StmF'] = 'Identity';
}
@ -11533,11 +11582,16 @@ class TCPDF {
}
} else {
$out .= ' /R';
if ($this->encryptdata['V'] == 4) {
if ($this->encryptdata['V'] == 5) { // AES-256
$out .= ' 5';
$out .= ' /OE ('.$this->_escape($this->encryptdata['OE']).')';
$out .= ' /UE ('.$this->_escape($this->encryptdata['UE']).')';
$out .= ' /Perms ('.$this->_escape($this->encryptdata['perms']).')';
} elseif ($this->encryptdata['V'] == 4) { // AES-128
$out .= ' 4';
} elseif ($this->encryptdata['V'] < 2) {
} elseif ($this->encryptdata['V'] < 2) { // RC-40
$out .= ' 2';
} else {
} else { // RC-128
$out .= ' 3';
}
$out .= ' /O ('.$this->_escape($this->encryptdata['O']).')';
@ -11555,7 +11609,7 @@ class TCPDF {
}
/**
* Returns the input text exrypted using RC4 algorithm and the specified key.
* Returns the input text encrypted using RC4 algorithm and the specified key.
* RC4 is the standard encryption algorithm used in PDF format
* @param string $key encryption key
* @param String $text input text to be encrypted
@ -11632,103 +11686,187 @@ class TCPDF {
return pack('H*', md5($str));
}
/**
* Compute O value (used for encryption)
* @param String $user_pass user password
* @param String $owner_pass user password
* @return String O value
* @access protected
* @since 2.0.000 (2008-01-02)
* @author Nicola Asuni
*/
protected function _Ovalue($user_pass, $owner_pass) {
$tmp = $this->_md5_16($owner_pass);
if ($this->encryptdata['mode'] > 0) {
for ($i = 0; $i < 50; ++$i) {
$tmp = $this->_md5_16($tmp);
}
}
$owner_key = substr($tmp, 0, ($this->encryptdata['Length'] / 8));
$enc = $this->_RC4($owner_key, $user_pass);
if ($this->encryptdata['mode'] > 0) {
$len = strlen($owner_key);
for ($i = 1; $i <= 19; ++$i) {
$ek = '';
for ($j = 0; $j < $len; ++$j) {
$ek .= chr(ord($owner_key{$j}) ^ $i);
}
$enc = $this->_RC4($ek, $enc);
}
}
return $enc;
}
/**
* Compute U value (used for encryption)
* @return String U value
* @return string U value
* @access protected
* @since 2.0.000 (2008-01-02)
* @author Nicola Asuni
*/
protected function _Uvalue() {
if ($this->encryptdata['mode'] == 0) {
if ($this->encryptdata['mode'] == 0) { // RC4-40
return $this->_RC4($this->encryptdata['key'], $this->enc_padding);
}
$tmp = $this->_md5_16($this->enc_padding.$this->encryptdata['fileid']);
$enc = $this->_RC4($this->encryptdata['key'], $tmp);
$len = strlen($tmp);
for ($i = 1; $i <= 19; ++$i) {
$ek = '';
for ($j = 0; $j < $len; ++$j) {
$ek .= chr(ord($this->encryptdata['key']{$j}) ^ $i);
} elseif ($this->encryptdata['mode'] < 3) { // RC4-128, AES-128
$tmp = $this->_md5_16($this->enc_padding.$this->encryptdata['fileid']);
$enc = $this->_RC4($this->encryptdata['key'], $tmp);
$len = strlen($tmp);
for ($i = 1; $i <= 19; ++$i) {
$ek = '';
for ($j = 0; $j < $len; ++$j) {
$ek .= chr(ord($this->encryptdata['key']{$j}) ^ $i);
}
$enc = $this->_RC4($ek, $enc);
}
$enc = $this->_RC4($ek, $enc);
$enc .= str_repeat("\x00", 16);
return substr($enc, 0, 32);
} elseif ($this->encryptdata['mode'] == 3) { // AES-256
$seed = $this->_md5_16($this->getRandomSeed());
// User Validation Salt
$this->encryptdata['UVS'] = substr($seed, 0, 8);
// User Key Salt
$this->encryptdata['UKS'] = substr($seed, 8, 16);
return hash('sha256', $this->encryptdata['user_password'].$this->encryptdata['UVS'], true).$this->encryptdata['UVS'].$this->encryptdata['UKS'];
}
$enc .= str_repeat("\x00", 16);
return substr($enc, 0, 32);
}
/**
* Compute encryption key
* @param String $user_pass user password
* @param String $owner_pass user password
* @param String $protection protection type
* Compute UE value (used for encryption)
* @return string UE value
* @access protected
* @since 5.9.006 (2010-10-19)
* @author Nicola Asuni
*/
protected function _UEvalue() {
$hashkey = hash('sha256', $this->encryptdata['user_password'].$this->encryptdata['UKS'], true);
$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata['key'], MCRYPT_MODE_CBC, $iv);
}
/**
* Compute O value (used for encryption)
* @return string O value
* @access protected
* @since 2.0.000 (2008-01-02)
* @author Nicola Asuni
*/
protected function _generateencryptionkey($user_pass, $owner_pass, $protection) {
$keybytelen = ($this->encryptdata['Length'] / 8);
if (!$this->encryptdata['pubkey']) { // standard mode
// Pad passwords
$user_pass = substr($user_pass.$this->enc_padding, 0, 32);
$owner_pass = substr($owner_pass.$this->enc_padding, 0, 32);
// Compute O value
$this->encryptdata['O'] = $this->_Ovalue($user_pass, $owner_pass);
// get default permissions (reverse byte order)
$permissions = $this->getEncPermissionsString($protection);
// Compute encryption key
$tmp = $this->_md5_16($user_pass.$this->encryptdata['O'].$permissions.$this->encryptdata['fileid']);
protected function _Ovalue() {
if ($this->encryptdata['mode'] < 3) { // RC4-40, RC4-128, AES-128
$tmp = $this->_md5_16($this->encryptdata['owner_password']);
if ($this->encryptdata['mode'] > 0) {
for ($i = 0; $i < 50; ++$i) {
$tmp = $this->_md5_16(substr($tmp, 0, $keybytelen));
$tmp = $this->_md5_16($tmp);
}
}
$this->encryptdata['key'] = substr($tmp, 0, $keybytelen);
// Compute U value
$this->encryptdata['U'] = $this->_Uvalue();
// Compute P value
$this->encryptdata['P'] = $protection;
$owner_key = substr($tmp, 0, ($this->encryptdata['Length'] / 8));
$enc = $this->_RC4($owner_key, $this->encryptdata['user_password']);
if ($this->encryptdata['mode'] > 0) {
$len = strlen($owner_key);
for ($i = 1; $i <= 19; ++$i) {
$ek = '';
for ($j = 0; $j < $len; ++$j) {
$ek .= chr(ord($owner_key{$j}) ^ $i);
}
$enc = $this->_RC4($ek, $enc);
}
}
return $enc;
} elseif ($this->encryptdata['mode'] == 3) { // AES-256
$seed = $this->_md5_16($this->getRandomSeed());
// Owner Validation Salt
$this->encryptdata['OVS'] = substr($seed, 0, 8);
// Owner Key Salt
$this->encryptdata['OKS'] = substr($seed, 8, 16);
return hash('sha256', $this->encryptdata['owner_password'].$this->encryptdata['OVS'].$this->encryptdata['U'], true).$this->encryptdata['OVS'].$this->encryptdata['OKS'];
}
}
/**
* Compute OE value (used for encryption)
* @return string OE value
* @access protected
* @since 5.9.006 (2010-10-19)
* @author Nicola Asuni
*/
protected function _OEvalue() {
$hashkey = hash('sha256', $this->encryptdata['owner_password'].$this->encryptdata['OKS'].$this->encryptdata['U'], true);
$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $hashkey, $this->encryptdata['key'], MCRYPT_MODE_CBC, $iv);
}
/**
* Convert password for AES-256 encryption mode
* @return string password
* @access protected
* @since 5.9.006 (2010-10-19)
* @author Nicola Asuni
*/
protected function _fixAES256Password($password) {
$psw = ''; // password to be returned
$psw_array = $this->utf8Bidi($this->UTF8StringToArray($password), $password, $this->rtl);
foreach ($psw_array as $c) {
$psw .= $this->unichr($c);
}
return substr($psw, 0, 127);
}
/**
* Compute encryption key
* @access protected
* @since 2.0.000 (2008-01-02)
* @author Nicola Asuni
*/
protected function _generateencryptionkey() {
$keybytelen = ($this->encryptdata['Length'] / 8);
if (!$this->encryptdata['pubkey']) { // standard mode
if ($this->encryptdata['mode'] == 3) { // AES-256
// generate 256 bit random key
$this->encryptdata['key'] = substr(hash('sha256', $this->getRandomSeed(), true), 0, $keybytelen);
// truncate passwords
$this->encryptdata['user_password'] = $this->_fixAES256Password($this->encryptdata['user_password']);
$this->encryptdata['owner_password'] = $this->_fixAES256Password($this->encryptdata['owner_password']);
// Compute U value
$this->encryptdata['U'] = $this->_Uvalue();
// Compute UE value
$this->encryptdata['UE'] = $this->_UEvalue();
// Compute O value
$this->encryptdata['O'] = $this->_Ovalue();
// Compute OE value
$this->encryptdata['OE'] = $this->_OEvalue();
// Compute P value
$this->encryptdata['P'] = $this->encryptdata['protection'];
// Computing the encryption dictionary's Perms (permissions) value
$perms = $this->getEncPermissionsString($this->encryptdata['protection']); // bytes 0-3
$perms .= chr(255).chr(255).chr(255).chr(255); // bytes 4-7
if (isset($this->encryptdata['CF']['EncryptMetadata']) AND (!$this->encryptdata['CF']['EncryptMetadata'])) { // byte 8
$perms .= 'F';
} else {
$perms .= 'T';
}
$perms .= 'adb'; // bytes 9-11
$perms .= 'nick'; // bytes 12-15
$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
$this->encryptdata['perms'] = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->encryptdata['key'], $perms, MCRYPT_MODE_ECB, $iv);
} else { // RC4-40, RC4-128, AES-128
// Pad passwords
$this->encryptdata['user_password'] = substr($this->encryptdata['user_password'].$this->enc_padding, 0, 32);
$this->encryptdata['owner_password'] = substr($this->encryptdata['owner_password'].$this->enc_padding, 0, 32);
// Compute O value
$this->encryptdata['O'] = $this->_Ovalue();
// get default permissions (reverse byte order)
$permissions = $this->getEncPermissionsString($this->encryptdata['protection']);
// Compute encryption key
$tmp = $this->_md5_16($this->encryptdata['user_password'].$this->encryptdata['O'].$permissions.$this->encryptdata['fileid']);
if ($this->encryptdata['mode'] > 0) {
for ($i = 0; $i < 50; ++$i) {
$tmp = $this->_md5_16(substr($tmp, 0, $keybytelen));
}
}
$this->encryptdata['key'] = substr($tmp, 0, $keybytelen);
// Compute U value
$this->encryptdata['U'] = $this->_Uvalue();
// Compute P value
$this->encryptdata['P'] = $this->encryptdata['protection'];
}
} else { // Public-Key mode
// random 20-byte seed
$seed = sha1(microtime().uniqid(''.rand()).$this->file_id, true);
$seed = sha1($this->getRandomSeed(), true);
$recipient_bytes = '';
foreach ($this->encryptdata['pubkeys'] as $pubkey) {
// for each public certificate
if (isset($pubkey['p'])) {
$pkprotection = $this->getUserPermissionCode($pubkey['p'], $this->encryptdata['mode']);
} else {
$pkprotection = $protection;
$pkprotection = $this->encryptdata['protection'];
}
// get default permissions (reverse byte order)
$pkpermissions = $this->getEncPermissionsString($pkprotection);
@ -11766,14 +11904,18 @@ class TCPDF {
$recipient_bytes .= $signature;
}
// calculate encryption key
$this->encryptdata['key'] = substr(sha1($seed.$recipient_bytes, true), 0, $keybytelen);
if ($this->encryptdata['mode'] == 3) { // AES-256
$this->encryptdata['key'] = substr(hash('sha256', $seed.$recipient_bytes, true), 0, $keybytelen);
} else { // RC4-40, RC4-128, AES-128
$this->encryptdata['key'] = substr(sha1($seed.$recipient_bytes, true), 0, $keybytelen);
}
}
}
/**
* Return the premission code used on encryption (P value).
* @param Array $permissions the set of permissions (specify the ones you want to block).
* @param int $mode encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit.
* @param int $mode encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
* @access protected
* @since 5.0.005 (2010-05-12)
* @author Nicola Asuni
@ -11790,7 +11932,7 @@ class TCPDF {
'assemble' => 1024,// bit 11
'print-high' => 2048 // bit 12
);
$protection = 2147422012; // (01111111111111110000111100111100)
$protection = 2147422012; // 32 bit: (01111111 11111111 00001111 00111100)
foreach ($permissions as $permission) {
if (!isset($options[$permission])) {
$this->Error('Incorrect permission: '.$permission);
@ -11816,14 +11958,14 @@ class TCPDF {
* @param Array $permissions the set of permissions (specify the ones you want to block):<ul><li>print : Print the document;</li><li>modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';</li><li>copy : Copy or otherwise extract text and graphics from the document;</li><li>annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);</li><li>fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;</li><li>extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);</li><li>assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;</li><li>print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.</li><li>owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.</li></ul>
* @param String $user_pass user password. Empty by default.
* @param String $owner_pass owner password. If not specified, a random value is used.
* @param int $mode encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit.
* @param int $mode encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
* @param String $pubkeys array of recipients containing public-key certificates ('c') and permissions ('p'). For example: array(array('c' => 'file://../tcpdf.crt', 'p' => array('print')))
* @access public
* @since 2.0.000 (2008-01-02)
* @author Nicola Asuni
*/
public function SetProtection($permissions=array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'), $user_pass='', $owner_pass=null, $mode=0, $pubkeys=null) {
$protection = $this->getUserPermissionCode($permissions, $mode);
$this->encryptdata['protection'] = $this->getUserPermissionCode($permissions, $mode);
if (($pubkeys !== null) AND (is_array($pubkeys))) {
// public-key mode
$this->encryptdata['pubkeys'] = $pubkeys;
@ -11848,15 +11990,21 @@ class TCPDF {
}
if ($mode > 1) { // AES
if (!extension_loaded('mcrypt')) {
$this->Error('AES encryption requires mcrypt library.');
$this->Error('AES encryption requires mcrypt library (http://www.php.net/manual/en/mcrypt.requirements.php).');
}
if (mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) === false) {
$this->Error('AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
}
if (($mode == 3) AND !function_exists('hash')) {
// the Hash extension requires no external libraries and is enabled by default as of PHP 5.1.2.
$this->Error('AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
}
}
if ($owner_pass === null) {
$owner_pass = uniqid(''.rand());
$owner_pass = md5($this->getRandomSeed());
}
$this->encryptdata['user_password'] = $user_pass;
$this->encryptdata['owner_password'] = $owner_pass;
$this->encryptdata['mode'] = $mode;
switch ($mode) {
case 0: { // RC4 40 bit
@ -11879,6 +12027,18 @@ class TCPDF {
$this->encryptdata['V'] = 4;
$this->encryptdata['Length'] = 128;
$this->encryptdata['CF']['CFM'] = 'AESV2';
$this->encryptdata['CF']['Length'] = 128;
if ($this->encryptdata['pubkey']) {
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
$this->encryptdata['Recipients'] = array();
}
break;
}
case 3: { // AES 256 bit
$this->encryptdata['V'] = 5;
$this->encryptdata['Length'] = 256;
$this->encryptdata['CF']['CFM'] = 'AESV3';
$this->encryptdata['CF']['Length'] = 256;
if ($this->encryptdata['pubkey']) {
$this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
$this->encryptdata['Recipients'] = array();
@ -11888,7 +12048,7 @@ class TCPDF {
}
$this->encrypted = true;
$this->encryptdata['fileid'] = $this->convertHexStringToString($this->file_id);
$this->_generateencryptionkey($user_pass, $owner_pass, $protection);
$this->_generateencryptionkey();
}
/**