ILIAS  release_8 Revision v8.23
ilTCPDFRenderer Class Reference
+ Inheritance diagram for ilTCPDFRenderer:
+ Collaboration diagram for ilTCPDFRenderer:

Public Member Functions

 __construct ()
 
 addConfigElementsToForm (ilPropertyFormGUI $form, string $service, string $purpose)
 
 populateConfigElementsInForm (ilPropertyFormGUI $form, string $service, string $purpose, array $config)
 
 validateConfigInForm (ilPropertyFormGUI $form, string $service, string $purpose)
 
 getConfigFromForm (ilPropertyFormGUI $form, string $service, string $purpose)
 
 getDefaultConfig (string $service, string $purpose)
 
 prepareGenerationRequest (string $service, string $purpose)
 Prepare the content processing at the beginning of a PDF generation request Should be used to initialize the processing of latex code The PDF renderers require different image formats generated by the MathJax service. More...
 
 generatePDF (string $service, string $purpose, array $config, ilPDFGenerationJob $job)
 

Protected Attributes

ilLanguage $lng
 

Detailed Description

Deprecated:

Definition at line 24 of file class.ilTCPDFRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ilTCPDFRenderer::__construct ( )

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

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

29  {
30  global $DIC;
31  $this->lng = $DIC->language();
32  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addConfigElementsToForm()

ilTCPDFRenderer::addConfigElementsToForm ( ilPropertyFormGUI  $form,
string  $service,
string  $purpose 
)
Parameters
ilPropertyFormGUI$formThe config form for the administration
string$serviceService Title
string$purposePurpose Title
Returns
void

Implements ilRendererConfig.

Definition at line 34 of file class.ilTCPDFRenderer.php.

References ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

34  : void
35  {
36  $margin_left = new ilTextInputGUI($this->lng->txt('margin_left'), 'margin_left');
37  $form->addItem($margin_left);
38 
39  $margin_top = new ilTextInputGUI($this->lng->txt('margin_top'), 'margin_top');
40  $form->addItem($margin_top);
41 
42  $margin_right = new ilTextInputGUI($this->lng->txt('margin_right'), 'margin_right');
43  $form->addItem($margin_right);
44 
45  $margin_bottom = new ilTextInputGUI($this->lng->txt('margin_bottom'), 'margin_bottom');
46  $form->addItem($margin_bottom);
47 
48  $image_scale = new ilTextInputGUI($this->lng->txt('image_scale'), 'image_scale');
49  $form->addItem($image_scale);
50  }
+ Here is the call graph for this function:

◆ generatePDF()

ilTCPDFRenderer::generatePDF ( string  $service,
string  $purpose,
array  $config,
ilPDFGenerationJob  $job 
)
Parameters
string$service
string$purpose
array<string,mixed>$config
ilPDFGenerationJob$job
Returns
void

Implements ilPDFRenderer.

Definition at line 101 of file class.ilTCPDFRenderer.php.

References exit, ilPDFGenerationJob\getFilename(), ilPDFGenerationJob\getOutputMode(), and ilPDFGenerationJob\getPages().

101  : void
102  {
103  // create new PDF document
104  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
105 
106  $pdf->SetMargins($config['margin_left'], $config['margin_top'], $config['margin_right']);
107  $pdf->SetAutoPageBreak('auto', $config['margin_bottom']);
108  $pdf->setImageScale($config['image_scale']);
109 
110  $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);
111  $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]);
112  $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
113  $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
114  $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
115  $pdf->SetFont('dejavusans', '', 10);
116  $pdf->setSpacesRE('/[^\S\xa0]/'); // Fixing unicode/PCRE-mess #17547
117 
118  foreach ($job->getPages() as $page) {
119  $page = ' ' . $page;
120  $pdf->AddPage();
121  $pdf->writeHTML($page, true, false, true, false, '');
122  }
123  $result = $pdf->Output($job->getFilename(), $job->getOutputMode()); // (I - Inline, D - Download, F - File)
124 
125  if (in_array($job->getOutputMode(), ['I', 'D'])) {
126  exit();
127  }
128  }
exit
Definition: login.php:28
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
+ Here is the call graph for this function:

◆ getConfigFromForm()

ilTCPDFRenderer::getConfigFromForm ( ilPropertyFormGUI  $form,
string  $service,
string  $purpose 
)
Parameters
ilPropertyFormGUI$formThe config form for the administration
string$serviceService Title
string$purposePurpose Title
Returns
array<string, mixed> KV-array with config

Implements ilRendererConfig.

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

References ilPropertyFormGUI\getItemByPostVar().

66  : array
67  {
68  $retval = [
69  'margin_left' => $form->getItemByPostVar('margin_left')->getValue(),
70  'margin_right' => $form->getItemByPostVar('margin_right')->getValue(),
71  'margin_top' => $form->getItemByPostVar('margin_top')->getValue(),
72  'margin_bottom' => $form->getItemByPostVar('margin_bottom')->getValue(),
73  'image_scale' => $form->getItemByPostVar('image_scale')->getValue(),
74  ];
75 
76  return $retval;
77  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:

◆ getDefaultConfig()

ilTCPDFRenderer::getDefaultConfig ( string  $service,
string  $purpose 
)
Parameters
string$serviceService Title
string$purposePurpose Title
Returns
mixed KV-array with config or an config instance

Implements ilRendererConfig.

Definition at line 79 of file class.ilTCPDFRenderer.php.

79  : array
80  {
81  $retval = [
82  'margin_left' => '10',
83  'margin_top' => '10',
84  'margin_right' => '10',
85  'margin_bottom' => '10',
86  'image_scale' => '1',
87  ];
88 
89  return $retval;
90  }

◆ populateConfigElementsInForm()

ilTCPDFRenderer::populateConfigElementsInForm ( ilPropertyFormGUI  $form,
string  $service,
string  $purpose,
array  $config 
)
Parameters
ilPropertyFormGUI$formThe config form for the administration
string$serviceService Title
string$purposePurpose Title
array<string,mixed>$config KV-array with config
Returns
void

Implements ilRendererConfig.

Definition at line 52 of file class.ilTCPDFRenderer.php.

References ilPropertyFormGUI\getItemByPostVar().

52  : void
53  {
54  $form->getItemByPostVar('margin_left')->setValue($config['margin_left']);
55  $form->getItemByPostVar('margin_right')->setValue($config['margin_right']);
56  $form->getItemByPostVar('margin_top')->setValue($config['margin_top']);
57  $form->getItemByPostVar('margin_bottom')->setValue($config['margin_bottom']);
58  $form->getItemByPostVar('image_scale')->setValue($config['image_scale']);
59  }
getItemByPostVar(string $a_post_var)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
+ Here is the call graph for this function:

◆ prepareGenerationRequest()

ilTCPDFRenderer::prepareGenerationRequest ( string  $service,
string  $purpose 
)

Prepare the content processing at the beginning of a PDF generation request Should be used to initialize the processing of latex code The PDF renderers require different image formats generated by the MathJax service.

Parameters
string$service
string$purpose
Returns
void

Implements ilPDFRenderer.

Definition at line 92 of file class.ilTCPDFRenderer.php.

References ilMathJax\getInstance(), ilMathJax\PURPOSE_PDF, and ilMathJax\RENDER_PNG_AS_IMG_EMBED.

92  : void
93  {
97  ->setDpi(600)
98  ->setZoomFactor(0.17);
99  }
const RENDER_PNG_AS_IMG_EMBED
const PURPOSE_PDF
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
+ Here is the call graph for this function:

◆ validateConfigInForm()

ilTCPDFRenderer::validateConfigInForm ( ilPropertyFormGUI  $form,
string  $service,
string  $purpose 
)
Parameters
ilPropertyFormGUI$formThe config form for the administration
string$serviceService Title
string$purposePurpose Title
Returns
bool True, if the form holds a valid config

Implements ilRendererConfig.

Definition at line 61 of file class.ilTCPDFRenderer.php.

61  : bool
62  {
63  return true;
64  }

Field Documentation

◆ $lng

ilLanguage ilTCPDFRenderer::$lng
protected

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


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