diff --git a/gosa-core/include/exporter/class_pdfExporter.inc b/gosa-core/include/exporter/class_pdfExporter.inc
index 28012a0d8c47cac94d01f52abaaeb4dd609e1051..d1c836e79e0296e0db033ac865126d856744bd59 100644 (file)
<?php
-
// Try to load PDF library
-define('FPDF_FONTPATH', '/usr/share/php/fpdf/font/');
-include('fpdf/fpdf.php');
+@include_once('fpdf/fpdf.php');
+
+// Load supporter class only if FPDF is loaded
+$classes= get_declared_classes();
+if(in_array('FPDF', $classes)) {
+ include('class_PDF.inc');
+}
class pdfExporter
{
var $result;
function pdfExporter($headline, $header, $entries, $columns= array()) {
+ // Bail out if no FPDF available
+ if(!class_exists('FPDF')) {
+ die(_("No PDF export possible: there is no FPDF library installed."));
+ }
+
// If no preset, render all columns
if (!count($columns)) {
foreach ($header as $index => $dummy) {
}
// Create new PDF
- $this->result=new FPDF('L', 'mm', 'A4');
+ $this->result=new PDF('L', 'mm', 'A4');
+ $this->result->AliasNbPages();
$this->result->SetFont('Helvetica', '', 10);
+ $this->result->setHeadline(utf8_decode($headline));
$this->result->AddPage();
// Analyze for width
// Render head
$this->result->SetFont('','B');
- $this->result->Cell(0,0,utf8_decode($headline),0,0,'L');
- $this->result->Ln(5);
-
- // Generate header
- $this->result->SetFillColor(240,240,240);
$this->result->SetTextColor(0);
$this->result->SetDrawColor(0,0,0);
$this->result->SetLineWidth(.3);
- $this->result->SetFont('','B');
-
- foreach ($columns as $order => $index) {
- if (isset($header[$index])){
- $this->result->Cell($width[$order], 7, utf8_decode($header[$index]), 1, 0, 'C', 1);
- } else {
- $this->result->Cell($width[$order], 7, '', 1, 0, 'C', 1);
- }
- }
- $this->result->Ln();
- // Append entries
- $this->result->SetFillColor(224,235,255);
- $this->result->SetTextColor(0);
- $this->result->SetFont('');
+ // Height calculator
+ $height= 0;
$fill= false;
foreach ($entries as $row) {
+ // Render header
+ if ($height == 0) {
+ // Generate header
+ $this->result->SetFillColor(230,230,230);
+ $this->result->SetFont('','B');
+
+ foreach ($columns as $order => $index) {
+ if (isset($header[$index])){
+ $this->result->Cell($width[$order], 7, utf8_decode($header[$index]), 1, 0, 'C', 1);
+ } else {
+ $this->result->Cell($width[$order], 7, '', 1, 0, 'C', 1);
+ }
+ }
+ $this->result->Ln();
+ $height= 7;
+
+ // Set entry collors
+ $this->result->SetFillColor(240,240,240);
+ $this->result->SetFont('');
+ }
+
foreach ($columns as $order => $index) {
if (isset($row["_sort$index"])){
}
$this->result->Ln();
- $fill= !$fill;
+
+ // Increase height to eventually create new page
+ $height+= 8;
+ if ($height > 220) {
+ $height= 0;
+ $this->result->Cell(array_sum($width), 0, '', 'T');
+ $this->result->AddPage();
+ $fill= false;
+ } else {
+ $fill= !$fill;
+ }
}
$this->result->Cell(array_sum($width), 0, '', 'T');
}