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

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

+ Inheritance diagram for ilHTMLToPDFTransformerUsingFOP:
+ Collaboration diagram for ilHTMLToPDFTransformerUsingFOP:

Public Member Functions

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

Protected Member Functions

 processHTML2FO ($print_output)
 Convert a print output to XSL-FO.
 deliverPDFFromFO ($fo)
 Delivers a PDF file from a XSL-FO string.
 createPDFFileFromFO ($fo, $target)
- Protected Member Functions inherited from ilHTMLToPDFTransformer
 generateFilename ()

Additional Inherited Members

- Static Public Member Functions inherited from ilHTMLToPDFTransformer
static transformerAvailable ()
- 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.ilHTMLToPDFTransformerUsingFOP.php.

Member Function Documentation

ilHTMLToPDFTransformerUsingFOP::createPDFFileFromFO (   $fo,
  $target 
)
protected

Definition at line 124 of file class.ilHTMLToPDFTransformerUsingFOP.php.

References $ilLog, ilRpcClientFactory\factory(), and ilUtil\ilTempnam().

Referenced by createPDFFileFromHTMLFile(), and createPDFFileFromHTMLString().

{
global $ilLog;
include_once "./Services/Utilities/classes/class.ilUtil.php";
$fo_file = ilUtil::ilTempnam() . ".fo";
$fp = fopen($fo_file, "w"); fwrite($fp, $fo); fclose($fp);
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
try
{
$pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo);
//$pdf_binary = base64_decode($pdf_base64);
//file_put_contents($target, $pdf_binary);
file_put_contents($target, $pdf_base64->scalar);
return true;
}
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
catch(Exception $e)
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
// TODO: catch possible exceptions caused by file_put_contents failing
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHTMLToPDFTransformerUsingFOP::createPDFFileFromHTMLFile (   $a_source,
  $a_target 
)

Reimplemented from ilHTMLToPDFTransformer.

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

References createPDFFileFromFO(), and processHTML2FO().

{
$input = file_get_contents($a_source);
$this->createPDFFileFromFO($this->processHTML2FO($input), $a_target);
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingFOP::createPDFFileFromHTMLString (   $a_string,
  $a_target 
)

Definition at line 41 of file class.ilHTMLToPDFTransformerUsingFOP.php.

References createPDFFileFromFO(), and processHTML2FO().

{
$this->createPDFFileFromFO($this->processHTML2FO($a_string), $a_target);
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingFOP::deliverPDFFromFO (   $fo)
protected

Delivers a PDF file from a XSL-FO string.

Parameters
string$foThe XSL-FO string public

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

References $ilLog, ilUtil\deliverData(), ilRpcClientFactory\factory(), and ilUtil\ilTempnam().

Referenced by deliverPDFFromHTMLString().

{
global $ilLog;
include_once "./Services/Utilities/classes/class.ilUtil.php";
$fo_file = ilUtil::ilTempnam() . ".fo";
$fp = fopen($fo_file, "w"); fwrite($fp, $fo); fclose($fp);
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
try
{
$pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo);
ilUtil::deliverData($pdf_base64->scalar, $this->filename, "application/pdf", false, true);
return true;
}
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
catch(Exception $e)
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHTMLToPDFTransformerUsingFOP::deliverPDFFromHTMLFile (   $a_path)

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 51 of file class.ilHTMLToPDFTransformerUsingFOP.php.

References deliverPDFFromHTMLString().

{
if (@file_exists($a_path))
{
$this->deliverPDFFromHTMLString(file_get_contents($a_path));
}
}

+ Here is the call graph for this function:

ilHTMLToPDFTransformerUsingFOP::deliverPDFFromHTMLString (   $a_string)

Reimplemented from ilHTMLToPDFTransformer.

Definition at line 46 of file class.ilHTMLToPDFTransformerUsingFOP.php.

References deliverPDFFromFO(), and processHTML2FO().

Referenced by deliverPDFFromHTMLFile().

{
$this->deliverPDFFromFO($this->processHTML2FO($a_string));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHTMLToPDFTransformerUsingFOP::processHTML2FO (   $print_output)
protected

Convert a print output to XSL-FO.

Parameters
string$print_outputThe print output
Returns
string XSL-FO code public

Definition at line 66 of file class.ilHTMLToPDFTransformerUsingFOP.php.

References $config, $tidy, xslt_create(), xslt_error(), xslt_free(), and xslt_process().

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

{
if (!@file_exists($this->xsl)) return "";
if (extension_loaded("tidy"))
{
$config = array(
"indent" => false,
"output-xml" => true,
"numeric-entities" => true
);
$tidy = new tidy();
$tidy->parseString($print_output, $config, 'utf8');
$tidy->cleanRepair();
$print_output = tidy_get_output($tidy);
$print_output = preg_replace("/^.*?(<html)/", "\\1", $print_output);
}
$xsl = file_get_contents($this->xsl);
$args = array( '/_xml' => $print_output, '/_xsl' => $xsl );
$xh = xslt_create();
$params = array();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
xslt_error($xh);
xslt_free($xh);
return $output;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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