31 $classes = get_declared_classes();
32 if (in_array(
'FPDF', $classes)) {
33 include(
'class_PDF.php');
54 function __construct ($headline, $header, $entries, $columns = [])
57 if (!class_exists(
'FPDF')) {
58 die(_(
"No PDF export possible: there is no FPDF library installed."));
62 if (!count($columns)) {
63 $columns = array_keys($header);
67 $this->result =
new PDF(
'L',
'mm',
'A4');
68 $this->result->AliasNbPages();
69 $this->result->SetFont(
'Helvetica',
'', 10);
70 $this->result->setHeadline(utf8_decode($headline));
71 $this->result->AddPage();
74 $width = $this->
calcWidth($header, $entries, $columns);
77 $this->result->SetFont(
'',
'B');
78 $this->result->SetTextColor(0);
79 $this->result->SetDrawColor(0, 0, 0);
80 $this->result->SetLineWidth(.3);
86 foreach ($entries as $row) {
90 $this->result->SetFillColor(230, 230, 230);
91 $this->result->SetFont(
'',
'B');
93 foreach ($columns as $order => $index) {
94 if (isset($header[$index])) {
95 $this->result->Cell($width[$order], 7, utf8_decode($header[$index]), 1, 0,
'C', 1);
97 $this->result->Cell($width[$order], 7,
'', 1, 0,
'C', 1);
104 $this->result->SetFillColor(240, 240, 240);
105 $this->result->SetFont(
'');
108 foreach ($columns as $order => $index) {
109 if (isset($row[
"_sort$index"])) {
110 $this->result->Cell($width[$order], 6, utf8_decode($row[
"_sort$index"]),
'LR', 0,
'L', $fill);
112 $this->result->Cell($width[$order], 6,
'',
'LR', 0,
'L', $fill);
122 $this->result->Cell(array_sum($width), 0,
'',
'T');
123 $this->result->AddPage();
129 $this->result->Cell(array_sum($width), 0,
'',
'T');
146 foreach ($columns as $index) {
149 if (isset($header[$index])) {
150 $len = $this->result->GetStringWidth($header[$index]);
156 foreach ($entries as $row) {
157 if (isset($row[
"_sort$index"])) {
158 $len = $this->result->GetStringWidth($row[
"_sort$index"]);
170 $scale = $printWidth / array_sum($width);
171 foreach ($width as &$w) {
187 foreach ($columns as $index => $column) {
188 if (!$column->isExportable()) {
193 $len = $result->GetStringWidth($column->getLabel());
198 foreach ($iterator as $entry) {
199 $len = $result->GetStringWidth(implode(
',', $column->getRawExportValues($entry)));
205 $width[$index] = $max;
210 $scale = $printWidth / array_sum($width);
211 foreach ($width as &$w) {
224 return $this->result->Output(
"",
"S");
232 if (!class_exists(
'FPDF')) {
233 die(_(
'No PDF export possible: there is no FPDF library installed.'));
236 $columns = $listing->getColumns();
237 $iterator = $listing->getIterator();
240 $result =
new PDF(
'L',
'mm',
'A4');
241 $result->AliasNbPages();
242 $result->SetFont(
'Helvetica',
'', 10);
243 $headline = $listing->parent->headline;
244 $headline .=
', '._(
'created by').
' '.$ui->cn.
' - '.strftime(
'%A, %d. %B %Y, %H:%M:%S');
245 $result->setHeadline(utf8_decode($headline));
249 $width = static::calcColumnsWidth($result, $columns, $iterator);
252 $result->SetTextColor(0);
253 $result->SetDrawColor(0, 0, 0);
254 $result->SetLineWidth(.3);
257 $result->SetFillColor(230, 230, 230);
258 $result->SetFont(
'',
'B');
260 foreach ($columns as $index => $column) {
261 if ($column->isExportable()) {
262 $result->Cell($width[$index], 7, utf8_decode($column->getLabel()), 1, 0,
'C', 1);
269 $result->SetFillColor(240, 240, 240);
270 $result->SetFont(
'');
273 foreach ($iterator as $entry) {
276 $result->Cell(array_sum($width), 0,
'',
'T');
283 foreach ($columns as $index => $column) {
284 if ($column->isExportable()) {
292 $column->getRawExportValues($entry)
308 $result->Cell(array_sum($width), 0,
'',
'T');
310 return $result->Output(
'',
'S');
319 $classes = get_declared_classes();
320 if (in_array(
'FPDF', $classes)) {
321 return [
"exportPDF" => [
"label" => _(
"PDF"),
"image" =>
"geticon.php?context=mimetypes&icon=application-pdf&size=16",
"class" =>
"pdfExporter",
"mime" =>
"application/pdf",
"filename" =>
"export.pdf" ]];
This class contains all the functions to manage pdf.
This class handles the entries list for a management instance.
__construct($headline, $header, $entries, $columns=[])
Export PDF.
calcWidth($header, $entries, $columns)
Calculate the width page.
static calcColumnsWidth($result, $columns, $iterator)
Calculate the width page.
static getInfo()
Get informations.
This class contains all the functions needed for pdf export.