ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestPDFGenerator.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
14 {
15  const PDF_OUTPUT_DOWNLOAD = 'D';
16  const PDF_OUTPUT_INLINE = 'I';
17  const PDF_OUTPUT_FILE = 'F';
18 
19  public static function generatePDF($pdf_output, $output_mode, $filename=null)
20  {
21  $pdf_output = self::preprocessHTML($pdf_output);
22 
23  if (substr($filename, strlen($filename) - 4, 4) != '.pdf')
24  {
25  $filename .= '.pdf';
26  }
27 
28  require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
29 
30  $job = new ilPDFGenerationJob();
31  $job->setAutoPageBreak(true)
32  ->setCreator('ILIAS Test')
33  ->setFilename($filename)
34  ->setMarginLeft('20')
35  ->setMarginRight('20')
36  ->setMarginTop('20')
37  ->setMarginBottom('20')
38  ->setOutputMode($output_mode)
39  ->addPage($pdf_output);
40 
42  }
43 
44  public static function preprocessHTML($html)
45  {
46  $pdf_css_path = self::getTemplatePath('test_pdf.css');
47  return '<style>' . file_get_contents($pdf_css_path) . '</style>' . $html;
48  }
49 
50  protected static function getTemplatePath($a_filename)
51  {
52  $module_path = "Modules/Test/";
53 
54  // use ilStyleDefinition instead of account to get the current skin
55  include_once "Services/Style/classes/class.ilStyleDefinition.php";
56  if (ilStyleDefinition::getCurrentSkin() != "default")
57  {
58  $fname = "./Customizing/global/skin/".
59  ilStyleDefinition::getCurrentSkin()."/".$module_path.basename($a_filename);
60  }
61 
62  if($fname == "" || !file_exists($fname))
63  {
64  $fname = "./".$module_path."templates/default/".basename($a_filename);
65  }
66  return $fname;
67  }
68 
69 }
Class ilTestPDFGenerator.
static getCurrentSkin()
get the current skin
$filename
Definition: buildRTE.php:89
static getTemplatePath($a_filename)
Class ilPDFGenerationJob.
static generatePDF($pdf_output, $output_mode, $filename=null)
static doJob(ilPDFGenerationJob $job)