32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-26 06:17:33 +00:00
This commit is contained in:
nicolaasuni 2011-04-15 11:24:02 +02:00
parent 3c71018636
commit b52780fe62
8 changed files with 117 additions and 72 deletions

View File

@ -1,3 +1,7 @@
5.9.068 (2011-04-15)
- Bookmark, addTOC and addHTMLTOC methods were improved to include font style and color (Examples 15, 49 and 59 were updated).
- Default $_SERVER['DOCUMENT_ROOT'] value on tcpdf_config.php file was changed.
5.9.067 (2011-04-10) 5.9.067 (2011-04-10)
- Performances were drastically improved (PDF documents are now created more quickly). - Performances were drastically improved (PDF documents are now created more quickly).

View File

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

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : tcpdf_config.php // File name : tcpdf_config.php
// Begin : 2004-06-11 // Begin : 2004-06-11
// Last Update : 2010-12-16 // Last Update : 2011-04-15
// //
// Description : Configuration file for TCPDF. // Description : Configuration file for TCPDF.
// //
@ -37,8 +37,8 @@ if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
} elseif(isset($_SERVER['PATH_TRANSLATED'])) { } elseif(isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
} else { } else {
// define here your DOCUMENT_ROOT path if the previous fails // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
$_SERVER['DOCUMENT_ROOT'] = '/var/www'; $_SERVER['DOCUMENT_ROOT'] = '/';
} }
} }

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : tcpdf_config.php // File name : tcpdf_config.php
// Begin : 2004-06-11 // Begin : 2004-06-11
// Last Update : 2010-12-16 // Last Update : 2011-04-15
// //
// Description : Alternative configuration file for TCPDF. // Description : Alternative configuration file for TCPDF.
// //
@ -33,8 +33,8 @@ if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
} elseif(isset($_SERVER['PATH_TRANSLATED'])) { } elseif(isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
} else { } else {
// define here your DOCUMENT_ROOT path if the previous fails // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
$_SERVER['DOCUMENT_ROOT'] = '/var/www'; $_SERVER['DOCUMENT_ROOT'] = '/';
} }
} }

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : example_015.php // File name : example_015.php
// Begin : 2008-03-04 // Begin : 2008-03-04
// Last Update : 2010-08-08 // Last Update : 2011-04-15
// //
// Description : Example 015 for TCPDF class // Description : Example 015 for TCPDF class
// Bookmarks (Table of Content) // Bookmarks (Table of Content)
@ -66,7 +66,7 @@ $pdf->setLanguageArray($l);
// --------------------------------------------------------- // ---------------------------------------------------------
// Bookmark($txt, $level=0, $y=-1, $page='') // Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0,0,0))
// set font // set font
$pdf->SetFont('times', 'B', 20); $pdf->SetFont('times', 'B', 20);
@ -75,7 +75,7 @@ $pdf->SetFont('times', 'B', 20);
$pdf->AddPage(); $pdf->AddPage();
// set a bookmark for the current position // set a bookmark for the current position
$pdf->Bookmark('Chapter 1', 0, 0); $pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128));
// print a line using Cell() // print a line using Cell()
$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L');
@ -88,27 +88,27 @@ $pdf->SetFont('times', 'B', 20);
// add other pages and bookmarks // add other pages and bookmarks
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.1', 1, 0); $pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(0,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.2', 1, 0); $pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(0,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0); $pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,0,0));
$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.3', 1, 0); $pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(0,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Chapter 2', 0, 0); $pdf->Bookmark('Chapter 2', 0, 0, '', 'BI', array(128,0,0));
$pdf->Cell(0, 10, 'Chapter 2', 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter 2', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Chapter 3', 0, 0); $pdf->Bookmark('Chapter 3', 0, 0, '', 'B', array(0,64,128));
$pdf->Cell(0, 10, 'Chapter 3', 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter 3', 0, 1, 'L');
// --------------------------------------------------------- // ---------------------------------------------------------

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : example_045.php // File name : example_045.php
// Begin : 2008-03-04 // Begin : 2008-03-04
// Last Update : 2010-08-08 // Last Update : 2011-04-15
// //
// Description : Example 045 for TCPDF class // Description : Example 045 for TCPDF class
// Bookmarks and Table of Content // Bookmarks and Table of Content
@ -73,31 +73,31 @@ $pdf->SetFont('times', 'B', 20);
$pdf->AddPage(); $pdf->AddPage();
// set a bookmark for the current position // set a bookmark for the current position
$pdf->Bookmark('Chapter 1', 0, 0); $pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128));
// print a line using Cell() // print a line using Cell()
$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.1', 1, 0); $pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.2', 1, 0); $pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0); $pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,128,0));
$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.3', 1, 0); $pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L');
// add some pages and bookmarks // add some pages and bookmarks
for ($i = 2; $i < 12; $i++) { for ($i = 2; $i < 12; $i++) {
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Chapter '.$i, 0, 0); $pdf->Bookmark('Chapter '.$i, 0, 0, '', 'B', array(0,64,128));
$pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L');
} }
@ -115,7 +115,7 @@ $pdf->SetFont('dejavusans', '', 12);
// add a simple Table Of Content at first page // add a simple Table Of Content at first page
// (check the example n. 59 for the HTML version) // (check the example n. 59 for the HTML version)
$pdf->addTOC(1, 'courier', '.', 'INDEX'); $pdf->addTOC(1, 'courier', '.', 'INDEX', 'B', array(128,0,0));
// end of TOC page // end of TOC page
$pdf->endTOCPage(); $pdf->endTOCPage();

View File

@ -2,7 +2,7 @@
//============================================================+ //============================================================+
// File name : example_059.php // File name : example_059.php
// Begin : 2010-05-06 // Begin : 2010-05-06
// Last Update : 2010-09-13 // Last Update : 2011-04-15
// //
// Description : Example 059 for TCPDF class // Description : Example 059 for TCPDF class
// Table Of Content using HTML templates. // Table Of Content using HTML templates.
@ -110,30 +110,31 @@ $pdf->SetFont('helvetica', '', 10);
$pdf->AddPage(); $pdf->AddPage();
// set a bookmark for the current position // set a bookmark for the current position
$pdf->Bookmark('Chapter 1', 0, 0); $pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128));
// print a line using Cell() // print a line using Cell()
$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.1', 1, 0); $pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.2', 1, 0); $pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0); $pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,128,0));
$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); $pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L');
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Paragraph 1.3', 1, 0); $pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(128,0,0));
$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); $pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L');
for ($i = 2; $i < 12; ++$i) { // add some pages and bookmarks
for ($i = 2; $i < 12; $i++) {
$pdf->AddPage(); $pdf->AddPage();
$pdf->Bookmark('Chapter '.$i, 0, 0); $pdf->Bookmark('Chapter '.$i, 0, 0, '', 'B', array(0,64,128));
$pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L'); $pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L');
} }
@ -172,7 +173,7 @@ $bookmark_templates[2] = '<table border="0" cellpadding="0" cellspacing="0"><tr>
// add table of content at page 1 // add table of content at page 1
// (check the example n. 45 for a text-only TOC // (check the example n. 45 for a text-only TOC
$pdf->addHTMLTOC($page=1, $toc_name='INDEX', $bookmark_templates, $correct_align=true); $pdf->addHTMLTOC(1, 'INDEX', $bookmark_templates, true, 'B', array(128,0,0));
// end of TOC page // end of TOC page
$pdf->endTOCPage(); $pdf->endTOCPage();

106
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.9.067 // Version : 5.9.068
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2011-04-10 // Last Update : 2011-04-15
// 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.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -134,7 +134,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.067 * @version 5.9.068
*/ */
// 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.
@ -146,7 +146,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.067 * @version 5.9.068
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -157,7 +157,7 @@ class TCPDF {
* Current TCPDF version. * Current TCPDF version.
* @private * @private
*/ */
private $tcpdf_version = '5.9.067'; private $tcpdf_version = '5.9.068';
// Protected properties // Protected properties
@ -4819,24 +4819,29 @@ class TCPDF {
$fontdir .= '/'; $fontdir .= '/';
} }
} }
$missing_style = false; // true when the font style variation is missing
// search and include font file // search and include font file
if ($this->empty_string($fontfile) OR (!file_exists($fontfile))) { if ($this->empty_string($fontfile) OR (!file_exists($fontfile))) {
// build a standard filenames for specified font // build a standard filenames for specified font
$fontfile1 = str_replace(' ', '', $family).strtolower($style).'.php'; $tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php';
$fontfile2 = str_replace(' ', '', $family).'.php';
// search files on various directories // search files on various directories
if (($fontdir !== false) AND file_exists($fontdir.$fontfile1)) { if (($fontdir !== false) AND file_exists($fontdir.$tmp_fontfile)) {
$fontfile = $fontdir.$fontfile1; $fontfile = $fontdir.$tmp_fontfile;
} elseif (file_exists($this->_getfontpath().$fontfile1)) { } elseif (file_exists($this->_getfontpath().$tmp_fontfile)) {
$fontfile = $this->_getfontpath().$fontfile1; $fontfile = $this->_getfontpath().$tmp_fontfile;
} elseif (file_exists($fontfile1)) { } elseif (file_exists($tmp_fontfile)) {
$fontfile = $fontfile1; $fontfile = $tmp_fontfile;
} elseif (($fontdir !== false) AND file_exists($fontdir.$fontfile2)) { } elseif (!$this->empty_string($style)) {
$fontfile = $fontdir.$fontfile2; $missing_style = true;
} elseif (file_exists($this->_getfontpath().$fontfile2)) { // try to remove the style part
$fontfile = $this->_getfontpath().$fontfile2; $tmp_fontfile = str_replace(' ', '', $family).'.php';
if (($fontdir !== false) AND file_exists($fontdir.$tmp_fontfile)) {
$fontfile = $fontdir.$tmp_fontfile;
} elseif (file_exists($this->_getfontpath().$tmp_fontfile)) {
$fontfile = $this->_getfontpath().$tmp_fontfile;
} else { } else {
$fontfile = $fontfile2; $fontfile = $tmp_fontfile;
}
} }
} }
// include font file // include font file
@ -4857,7 +4862,7 @@ class TCPDF {
$enc = ''; $enc = '';
} }
if (!isset($cidinfo) OR $this->empty_string($cidinfo)) { if (!isset($cidinfo) OR $this->empty_string($cidinfo)) {
$cidinfo = array('Registry'=>'Adobe','Ordering'=>'Identity','Supplement'=>0); $cidinfo = array('Registry'=>'Adobe', 'Ordering'=>'Identity', 'Supplement'=>0);
$cidinfo['uni2cid'] = array(); $cidinfo['uni2cid'] = array();
} }
if (!isset($ctg) OR $this->empty_string($ctg)) { if (!isset($ctg) OR $this->empty_string($ctg)) {
@ -4886,10 +4891,11 @@ class TCPDF {
} }
} }
++$this->numfonts; ++$this->numfonts;
if ($type == 'cidfont0') { // create artificial font style variations if missing (only works with non-embedded fonts)
// register CID font (all styles at once) if ($missing_style) {
// style variations
$styles = array('' => '', 'B' => ',Bold', 'I' => ',Italic', 'BI' => ',BoldItalic'); $styles = array('' => '', 'B' => ',Bold', 'I' => ',Italic', 'BI' => ',BoldItalic');
$sname = $name.$styles[$bistyle]; $name .= $styles[$bistyle];
// artificial bold // artificial bold
if (strpos($bistyle, 'B') !== false) { if (strpos($bistyle, 'B') !== false) {
if (isset($desc['StemV'])) { if (isset($desc['StemV'])) {
@ -4905,15 +4911,21 @@ class TCPDF {
} else { } else {
$desc['ItalicAngle'] = -11; $desc['ItalicAngle'] = -11;
} }
if (isset($desc['Flags'])) {
$desc['Flags'] |= 128; //bit 7
} else {
$desc['Flags'] = 128;
} }
} elseif ($type == 'core') { }
}
if ($type == 'core') {
$name = $this->CoreFonts[$fontkey]; $name = $this->CoreFonts[$fontkey];
$subset = false; $subset = false;
} elseif (($type == 'TrueType') OR ($type == 'Type1')) { } elseif (($type == 'TrueType') OR ($type == 'Type1')) {
$subset = false; $subset = false;
} elseif ($type == 'TrueTypeUnicode') { } elseif ($type == 'TrueTypeUnicode') {
$enc = 'Identity-H'; $enc = 'Identity-H';
} else { } elseif ($type != 'cidfont0') {
$this->Error('Unknow font type: '.$type.''); $this->Error('Unknow font type: '.$type.'');
} }
// initialize subsetchars to contain default ASCII values (0-255) // initialize subsetchars to contain default ASCII values (0-255)
@ -14302,11 +14314,13 @@ class TCPDF {
* @param $level (int) bookmark level (minimum value is 0). * @param $level (int) bookmark level (minimum value is 0).
* @param $y (float) Y position in user units of the bookmark on the selected page (default = -1 = current position; 0 = page start;). * @param $y (float) Y position in user units of the bookmark on the selected page (default = -1 = current position; 0 = page start;).
* @param $page (int) target page number (leave empty for current page). * @param $page (int) target page number (leave empty for current page).
* @param $style (string) Font style: B = Bold, I = Italic, BI = Bold + Italic.
* @param $color (array) RGB color array (values from 0 to 255).
* @public * @public
* @author Olivier Plathey, Nicola Asuni * @author Olivier Plathey, Nicola Asuni
* @since 2.1.002 (2008-02-12) * @since 2.1.002 (2008-02-12)
*/ */
public function Bookmark($txt, $level=0, $y=-1, $page='') { public function Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0,0,0)) {
if ($level < 0) { if ($level < 0) {
$level = 0; $level = 0;
} }
@ -14328,7 +14342,7 @@ class TCPDF {
return; return;
} }
} }
$this->outlines[] = array('t' => $txt, 'l' => $level, 'y' => $y, 'p' => $page); $this->outlines[] = array('t' => $txt, 'l' => $level, 'y' => $y, 'p' => $page, 's' => strtoupper($style), 'c' => $color);
} }
/** /**
@ -14402,7 +14416,29 @@ class TCPDF {
$out .= ' /Last '.($n + $o['last']).' 0 R'; $out .= ' /Last '.($n + $o['last']).' 0 R';
} }
$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)));
$out .= ' /Count 0 >>'; // set font style
$style = 0;
if (!empty($o['s'])) {
// bold
if (strpos($o['s'], 'B') !== false) {
$style |= 2;
}
// oblique
if (strpos($o['s'], 'I') !== false) {
$style |= 1;
}
}
$out .= sprintf(' /F %d', $style);
// set bookmark color
if (isset($o['c']) AND is_array($o['c']) AND (count($o['c']) == 3)) {
$color = array_values($o['c']);
$out .= sprintf(' /C [%.3F %.3F %.3F]', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
} else {
// black
$out .= ' /C [0.0 0.0 0.0]';
}
$out .= ' /Count 0'; // normally closed item
$out .= ' >>';
$out .= "\n".'endobj'; $out .= "\n".'endobj';
$this->_out($out); $this->_out($out);
} }
@ -20865,7 +20901,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
case 'img': { case 'img': {
if (isset($tag['attribute']['src'])) { if (isset($tag['attribute']['src'])) {
// replace relative path with real server path // replace relative path with real server path
if (($tag['attribute']['src'][0] == '/') AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { if (($tag['attribute']['src'][0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
$findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']); $findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']);
if (($findroot === false) OR ($findroot > 1)) { if (($findroot === false) OR ($findroot > 1)) {
$tag['attribute']['src'] = $_SERVER['DOCUMENT_ROOT'].$tag['attribute']['src']; $tag['attribute']['src'] = $_SERVER['DOCUMENT_ROOT'].$tag['attribute']['src'];
@ -23326,7 +23362,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'] == $page) { if ($outline['p'] == $page) {
$this->outlines[] = array('t' => $outline['t'], 'l' => $outline['l'], 'y' => $outline['y'], 'p' => $this->page); $this->outlines[] = array('t' => $outline['t'], 'l' => $outline['l'], 'y' => $outline['y'], 'p' => $this->page, 's' => $outline['s'], 'c' => $outline['c']);
} }
} }
// copy links // copy links
@ -23350,12 +23386,14 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @param $numbersfont (string) set the font for page numbers (please use monospaced font for better alignment). * @param $numbersfont (string) set the font for page numbers (please use monospaced font for better alignment).
* @param $filler (string) string used to fill the space between text and page number. * @param $filler (string) string used to fill the space between text and page number.
* @param $toc_name (string) name to use for TOC bookmark. * @param $toc_name (string) name to use for TOC bookmark.
* @param $style (string) Font style for title: B = Bold, I = Italic, BI = Bold + Italic.
* @param $color (array) RGB color array for title (values from 0 to 255).
* @public * @public
* @author Nicola Asuni * @author Nicola Asuni
* @since 4.5.000 (2009-01-02) * @since 4.5.000 (2009-01-02)
* @see addTOCPage(), endTOCPage(), addHTMLTOC() * @see addTOCPage(), endTOCPage(), addHTMLTOC()
*/ */
public function addTOC($page='', $numbersfont='', $filler='.', $toc_name='TOC') { public function addTOC($page='', $numbersfont='', $filler='.', $toc_name='TOC', $style='', $color=array(0,0,0)) {
$fontsize = $this->FontSizePt; $fontsize = $this->FontSizePt;
$fontfamily = $this->FontFamily; $fontfamily = $this->FontFamily;
$fontstyle = $this->FontStyle; $fontstyle = $this->FontStyle;
@ -23508,7 +23546,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->setPageBuffer($p, $temppage); $this->setPageBuffer($p, $temppage);
} }
// move pages // move pages
$this->Bookmark($toc_name, 0, 0, $page_first); $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
for ($i = 0; $i < $numpages; ++$i) { for ($i = 0; $i < $numpages; ++$i) {
$this->movePage($page_last, $page); $this->movePage($page_last, $page);
} }
@ -23523,12 +23561,14 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @param $toc_name (string) name to use for TOC bookmark. * @param $toc_name (string) name to use for TOC bookmark.
* @param $templates (array) array of html templates. Use: "#TOC_DESCRIPTION#" for bookmark title, "#TOC_PAGE_NUMBER#" for page number. * @param $templates (array) array of html templates. Use: "#TOC_DESCRIPTION#" for bookmark title, "#TOC_PAGE_NUMBER#" for page number.
* @param $correct_align (boolean) if true correct the number alignment (numbers must be in monospaced font like courier and right aligned on LTR, or left aligned on RTL) * @param $correct_align (boolean) if true correct the number alignment (numbers must be in monospaced font like courier and right aligned on LTR, or left aligned on RTL)
* @param $style (string) Font style for title: B = Bold, I = Italic, BI = Bold + Italic.
* @param $color (array) RGB color array for title (values from 0 to 255).
* @public * @public
* @author Nicola Asuni * @author Nicola Asuni
* @since 5.0.001 (2010-05-06) * @since 5.0.001 (2010-05-06)
* @see addTOCPage(), endTOCPage(), addTOC() * @see addTOCPage(), endTOCPage(), addTOC()
*/ */
public function addHTMLTOC($page='', $toc_name='TOC', $templates=array(), $correct_align=true) { public function addHTMLTOC($page='', $toc_name='TOC', $templates=array(), $correct_align=true, $style='', $color=array(0,0,0)) {
$prev_htmlLinkColorArray = $this->htmlLinkColorArray; $prev_htmlLinkColorArray = $this->htmlLinkColorArray;
$prev_htmlLinkFontStyle = $this->htmlLinkFontStyle; $prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
// set new style for link // set new style for link
@ -23623,7 +23663,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->setPageBuffer($p, $temppage); $this->setPageBuffer($p, $temppage);
} }
// move pages // move pages
$this->Bookmark($toc_name, 0, 0, $page_first); $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
for ($i = 0; $i < $numpages; ++$i) { for ($i = 0; $i < $numpages; ++$i) {
$this->movePage($page_last, $page); $this->movePage($page_last, $page);
} }