LDAPAccountManager/lam/lib/lamPDF.inc

130 lines
4.0 KiB
PHP
Raw Normal View History

2007-11-14 10:28:39 +00:00
<?PHP
/*
$Id$
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
2007-11-14 10:28:39 +00:00
Copyright (C) 2003 - 2006 Michael Duergner
2013-03-16 13:39:33 +00:00
2007 - 2013 Roland Gruber
2007-11-14 10:28:39 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* LDAP Account Manager PDF printing library. It consists of lamPDF class,
* the createModulePDF() function that may be called by other pages
* and furthermore some helper functions.
2015-08-23 17:56:27 +00:00
*
2007-11-14 10:28:39 +00:00
* @author Michael Duergner
2012-02-05 10:38:59 +00:00
* @author Roland Gruber
2007-11-14 10:28:39 +00:00
* @package PDF
*/
/**
* Creates a LAM information page in PDF format.
2015-08-23 17:56:27 +00:00
*
2007-11-14 10:28:39 +00:00
* @package PDF
* @author Michael Duergner
2012-02-05 10:38:59 +00:00
* @author Roland Gruber
2007-11-14 10:28:39 +00:00
*/
class lamPDF extends UFPDF {
2015-08-23 17:56:27 +00:00
2007-11-14 10:28:39 +00:00
/**
* format settings for page layout
*/
2008-01-08 18:10:41 +00:00
private $page_definitions;
2015-08-23 17:56:27 +00:00
2007-11-14 10:28:39 +00:00
/**
* current active font name
*/
2008-01-08 18:10:41 +00:00
private $fontName;
2015-08-23 17:56:27 +00:00
2007-11-14 10:28:39 +00:00
/**
* list of supported fonts
* format: <font name> => array(<file for default font style>, <file for bold>, <italic>, <bold italic>)
*/
2008-01-08 18:10:41 +00:00
private $fontList = array(
2007-11-14 10:28:39 +00:00
'BitstreamVeraSans-Roman' => array('vera.php', 'verab.php', 'verabi.php', 'verai.php')
);
/**
2012-07-15 12:05:47 +00:00
* Creates a new lamPDF object.
2015-08-23 17:56:27 +00:00
*
2012-07-15 12:05:47 +00:00
* @param array $page_definitions page settings
* @param String $fontName font name
2007-11-14 10:28:39 +00:00
*/
2008-01-08 18:10:41 +00:00
function __construct($page_definitions = array(),$fontName) {
2007-11-14 10:28:39 +00:00
$this->fontName = $fontName;
2012-02-05 10:38:59 +00:00
if (!defined('FPDF_FONTPATH')) {
define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
}
2007-11-14 10:28:39 +00:00
// Call constructor of superclass
parent::__construct('P','mm','A4');
2015-08-23 17:56:27 +00:00
2007-11-14 10:28:39 +00:00
$this->page_definitions = $page_definitions;
2015-08-23 17:56:27 +00:00
2007-11-14 10:28:39 +00:00
// Open PDF file and write some basic information
$this->Open();
$this->AddFont($this->fontName, '', $this->fontList[$this->fontName][0]);
$this->AddFont($this->fontName, 'B', $this->fontList[$this->fontName][1]);
$this->AddFont($this->fontName, 'I', $this->fontList[$this->fontName][2]);
$this->AddFont($this->fontName, 'BI', $this->fontList[$this->fontName][3]);
$this->setFont($this->fontName,"",12);
$this->setTitle($this->page_definitions['headline']);
$this->setCreator("LDAP Account Manager");
2008-03-16 10:52:50 +00:00
$this->setMargins('10.0','10.0','10.0');
$this->setAutoPageBreak(true,'20.0');
2007-11-14 10:28:39 +00:00
}
2012-10-28 14:37:54 +00:00
2007-11-14 10:28:39 +00:00
/**
2012-07-15 12:05:47 +00:00
* Creates the PDF page header.
2007-11-14 10:28:39 +00:00
*/
function header() {
if($this->page_definitions['filename'] != 'none') {
2012-10-28 14:37:54 +00:00
$imageFile = substr(__FILE__,0,strlen(__FILE__)- 14) . "config/pdf/" . $_SESSION['config']->getName() . "/logos/" . $this->page_definitions['filename'];
2010-11-06 09:40:46 +00:00
$imgProperties = getimagesize($imageFile);
$this->Image($imageFile,10,15,($imgProperties[0] / $this->k) / 5, ($imgProperties[1] / $this->k) / 5,0,"JPG");
2007-11-14 10:28:39 +00:00
}
2010-11-06 09:40:46 +00:00
$this->SetY(23);
2007-11-14 10:28:39 +00:00
$this->SetFont($this->fontName,"B",18);
$this->Cell(170,5,$this->page_definitions['headline'],0,1,"R",0);
$this->Ln(3);
$this->SetLineWidth(0.4);
2010-11-06 09:40:46 +00:00
$this->Line(10,38,200,38);
2008-03-16 10:52:50 +00:00
$this->Line(10,40,200,40);
2007-11-14 10:28:39 +00:00
$this->SetY(50);
2013-03-16 13:39:33 +00:00
//set folding marks
if (isset($this->page_definitions['foldingmarks']) && ($this->page_definitions['foldingmarks'] == 'standard')) {
$this->SetLineWidth(0.2);
$foldingMarks = array(97, 202);
foreach ($foldingMarks as $mark) {
$this->Line(0, $mark, 5, $mark);
}
}
2007-11-14 10:28:39 +00:00
}
/**
2012-07-15 12:05:47 +00:00
* Creates the PDF page footer.
2007-11-14 10:28:39 +00:00
*/
function footer() {
$this->SetLineWidth(0.4);
$this->Line(10,280,200,280);
$this->Line(10,282,200,282);
$this->SetY(286);
$this->SetFont($this->fontName,"",7);
2015-08-23 17:56:27 +00:00
$this->Cell(0,5,_("This document was automatically created by LDAP Account Manager") . ' (' . getFormattedTime('Y-m-d H:i:s T') . ')',0,0,"C",0);
2007-11-14 10:28:39 +00:00
}
}
?>