30
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-06-04 23:10:46 +00:00
This commit is contained in:
nicolaasuni 2009-08-25 20:07:52 +02:00
parent f0d036e555
commit 7da82c6417
16 changed files with 508 additions and 380 deletions

View File

@ -1,3 +1,6 @@
4.6.028 (2009-08-25)
- Signature algorithm was fixed (see example n. 52).
4.6.027 (2009-08-24)
- TCPDF now supports unembedded TrueTypeUnicode Fonts (just comment the $file entry on the fonts' php file.

View File

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

View File

@ -45,7 +45,7 @@
<div class="credit">
<hr />
Documentation generated on Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +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 Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +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 Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +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 Mon, 24 Aug 2009 17:52:28 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:44 +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 Mon, 24 Aug 2009 17:52:22 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:39 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -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.027</td>
<td><b>version:</b>&nbsp;&nbsp;</td><td>4.6.028</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>
@ -104,7 +104,7 @@ unicode data<br /><br /></div>
<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.027 (http://www.tcpdf.org)'</code>
<code>PDF_PRODUCER = 'TCPDF 4.6.028 (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 Mon, 24 Aug 2009 17:52:22 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:39 +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 Mon, 24 Aug 2009 17:52:28 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:44 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -121,6 +121,8 @@
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$buffer">TCPDF::$buffer</a></dd>
<dt><b>$bufferlen</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$bufferlen">TCPDF::$bufferlen</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Lenght of the buffer in bytes.</dd>
<dt><b>$byterange_string</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$byterange_string">TCPDF::$byterange_string</a><br>&nbsp;&nbsp;&nbsp;&nbsp;ByteRange placemark used during signature process.</dd>
<dt><b>barcodes.php</b></dt>
<dd>procedural page <a href="com-tecnick-tcpdf/_barcodes.php.html">barcodes.php</a></dd>
<dt><b>barcode_c128</b></dt>
@ -889,6 +891,8 @@
<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>$sig_annot_ref</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sig_annot_ref">TCPDF::$sig_annot_ref</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Placemark used during signature process.</dd>
<dt><b>$sig_obj_id</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sig_obj_id">TCPDF::$sig_obj_id</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature object ID</dd>
<dt><b>$spot_colors</b></dt>
@ -912,9 +916,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 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>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>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>
@ -1258,7 +1262,9 @@
<dt><b>_beginpage</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_beginpage">TCPDF::_beginpage()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Initialize a new page.</dd>
<dt><b>_datastring</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datastring">TCPDF::_datastring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Format a date string for meta information</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datastring">TCPDF::_datastring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Format a data string for meta information</dd>
<dt><b>_datestring</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datestring">TCPDF::_datestring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a formatted date for meta information</dd>
<dt><b>_destroy</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_destroy">TCPDF::_destroy()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Unset all class variables except the following critical variables: internal_encoding, state, bufferlen, buffer and diskcache.</dd>
<dt><b>_dochecks</b></dt>
@ -1378,7 +1384,7 @@
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

View File

@ -91,7 +91,9 @@
<dt><b>_beginpage</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_beginpage">TCPDF::_beginpage()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Initialize a new page.</dd>
<dt><b>_datastring</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datastring">TCPDF::_datastring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Format a date string for meta information</dd>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datastring">TCPDF::_datastring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Format a data string for meta information</dd>
<dt><b>_datestring</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_datestring">TCPDF::_datestring()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Returns a formatted date for meta information</dd>
<dt><b>_destroy</b></dt>
<dd>in file tcpdf.php, method <a href="com-tecnick-tcpdf/TCPDF.html#method_destroy">TCPDF::_destroy()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Unset all class variables except the following critical variables: internal_encoding, state, bufferlen, buffer and diskcache.</dd>
<dt><b>_dochecks</b></dt>
@ -272,6 +274,8 @@
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$buffer">TCPDF::$buffer</a></dd>
<dt><b>$bufferlen</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$bufferlen">TCPDF::$bufferlen</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Lenght of the buffer in bytes.</dd>
<dt><b>$byterange_string</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$byterange_string">TCPDF::$byterange_string</a><br>&nbsp;&nbsp;&nbsp;&nbsp;ByteRange placemark used during signature process.</dd>
<dt><b>barcodes.php</b></dt>
<dd>procedural page <a href="com-tecnick-tcpdf/_barcodes.php.html">barcodes.php</a></dd>
<dt><b>barcode_c128</b></dt>
@ -1040,6 +1044,8 @@
<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>$sig_annot_ref</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sig_annot_ref">TCPDF::$sig_annot_ref</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Placemark used during signature process.</dd>
<dt><b>$sig_obj_id</b></dt>
<dd>in file tcpdf.php, variable <a href="com-tecnick-tcpdf/TCPDF.html#var$sig_obj_id">TCPDF::$sig_obj_id</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Signature object ID</dd>
<dt><b>$spot_colors</b></dt>
@ -1063,9 +1069,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 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>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>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>
@ -1401,7 +1407,7 @@
<a href="elementindex_com-tecnick-tcpdf.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +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 Mon, 24 Aug 2009 17:52:28 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:44 +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 Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +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 Mon, 24 Aug 2009 17:52:21 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
Documentation generated on Tue, 25 Aug 2009 20:07:38 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
</div>
</td></tr></table>
</td>

121
tcpdf.php
View File

@ -2,9 +2,9 @@
//============================================================+
// File name : tcpdf.php
// Begin : 2002-08-03
// Last Update : 2009-08-24
// Last Update : 2009-08-25
// Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org
// Version : 4.6.027
// Version : 4.6.028
// License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2009 Nicola Asuni - Tecnick.com S.r.l.
@ -126,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.027
* @version 4.6.028
*/
/**
@ -150,14 +150,14 @@ if (!class_exists('TCPDF', false)) {
/**
* define default PDF document producer
*/
define('PDF_PRODUCER', 'TCPDF 4.6.027 (http://www.tcpdf.org)');
define('PDF_PRODUCER', 'TCPDF 4.6.028 (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.027
* @version 4.6.028
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
@ -1308,6 +1308,20 @@ if (!class_exists('TCPDF', false)) {
* @since 4.6.022 (2009-06-23)
*/
protected $sig_obj_id = 0;
/**
* ByteRange placemark used during signature process.
* @access protected
* @since 4.6.028 (2009-08-25)
*/
protected $byterange_string = '/ByteRange[0 ********** ********** **********]';
/**
* Placemark used during signature process.
* @access protected
* @since 4.6.028 (2009-08-25)
*/
protected $sig_annot_ref = '/Annots [********** 0 R';
//------------------------------------------------------------
// METHODS
@ -5094,17 +5108,18 @@ if (!class_exists('TCPDF', false)) {
}
unset($this->buffer);
// remove filler space
$tmppos = strpos($pdfdoc, '/ByteRange[0 ********** ********** **********]') + 58;
$pdfdoc = substr($pdfdoc, 0, $tmppos).substr($pdfdoc, $tmppos + $this->signature_max_lenght);
$byterange_string_len = strlen($this->byterange_string);
// 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];
$byte_range[1] = strpos($pdfdoc, $this->byterange_string) + $byterange_string_len + 10;
$byte_range[2] = $byte_range[1] + $this->signature_max_lenght + 2;
$byte_range[3] = strlen($pdfdoc) - $byte_range[2];
$pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
// 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);
$byterange = sprintf('/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
$byterange .= str_repeat(' ', ($byterange_string_len - strlen($byterange)));
$pdfdoc = str_replace($this->byterange_string, $byterange, $pdfdoc);
// write the document to a temporary folder
$tempdoc = tempnam(K_PATH_CACHE, 'tmppdf_');
$f = fopen($tempdoc, 'wb');
@ -5136,7 +5151,7 @@ if (!class_exists('TCPDF', false)) {
$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]));
$pdfdoc = substr($pdfdoc, 0, $byte_range[1]).'<'.$signature.'>'.substr($pdfdoc, ($byte_range[1]));
$this->diskcache = false;
$this->buffer = &$pdfdoc;
$this->bufferlen = strlen($pdfdoc);
@ -5235,6 +5250,7 @@ if (!class_exists('TCPDF', false)) {
AND ($val != 'sign')
AND ($val != 'signature_data')
AND ($val != 'signature_max_lenght')
AND ($val != 'byterange_string')
)) {
if (!$preserve_objcopy OR ($val != 'objcopy')) {
unset($this->$val);
@ -5421,10 +5437,10 @@ if (!class_exists('TCPDF', false)) {
*/
protected function _putannots($n) {
if ($this->sign AND isset($this->signature_data['cert_type']) AND $this->signature_data['cert_type'] > 0) {
// set reference for signature object
$annots = '/Annots [ *!*!*! 0 R';
// set reference for signature object
$annots = $this->sig_annot_ref;
if (!isset($this->PageAnnots[$n])) {
$annots .= "\n]";
$annots .= ']';
$this->_out($annots);
return;
}
@ -5447,7 +5463,7 @@ if (!class_exists('TCPDF', false)) {
$annots .= ' /Contents '.$this->_textstring($pl['txt']);
//$annots .= ' /P ';
$annots .= ' /NM '.$this->_textstring(sprintf('%04u-%04u', $n, $key));
$annots .= ' /M '.$this->_datastring('D:'.date('YmdHis'));
$annots .= ' /M '.$this->_datestring();
if (isset($pl['opt']['f'])) {
$val = 0;
if (is_array($pl['opt']['f'])) {
@ -5575,7 +5591,7 @@ if (!class_exists('TCPDF', false)) {
if (isset($pl['opt']['rc'])) {
$annots .= ' /RC '.$this->_textstring($pl['opt']['rc']);
}
$annots .= ' /CreationDate '.$this->_datastring('D:'.date('YmdHis'));
$annots .= ' /CreationDate '.$this->_datestring();
//$annots .= ' /IRT ';
if (isset($pl['opt']['subj'])) {
$annots .= ' /Subj '.$this->_textstring($pl['opt']['subj']);
@ -6345,8 +6361,8 @@ if (!class_exists('TCPDF', false)) {
} else {
$this->_out('/Producer '.$this->_textstring('TCPDF'));
}
$this->_out('/CreationDate '.$this->_datastring('D:'.date('YmdHis')));
$this->_out('/ModDate '.$this->_datastring('D:'.date('YmdHis')));
$this->_out('/CreationDate '.$this->_datestring());
$this->_out('/ModDate '.$this->_datestring());
}
/**
@ -6519,8 +6535,9 @@ if (!class_exists('TCPDF', false)) {
unlink($this->buffer);
}
unset($this->buffer);
$signature_widget_ref = sprintf('/Annots [ % 6u 0 R', $this->sig_obj_id);
$pdfdoc = str_replace('/Annots [ *!*!*! 0 R', $signature_widget_ref, $pdfdoc);
$signature_widget_ref = sprintf('/Annots [%u 0 R', $this->sig_obj_id);
$signature_widget_ref .= str_repeat(' ', (strlen($this->sig_annot_ref) - strlen($signature_widget_ref)));
$pdfdoc = str_replace($this->sig_annot_ref, $signature_widget_ref, $pdfdoc);
$this->diskcache = false;
$this->buffer = &$pdfdoc;
$this->bufferlen = strlen($pdfdoc);
@ -6703,7 +6720,7 @@ if (!class_exists('TCPDF', false)) {
}
/**
* Format a date string for meta information
* Format a data string for meta information
* @param string $s date string to escape.
* @return string escaped string.
* @access protected
@ -6714,7 +6731,18 @@ if (!class_exists('TCPDF', false)) {
}
return '('. $this->_escape($s).')';
}
/**
* Returns a formatted date for meta information
* @return string escaped date string.
* @access protected
* @since 4.6.028 (2009-08-25)
*/
protected function _datestring() {
$current_time = substr_replace(date('YmdHisO'), '\'', (0 - 2), 0).'\'';
return $this->_datastring('D:'.$current_time);
}
/**
* Format a text string for meta information
* @param string $s string to escape.
@ -9446,21 +9474,21 @@ if (!class_exists('TCPDF', false)) {
if ((!$this->sign) OR (isset($this->signature_data['cert_type']) AND ($this->signature_data['cert_type'] > 0))) {
return;
}
$this->_out('/Type/Sig');
$this->_out('/Filter/Adobe.PPKLite');
$this->_out('/SubFilter/adbe.pkcs7.detached');
$this->_out('/ByteRange[0 ********** ********** **********]');
$this->_out('/Type /Sig');
$this->_out('/Filter /Adobe.PPKLite');
$this->_out('/SubFilter /adbe.pkcs7.detached');
$this->_out($this->byterange_string);
$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('/Type /SigRef');
$this->_out('/TransformMethod /UR3');
$this->_out('/TransformParams');
$this->_out('<<');
$this->_out('/Type/TransformParams');
$this->_out('/V/2.2');
$this->_out('/Type /TransformParams');
$this->_out('/V /2.2');
if (!$this->empty_string($this->ur_document)) {
$this->_out('/Document['.$this->ur_document.']');
}
@ -9474,13 +9502,10 @@ if (!class_exists('TCPDF', false)) {
$this->_out('/Signature['.$this->ur_signature.']');
}
$this->_out('>>');
// /Data 30 0 R
$this->_out('>>');
$this->_out(']');
}
$this->_out('/M '.$this->_datastring('D:'.date('YmdHisO')));
$this->_out('/M '.$this->_datestring());
}
/*
@ -9493,25 +9518,24 @@ if (!class_exists('TCPDF', false)) {
if ((!$this->sign) OR (isset($this->signature_data['cert_type']) AND ($this->signature_data['cert_type'] <= 0))) {
return;
}
$this->_out('/Type/Sig');
$this->_out('/Filter/Adobe.PPKLite');
$this->_out('/SubFilter/adbe.pkcs7.detached');
$this->_out('/ByteRange[0 ********** ********** **********]');
$this->_out('/Type /Sig');
$this->_out('/Filter /Adobe.PPKLite');
$this->_out('/SubFilter /adbe.pkcs7.detached');
$this->_out($this->byterange_string);
$this->_out('/Contents<>'.str_repeat(' ', $this->signature_max_lenght));
$this->_out('/Reference');
$this->_out('[');
$this->_out('<<');
$this->_out('/Type/SigRef');
$this->_out('/TransformMethod/DocMDP');
$this->_out('/Type /SigRef');
$this->_out('/TransformMethod /DocMDP');
$this->_out('/TransformParams');
$this->_out('<<');
$this->_out('/Type/TransformParams');
$this->_out('/V/1.2');
$this->_out('/Type /TransformParams');
$this->_out('/V /1.2');
$this->_out('/P '.$this->signature_data['cert_type'].'');
$this->_out('>>');
$this->_out('>>');
$this->_out(']');
$this->_out('/M '.$this->_datastring('D:'.date('YmdHisO')));
if (isset($this->signature_data['info']['Name']) AND !$this->empty_string($this->signature_data['info']['Name'])) {
$this->_out('/Name '.$this->_textstring($this->signature_data['info']['Name']).'');
}
@ -9524,6 +9548,7 @@ if (!class_exists('TCPDF', false)) {
if (isset($this->signature_data['info']['ContactInfo']) AND !$this->empty_string($this->signature_data['info']['ContactInfo'])) {
$this->_out('/ContactInfo '.$this->_textstring($this->signature_data['info']['ContactInfo']).'');
}
$this->_out('/M '.$this->_datestring());
}
/*
@ -9567,13 +9592,13 @@ if (!class_exists('TCPDF', false)) {
* @since 4.6.005 (2009-04-24)
*/
public function setSignature($signing_cert='', $private_key='', $private_key_password='', $extracerts='', $cert_type=2, $info=array()) {
// to create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.pem -out tcpdf.pem
// to create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
// to convert pfx certificate to pem: openssl
// OpenSSL> pkcs12 -in <cert.pfx> -out <cert.pem> -nodes
// OpenSSL> pkcs12 -in <cert.pfx> -out <cert.crt> -nodes
$this->sign = true;
$this->signature_data = array();
if (strlen($signing_cert) == 0) {
$signing_cert = 'file://'.dirname(__FILE__).'/tcpdf.pem';
$signing_cert = 'file://'.dirname(__FILE__).'/tcpdf.crt';
}
if (strlen($private_key) == 0) {
$private_key = $signing_cert;