コード例 #1
0
 /**
  * Methode zur Erstellung von PDFs
  * output modes:
  * PDF_OUTPUT_DOWNLOAD = 'D'
  * PDF_OUTPUT_INLINE = 'I'
  * PDF_OUTPUT_FILE = 'F'
  *
  * @param type   $html_input
  * @param type   $output_mode
  * @param string $filename
  */
 public static function generatePDF($html_input, $output_mode, $filename)
 {
     $preprocessed_html = self::preprocessHTML($html_input);
     if (substr($filename, strlen($filename) - 4, 4) != '.pdf') {
         $filename .= '.pdf';
     }
     $job = new ilPDFGenerationJob();
     $job->setAutoPageBreak(true)->setCreator('RoomSharing Export Test')->setFilename($filename)->setMarginLeft('20')->setMarginRight('20')->setMarginTop('20')->setMarginBottom('20')->setOutputMode($output_mode)->addPage($preprocessed_html);
     ilRoomSharingPDFGeneration::doJob($job);
 }
 /**
  * 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;
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public static function generatePDF(ilPDFGenerationJob $job)
 {
     require_once 'tcpdf/tcpdf.php';
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator($job->getCreator());
     $pdf->SetAuthor($job->getAuthor());
     $pdf->SetTitle($job->getTitle());
     $pdf->SetSubject($job->getSubject());
     $pdf->SetKeywords($job->getKeywords());
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING); // TODO
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     // TODO
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // TODO
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // TODO
     $pdf->SetMargins($job->getMarginLeft(), $job->getMarginTop(), $job->getMarginRight());
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     // TODO
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // TODO
     $pdf->SetAutoPageBreak($job->getAutoPageBreak(), $job->getMarginBottom());
     $pdf->setImageScale($job->getImageScale());
     $pdf->SetFont('dejavusans', '', 10);
     // TODO
     /* // TODO
     		// set some language-dependent strings (optional)
     		if (file_exists(dirname(__FILE__).'/lang/eng.php')) {
     			require_once(dirname(__FILE__).'/lang/eng.php');
     			$pdf->setLanguageArray($l);
     		}
     		*/
     // set font
     foreach ($job->getPages() as $page) {
         $pdf->AddPage();
         $pdf->writeHTML($page, true, false, true, false, '');
     }
     $result = $pdf->Output($job->getFilename(), $job->getOutputMode());
     // (I - Inline, D - Download, F - File)
 }
コード例 #5
0
 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);
 }
コード例 #6
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);
 }
コード例 #7
0
 /**
  * Method creates a PDF in landscape mode, using ilPDFGeneration Job
  * Rest of method similar to superclass method
  *
  * @param ilPDFGenerationJob $job
  */
 public static function generatePDF(ilPDFGenerationJob $job)
 {
     // create new PDF document
     // 'L' for Landscape
     $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator($job->getCreator());
     $pdf->SetAuthor($job->getAuthor());
     $pdf->SetTitle($job->getTitle());
     $pdf->SetSubject($job->getSubject());
     $pdf->SetKeywords($job->getKeywords());
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins($job->getMarginLeft(), $job->getMarginTop(), $job->getMarginRight());
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetAutoPageBreak($job->getAutoPageBreak(), $job->getMarginBottom());
     $pdf->setImageScale($job->getImageScale());
     $pdf->SetFont('dejavusans', '', 10);
     foreach ($job->getPages() as $page) {
         $pdf->AddPage();
         $pdf->writeHTML($page, true, false, true, false, '');
     }
     $result = $pdf->Output($job->getFilename(), $job->getOutputMode());
     // (I - Inline, D - Download, F - File)
 }