CMS  Version 3.9
pdf_manager.inc
Go to the documentation of this file.
1 <?php
7 Fakoli::using("settings");
8 
16 {
17  function PdfManager()
18  {
19 
20  }
21 
22  static function setDefaults()
23  {
24  Settings::setDefaultValue("pdf", "wkhtmltopdf_path", "wkhtmltopdf", String, "The path to the wkhtmltopdf executable on your system.", "PDF Settings", null, 2);
25  Settings::setDefaultValue("pdf", "PDF_convertor", "wkhtmltopdf", String, "Specifies the method used to convert HTML to PDF", "PDF Settings", "wkhtmltopdf\nchrome\nexternal", 1);
26  Settings::setDefaultValue("pdf", "chrome_path", "chrome", String, "The path to the chrome (or chromium) executable on your system", "PDF Settings", null, 3);
27  Settings::setDefaultValue("pdf", "chrome_screenshot_path", "", String, "Path to the screenshot script on your system", "PDF Settings", null, 4);
28  Settings::setDefaultValue("pdf", "external_PDF_url", "", String, "External URL to web-based PDF generator", "PDF Settings", null, 5);
29  Settings::setDefaultValue("pdf", "external_PNG_url", "", String, "External URL to web-based PNG generator", "PDF Settings", null, 5);
30  }
31 
32  static function getTempDirectory()
33  {
34  global $config;
35 
36  $dir = $config["uploadbase"] . DIRECTORY_SEPARATOR . "pdf_tmp";
37 
38  if (!file_exists($dir))
39  {
40  mkdir($dir);
41  chmod($dir, 0777);
42  }
43 
44  return $dir;
45  }
46 
47  static function preprocessTemplate($template)
48  {
49  $convertor = PdfManager::createConvertor(null);
50  return $convertor->preProcessTemplate($template);
51  }
52 
53  static function createConvertor($pdf)
54  {
55  $mode = Settings::getValue("pdf", "PDF_convertor");
56  switch($mode)
57  {
58  case "external":
59  return new ExternalPDFConvertor($pdf);
60 
61  case "chrome":
62  return new ChromePDFConvertor($pdf);
63 
64  case "whtmktopdf":
65  default:
66  return new WkhtmltoPDFConvertor($pdf);
67  }
68  }
69 
70 }
71 ?>
$dir
Definition: delete.inc:44
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
Provides a central management class for event handlers and common functionality for the pdf component...
Definition: pdf_manager.inc:16
static createConvertor($pdf)
Definition: pdf_manager.inc:53
static setDefaults()
Definition: pdf_manager.inc:22
static getTempDirectory()
Definition: pdf_manager.inc:32
static preprocessTemplate($template)
Definition: pdf_manager.inc:47
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
$pdf
Definition: generate.inc:8
$mode
global $config
Definition: import.inc:4