CMS  Version 3.9
ExternalPDFConvertor Class Reference

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)
 

Detailed Description

Definition at line 236 of file pdf.inc.

Constructor & Destructor Documentation

◆ __construct()

ExternalPDFConvertor::__construct (   $pdf)

Definition at line 241 of file pdf.inc.

242  {
243  $this->pdf = $pdf;
244  }

Member Function Documentation

◆ coverPage()

ExternalPDFConvertor::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

Definition at line 251 of file pdf.inc.

252  {
253  //NOTE: Not available with external processor
254  $this->cover = $url;
255  return $this;
256  }
if(! $blog->published||! $blog->enable_rss_feed||!checkRole($blog->allow_read)) $url
Definition: rss.inc:58

◆ footer()

ExternalPDFConvertor::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

Definition at line 264 of file pdf.inc.

265  {
266  //TODO: Implement support for this
267  }

◆ generate()

ExternalPDFConvertor::generate ( )

Definition at line 269 of file pdf.inc.

270  {
271  global $config;
272 
273  $handler = Settings::getValue("pdf", "external_PDF_url");
274  if (!$handler)
275  {
276  $handler = $config["external_pdf_url"];
277  }
278 
279  if (!$handler) throw new FakoliException("External PDF convertor URL not specified");
280 
281  $uri = $this->pdf->uri;
282  $uri = appendToQueryString($uri, "__pdfoutput=1");
283  if ($this->pdf->landscape)
284  {
285  $uri = appendToQueryString($uri, "__pdflayout=landscape");
286  }
287 
288  if ($this->pdf->useToken)
289  {
291  $uri = "/action/auto_login/authenticate?token=$token";
292  }
293 
294  $urlparam = "http".($this->pdf->ssl?"s":"")."://".$config["http_host"].$uri;
295 
296  $url = $handler."?url=".urlencode($urlparam);
297 
298  $content = getRemote($url);
299 
300  if ($this->pdf->output)
301  {
302  file_put_contents($this->pdf->output, $content);
303  }
304 
305  return $content;
306  }
$handler
Definition: event_form.inc:62
static createOneTimeToken($url, $ip_addr=null)
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
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()

ExternalPDFConvertor::preProcessTemplate (   $template)

Definition at line 347 of file pdf.inc.

348  {
349  if (!isset($_GET["__pdfoutput"])) return $template;
350  $layout = ($_GET["__pdflayout"] == "landscape") ? " @page { size: landscape; }" : "";
351  $styles = "<style type='text/css' media='print'>{$layout} @page {margin:0;} body { margin: 1.5cm }</style></head>";
352 
353  $template = preg_replace("/<\\/head>/i", $styles, $template);
354  return $template;
355  }
$styles

◆ screenshot()

ExternalPDFConvertor::screenshot ( )

Definition at line 308 of file pdf.inc.

309  {
310  global $config;
311 
312  $handler = Settings::getValue("pdf", "external_PNG_url");
313  if (!$handler)
314  {
315  $handler = $config["external_png_url"];
316  }
317 
318  if (!$handler) throw new FakoliException("External PDF convertor URL not specified");
319 
320  $uri = $this->pdf->uri;
321  $uri = appendToQueryString($uri, "__pdfoutput=1");
322  if ($this->pdf->landscape)
323  {
324  $uri = appendToQueryString($uri, "__pdflayout=landscape");
325  }
326 
327  if ($this->pdf->useToken)
328  {
330  $uri = "/action/auto_login/authenticate?token=$token";
331  }
332 
333  $urlparam = "http".($this->pdf->ssl?"s":"")."://".$config["http_host"].$uri;
334 
335  $url = $handler."?url=".urlencode($urlparam);
336 
337  $content = getRemote($url);
338 
339  if ($this->pdf->output)
340  {
341  file_put_contents($this->pdf->output, $content);
342  }
343 
344  return $content;
345  }

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