32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-12-02 00:53:53 +00:00
This commit is contained in:
Nick 2011-09-17 11:56:20 +02:00
parent d303c731f8
commit 04a8c74240
3 changed files with 103 additions and 65 deletions

View File

@ -1,5 +1,8 @@
5.9.117 (2011-09-17) 5.9.118 (2011-09-17)
- TCPDFBarcode and TCPDF2DBarcode were extended to include a method for exporting barcodes as PNG images. - THis version includes some changes that allows you to add a bookmark for a page that do not exist.
5.9.117 (2011-09-15)
- TCPDFBarcode and TCPDF2DBarcode classes were extended to include a method for exporting barcodes as PNG images.
5.9.116 (2011-09-14) 5.9.116 (2011-09-14)
- Datamatrix class was improved and documentation was fixed. - Datamatrix class was improved and documentation was fixed.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 5.9.117 Version: 5.9.118
Release date: 2011-09-15 Release date: 2011-09-17
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2011: Copyright (c) 2002-2011:

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.9.117 // Version : 5.9.118
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2011-09-15 // Last Update : 2011-09-17
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS. // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -136,7 +136,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 5.9.117 * @version 5.9.118
*/ */
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -148,7 +148,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
* 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> * 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>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 5.9.117 * @version 5.9.118
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -159,7 +159,7 @@ class TCPDF {
* Current TCPDF version. * Current TCPDF version.
* @private * @private
*/ */
private $tcpdf_version = '5.9.117'; private $tcpdf_version = '5.9.118';
// Protected properties // Protected properties
@ -3880,6 +3880,31 @@ class TCPDF {
if ($tocpage) { if ($tocpage) {
$this->tocpage = true; $this->tocpage = true;
} }
// move page numbers of documents to be attached
if ($this->tocpage) {
// move reference to unexistent pages (used for page attachments)
// adjust outlines
$tmpoutlines = $this->outlines;
foreach ($tmpoutlines as $key => $outline) {
if ($outline['p'] > $this->numpages) {
$this->outlines[$key]['p'] = ($outline['p'] + 1);
}
}
// adjust dests
$tmpdests = $this->dests;
foreach ($tmpdests as $key => $dest) {
if ($dest['p'] > $this->numpages) {
$this->dests[$key]['p'] = ($dest['p'] + 1);
}
}
// adjust links
$tmplinks = $this->links;
foreach ($tmplinks as $key => $link) {
if ($link[0] > $this->numpages) {
$this->links[$key][0] = ($link[0] + 1);
}
}
}
if ($this->numpages > $this->page) { if ($this->numpages > $this->page) {
// this page has been already added // this page has been already added
$this->setPage($this->page + 1); $this->setPage($this->page + 1);
@ -9155,8 +9180,10 @@ class TCPDF {
} else { } else {
// internal link // internal link
$l = $this->links[$pl['txt']]; $l = $this->links[$pl['txt']];
if (isset($this->page_obj_id[($l[0])])) {
$annots .= sprintf(' /Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[($l[0])], ($this->pagedim[$l[0]]['h'] - ($l[1] * $this->k))); $annots .= sprintf(' /Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[($l[0])], ($this->pagedim[$l[0]]['h'] - ($l[1] * $this->k)));
} }
}
$hmodes = array('N', 'I', 'O', 'P'); $hmodes = array('N', 'I', 'O', 'P');
if (isset($pl['opt']['h']) AND in_array($pl['opt']['h'], $hmodes)) { if (isset($pl['opt']['h']) AND in_array($pl['opt']['h'], $hmodes)) {
$annots .= ' /H /'.$pl['opt']['h']; $annots .= ' /H /'.$pl['opt']['h'];
@ -14975,7 +15002,6 @@ class TCPDF {
$n = $this->n + 1; $n = $this->n + 1;
$nltags = '/<br[\s]?\/>|<\/(blockquote|dd|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|p|pre|ul|tcpdf|table|tr|td)>/si'; $nltags = '/<br[\s]?\/>|<\/(blockquote|dd|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|p|pre|ul|tcpdf|table|tr|td)>/si';
foreach ($this->outlines as $i => $o) { foreach ($this->outlines as $i => $o) {
if (isset($this->page_obj_id[($o['p'])])) {
$oid = $this->_newobj(); $oid = $this->_newobj();
// covert HTML title to string // covert HTML title to string
$title = preg_replace($nltags, "\n", $o['t']); $title = preg_replace($nltags, "\n", $o['t']);
@ -14997,7 +15023,9 @@ class TCPDF {
if (isset($o['last'])) { if (isset($o['last'])) {
$out .= ' /Last '.($n + $o['last']).' 0 R'; $out .= ' /Last '.($n + $o['last']).' 0 R';
} }
if (isset($this->page_obj_id[($o['p'])])) {
$out .= ' '.sprintf('/Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[($o['p'])], ($this->pagedim[$o['p']]['h'] - ($o['y'] * $this->k))); $out .= ' '.sprintf('/Dest [%u 0 R /XYZ 0 %.2F null]', $this->page_obj_id[($o['p'])], ($this->pagedim[$o['p']]['h'] - ($o['y'] * $this->k)));
}
// set font style // set font style
$style = 0; $style = 0;
if (!empty($o['s'])) { if (!empty($o['s'])) {
@ -15024,7 +15052,6 @@ class TCPDF {
$out .= "\n".'endobj'; $out .= "\n".'endobj';
$this->_out($out); $this->_out($out);
} }
}
//Outline root //Outline root
$this->OutlineRoot = $this->_newobj(); $this->OutlineRoot = $this->_newobj();
$this->_out('<< /Type /Outlines /First '.$n.' 0 R /Last '.($n + $lru[0]).' 0 R >>'."\n".'endobj'); $this->_out('<< /Type /Outlines /First '.$n.' 0 R /Last '.($n + $lru[0]).' 0 R >>'."\n".'endobj');
@ -23905,7 +23932,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tmpoutlines = $this->outlines; $tmpoutlines = $this->outlines;
foreach ($tmpoutlines as $key => $outline) { foreach ($tmpoutlines as $key => $outline) {
if (($outline['p'] >= $topage) AND ($outline['p'] < $frompage)) { if (($outline['p'] >= $topage) AND ($outline['p'] < $frompage)) {
$this->outlines[$key]['p'] = $outline['p'] + 1; $this->outlines[$key]['p'] = ($outline['p'] + 1);
} elseif ($outline['p'] == $frompage) { } elseif ($outline['p'] == $frompage) {
$this->outlines[$key]['p'] = $topage; $this->outlines[$key]['p'] = $topage;
} }
@ -23914,7 +23941,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tmpdests = $this->dests; $tmpdests = $this->dests;
foreach ($tmpdests as $key => $dest) { foreach ($tmpdests as $key => $dest) {
if (($dest['p'] >= $topage) AND ($dest['p'] < $frompage)) { if (($dest['p'] >= $topage) AND ($dest['p'] < $frompage)) {
$this->dests[$key]['p'] = $dest['p'] + 1; $this->dests[$key]['p'] = ($dest['p'] + 1);
} elseif ($dest['p'] == $frompage) { } elseif ($dest['p'] == $frompage) {
$this->dests[$key]['p'] = $topage; $this->dests[$key]['p'] = $topage;
} }
@ -23923,7 +23950,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tmplinks = $this->links; $tmplinks = $this->links;
foreach ($tmplinks as $key => $link) { foreach ($tmplinks as $key => $link) {
if (($link[0] >= $topage) AND ($link[0] < $frompage)) { if (($link[0] >= $topage) AND ($link[0] < $frompage)) {
$this->links[$key][0] = $link[0] + 1; $this->links[$key][0] = ($link[0] + 1);
} elseif ($link[0] == $frompage) { } elseif ($link[0] == $frompage) {
$this->links[$key][0] = $topage; $this->links[$key][0] = $topage;
} }
@ -24185,6 +24212,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
/** /**
* Output a Table of Content Index (TOC). * Output a Table of Content Index (TOC).
* This method must be called after all Bookmarks were set.
* Before calling this method you have to open the page using the addTOCPage() method. * Before calling this method you have to open the page using the addTOCPage() method.
* After calling this method you have to call endTOCPage() to close the TOC page. * After calling this method you have to call endTOCPage() to close the TOC page.
* You can override this method to achieve different styles. * You can override this method to achieve different styles.
@ -24227,6 +24255,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
$this->SetFont($numbersfont, $fontstyle, $fontsize); $this->SetFont($numbersfont, $fontstyle, $fontsize);
$numwidth = $this->GetStringWidth('00000'); $numwidth = $this->GetStringWidth('00000');
$maxpage = 0; //used for pages on attached documents
foreach ($this->outlines as $key => $outline) { foreach ($this->outlines as $key => $outline) {
if ($this->rtl) { if ($this->rtl) {
$aligntext = 'R'; $aligntext = 'R';
@ -24291,6 +24320,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if ($this->isUnicodeFont()) { if ($this->isUnicodeFont()) {
$pagenum = '{'.$pagenum.'}'; $pagenum = '{'.$pagenum.'}';
} }
$maxpage = max($maxpage, $outline['p']);
} }
$fw = ($tw - $this->GetStringWidth($pagenum.$filler)); $fw = ($tw - $this->GetStringWidth($pagenum.$filler));
$numfills = floor($fw / $this->GetStringWidth($filler)); $numfills = floor($fw / $this->GetStringWidth($filler));
@ -24308,18 +24338,19 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0); $this->Cell($tw, 0, $pagenum, 0, 1, $alignnum, 0, $link, 0);
} }
$page_last = $this->getPage(); $page_last = $this->getPage();
$maxpage = max($maxpage, $page_last);
$numpages = $page_last - $page_first + 1; $numpages = $page_last - $page_first + 1;
if (!$this->empty_string($page)) { if (!$this->empty_string($page)) {
for ($p = $page_first; $p <= $page_last; ++$p) { for ($p = $page_first; $p <= $page_last; ++$p) {
// get page data // get page data
$temppage = $this->getPageBuffer($p); $temppage = $this->getPageBuffer($p);
for ($n = 1; $n <= $this->numpages; ++$n) { for ($n = 1; $n <= $maxpage; ++$n) {
// update page numbers // update page numbers
$a = '{#'.$n.'}'; $a = '{#'.$n.'}';
// get page number aliases // get page number aliases
$pnalias = $this->getInternalPageNumberAliases($a); $pnalias = $this->getInternalPageNumberAliases($a);
// calculate replacement number // calculate replacement number
if ($n >= $page) { if (($n >= $page) AND ($n <= $this->numpages)) {
$np = $n + $numpages; $np = $n + $numpages;
} else { } else {
$np = $n; $np = $n;
@ -24359,6 +24390,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
/** /**
* Output a Table Of Content Index (TOC) using HTML templates. * Output a Table Of Content Index (TOC) using HTML templates.
* This method must be called after all Bookmarks were set.
* Before calling this method you have to open the page using the addTOCPage() method. * Before calling this method you have to open the page using the addTOCPage() method.
* After calling this method you have to call endTOCPage() to close the TOC page. * After calling this method you have to call endTOCPage() to close the TOC page.
* @param $page (int) page number where this TOC should be inserted (leave empty for current page). * @param $page (int) page number where this TOC should be inserted (leave empty for current page).
@ -24392,6 +24424,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
} }
$this->SetFont($current_font); $this->SetFont($current_font);
$maxpage = 0; //used for pages on attached documents
foreach ($this->outlines as $key => $outline) { foreach ($this->outlines as $key => $outline) {
// get HTML template // get HTML template
$row = $templates[$outline['l']]; $row = $templates[$outline['l']];
@ -24403,6 +24436,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if ($templates['F'.$outline['l']]) { if ($templates['F'.$outline['l']]) {
$pagenum = '{'.$pagenum.'}'; $pagenum = '{'.$pagenum.'}';
} }
$maxpage = max($maxpage, $outline['p']);
} }
// replace templates with current values // replace templates with current values
$row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row); $row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
@ -24417,12 +24451,13 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->htmlLinkFontStyle = $prev_htmlLinkFontStyle; $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
// move TOC page and replace numbers // move TOC page and replace numbers
$page_last = $this->getPage(); $page_last = $this->getPage();
$maxpage = max($maxpage, $page_last);
$numpages = $page_last - $page_first + 1; $numpages = $page_last - $page_first + 1;
if (!$this->empty_string($page)) { if (!$this->empty_string($page)) {
for ($p = $page_first; $p <= $page_last; ++$p) { for ($p = $page_first; $p <= $page_last; ++$p) {
// get page data // get page data
$temppage = $this->getPageBuffer($p); $temppage = $this->getPageBuffer($p);
for ($n = 1; $n <= $this->numpages; ++$n) { for ($n = 1; $n <= $maxpage; ++$n) {
// update page numbers // update page numbers
$a = '{#'.$n.'}'; $a = '{#'.$n.'}';
// get page number aliases // get page number aliases