2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 require_once('include/Sugarpdf/Sugarpdf.php');
42 * This is an helper class to generate PDF using smarty template.
43 * You have to extend this class, set the templateLocation to your smarty template
44 * location and assign the Smarty variables ($this->ss->assign()) in the overriden
45 * preDisplay method (don't forget to call the parent).
50 class SugarpdfSmarty extends Sugarpdf{
56 protected $templateLocation = "";
58 * The Sugar_Smarty object
63 * These 5 variables are use for the writeHTML method.
64 * @see include/tcpdf/tcpdf.php writeHTML()
66 protected $smartyLn = true;
67 protected $smartyFill = false;
68 protected $smartyReseth = false;
69 protected $smartyCell = false;
70 protected $smartyAlign = "";
72 function preDisplay(){
74 $this->print_header = false;
75 $this->print_footer = false;
76 $this->_initSmartyInstance();
80 //turn off all error reporting so that PHP warnings don't munge the PDF code
81 error_reporting(E_ALL);
86 $this->SetFont(PDF_FONT_NAME_MAIN,'',8);
88 if(!empty($this->templateLocation)){
89 $str = $this->ss->fetch($this->templateLocation);
90 $this->writeHTML($str, $this->smartyLn, $this->smartyFill, $this->smartyReseth, $this->smartyCell, $this->smartyAlign);
92 $this->Error('The class SugarpdfSmarty has to be extended and you have to set a location for the Smarty template.');
97 * Init the Sugar_Smarty object.
99 private function _initSmartyInstance(){
100 if ( !($this->ss instanceof Sugar_Smarty) ) {
101 require_once('include/Sugar_Smarty.php');
102 $this->ss = new Sugar_Smarty();
103 $this->ss->assign('MOD', $GLOBALS['mod_strings']);
104 $this->ss->assign('APP', $GLOBALS['app_strings']);