Select Git revision
ExternModule.class.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Elmar Ludwig authoredElmar Ludwig authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ExportPDF.class.php 14.75 KiB
<?php
# Lifter010: TODO
/**
* ExportPDF.class.php - create and export or save a pdf with simple HTML-Data
*
* 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.
*
* @author Rasmus Fuhse & Peter Thienel
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
define('K_PATH_IMAGES', $GLOBALS['STUDIP_BASE_PATH'] . '/public/assets/images/');
/**
* Class to create an PDF by putting in Stud.IP-formatted code.
* Usage:
*
* $doc = new ExportPDF();
* $doc->addPage();
* $doc->addContent('Hallo, %%wir%% benutzen :studip:-Formatierung.');
* $doc->dispatch("test_pdf");
* //lines following dispatch won't be accessed anymor, because dispatch
* //cancels all other output.
*
*/
class ExportPDF extends TCPDF implements ExportDocument
{
private $media_proxy = NULL;
private $config;
private $defaults = false;
private $page_added = false;
private $h_title = '';
private $h_string = '';
private $domains;
static protected $countEndnote = 0;
/**
* Create a basic document (without any content so far).
* @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul>
* @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
* @param mixed $format The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
* @param boolean $unicode TRUE means that the input text is unicode (default = true)
* @param String $encoding charset encoding; default is UTF-8
*/
public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
{
$this->config = Config::GetInstance();
if ($this->config->getValue('LOAD_EXTERNAL_MEDIA') == 'proxy') {
$this->media_proxy = new MediaProxy();
}
parent::__construct($orientation, $unit, $format, $unicode, $encoding, false);
$this->getDomains();
$this->setDefaults();
}
/**
* Adding a new page to the document. This page can contain even more content
* than for just one page. The pagebreak will be managed by tcpdf. But this function
* will create a new pagebreak. Needs to be called at least once to addContent.
* @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul>
* @param mixed $format The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
* @param boolean $keepmargins if true overwrites the default page margins with the current margins
* @param boolean $tocpage if true set the tocpage state to true (the added page will be used to display Table Of Content).
*/
public function addPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false)
{