ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilHTMLToPDFTransformerUsingWebkit Class Reference

class to transform HTML content into PDF content More...

+ Inheritance diagram for ilHTMLToPDFTransformerUsingWebkit:
+ Collaboration diagram for ilHTMLToPDFTransformerUsingWebkit:

Public Member Functions

 __construct ($filename="")
 deliverPDFFromHTMLString ($a_string)
 createPDFFileFromHTMLString ($a_string, $a_target)
 deliverPDFFromHTMLFile ($html_file)
 createPDFFileFromHTMLFile ($a_source, $a_target)
- Public Member Functions inherited from ilHTMLToPDFTransformer
 __set ($name, $value)
 __get ($name)
 __isset ($name)
 __unset ($name)

Private Member Functions

 getArgs ()

Private Attributes

 $wkhtmltopdf
 $setting

Additional Inherited Members

- Static Public Member Functions inherited from ilHTMLToPDFTransformer
static transformerAvailable ()
- Protected Member Functions inherited from ilHTMLToPDFTransformer
 generateFilename ()
- Protected Attributes inherited from ilHTMLToPDFTransformer
 $arrData

Detailed Description

class to transform HTML content into PDF content

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 33 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

Constructor & Destructor Documentation

ilHTMLToPDFTransformerUsingWebkit::__construct (   $filename = "")

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 38 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References $filename.

{
$this->setting = new ilSetting("pdf");
$this->wkhtmltopdf = $this->setting->get("path_to_wkhtml");
}

Member Function Documentation

ilHTMLToPDFTransformerUsingWebkit::createPDFFileFromHTMLFile (   $a_source,
  $a_target 
)

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 132 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References $ilLog, ilUtil\execQuoted(), getArgs(), and ilUtil\ilTempnam().

{
global $ilLog;
include_once "./Services/Utilities/classes/class.ilUtil.php";
$temp_file = ilUtil::ilTempnam() . ".pdf";
$args = $this->getArgs() . " $a_source $temp_file";
ilUtil::execQuoted($this->wkhtmltopdf, $args);
if (!rename($temp_file, $a_target))
{
$ilLog->write("Could not rename $temp_file to $a_target\n");
// TODO complain; unlink temp file? check beforehand whether target exists?
}
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingWebkit::createPDFFileFromHTMLString (   $a_string,
  $a_target 
)

Definition at line 98 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References $ilLog, ilUtil\execQuoted(), getArgs(), and ilUtil\ilTempnam().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$cover_file = ilUtil::ilTempnam() . ".html";
$pdf_file = ilUtil::ilTempnam() . ".pdf";
$html_file = ilUtil::ilTempnam() . ".html";
$fp = fopen($html_file, "w"); fwrite($fp, $a_string); fclose($fp);
/* $cover = new ilTemplate("tpl.print_cover.html", TRUE, TRUE, "Services/PDF");
$cover->setVariable("IMAGE", ilUtil::getImagePath('ilias_logo_big.png'));
$cover->setVariable("IMAGE_ALT", 'ILIAS Logo');
$html = str_replace("src=\"./", "src=\"" . ILIAS_HTTP_PATH . "/", $cover->get());
$fp = fopen($cover_file, "w"); fwrite($fp, $html); fclose($fp);*/
// $args = $this->getArgs() . " cover $cover_file $html_file $pdf_file";
$args = $this->getArgs() . " $html_file $pdf_file";
ilUtil::execQuoted($this->wkhtmltopdf, $args);
if (!rename($pdf_file, $a_target))
{
$ilLog->write("Could not rename $pdf_file to $a_target\n");
// TODO complain; unlink temp file? check beforehand whether target exists?
}
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingWebkit::deliverPDFFromHTMLFile (   $html_file)

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 123 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References ilUtil\deliverFile(), ilUtil\execQuoted(), getArgs(), and ilUtil\ilTempnam().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$pdf_file = ilUtil::ilTempnam() . ".pdf";
$args = $this->getArgs() . " $html_file $pdf_file";
ilUtil::execQuoted($this->wkhtmltopdf, $args);
ilUtil::deliverFile($pdf_file, $this->filename);
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingWebkit::deliverPDFFromHTMLString (   $a_string)

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 77 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References ilUtil\deliverFile(), ilUtil\execQuoted(), getArgs(), and ilUtil\ilTempnam().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$cover_file = ilUtil::ilTempnam() . ".html";
$pdf_file = ilUtil::ilTempnam() . ".pdf";
$html_file = ilUtil::ilTempnam() . ".html";
$fp = fopen($html_file, "w"); fwrite($fp, $a_string); fclose($fp);
/* $cover = new ilTemplate("tpl.print_cover.html", TRUE, TRUE, "Services/PDF");
$cover->setVariable("IMAGE", ilUtil::getImagePath('ilias_logo_big.png'));
$cover->setVariable("IMAGE_ALT", 'ILIAS Logo');
$html = str_replace("src=\"./", "src=\"" . ILIAS_HTTP_PATH . "/", $cover->get());
$fp = fopen($cover_file, "w"); fwrite($fp, $html); fclose($fp);*/
// $args = $this->getArgs() . " cover $cover_file $html_file $pdf_file";
$args = $this->getArgs() . " $html_file $pdf_file";
ilUtil::execQuoted($this->wkhtmltopdf, $args);
ilUtil::deliverFile($pdf_file, $this->filename);
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingWebkit::getArgs ( )
private

Definition at line 45 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

References $arg.

Referenced by createPDFFileFromHTMLFile(), createPDFFileFromHTMLString(), deliverPDFFromHTMLFile(), and deliverPDFFromHTMLString().

{
$args = array();
$singleargs = array();
foreach ($this->setting->getAll() as $arg => $value)
{
if (strpos($arg, 'args_') === 0)
{
if (strlen($value))
{
if (strpos($value, '--') === 0)
{
array_push($singleargs, $value);
}
else
{
$args['--'.preg_replace('/_/', '-', substr($arg, 5))] = $value;
}
}
}
}
$args_string = '';
foreach ($args as $key => $value)
{
$args_string .= $key . ' ' . '"' . $value . '"' . ' ';
}
if (count($singleargs)) $args_string .= join($singleargs, ' ');
// global $ilLog;
// $ilLog->write($args_string);
return $args_string;
}

+ Here is the caller graph for this function:

Field Documentation

ilHTMLToPDFTransformerUsingWebkit::$setting
private

Definition at line 36 of file class.ilHTMLToPDFTransformerUsingWebkit.php.

ilHTMLToPDFTransformerUsingWebkit::$wkhtmltopdf
private

Definition at line 35 of file class.ilHTMLToPDFTransformerUsingWebkit.php.


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