ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 'libs/composer/vendor/autoload.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  $pdf->setSpacesRE('/[^\S\xa0]/'); // Fixing unicode/PCRE-mess #17547
39 
40  /* // TODO
41  // set some language-dependent strings (optional)
42  if (file_exists(dirname(__FILE__).'/lang/eng.php')) {
43  require_once(dirname(__FILE__).'/lang/eng.php');
44  $pdf->setLanguageArray($l);
45  }
46  */
47  // set font
48 
49  foreach ($job->getPages() as $page) {
50  $page = ' ' . $page;
51  $pdf->AddPage();
52  $pdf->writeHTML($page, true, false, true, false, '');
53  }
54  $result = $pdf->Output($job->getFilename(), $job->getOutputMode()); // (I - Inline, D - Download, F - File)
55 
56  if (in_array($job->getOutputMode(), array('I', 'D'))) {
57  exit();
58  }
59  }
60 }
const PDF_MARGIN_HEADER
Header margin.
$result
const PDF_FONT_SIZE_MAIN
Default main font size.
$pdf
Definition: example_001.php:31
const PDF_FONT_SIZE_DATA
Default data font size.
const PDF_FONT_NAME_MAIN
Default main font name.
PHP class for generating PDF documents without requiring external extensions.
Definition: tcpdf.php:134
const PDF_UNIT
Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch].
const PDF_PAGE_ORIENTATION
Page orientation (P=portrait, L=landscape).
Create styles array
The data for the language used.
Class ilTCPDFGenerator.
Class ilPDFGenerationJob.
const PDF_FONT_NAME_DATA
Default data font name.
const PDF_PAGE_FORMAT
Page format.
const PDF_FONT_MONOSPACED
Default monospaced font name.
static generatePDF(ilPDFGenerationJob $job)
const PDF_MARGIN_FOOTER
Footer margin.