ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTCPDFGenerator.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
12{
13 public static function generatePDF(ilPDFGenerationJob $job)
14 {
15 require_once 'tcpdf/tcpdf.php';
16
17 // create new PDF document
18 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
19
20 // set document information
21 $pdf->SetCreator( $job->getCreator() );
22 $pdf->SetAuthor( $job->getAuthor() );
23 $pdf->SetTitle( $job->getTitle() );
24 $pdf->SetSubject( $job->getSubject() );
25 $pdf->SetKeywords( $job->getKeywords() );
26
27 //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING); // TODO
28 $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); // TODO
29 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // TODO
30 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // TODO
31 $pdf->SetMargins($job->getMarginLeft(), $job->getMarginTop(), $job->getMarginRight());
32 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); // TODO
33 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // TODO
34 $pdf->SetAutoPageBreak($job->getAutoPageBreak(), $job->getMarginBottom());
35 $pdf->setImageScale($job->getImageScale());
36 $pdf->SetFont('dejavusans', '', 10); // TODO
37
38 /* // TODO
39 // set some language-dependent strings (optional)
40 if (file_exists(dirname(__FILE__).'/lang/eng.php')) {
41 require_once(dirname(__FILE__).'/lang/eng.php');
42 $pdf->setLanguageArray($l);
43 }
44 */
45 // set font
46
47 foreach ($job->getPages() as $page)
48 {
49 $pdf->AddPage();
50 $pdf->writeHTML($page, true, false, true, false, '');
51 }
52
53 $result = $pdf->Output($job->getFilename(), $job->getOutputMode() ); // (I - Inline, D - Download, F - File)
54 }
55}
$result
PHP class for generating PDF documents without requiring external extensions.
Definition: tcpdf.php:184
Class ilPDFGenerationJob.
Class ilTCPDFGenerator.
static generatePDF(ilPDFGenerationJob $job)