CMS  Version 3.9
WkhtmltoPDFConvertor Class Reference
+ Inheritance diagram for WkhtmltoPDFConvertor:
+ Collaboration diagram for WkhtmltoPDFConvertor:

Public Member Functions

 __construct ($pdf)
 
 coverPage ($url)
 Provides a separate URL to use as the cover page of the PDF. More...
 
 footer ($text, $position="center", $size=11)
 
 generate ()
 
 screenshot ()
 
 preProcessTemplate ($template)
 
- Public Member Functions inherited from PDFConvertor
 preprocessTemplate ($template)
 

Detailed Description

Definition at line 18 of file pdf.inc.

Constructor & Destructor Documentation

◆ __construct()

WkhtmltoPDFConvertor::__construct (   $pdf)

Definition at line 23 of file pdf.inc.

24  {
25  $this->pdf = $pdf;
26  }

Member Function Documentation

◆ coverPage()

WkhtmltoPDFConvertor::coverPage (   $url)

Provides a separate URL to use as the cover page of the PDF.

Parameters
string$urlthe URL used to generate the cover page
Returns
PDF

Implements PDFConvertor.

Definition at line 33 of file pdf.inc.

34  {
35  $this->cover = $url;
36  return $this;
37  }
if(! $blog->published||! $blog->enable_rss_feed||!checkRole($blog->allow_read)) $url
Definition: rss.inc:58

◆ footer()

WkhtmltoPDFConvertor::footer (   $text,
  $position = "center",
  $size = 11 
)
Parameters
$text- text of the footer
$position- valid positions are left, right, and center
$size- font size for the footer ?? doesn't work

Implements PDFConvertor.

Definition at line 45 of file pdf.inc.

46  {
47  $this->footer = "--footer-font-size {$size} --footer-{$position} \"{$text}\"";
48  }
footer($text, $position="center", $size=11)
Definition: pdf.inc:45

◆ generate()

WkhtmltoPDFConvertor::generate ( )

Implements PDFConvertor.

Definition at line 50 of file pdf.inc.

51  {
52  global $config;
53 
54  $exe = Settings::getValue("pdf", "wkhtmltopdf_path");
55  if (!$exe) throw new FakoliException("Convertor path not specified");
56 
57  $uri = $this->pdf->uri;
58 
59  if ($this->pdf->useToken)
60  {
62  $uri = "/action/auto_login/authenticate?token=$token";
63  }
64 
65  $url = "http".($this->pdf->ssl?"s":"")."://".$config["http_host"].$uri;
66 
67  $flags = "";
68  if ($this->pdf->landscape)
69  {
70  $flags = "-O landscape ";
71  }
72 
73  $tmpName = sha1($url . now()) . ".pdf";
74 
75  $footer = ($this->footer) ? $this->footer : "";
76 
77  $output = $this->pdf->output ? $this->pdf->output : (PdfManager::getTempDirectory() . DIRECTORY_SEPARATOR . $tmpName);
78  $cmd = "{$exe} {$footer} {$flags}-q \"{$url}\" {$output}";
79 
80  trace($cmd, 3);
81 
82  $out = array();
83 
84  exec($cmd, $out);
85 
86  trace(implode("\n", $out), 3);
87 
88  $content = file_get_contents($output);
89  if (!$this->pdf->output) unlink($output);
90 
91  return $content;
92  }
$out
Definition: page.inc:66
static createOneTimeToken($url, $ip_addr=null)
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static getTempDirectory()
Definition: pdf_manager.inc:32
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
$output
Definition: generate.inc:9
global $config
Definition: import.inc:4
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24
$uri
Definition: tearoff.inc:4

◆ preProcessTemplate()

WkhtmltoPDFConvertor::preProcessTemplate (   $template)

Definition at line 99 of file pdf.inc.

100  {
101  return $template;
102  }

◆ screenshot()

WkhtmltoPDFConvertor::screenshot ( )

Implements PDFConvertor.

Definition at line 94 of file pdf.inc.

95  {
96  return "";
97  }

The documentation for this class was generated from the following file: