ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilHtmlToPdfTransformerFactory Class Reference
+ Collaboration diagram for ilHtmlToPdfTransformerFactory:

Public Member Functions

 __construct (string $component='')
 
 deliverPDFFromHTMLString (string $src, string $output, string $delivery_type, string $service, string $purpose)
 

Protected Member Functions

 generateTempPath (string $output)
 
 deliverPDF (string $file, string $delivery_type)
 
 createOneFileFromArray (array $src)
 

Protected Attributes

ilLanguage $lng
 

Private Attributes

const PDF_OUTPUT_DOWNLOAD = 'D'
 
const PDF_OUTPUT_INLINE = 'I'
 
const PDF_OUTPUT_FILE = 'F'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilHtmlToPdfTransformerFactory::__construct ( string  $component = '')

Definition at line 32 of file class.ilHtmlToPdfTransformerFactory.php.

References $lng, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ createOneFileFromArray()

ilHtmlToPdfTransformerFactory::createOneFileFromArray ( array  $src)
protected

Definition at line 88 of file class.ilHtmlToPdfTransformerFactory.php.

References $filename.

88  : string
89  {
90  $tmp_file = dirname(reset($src)) . '/complete_pages_overview.html';
91  $html_content = '';
92  foreach ($src as $filename) {
93  if (file_exists($filename)) {
94  $html_content .= file_get_contents($filename);
95  }
96  }
97  file_put_contents($tmp_file, $html_content);
98  return $tmp_file;
99  }
$filename
Definition: buildRTE.php:78

◆ deliverPDF()

ilHtmlToPdfTransformerFactory::deliverPDF ( string  $file,
string  $delivery_type 
)
protected

Definition at line 72 of file class.ilHtmlToPdfTransformerFactory.php.

References ilFileDelivery\deliverFileLegacy().

Referenced by deliverPDFFromHTMLString().

73  {
74  if (file_exists($file)) {
75  if (strtoupper($delivery_type) === self::PDF_OUTPUT_DOWNLOAD) {
76  ilFileDelivery::deliverFileLegacy($file, basename($file), '', false, true);
77  } elseif (strtoupper($delivery_type) === self::PDF_OUTPUT_INLINE) {
78  ilFileDelivery::deliverFileLegacy($file, basename($file), '', true, true);
79  } elseif (strtoupper($delivery_type) === self::PDF_OUTPUT_FILE) {
80  return $file;
81  }
82  return $file;
83  }
84 
85  return false;
86  }
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverPDFFromHTMLString()

ilHtmlToPdfTransformerFactory::deliverPDFFromHTMLString ( string  $src,
string  $output,
string  $delivery_type,
string  $service,
string  $purpose 
)
Exceptions
Exception

Definition at line 53 of file class.ilHtmlToPdfTransformerFactory.php.

References $config, deliverPDF(), generateTempPath(), ilPDFGeneratorUtils\getRendererConfig(), ilPDFGeneratorUtils\getRendererInstance(), and ilPDFGeneratorUtils\getRendererMapForPurpose().

54  {
56  $renderer = ilPDFGeneratorUtils::getRendererInstance($map['selected']);
57  $config = ilPDFGeneratorUtils::getRendererConfig($service, $purpose, $map['selected']);
58 
59  if (basename($output) === $output) {
60  $output = $this->generateTempPath($output);
61  }
62 
63  $job = new ilPDFGenerationJob();
64  $job->setFilename($output);
65  $job->addPage($src);
66  $job->setOutputMode($delivery_type);
67 
68  $renderer->generatePDF($service, $purpose, $config, $job);
69  return $this->deliverPDF($output, $delivery_type);
70  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
static getRendererConfig(string $service, string $purpose, string $renderer)
static getRendererInstance(string $renderer)
deliverPDF(string $file, string $delivery_type)
static getRendererMapForPurpose(string $service, string $purpose)
$service
Definition: ltiservices.php:43
+ Here is the call graph for this function:

◆ generateTempPath()

ilHtmlToPdfTransformerFactory::generateTempPath ( string  $output)
protected

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

References ilFileUtils\ilTempnam(), and ilFileUtils\makeDirParents().

Referenced by deliverPDFFromHTMLString().

38  : string
39  {
40  $dir = ilFileUtils::ilTempnam();
41  if (!is_dir($dir)) {
43  }
44 
45  $output = preg_replace('#[\\\\/:*?"<>|]#', '-', $output);
46  $output = $dir . '/' . $output;
47  return $output;
48  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilLanguage ilHtmlToPdfTransformerFactory::$lng
protected

Definition at line 30 of file class.ilHtmlToPdfTransformerFactory.php.

Referenced by __construct().

◆ PDF_OUTPUT_DOWNLOAD

const ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD = 'D'
private

Definition at line 26 of file class.ilHtmlToPdfTransformerFactory.php.

◆ PDF_OUTPUT_FILE

const ilHtmlToPdfTransformerFactory::PDF_OUTPUT_FILE = 'F'
private

Definition at line 28 of file class.ilHtmlToPdfTransformerFactory.php.

◆ PDF_OUTPUT_INLINE

const ilHtmlToPdfTransformerFactory::PDF_OUTPUT_INLINE = 'I'
private

Definition at line 27 of file class.ilHtmlToPdfTransformerFactory.php.


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