src.dualinventive.com/mtinfo/dist/webroot/main/include/pdf.php

580 lines
23 KiB
PHP

<?php
/** \file scripts\page\pdf.php
* \brief DI webinterface pdf script.
* \author Rob Schalken, Core|Vision
* \version 1.0
* \date 17-10-2008
*
* This file contains the pdf scripts.
*/
/*
* Definitions
*/
define("PDF_MARGIN_LEFT" ,27);
define("PDF_MARGIN_RIGHT" ,28);
define("PDF_MARGIN_BOTTOM" ,40);
define("PDF_MARGIN_TOP" ,10);
define("PDF_WIDTH" ,595 - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT);
define("PDF_LOGO_WIDTH" ,100);
define("PDF_LOGO_HEIGHT" ,41);
/**
* Print pdf line
*/
function pdf_print_line($value, $border = "", $bold = "", $align = "", $font_size = "", $cell_width = "", $cell_height = 16, $check_page_end = 1, $ishtml = "", $nr_lines = 1, $new_page_hdr = "", $styling_options = "") {
global $_PAGE_INFO;
// New page header?
if (strlen($new_page_hdr)) {
if ($new_page_hdr) {
// store new page header
$_PAGE_INFO['new_page_hdr'] = array(value => $value ,
border => $border ,
bold => $bold ,
align => $align ,
font_size => $font_size ,
cell_width => $cell_width ,
cell_height => $cell_height ,
check_page_end => $check_page_end ,
ishtml => $ishtml );
}
else {
$_PAGE_INFO['new_page_hdr'] = "";
}
}
if (is_array($value)) {
// New page?
if ((($_PAGE_INFO['height'] - ($nr_lines * $cell_height)) < PDF_MARGIN_BOTTOM) || (($nr_lines * $cell_height) > $_PAGE_INFO['height'])) {
pdf_page_new();
}
// Add new page header?
if (($_PAGE_INFO['header_first']) && (is_array($_PAGE_INFO['new_page_hdr']))) {
print_line($_PAGE_INFO['new_page_hdr']['value'] ,
$_PAGE_INFO['new_page_hdr']['border'] ,
$_PAGE_INFO['new_page_hdr']['bold'] ,
$_PAGE_INFO['new_page_hdr']['align'] ,
$_PAGE_INFO['new_page_hdr']['font_size'] ,
$_PAGE_INFO['new_page_hdr']['cell_width'] ,
$_PAGE_INFO['new_page_hdr']['cell_height'] ,
$_PAGE_INFO['new_page_hdr']['check_page_end'] ,
$_PAGE_INFO['new_page_hdr']['ishtml'] ,
$_PAGE_INFO['new_page_hdr']['styling_options'] );
}
// New line
print_line($value, $border, $bold, $align, $font_size, $cell_width, $cell_height, $check_page_end, $ishtml, $styling_options);
}
}
/**
* Create image
*/
function pdf_print_image($name, $source, $height, $width = PDF_WIDTH, $left = PDF_MARGIN_LEFT) {
global $_PAGE_INFO;
// New page?
if (($_PAGE_INFO['height'] - $height) < PDF_MARGIN_BOTTOM) {
pdf_page_new();
}
// Skip image?
if ($height < $_PAGE_INFO['height']) {
// Load header image
$_PAGE_INFO[$name] = PDF_load_image($_PAGE_INFO['pdf'], "auto", $source, "");
if ($_PAGE_INFO[$name] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Create table
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "image=" . $_PAGE_INFO[$name] . "");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Add table
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, $left, ($_PAGE_INFO['height'] - $height), ($left + $width), $_PAGE_INFO['height'], "");
if ($result == "_error") {
die("Couldn't place table (7): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Decrement height counter
$_PAGE_INFO['height'] -= $height;
}
}
/**
* New page pdf
*/
function pdf_page_new() {
page_footer();
page_header();
}
/**
* Print the pdf page header
*/
function pdf_page_header($page_subject = "", $header_subject = "", $data = "") {
global $_PAGE_INFO;
// Define page subject
$_PAGE_INFO['page_subject'] = $page_subject;
// Create new pdf document
$_PAGE_INFO['pdf'] = PDF_new();
// Set license
PDF_set_parameter($_PAGE_INFO['pdf'], "license", "L700102-010500-736029-N8GN22-6BRR72");
// This means we must check return values
PDF_set_parameter($_PAGE_INFO['pdf'], "errorpolicy", "return");
// Set parameters needed for font
PDF_set_parameter($_PAGE_INFO['pdf'], "textformat", "utf8");
PDF_set_parameter($_PAGE_INFO['pdf'], "SearchPath", FONT_DIR);
PDF_set_parameter($_PAGE_INFO['pdf'], "FontOutline", "Verdana=verdana.ttf");
PDF_set_parameter($_PAGE_INFO['pdf'], "FontOutline", "Verdana-Bold=verdanab.ttf");
PDF_set_parameter($_PAGE_INFO['pdf'], "FontOutline", "Verdana-Italic=verdanai.ttf");
PDF_set_parameter($_PAGE_INFO['pdf'], "FontOutline", "Verdana-BoldItalic=verdanaz.ttf");
if (PDF_begin_document($_PAGE_INFO['pdf'], "", "openmode=bookmarks flush=page") == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Set creator/Author/subject
PDF_set_info($_PAGE_INFO['pdf'], "Creator", $_PAGE_INFO['skin_name']);
PDF_set_info($_PAGE_INFO['pdf'], "Author" , $_PAGE_INFO['skin_name']);
PDF_set_info($_PAGE_INFO['pdf'], "Subject", _($page_subject));
// Load header image
$image_src = $_PAGE_INFO['base_path'] . SKIN_DIR . $_PAGE_INFO['skin'] . "/" . $_PAGE_INFO['ini']['report']['header_logo'];
$_PAGE_INFO['header'] = PDF_load_image($_PAGE_INFO['pdf'], "auto", $image_src, "");
if ($_PAGE_INFO['header'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Load Font
$_PAGE_INFO['font'] = PDF_load_font($_PAGE_INFO['pdf'], "Verdana", "unicode", "");
if ($_PAGE_INFO['font'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$_PAGE_INFO['font-bold'] = PDF_load_font($_PAGE_INFO['pdf'], "Verdana-Bold", "unicode", "");
if ($_PAGE_INFO['font-bold'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$_PAGE_INFO['font-italic'] = PDF_load_font($_PAGE_INFO['pdf'], "Verdana-Italic", "unicode", "");
if ($_PAGE_INFO['font-italic'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$_PAGE_INFO['font-bolditalic'] = PDF_load_font($_PAGE_INFO['pdf'], "Verdana-BoldItalic", "unicode", "");
if ($_PAGE_INFO['font-bolditalic'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Initial values
$_PAGE_INFO['link'] = 0;
$_PAGE_INFO['page'] = 0;
// Create header
page_header();
// Header
if (strlen($header_subject)) {
print_line(array($header_subject), array("LRT"), array(1), "", array(16), "", 18, 0, "");
print_line(array(""), array("LR"), "", "", "", "", 4, 0, "");
}
// Header data
if (is_array($data)) {
// Default width
$width = 115;
if ((isset($_PAGE_INFO['orientation'])) && ($_PAGE_INFO['orientation'] == "landscape")) {
$width = 198;
}
for ($i = 0; $i < sizeof($data); $i++) {
if (($i + 1) == sizeof($data)) {
print_line(array(_($data[$i][0]) . ":",$data[$i][1]), array("LB","LRBT"), array(1,0), array("R","L"), array(8,8), array($width,65), 16, 0, "");
}
else {
print_line(array(_($data[$i][0]) . ":",$data[$i][1]), array("L","LRBT"), array(1,0), array("R","L"), array(8,8), array($width,65), 16, 0, "");
}
}
}
// Empty line
print_line(array(""), "", "", "", "", "", 16, 0, "");
print_line(array(""), "", "", "", "", "", 16, 0, "");
}
/**
* Print the pdf page footer
*/
function pdf_page_footer($file = "", $dest = "D") {
global $_PAGE_INFO;
// Initial value
$result = "";
// Set title
PDF_set_info($_PAGE_INFO['pdf'], "Title", $file);
// Create footer
page_footer();
// Add page footers
for ($i = 1; $i <= $_PAGE_INFO['page']; $i++) {
// Go to previous page
PDF_resume_page($_PAGE_INFO['pdf'], "pagenumber " . $i);
// Bottom line
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "matchbox={borderwidth=1 drawbottom=false drawright=false drawleft=false drawtop=true}");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT, (PDF_MARGIN_BOTTOM - 10), PDF_MARGIN_LEFT + $_PAGE_INFO['PDF_WIDTH'], (PDF_MARGIN_BOTTOM - 14), "");
if ($result == "_error") {
die("Couldn't place table (1): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// page number
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, $i . " / " . $_PAGE_INFO['page'], "fittextline={font=" . $_PAGE_INFO['font'] . " fontsize=8 position={center center}} colwidth=100");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Create new page
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, (($_PAGE_INFO['PDF_WIDTH'] + PDF_MARGIN_LEFT + PDF_MARGIN_RIGHT)/2 - 50), (PDF_MARGIN_BOTTOM - 14), (($_PAGE_INFO['PDF_WIDTH'] + PDF_MARGIN_LEFT + PDF_MARGIN_RIGHT)/2 + 50), (PDF_MARGIN_BOTTOM - 30), "");
if ($result == "_error") {
die("Couldn't place table (2): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// page footer text
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, $_PAGE_INFO['ini']['report']['footer_text'], "fittextline={font=" . $_PAGE_INFO['font'] . " fontsize=8}");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT + 10, (PDF_MARGIN_BOTTOM - 14), PDF_MARGIN_LEFT + 200, (PDF_MARGIN_BOTTOM - 30), "");
if ($result == "_error") {
die("Couldn't place table (4): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Delete table
PDF_delete_table($_PAGE_INFO['pdf'], $table, "");
// EOP
PDF_end_page_ext($_PAGE_INFO['pdf'], "");
}
// EOF
PDF_end_document($_PAGE_INFO['pdf'], "");
if ($dest == "D") {
// Download document
download_document(array('mimetype' => "application/pdf", 'document' => PDF_get_buffer($_PAGE_INFO['pdf']), 'filename' => $file));
}
else {
$result = PDF_get_buffer($_PAGE_INFO['pdf']);
}
// Delete document
PDF_delete($_PAGE_INFO['pdf']);
// Remove all attached files
if (!empty($_PAGE_INFO['delete'])) {
foreach ($_PAGE_INFO['delete'] as $file) {
if (file_exists($file)) {
unlink($file);
}
}
}
return $result;
}
/********************************************************************************
* Internal functions
********************************************************************************/
/**
* Create page header
*/
function page_header() {
global $_PAGE_INFO;
// Create new page
if ((isset($_PAGE_INFO['orientation'])) && ($_PAGE_INFO['orientation'] == "landscape")) {
PDF_begin_page_ext($_PAGE_INFO['pdf'], 0, 0, "width=a4.height height=a4.width");
$_PAGE_INFO['PDF_WIDTH'] = 844 - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT;
$_PAGE_INFO['PDF_HEIGHT'] = 595;
//define("PDF_WIDTH" ,844 - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT); // Width 100% = 180
//define("PDF_HEIGHT" ,595);
}
else {
PDF_begin_page_ext($_PAGE_INFO['pdf'], 0, 0, "width=a4.width height=a4.height");
$_PAGE_INFO['PDF_WIDTH'] = 595 - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT;
$_PAGE_INFO['PDF_HEIGHT'] = 842;
//define("PDF_HEIGHT" ,842);
//define("PDF_WIDTH" ,595 - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT); // Width 100% = 262
}
// Reset height counter
$_PAGE_INFO['height'] = $_PAGE_INFO['PDF_HEIGHT'];
// Add header image
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "image=" . $_PAGE_INFO['header']);
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT, ($_PAGE_INFO['height'] - PDF_MARGIN_TOP - PDF_LOGO_HEIGHT), (PDF_MARGIN_LEFT + PDF_LOGO_WIDTH), $_PAGE_INFO['height'] - PDF_MARGIN_TOP, "");
if ($result == "_error") {
die("Couldn't place table (5): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Add header info
print_line(array("") , "" , "" , "", "" , "" , 12, 0, "");
print_line(array("", ucwords($_PAGE_INFO['skin_name'])) , "" , array(0,1), "", array(12,12), array(40,140), 14, 0, "");
print_line(array("", _($_PAGE_INFO['page_subject'])) , "" , array(0,0), "", array(10,10), array(40,140), 14, 0, "");
print_line(array("", $_PAGE_INFO['ini']['report']['website']), "" , array(0,0), "", array(10,10), array(40,140), 10, 0, array("",$_PAGE_INFO['ini']['report']['website']));
// Top line
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "matchbox={borderwidth=1 drawbottom=false drawright=false drawleft=false drawtop=true}");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT, ($_PAGE_INFO['PDF_HEIGHT'] - 55), PDF_MARGIN_LEFT + $_PAGE_INFO['PDF_WIDTH'], (PDF_HEIGHT - 65), "");
if ($result == "_error") {
die("Couldn't place table (6): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Delete table
PDF_delete_table($_PAGE_INFO['pdf'], $table, "");
// empty lines
print_line(array(""), "" , "", "", "", "", 20, 0, "");
// Set header first flag
$_PAGE_INFO['header_first'] = 1;
// Increment page
$_PAGE_INFO['page']++;
}
/**
* Create page footer
*/
function page_footer() {
global $_PAGE_INFO;
// EOP => suspend
PDF_suspend_page($_PAGE_INFO['pdf'], "");
}
/**
* Create page line
*/
function print_line($value, $border = "", $bold = "", $align = "", $font_size = "", $cell_width = "", $cell_height = 16, $check_page_end = 1, $ishtml = "", $styling_options = "") {
global $_PAGE_INFO;
// Reset row width
$row_width = PDF_MARGIN_LEFT;
if (is_array($value)) {
for($i = 0; $i < sizeof($value); $i++) {
// Link?
$optlist = "";
// Font bold/regular?
$font = ((is_array($bold)) && ($bold[$i])) ? $_PAGE_INFO['font-bold'] : $_PAGE_INFO['font'];
// Font alignment?
if ((is_array($align)) && (strtolower($align[$i]) == "c")) {
$fittextoptions = "alignment=center ";
}
else if ((is_array($align)) && (strtolower($align[$i]) == "r")) {
$fittextoptions = "alignment=right ";
$optlist .= "marginright=2 ";
}
else {
$fittextoptions = "alignment=left ";
$optlist .= "marginleft=2 ";
}
// Create matchbox
$optlist .= "matchbox={name=matchbox_" . $_PAGE_INFO['link'] . " ";
// Borders?
if ((is_array($border)) && (strlen($border[$i]))) {
$optlist .= (strpos(strtolower($border[$i]), "l") !== FALSE) ? "drawleft=true " : "drawleft=false ";
$optlist .= (strpos(strtolower($border[$i]), "r") !== FALSE) ? "drawright=true " : "drawright=false ";
$optlist .= (strpos(strtolower($border[$i]), "t") !== FALSE) ? "drawtop=true " : "drawtop=false ";
$optlist .= (strpos(strtolower($border[$i]), "b") !== FALSE) ? "drawbottom=true " : "drawbottom=false ";
$optlist .= "borderwidth=0.5 ";
}
else {
$optlist .= "drawleft=false drawright=false drawtop=false drawbottom=false borderwidth=0 ";
}
// Extra styling options for cell?
$optlist_font = "";
if ((is_array($styling_options)) && (isset($styling_options[$i]))) {
if (isset($styling_options[$i]['cell'])) {
$optlist .= $styling_options[$i]['cell'] . " ";
}
if (isset($styling_options[$i]['font'])) {
$optlist_font = $styling_options[$i]['font'];
}
if (isset($styling_options[$i]['fontstyle'])) {
switch($styling_options[$i]['fontstyle']) {
case "italic":
if (!$bold) {
$font = $_PAGE_INFO['font-italic'];
}
else {
$font = $_PAGE_INFO['font-bolditalic'];
}
break;
default:
// Rest (normal, bold) already supported
break;
}
}
}
// Add EOF/BOF border
if ($check_page_end) {
if (($_PAGE_INFO['height'] - (2 * $cell_height)) < PDF_MARGIN_BOTTOM) {
if (strpos(strtolower($border[$i]), "b") !== FALSE) {
$optlist .= "drawbottom=true borderwidth=0.5 ";
}
}
if ($_PAGE_INFO['header_first']) {
if (strpos(strtolower($border[$i]), "b") !== FALSE) {
$optlist .= "drawtop=true borderwidth=0.5 ";
}
}
}
$optlist .= "} ";
if ((is_array($ishtml)) && (((strtolower($ishtml[$i]['type']) == "link") && (strlen($ishtml[$i]['data']))) || (strtolower($ishtml[$i]['type']) == "attachment"))) {
$fittextoptions .= "fillcolor={" . $_PAGE_INFO['ini']['report']['link_color'] . "} ";
}
// Table width
$width = (!is_array($cell_width)) ? $_PAGE_INFO['PDF_WIDTH']/sizeof($value) : ($cell_width[$i] * 3);
$fittextoptions = $fittextoptions . " font=" . $font;
if (is_numeric($font_size[$i])) {
$fittextoptions .= " fontsize=" . $font_size[$i];
}
$fittextoptions .= " " . $optlist_font;
$textFlow = PDF_add_textflow($_PAGE_INFO['pdf'], 0, _($value[$i]), $fittextoptions);
// Create table
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, '', $optlist . "textflow=$textFlow colwidth=100% rowheight=100%");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Add table
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, $row_width, ($_PAGE_INFO['height'] - $cell_height), ($row_width + $width), $_PAGE_INFO['height'], "horshrinklimit=25%");
if ($result == "_error") {
//die("Couldn't place table (7): " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
// Add link?
if ((is_array($ishtml)) && (strtolower($ishtml[$i]['type']) == "link") && (strlen($ishtml[$i]['data']))) {
$action = PDF_create_action($_PAGE_INFO['pdf'], "URI", "url={" . $ishtml[$i]['data'] . "}");
$annotation = PDF_create_annotation($_PAGE_INFO['pdf'],0, 0, 0, 0, "link", "action={activate " . $action . "} usematchbox={matchbox_" . $_PAGE_INFO['link'] . "} linewidth=0");
}
// Add file attachment?
if ((is_array($ishtml)) && (strtolower($ishtml[$i]['type']) == "attachment")) {
// Check if file exists
if ((file_exists($ishtml[$i]['filename'])) && (filesize($ishtml[$i]['filename'])) > 0) {
// Load attachment image
$image_src = $_PAGE_INFO['base_path'] . IMAGE_DIR . "attachment.png";
$_PAGE_INFO['attachment'] = PDF_load_image($_PAGE_INFO['pdf'], "auto", $image_src, "");
if ($_PAGE_INFO['attachment'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$_PAGE_INFO['filename'] = $ishtml[$i]['filename'];
$_PAGE_INFO['mimetype'] = $ishtml[$i]['mimetype'];
$annotation = PDF_create_annotation($_PAGE_INFO['pdf'],0, 0, 0, 0, "FileAttachment", "filename={" . $ishtml[$i]['filename'] . "} contents={". $ishtml[$i]['data'] . "} mimetype=\"" . $ishtml[$i]['mimetype'] . "\" opacity=0 usematchbox={matchbox_" . $_PAGE_INFO['link'] . "}");
// Add paperclip
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "image=" . $_PAGE_INFO['attachment']);
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT + ($i * $row_width) + 2, ($_PAGE_INFO['height'] - $cell_height + 1), PDF_MARGIN_LEFT + ($i * $row_width) + 14, $_PAGE_INFO['height'] - 1, "");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
}
}
// Add image?
if ((is_array($ishtml)) && (strtolower($ishtml[$i]['type']) == "image")) {
// Load item image
$image_src = $_PAGE_INFO['base_path'] . IMAGE_DIR . $ishtml[$i]['filename'];
$_PAGE_INFO['image'] = PDF_load_image($_PAGE_INFO['pdf'], "auto", $image_src, "");
if ($_PAGE_INFO['image'] == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
$table = PDF_add_table_cell($_PAGE_INFO['pdf'], 0, 1, 1, "", "image=" . $_PAGE_INFO['image']);
$result = PDF_fit_table($_PAGE_INFO['pdf'], $table, PDF_MARGIN_LEFT + ($ishtml[$i]['left'] * 3), ($_PAGE_INFO['height'] - $cell_height + 1), PDF_MARGIN_LEFT + ($ishtml[$i]['left'] * 3) + $ishtml[$i]['width'], $_PAGE_INFO['height'] - 1, "");
if ($table == 0) {
die("Error: " . PDF_get_errmsg($_PAGE_INFO['pdf']));
}
}
// Add bookmark?
if ((is_array($ishtml)) && (strtolower($ishtml[$i]['type']) == "bookmark")) {
// Bold?
$font = ((isset($ishtml[$i]['bold'])) && ($ishtml[$i]['bold'])) ? "fontstyle=bold" : "";
// New parent?
$parent = ((isset($ishtml[$i]['parent'])) && ($ishtml[$i]['parent'])) ? "parent=" . $ishtml[$i]['parent'] . "" : "parent=0";
// Create bookmark
$txt = _($ishtml[$i]['data']);
$handle = PDF_create_bookmark($_PAGE_INFO['pdf'], (strlen($txt) ? $txt : $ishtml[$i]['data'] . ' '), $font . " " . $parent);
// New handle?
$_PAGE_INFO['bookmark_handle'] = ((isset($ishtml[$i]['parent'])) && (!$ishtml[$i]['parent'])) ? $handle : $_PAGE_INFO['bookmark_handle'];
}
// Delete table
PDF_delete_table($_PAGE_INFO['pdf'], $table, "");
// Increment counters
$row_width += $width;
$_PAGE_INFO['link']++;
}
// Decrement height counter
$_PAGE_INFO['height'] -= $cell_height;
// Clear header first
$_PAGE_INFO['header_first'] = 0;
}
}
?>