Code: Select all
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('JPATH_BASE') or die();
jimport('joomla.filesystem.file');
class PhocaPDFRender extends JDocument
{
function renderPDF( $document = '', $staticData = array()) {
// LOADING OF HELPER FILES (extended TCPDF library), LISTENING TO Phoca PDF Plugins
$option = JRequest::getCmd('option');
$t = JString::ucfirst(str_replace('com_', '', $option));
// Used abstract class of Phoca PDF (e.g. in VM)
if ($option == 'com_phocapdf') {
$type = JRequest::getCmd('type');
switch($type) {
case 'invoice':
case 'receipt':
case 'deliverynote':
$option = 'com_virtuemart';
break;
}
}
// Static Data - if the function is called as static with defined parameters
// and the pdf is not rendered as document
if (isset($staticData['option']) && $staticData['option'] != '') {
$option = $staticData['option'];
$pdfFileName = $staticData['filename'];
$t = '';
}
// Define - must be called before calling the plugin (because plugin includes definition file of tcpdf,
// so it must be defined before
if(!defined('K_TCPDF_EXTERNAL_CONFIG')) {define('K_TCPDF_EXTERNAL_CONFIG', true);}
if(!defined('K_PATH_MAIN')) {define("K_PATH_MAIN", JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'assets'.DS.'tcpdf');}
if(!defined('K_PATH_URL')) {define("K_PATH_URL", JPATH_BASE);}// URL path
if(!defined('K_PATH_FONTS')) {define("K_PATH_FONTS", JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'fonts'.DS);}
if(!defined('K_PATH_CACHE')) {define("K_PATH_CACHE", K_PATH_MAIN.DS.'cache'.DS);}// Cache directory path
$urlPath = JURI::base(true) . '/administrator/components/com_phocapdf/assets/tcpdf/';// Cache URL path
if(!defined('K_PATH_URL_CACHE')) {define("K_PATH_URL_CACHE", $urlPath.'cache/');}
if(!defined('K_PATH_IMAGES')) {define("K_PATH_IMAGES", K_PATH_MAIN.DS.'images'.DS);}// Images path
if(!defined('K_BLANK_IMAGE')) {define("K_BLANK_IMAGE", K_PATH_IMAGES.DS."_blank.png");}// Blank image path
if(!defined('K_CELL_HEIGHT_RATIO')) {define("K_CELL_HEIGHT_RATIO", 1.25);}// Cell height ratio
if(!defined('K_TITLE_MAGNIFICATION')) {define("K_TITLE_MAGNIFICATION", 1.3);}// Magnification scale for titles
if(!defined('K_SMALL_RATIO')) {define("K_SMALL_RATIO", 2/3);}// Reduction scale for small font
if(!defined('HEAD_MAGNIFICATION')) {define("HEAD_MAGNIFICATION", 1.1);}// Magnication scale for head
if(!defined('PDF_PAGE_FORMAT')) {define('PDF_PAGE_FORMAT', 'A4');}// page format
if(!defined('PDF_PAGE_ORIENTATION')) {define('PDF_PAGE_ORIENTATION', 'P');}// page orientation (P=portrait, L=landscape)
if(!defined('PDF_CREATOR')) {define('PDF_CREATOR', 'Phoca PDF');}// document creator
if(!defined('PDF_AUTHOR')) {define('PDF_AUTHOR', 'Phoca PDF');}// document author
if(!defined('PDF_HEADER_TITLE')) {define('PDF_HEADER_TITLE', 'Phoca PDF');}// header title
if(!defined('PDF_HEADER_STRING')) {define('PDF_HEADER_STRING', "Phoca PDF");}// header description string
//define('PDF_HEADER_LOGO', 'tcpdf_logo.jpg');// image logo
//define('PDF_HEADER_LOGO_WIDTH', 30);// header logo image width [mm]
if(!defined('PDF_UNIT')) {define('PDF_UNIT', 'mm');}// document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
if(!defined('PDF_header_margin')) {define('PDF_header_margin', 10);}// header margin
if(!defined('PDF_footer_margin')) {define('PDF_footer_margin', 10);}// footer margin
if(!defined('PDF_MARGIN_TOP')) {define('PDF_MARGIN_TOP', 33);}// top margin
if(!defined('PDF_MARGIN_BOTTOM')) {define('PDF_MARGIN_BOTTOM', 25);}// bottom margin
if(!defined('PDF_MARGIN_LEFT')) {define('PDF_MARGIN_LEFT', 15);}// left margin
if(!defined('PDF_MARGIN_RIGHT')) {define('PDF_MARGIN_RIGHT', 15);}// right margin
if(!defined('PDF_FONT_NAME_MAIN')) {define('PDF_FONT_NAME_MAIN', 'helvetica');}// main font name
if(!defined('PDF_FONT_SIZE_MAIN')) {define('PDF_FONT_SIZE_MAIN', 10);}// main font size
if(!defined('PDF_FONT_NAME_DATA')) {define('PDF_FONT_NAME_DATA', 'helvetica');}// data font name
if(!defined('PDF_FONT_SIZE_DATA')) {define('PDF_FONT_SIZE_DATA', 8);}// data font size
if(!defined('PDF_IMAGE_SCALE_RATIO')) {define('PDF_IMAGE_SCALE_RATIO', 4);}// Ratio used to scale the images
if(!defined('K_TCPDF_CALLS_IN_HTML')) {define('K_TCPDF_CALLS_IN_HTML', true);}
switch ($option) {
case 'com_content':
$content = new JObject();
// Get info from Phoca PDF Content Plugin
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin('system');
$results = $dispatcher->trigger('onBeforeCreatePDFContent', array (&$content));
if (JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'helpers'.DS.'phocapdfcontenttcpdf.php')) {
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'helpers'.DS.'phocapdfcontenttcpdf.php');
$pdf = new PhocaPDFContentTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
} else {
return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF library (Content) failed');
}
break;
case 'com_phocamenu':
// Get info from Phoca PDF Restaurant Menu Plugin
$content = new JObject();
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin('phocapdf');
$results = $dispatcher->trigger('onBeforeCreatePDFRestaurantMenu', array (&$content));
if (JFile::exists(JPATH_SITE.DS.'plugins'.DS.'phocapdf'.DS.'restaurantmenu.php')) {
require_once(JPATH_SITE.DS.'plugins'.DS.'phocapdf'.DS.'restaurantmenu.php');
$pdf = new PhocaPDFRestaurantMenuTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
} else {
return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF Plugin (Restaurant Menu) failed');
}
break;
case 'com_virtuemart':
// Get info from Phoca PDF VirtueMart Plugin
$content = new JObject();
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin('phocapdf');
$results = $dispatcher->trigger('onBeforeCreatePDFVirtueMart', array (&$content, $staticData));
if (JFile::exists(JPATH_SITE.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart.php')) {
require_once(JPATH_SITE.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart.php');
$pdf = new PhocaPDFVirtueMartTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
$pdf->setStaticData($staticData);
} else {
return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF Plugin (VirtueMart) failed');
}
break;
default:
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'helpers'.DS.'phocapdf.php');
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'assets'.DS.'tcpdf'.DS.'tcpdf.php');
$content = new JObject();
// Get info from Phoca PDF Content Plugin
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin('system');
$results = $dispatcher->trigger('onBeforeCreatePDF'.$t, array (&$content));
$pdf = new TCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
break;
break;
}
//krumo("exit");exit;
$pdf->SetMargins($content->margin_left, $content->margin_top, $content->margin_right);
$pdf->SetAutoPageBreak(TRUE, $content->margin_bottom);
$pdf->setCellHeightRatio($content->site_cell_height);
$pdf->setFont($content->font_type);
$siteFontColor = $pdf->convertHTMLColorToDec($content->site_font_color);
$pdf->SetTextColor($siteFontColor['R'], $siteFontColor['G'], $siteFontColor['B']);
//$pdf->setPageFormat($content->page_format, $content->page_orientation);
$pdf->SetHeaderMargin($content->header_margin);
$pdf->SetFooterMargin($content->footer_margin);
$pdf->setImageScale($content->image_scale);
// PDF Metadata
$pdf->SetCreator(PDF_CREATOR);
// Content
switch ($option) {
default:
$results = $dispatcher->trigger('onBeforeDisplayPDF'.$t, array (&$pdf, &$content, &$this));
break;
case 'com_content':
$results = $dispatcher->trigger('onBeforeDisplayPDFContent', array (&$pdf, &$content, &$document));
break;
case 'com_phocamenu':
$results = $dispatcher->trigger('onBeforeDisplayPDFRestaurantMenu', array (&$pdf, &$content, &$document));
break;
case 'com_virtuemart':
$results = $dispatcher->trigger('onBeforeDisplayPDFVirtueMart', array (&$pdf, &$content, &$document, $staticData));
break;
}
if (isset($staticData['file']) && $staticData['file'] != '') {
$pdf->Output($staticData['file'], 'F');
return true;
}
// Called from administrator area (administrator calls frontend view, but it still administrator area)
$adminView = JRequest::getVar('admin', 0, '', 'int');
if ($adminView == 1) {
$content->pdf_destination = 'S';
}
if ($content->pdf_destination == 'D' || $content->pdf_destination == 'I') {
$pdf->Output($content->pdf_name, $content->pdf_destination);
return true;
}
$data = $pdf->Output($content->pdf_name, $content->pdf_destination);
return $data;
}
}
Code: Select all
<?php
// core font definition file for TCPDF (www.tcpdf.org)
$type='core';
$dw=788;
$cw=array(0=>0,1=>0,2=>0,3=>0,4=>0,5=>0,6=>0,7=>0,8=>0,9=>0,10=>0,11=>0,12=>0,
13=>0,14=>0,15=>0,16=>0,17=>0,18=>0,19=>0,20=>0,21=>0,22=>0,23=>0,24=>0,25=>0,
26=>0,27=>0,28=>0,29=>0,30=>0,31=>0,32=>278,33=>974,34=>961,35=>974,36=>980,
37=>719,38=>789,39=>790,40=>791,41=>690,42=>960,43=>939,44=>549,45=>855,46=>911,
47=>933,48=>911,49=>945,50=>974,51=>755,52=>846,53=>762,54=>761,55=>571,56=>677,
57=>763,58=>760,59=>759,60=>754,61=>494,62=>552,63=>537,64=>577,65=>692,66=>786,
67=>788,68=>788,69=>790,70=>793,71=>794,72=>816,73=>823,74=>789,75=>841,76=>823,
77=>833,78=>816,79=>831,80=>923,81=>744,82=>723,83=>749,84=>790,85=>792,86=>695,
87=>776,88=>768,89=>792,90=>759,91=>707,92=>708,93=>682,94=>701,95=>826,96=>815,
97=>789,98=>789,99=>707,100=>687,101=>696,102=>689,103=>786,104=>787,105=>713,
106=>791,107=>785,108=>791,109=>873,110=>761,111=>762,112=>762,113=>759,114=>759,
115=>892,116=>892,117=>788,118=>784,119=>438,120=>138,121=>277,122=>415,123=>392,
124=>392,125=>668,126=>668,127=>0,128=>390,129=>390,130=>317,131=>317,132=>276,
133=>276,134=>509,135=>509,136=>410,137=>410,138=>234,139=>234,140=>334,141=>334,
142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0,149=>0,150=>0,151=>0,152=>0,
153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0,160=>0,161=>732,162=>544,163=>544,
164=>910,165=>667,166=>760,167=>760,168=>776,169=>595,170=>694,171=>626,172=>788,
173=>788,174=>788,175=>788,176=>788,177=>788,178=>788,179=>788,180=>788,181=>788,
182=>788,183=>788,184=>788,185=>788,186=>788,187=>788,188=>788,189=>788,190=>788,
191=>788,192=>788,193=>788,194=>788,195=>788,196=>788,197=>788,198=>788,199=>788,
200=>788,201=>788,202=>788,203=>788,204=>788,205=>788,206=>788,207=>788,208=>788,
209=>788,210=>788,211=>788,212=>894,213=>838,214=>1016,215=>458,216=>748,217=>924,
218=>748,219=>918,220=>927,221=>928,222=>928,223=>834,224=>873,225=>828,226=>924,
227=>924,228=>917,229=>930,230=>931,231=>463,232=>883,233=>836,234=>836,235=>867,
236=>867,237=>696,238=>696,239=>874,240=>0,241=>874,242=>760,243=>946,244=>771,
245=>865,246=>771,247=>888,248=>967,249=>888,250=>831,251=>873,252=>927,253=>970,
254=>918,255=>0);
// --- EOF ---
as the fabrik forms / tables can contain checkboxes which are rendered in this font.
Also anything outputted as a heading seems to get its encoding messed up, but I'm not sure why that is (if I copy it and try to paste it here the correct text is pasted but in Foxit PDF reader the text is shown as garbled characters.
Finally I saw no way of getting the plug-ins parameters to show in the phocpdf plugin administration interface. Could you give me a hint as to how to do that?