/**
  * Generate the report for given certificate
  *
  * @param srCertificate $cert
  * @throws ilException
  * @return bool
  */
 public function generate(srCertificate $cert)
 {
     if (!$this->isAvailable()) {
         throw new ilException("Generating certificates with TemplateTypeHtml is only available for ILIAS > 4.4");
     }
     $template = $cert->getDefinition()->getType()->getCertificateTemplatesPath(true);
     // A template is required, so quit early if it does not exist for some reason
     if (!is_file($template)) {
         return false;
     }
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     // Get HTML markup by parsing the template and replace placeholders
     $markup = file_get_contents($template);
     $markup = srCertificatePlaceholdersParser::getInstance()->parse($markup, $cert->getPlaceholders());
     try {
         $job = new ilPDFGenerationJob();
         $job->setMarginLeft('20');
         $job->setMarginBottom('20');
         $job->setMarginRight('20');
         $job->setMarginTop('20');
         $job->setOutputMode('F');
         // Save to disk
         $job->setFilename($cert->getFilePath());
         $job->addPage($markup);
         ilPDFGeneration::doJob($job);
         return true;
         // Method above gives no feedback so assume true -.-
     } catch (Exception $e) {
         $this->log->write("srCertificateTemplyteTypeHtml::generate() : " . $e->getMessage());
         return false;
     }
 }
 public static function generatePDF($pdf_output, $output_mode, $filename = null)
 {
     $pdf_output = self::preprocessHTML($pdf_output);
     if (substr($filename, strlen($filename) - 4, 4) != '.pdf') {
         $filename .= '.pdf';
     }
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     $job = new ilPDFGenerationJob();
     $job->setAutoPageBreak(true)->setCreator('ILIAS Test')->setFilename($filename)->setMarginLeft('20')->setMarginRight('20')->setMarginTop('20')->setMarginBottom('20')->setOutputMode($output_mode)->addPage($pdf_output);
     ilPDFGeneration::doJob($job);
 }
 public static function generatePDF($pdf_output, $output_mode, $filename = null)
 {
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     define('PDF_PAGE_ORIENTATION', 'L');
     ob_clean();
     if (substr($filename, strlen($filename) - 4, 4) != '.pdf') {
         $filename .= '.pdf';
     }
     $job = new ilPDFGenerationJob();
     $job->setAutoPageBreak(true)->setCreator('rubric')->setFilename($filename)->setMarginLeft('20')->setMarginRight('20')->setMarginTop('20')->setMarginBottom('20')->setOutputMode($output_mode)->addPage($pdf_output);
     ilPDFGeneration::doJob($job);
 }
Exemplo n.º 4
0
 public function pdfExportObject()
 {
     $html = $this->printViewObject(true);
     // :TODO: fixing css dummy parameters
     $html = preg_replace("/\\?dummy\\=[0-9]+/", "", $html);
     $html = preg_replace("/\\?vers\\=[0-9A-Za-z\\-]+/", "", $html);
     include_once "Services/PDFGeneration/classes/class.ilPDFGeneration.php";
     include_once "Services/PDFGeneration/classes/class.ilPDFGenerationJob.php";
     $job = new ilPDFGenerationJob();
     $job->setAutoPageBreak(true)->setMarginLeft("10")->setMarginRight("10")->setMarginTop("10")->setMarginBottom("10")->setOutputMode("D")->setFilename("wiki.pdf")->setCreator("ILIAS Wiki")->setImageScale(1.25)->addPage($html);
     ilPDFGeneration::doJob($job);
 }