/**
  * @param $path
  * @param $print_portrait
  * @param $print_paper_size
  * @param $labels
  * @return bool|string
  */
 public function explodePDF($path, $print_portrait, $print_paper_size, $labels)
 {
     ini_set('memory_limit', '1024M');
     if (!is_file($path)) {
         return false;
     }
     $isPortrait = $print_portrait;
     $paperSize = in_array($print_paper_size, ['A2', 'A3', 'A4', 'A5']) ? $print_paper_size : 'A4';
     $pdfInfo = $this->pdfInfo($path);
     if (!$pdfInfo) {
         return false;
     }
     $pdfSize = array_map(function ($item) {
         return trim((int) $item);
     }, explode('x', $pdfInfo['Page size']));
     $pdfSize['w'] = $pdfSize[0] * 0.75;
     $pdfSize['h'] = $pdfSize[1] * 0.75;
     $paperSizes = ['A2' => ['w' => 420, 'h' => 594], 'A3' => ['w' => 297, 'h' => 420], 'A4' => ['w' => 210, 'h' => 297], 'A5' => ['w' => 148, 'h' => 210]];
     include dirname(__DIR__) . "/lib/mpdf/mpdf.php";
     $mgl = 10;
     $mgr = 10;
     $mgt = 20 + 10;
     $mgb = 5 + 10;
     $mgh = 9;
     $mgf = 9;
     if ($isPortrait) {
         $mgl = 20;
         $mgr = 10;
         $mgt = 5 + 10;
         $mgb = 5 + 10;
         $mgh = 9;
         $mgf = 9;
     }
     $mpdf = new \mPDF('c', $paperSize . ($isPortrait ? '-P' : '-L'));
     $mpdf->SetImportUse();
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->SetCompression(true);
     //$mpdf->SetAutoPageBreak(true);
     $mpdf->mirrorMargins = true;
     $source = $mpdf->SetSourceFile($path);
     $page_w = $isPortrait ? $paperSizes[$paperSize]['w'] : $paperSizes[$paperSize]['h'];
     $page_h = $isPortrait ? $paperSizes[$paperSize]['h'] : $paperSizes[$paperSize]['w'];
     $iter_w = ceil($pdfSize['w'] / $page_w / 2);
     $iter_h = ceil($pdfSize['h'] / $page_h / 1);
     $crop_x = 0;
     $crop_y = 0;
     $head_left = isset($labels['head_left']) ? $labels['head_left'] : '';
     $head_center = isset($labels['head_center']) ? $labels['head_center'] : '';
     $head_right = isset($labels['head_right']) ? $labels['head_right'] : '';
     $footer_left = isset($labels['footer_left']) ? $labels['footer_left'] : '';
     $footer_center = isset($labels['footer_center']) ? $labels['footer_center'] : '';
     $footer_right = isset($labels['footer_right']) ? $labels['footer_right'] : '';
     $header = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $head_left . '</td>
         <td width="33%" align="center">' . $head_center . '</td>
         <td width="33%" style="text-align: right;">' . $head_right . '</td>
         </tr></table>
         ';
     $footer = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $footer_left . '</td>
         <td width="33%" align="center">' . $footer_center . '</td>
         <td width="33%" style="text-align: right;">' . $footer_right . '</td>
         </tr></table>
         ';
     $mpdf->SetHTMLHeader($header);
     $mpdf->SetHTMLHeader($header, 'E');
     $mpdf->SetHTMLFooter($footer);
     $mpdf->SetHTMLFooter($footer, 'E');
     for ($i = 0; $i < $iter_w; $i++) {
         if ($i > 0) {
             $mpdf->AddPage();
         }
         // '', '', '', '', '', $mgl, $mgr, $mgt, $mgb, $mgh, $mgf
         $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
         $mpdf->UseTemplate($tpl, $mgl, $mgt);
         if ($iter_h > 2) {
             $mpdf->AddPage();
             $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
             $mpdf->UseTemplate($tpl, $mgl, $mgt);
         }
         $crop_x += $page_w - ($mgl + $mgr);
     }
     $mpdf->Output($path . 'gen.pdf', 'F');
     return $path . 'gen.pdf';
 }
Esempio n. 2
1
 /**
  * @param string $dest
  * @param string[] $files
  * @return bool true, falls min ein Quelldokument verwendbar war
  */
 public static function merge($dest, $files)
 {
     Logging::info('Erzeuge ' . $dest);
     //$dest = Files::validateFilename($dest);
     $pdf = new \mPDF('de-DE', 'A4');
     $pdf->SetImportUse();
     $page = 0;
     foreach ($files as $curFile) {
         Logging::info('Eingangsdatei ' . $curFile);
         if ($curFile == '') {
             continue;
         }
         $pagecount = $pdf->SetSourceFile($curFile);
         if ($page != 0) {
             $pdf->AddPage();
         }
         for ($i = 1; $i <= $pagecount; $i++) {
             $import_page = $pdf->ImportPage($i);
             $pdf->UseTemplate($import_page);
             if ($i < $pagecount) {
                 $pdf->AddPage();
             }
         }
         $page++;
     }
     $pdf->Output($dest, 'F');
     return $page > 0;
 }
Esempio n. 3
1
 /**
  * merge another pdf to current
  * @param type $anotherPdfPath
  * @return \Kohana_MPDF
  */
 public function mergePdf($anotherPdfPath)
 {
     $this->checkMpdfInit();
     $pagecount = $this->setSourceFile($anotherPdfPath);
     for ($i = 1; $i <= $pagecount; $i++) {
         $this->mpdf->AddPage();
         $tplId = $this->mpdf->ImportPage($i);
         $this->mpdf->UseTemplate($tplId);
         $this->mpdf->WriteHTML();
     }
     return $this;
 }
// exit;
//set gambar untuk laporan
$gambar = $FILE_GAMBAR_KABUPATEN;


$html=$REPORT->retrieve_html_cetak_label($result_query,$gambar,$tahun);

/*$count = count($html);
	for ($i = 0; $i < $count; $i++) {
		 
		 echo $html[$i];     
	}
exit;*/
$REPORT->show_status_download();
$mpdf=new mPDF('','','','',8,8,5,5,10,10,'P');
$mpdf->AddPage('P','','','','',8,8,5,5,10,10);
// $mpdf->setFooter('{PAGENO}') ;
$mpdf->progbar_heading = '';
$mpdf->StartProgressBarOutput(2);
$mpdf->useGraphs = true;
$mpdf->list_number_suffix = ')';
$mpdf->hyphenate = true;
$count = count($html);
for ($i = 0; $i < $count; $i++) {
     if($i==0)
			$mpdf->WriteHTML($html[$i]);
     else
     {
           $mpdf->AddPage('P','','','','',15,15,16,16,9,9);
           $mpdf->WriteHTML($html[$i]);
           
        // Split $lorem into words
        $words = preg_split('/([\\s,\\.]+)/', $lorem, -1, PREG_SPLIT_DELIM_CAPTURE);
        foreach ($words as $i => $e) {
            if ($i % 2 == 0) {
                $y = rand(1, 10);
                // every tenth word
                if (preg_match('/^[a-zA-Z]{4,99}$/', $e) && $y > 8) {
                    // If it is just a word use it as an index entry
                    $content = ucfirst(trim($e));
                    $html .= '<indexentry content="' . $content . '" />';
                    $html .= '<i>' . $e . '</i>';
                } else {
                    $html .= $e;
                }
            } else {
                $html .= $e;
            }
        }
        $mpdf->WriteHTML($html);
    }
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Index - This should be inserted where it is intended to appear in the document
$mpdf->AddPage('', 'E');
$mpdf->AddPage();
$mpdf->WriteHTML('<h2>Index</h2>', 2);
$mpdf->CreateIndex(2, '', '', 5, 1, 15, 5, 'trebuchet', 'sans-serif', true);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
Esempio n. 6
1
<?php

$mpdf = new mPDF('', '', 0, '', 10, 10, 16, 16, 9, 26, 'L');
$stylesheet = file_get_contents("../web/css/relatorios-css/relatorio.css");
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->SetTitle($model->titulo);
// Set a simple Footer including the page number
$mpdf->setFooter('<div>Relatório emitido SiGeCentro  <br> {PAGENO}/{nb}</div>');
// Turn off (suppress) page numbering from the start of the document
$mpdf->AddPage('', '', '', '', 'on');
$header = "<div id='cabecalho' >\n        \t\t\t<div id='cabecalho-imagem'>\n        \t\t\t\t<img id='cabecalho-img'   src='" . $model->getImagemLogo() . "'/>\n        \t\t\t</div>\t\n        \t\t\t<div id='cabecalho-titulo' >\n        \t\t\t\t" . $model->titulo . "\n        \t\t\t</div>\n        \t\t\t<div id='cabecalho-emissao'>\n                        <b>SiGeCentro</b>  \n                        <br/>\n        \t\t\t\t<b>Emitido em: " . $model->getDataHora() . "</b>\n\n        \t\t\t</div>\t\n        \t\t</div>\n               <div class='clear'> </div>";
$mpdf->SetHTMLHeader($header, null, true);
$html = "<div id='corpo'>";
for ($i = 1; $i < 400; $i++) {
    $html .= "linha número {$i} | " . $i % 40 . "<br>";
    if ($i % 40 == 0) {
        // realiza quebra de página e adiciona uma nova
        $html .= "</div><pagebreak /><div id='corpo'>";
    }
}
$html .= "</div>";
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
 function loadMpdf($html, $output = null, $param = 1)
 {
     // echo "masuk";
     // echo $output;
     // exit;
     global $CONFIG;
     $pdf_ext = '.pdf';
     $mpdfEngine = '../' . LIBS . 'mpdf/mpdf' . $CONFIG[$this->configkey]['php_ext'];
     if (is_file($mpdfEngine)) {
         require_once $mpdfEngine;
         if ($param == 1) {
             $mpdf = new mPDF('c', 'A4', '', '', 15, 15, 16, 16, 9, 9, 'L');
             $mpdf->SetDisplayMode('fullpage');
         } elseif ($param == 2) {
             $mpdf = new mPDF('', '', '', '', 15, 15, 16, 16, 9, 9, 'P');
             $mpdf->AddPage('L', '', '', '', '', 15, 15, 16, 16, 9, 9);
         }
         // $mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
         // $mpdf->setFooter('{PAGENO}') ;
         $mpdf->WriteHTML($html);
         $mpdf->Output($output . '-' . date(ymdhis) . $pdf_ext, 'D');
         logFile('load excel success');
     } else {
         logFile('excel lib not found');
     }
     exit;
 }
Esempio n. 8
0
 public function index()
 {
     $final_html = "";
     $css = "<style type='text/css'>\n\t\ttd{\n\t\t\tborder:1px solid black; \n\t\t}\n\t\t.no_border{\n\t\t\tborder: none;\n\t\t} \n\t\t.regionals td{\n\t\t\tmin-width:110px;\n\t\t}\n\t\tth, .title{\n\t\t\tbackground:#DDD;\n\t\t\tborder:none;\n\t\t\tpadding:0;\n\t\t\tmargin:0;\n\t\t}\n\t\t\n\t\t</style>";
     $final_html .= $css;
     $html_title = "<img src='Images/coat_of_arms.png' style='position:absolute;  width:160px; top:0px; right:0px; margin-bottom:-100px;margin-right:-100px;'></img>";
     $html_title .= "<h2 style='text-align:center; text-decoration:underline;'>Republic of Kenya</h2>";
     $html_title .= "<h3 style='text-align:center; text-decoration:underline;'>Ministry of Public Health and Sanitation</h3>";
     $html_title .= "<h1 style='text-align:center; text-decoration:underline;'>MONTHLY VACCINE STOCK MANAGEMENT REPORT</h1>";
     //echo "$html_title";
     $final_html .= $html_title;
     $final_html .= $this->create_national_report();
     $this->load->library('mpdf');
     $mpdf = new mPDF('', 'A4-L', 0, '', 15, 15, 16, 16, 9, 9, '');
     $mpdf->SetTitle('MONTHLY VACCINE STOCK MANAGEMENT REPORT');
     $mpdf->WriteHTML($final_html);
     $regions = Regions::getAllRegions();
     foreach ($regions as $region) {
         $regional_report = $this->create_regional_reports($region);
         $mpdf->AddPage();
         $mpdf->WriteHTML($regional_report);
         //
     }
     //echo $final_html
     $mpdf->Output('Summaries/Monthly_Summary.pdf', 'F');
     $this->email_reports();
 }
Esempio n. 9
0
 public function _gen_pdf($html, $paper, $layoutpage)
 {
     ob_end_clean();
     $mpdf = new mPDF('utf-8', $paper);
     ini_set('memory_limit', '100M');
     $mpdf->debug = true;
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->AddPage($layoutpage);
     $mpdf->WriteHTML($html);
     $mpdf->Output();
 }
Esempio n. 10
0
 /**
  * @param Carne $carne
  * @return \mPDF
  */
 public function gerar(Carne $carne)
 {
     $mpdf = new \mPDF("", 'A4');
     $mpdf->DeflMargin = 3;
     $mpdf->DefrMargin = 3;
     $mpdf->SetTopMargin(3);
     $mpdf->AddPage();
     /**
      * @var $boleto Boleto
      */
     foreach ($carne->getBoletos() as $boleto) {
         $codigoBarras = $this->geradorCodigoBarras->getBarcode($boleto->getLinha(), BarcodeGeneratorSVG::TYPE_INTERLEAVED_2_5, 1, 40);
         $html = $this->twig->render($carne->getBanco()->getLayoutCarne(), ['boleto' => $boleto, 'codigoBarras' => base64_encode($codigoBarras), 'logoBanco' => base64_encode(file_get_contents(GeradorCarne::getDirImages() . 'logocaixa.jpg'))]);
         $mpdf->WriteHTML($html);
         $mpdf->Ln(2);
     }
     return $mpdf;
 }
Esempio n. 11
0
	function index(){

		$this->load->library('mpdf/mpdf');// Load the mpdf library

		//calculate previous dates
		if(date('m')==1)
		{
			$previous_month=12;
			$year=date('Y')-1;
		}
		else
		{
			$previous_month=date('m')-1;
			$year=date('Y');
		}

		$fromdate=$year.'-'.$previous_month.'-01';
		$num_of_days=cal_days_in_month(CAL_GREGORIAN, $previous_month,$year);
		$todate=$year.'-'.$previous_month.'-'.$num_of_days;

		$CHAI_team=array('*****@*****.**','*****@*****.**');

		//table styling
		$css_styling = '<style>table.data-table {border: 1px solid #DDD;margin: 10px auto;border-spacing: 0px;}
						table.data-table th {border: none;color: #036;text-align: center;background-color: #F5F5F5;border: 1px solid #DDD;border-top: none;max-width: 450px;}
						table.data-table td, table th {padding: 4px;}
						table.data-table td {border: none;border-left: 1px solid #DDD;border-right: 1px solid #DDD;height: 30px;margin: 0px;border-bottom: 1px solid #DDD;}
						.col5{background:#D8D8D8;}</style>';

		$header='<h2>FACILITY CONSUMPTION DATA REPORT & REQUEST(F-CDRR) FOR ART LABORATORY MONITORING REAGENTS</h2>';

		$fromdate='2015-02-01';
		$todate='2015-02-28';

		$fcdrr_list="";

		$fcdrr_list=$this->fcdrr_model->get_fcdrr_list($fromdate,$todate);

			foreach($fcdrr_list->result_array() as $fcdrr_result)
			{	
				$final_pdf_data=$this->fcdrr_model->get_fcdrr_content($fcdrr_result);

				if($final_pdf_data)
				{
					$pdf_document=$css_styling.$header.$final_pdf_data;

					$mpdf=new mPDF(); 
					$mpdf->AddPage('', 'A4-L', 0, '', 15, 15, 16, 16, 9, 9, ''); 
					$mpdf->SetDisplayMode('fullpage');
					$mpdf->simpleTables = true;

					$mpdf->SetDisplayMode('fullpage');
					$mpdf->simpleTables = true;

					$mpdf->list_indent_first_level = 0;	// 1 or 0 - whether to indent the first level of a list
					$mpdf->list_indent_first_level = 0;	// 1 or 0 - whether to indent the first level of a list
					//Generate pdf using mpdf
					               
			        $mpdf ->SetWatermarkText("Nascop",-5);
			        $mpdf ->watermark_font = "sans-serif";
			        $mpdf ->showWatermarkText = true;
					$mpdf ->watermark_size="0.5";

					$filename=str_replace('/','-', $fcdrr_result['name']);

					$mpdf->WriteHTML($pdf_document);
					try
					{
						$filename=$this->config->item('server_root').'pdf_documents/fcdrr_individual_monthly/'.$filename.'.pdf';

						$mpdf->Output($filename,'F');
					}
					catch(exception $e)
					{
						$e->getMessage();
					}

					/* Prepare email configurations */

					//$month_name=$this->GetMonthName($previous_month);

					// $this->email->from('*****@*****.**', 'CD4 Notification');

					// $this->email->subject('CD4 FCDRR Commodity Reports for '.$month_name.' - '.$year.' '); //subject

					// $message="Good Day<br />Find attached the FCDRR Report For ART Lab Monitoring Reagents for ".$fcdrr_result['name']." for the month of ".$month_name.", ".$year.".<br />
					// 	Regards.
					// 	<br /><br />CD4 Support Team";

					//$this->email->message($message);// the message

					// $county_coordinator_email=$this->fcdrr_model->get_county_email($fcdrr_result['sub_county_id']);

					// foreach($county_coordinator_email as $cemail)
					// {
					// 	$county_receipients[]=$cemail;
					// }
					
					// $partner_email=$this->fcdrr_model->get_partner_email($fcdrr_result['partner_id']);

					// foreach($partner_email as $pemail)
					// {
					// 	$partner_receipients[]=$pemail;
					// }

					// $email_receipients=array_merge($partner_receipients,$county_receipients);

					// echo $fcdrr_result['name']."-----------------";
					// echo "<pre>";
					// print_r($email_receipients);
					// echo "</pre>";
					// echo "---------------------------------------";

					//$this->email->to($email_receipients); //send to specific receiver
					// $this->email->to($CHAI_team); //CHAI team

					// $this->email->attach($filename);

					// if($this->email->send())//send email and check if the email was sent
					// {	
					// 	$this->email->clear(TRUE);//clear any attachments on the email
					// 	echo "FCDRR Email Alert to '".$fcdrr_result["name"]."' has been sent! <br />";
					// }
					// else 
					// {
					// 	show_error($this->email->print_debugger());//show error message
					// }
				}

			} // end foreach

		
	} // end function
Esempio n. 12
0
 public function generateInvoice($id)
 {
     $order = $this->getOrder($id);
     $CompanySettings = $this->em->getRepository('MeVisaERPBundle:CompanySettings')->find(1);
     $invoice = new \MeVisa\ERPBundle\Entity\Invoices();
     $invoice->setCreatedAt(new \DateTime());
     $order->addInvoice($invoice);
     $this->em->persist($invoice);
     $this->em->flush();
     $products = $order->getOrderProducts();
     $productsLine = array();
     foreach ($products as $product) {
         $productsLine[] = $product->getProduct()->getName();
     }
     $productsLine = implode(',', $productsLine);
     $myProjectDirectory = __DIR__ . '/../../../../';
     $invoiceName = 'mevisa-invoice-' . $order->getNumber() . '-' . $invoice->getId() . '.pdf';
     $invoicePath = $myProjectDirectory . 'web/invoices/';
     $pdfInvoiceHTML = $this->templating->render('MeVisaERPBundle:Orders:pdfinvoice.html.twig', array('order' => $order, 'invoice' => $invoice, 'companySettings' => $CompanySettings));
     $pdfAgreementHTML = $this->templating->render('MeVisaERPBundle:Orders:pdfagreement.html.twig', array('order' => $order, 'productsLine' => $productsLine, 'invoice' => $invoice, 'companySettings' => $CompanySettings));
     $pdfWaiverHTML = $this->templating->render('MeVisaERPBundle:Orders:pdfwaiver.html.twig', array('order' => $order, 'invoice' => $invoice, 'companySettings' => $CompanySettings));
     $mpdf = new \mPDF("ru-RU", "A4");
     $mpdf->SetTitle("MeVisa Invoice " . $order->getNumber() . '-' . $invoice->getId());
     $mpdf->SetAuthor($CompanySettings->getName());
     $mpdf->WriteHTML($pdfInvoiceHTML);
     $mpdf->AddPage();
     $mpdf->WriteHTML($pdfAgreementHTML);
     $mpdf->AddPage();
     $mpdf->WriteHTML($pdfWaiverHTML);
     $mpdf->Output($invoicePath . $invoiceName, 'F');
     $this->em->flush();
 }
Esempio n. 13
0
 public function cetak_surat()
 {
     setlocale(LC_TIME, 'id_ID');
     $this->load->helper('date');
     $timenow = unix_to_human(now('Asia/Jakarta'), TRUE, 'us');
     $time = date("Ymd-Hi", strtotime($timenow));
     $this->load->model('m_mpdf');
     $iduser = $this->input->post('iduser', TRUE);
     $kategori = $this->input->post('kategori', TRUE);
     $noaplikasi = $this->input->post('noaplikasi', TRUE);
     if ($kategori == "menlu") {
         $result = $this->m_mpdf->get_pdln_user($iduser);
         $nip = $result['nip_pemohon'];
         $html = $this->load->view('mpdf_template/surat_menlu', $result, true);
     } else {
         $result['query'] = $this->m_mpdf->get_pdln_user2($iduser, $noaplikasi);
         $nip = $result['query'][0]['nip_pemohon'];
         $html1 = $this->load->view('mpdf_template/surat_setneg_2', $result, true);
         $html2 = $this->load->view('mpdf_template/surat_setneg_2_page2', $result, true);
     }
     $filename = $time . '-' . $menset . '-' . $nip;
     $this->load->library('l_mpdf');
     $mpdf = $this->l_mpdf->load();
     $mpdf = new mPDF('', 'A4', '', '', 30, 20, 20, 25);
     if ($kategori == "menlu") {
         $mpdf->WriteHTML($html);
     } else {
         $mpdf->WriteHTML($html1);
         $mpdf->AddPage();
         $mpdf->WriteHTML($html2);
     }
     if ($filename != "") {
         $mpdf->Output(FCPATH . '../files/' . $kategori . '.pdf', 'F');
     }
     $mpdf->Output();
 }
Esempio n. 14
0
<td width="33%"><span style="font-weight: bold;">Outer footer</span></td>
<td width="33%" align="center"><img src="sunset.jpg" width="126px" /></td>
<td width="33%" style="text-align: right;">Inner footer p <span style="font-size:14pt;">{PAGENO}</span></td>
</tr></table>
';
$footer = '<div align="center" style="color:blue;font-family:mono;font-size:18pt;font-weight:bold;font-style:italic;">{DATE j-m-Y} &raquo; {PAGENO} &raquo; My document</div>';
$footerE = '<div align="center" style="color:green;font-family:mono;font-size:18pt;font-weight:bold;font-style:italic;">Even page footer - {PAGENO} -</div>';
$shortheader = '<div align="center" style="color:blue;font-family:mono;font-size:18pt;font-weight:bold;font-style:italic;">{DATE j-m-Y} &raquo; {PAGENO} &raquo; My document</div>';
$shortheaderE = '<div align="center" style="color:green;font-family:mono;font-size:18pt;font-weight:bold;font-style:italic;">Even page header - {PAGENO} -</div>';
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLHeader($headerE, 'E');
$mpdf->setFooter('{PAGENO} of {nbpg} pages||{PAGENO} of {nbpg} pages');
$mpdf->WriteHTML($html);
$mpdf->setHeader();
// Clear headers before adding page
$mpdf->AddPage('L', '', '', '', '', 25, 25, 55, 45, 18, 12);
$mpdf->SetHTMLHeader($shortheader, '', true);
// New parameter in v1.4 to add the header to the new page
$mpdf->SetHTMLHeader($shortheaderE, 'E', true);
$mpdf->SetHTMLFooter($longfooter);
$mpdf->SetHTMLFooter($longfooterE, 'E');
$mpdf->WriteHTML($html);
$mpdf->WriteHTML($html);
$mpdf->WriteHTML($html);
$mpdf->setHeader('{PAGENO} of {nbpg} pages||{PAGENO} of {nbpg} pages');
$mpdf->SetHTMLFooter($footer);
$mpdf->SetHTMLFooter($footerE, 'E');
$mpdf->WriteHTML($html);
$mpdf->WriteHTML($html);
$mpdf->setHeader();
// Clear headers before adding page
$gambar = $FILE_GAMBAR_KABUPATEN;

//retrieve html
$html=$REPORT->retrieve_html_mutasi_transfer_antar_skpd($result_query, $gambar);

//print html
$count = count($html);
for ($i = 0; $i < $count; $i++) {
    //echo $html[$i];     
}

//cetak reporting
$REPORT->show_status_download_kib();
$mpdf=new mPDF('','','','',15,15,16,16,9,9,'L');
$mpdf->debug=true;
$mpdf->AddPage('L','','','','',15,15,16,16,9,9);
$mpdf->setFooter('{PAGENO}') ;
$mpdf->progbar_heading = '';
$mpdf->StartProgressBarOutput(2);
$mpdf->useGraphs = true;
$mpdf->list_number_suffix = ')';
$mpdf->hyphenate = true;

$count = count($html);
for ($i = 0; $i <= $count; $i++) {
     if($i==0)
          $mpdf->WriteHTML($html[$i]);
     else
     {
           $mpdf->AddPage('L','','','','',15,15,16,16,9,9);
           $mpdf->WriteHTML($html[$i]);
//==============================================================
require_once __DIR__ . '/../vendor/autoload.php';
$mpdf = new mPDF('', 'A4', '', '', 32, 25, 27, 25, 16, 13);
$mpdf->SetDirectionality('rtl');
$mpdf->mirrorMargins = true;
$mpdf->SetDisplayMode('fullpage', 'two');
$mpdf->autoLangToFont = true;
$mpdf->defaultPageNumStyle = 'arabic-indic';
$mpdf->setHeader($h);
$mpdf->setFooter($f);
$mpdf->debug = true;
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet, 1);
// The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($html);
$mpdf->AddPage();
$mpdf->SetColumns(2, 'J');
$mpdf->WriteHTML($html);
$mpdf->SetColumns(0);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// INDEX
$html = '
<pagebreak type="next-odd" />
<h2>Index</h2>
<columns column-count="2" column-gap="5" />
<indexinsert usedivletters="on" links="on" collation="ar_SA.utf8" collation-group="Arabic_Saudi_Arabia" />
';
$mpdf->WriteHTML($html);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$mpdf->Output();
exit;
Esempio n. 17
0
 public function gerarRelatorio($data = NULL, $origem = NULL)
 {
     //verificando a sessao
     $this->verificarSessao();
     //iniciando o relatório
     $mpdf = new mPDF('', '', 0, '', 15, 15, 35, 16, 9, 9, 'L');
     //tamanho do pdf
     $mpdf->SetDisplayMode('fullpage');
     //cabeçalho
     $mpdf->SetHeader('|Faculdade de Tecnologia Dom Amaury Castanho <br /> 	Av. Tiradentes, 1211 - Parque Industrial, Itu - SP, 13309-640 <br />(11) 4013-1872|');
     //rodapé
     $mpdf->SetFooter('|Página {PAGENO} de {nb}|www.fatecitu.edu.br');
     switch ($origem) {
         case 1:
             $html = $this->load->view('relatorio/modelos/historicoAtivo_view', $data, true);
             //titulo
             $mpdf->SetTitle('Histórico do Ativo');
             //conteúdo
             $mpdf->WriteHTML($html);
             //gerar pdf
             $mpdf->Output('historicoDoAtivo.pdf', 'D');
             break;
         case 2:
             $html = $this->load->view('relatorio/modelos/ativosPorLocal_view', $data, true);
             //titulo
             $mpdf->SetTitle('Ativos por Local');
             //conteúdo
             $mpdf->WriteHTML($html);
             //gerar pdf
             $mpdf->Output('ativosPorLocal.pdf', 'D');
             break;
         case 3:
             //titulo
             $mpdf->SetTitle('Relatório de Divergência');
             $html = $this->load->view('relatorio/modelos/divergencia_view', $data, true);
             $mpdf->WriteHTML($html);
             //adicionando uma nova página
             $mpdf->AddPage();
             $html = $this->load->view('relatorio/modelos/ativosLocalErrado_view', $data, true);
             $mpdf->WriteHTML($html);
             //adicionando uma nova página
             $mpdf->AddPage();
             $html = $this->load->view('relatorio/modelos/ativoNaoEncontrado_view', $data, true);
             $mpdf->WriteHTML($html);
             //gerar pdf
             $mpdf->Output('assets/docs/' . $data['id'] . '.pdf', 'F');
             $mpdf->Output('relatorioDeDivergencia.pdf', 'D');
             break;
     }
     redirect('ativo/carregarRelatorio');
 }
Esempio n. 18
0
			 
			$html14=file_get_contents(home_url().'/pdf14/?order_id='.$order_id);
			//print_r($weight_range_new);
			
		// mode, format, default_font_size, default_font, margin_left, margin_right,
				// margin_top, margin_bottom, margin_header, margin_footer, orientation
			//echo "after for loop";
			$mpdf = new mPDF('UTF-8','A4-L');
			$mpdf->defaultPagebreakType='clonebycss';
			$mpdf->SetCompression(true);
			$mpdf->useLang = true;
			//$mpdf->use_kwt = true;  
			$css=file_get_contents(get_template_directory_uri().'-child/PDF_html/pdf_style.css');
		
			//--------------------------------------------------, L , R , T , B , 
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML($css,1);
			
			$mpdf->WriteHTML(htmlspecialchars_decode($html1),2);
			//file_put_contents($uppath1.'status.json',json_encode(array('current'=>'58','total'=>'100')));
			$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
			$mpdf->WriteHTML(htmlspecialchars_decode($html2));

			$header3=__('<div style="padding:0px 0px 0px 0px;height:12mm;width:100%;background:#FFF;border:0;outline:none;margin:0;">
							<div style="padding:1px 38.4px 0px 37px;">
								 <div style="width:20%; float:left; color:#162c5d;text-align:left; line-height:10px;">
									  <p style="float:left;">Tipps & Tricks</p>
								</div>
								<div style="float:left;width:60%;text-align:center; vertical-align:middle;">
									<img style="margin-top:8px;" width="100" height=""  src="'.$site_logo.'"></div>
								<div style="float:right;width:19%;padding-right:2px; color:#162c5d;text-align:right;line-height:10px; ">
Esempio n. 19
0
    /**
     * Create a PDF and export to defined path
     * @param $dir str directory of the source file to convert
     * @param $src str filename of the source file to convert
     * @param $path str path to export the resultant PDF to
     * @param $chapters array chapters to convert into a single PDF
     * @param $journalId int Id of the journal(imprint)
     * @param $args array arguments for the conversion (e.g. Description, cover image, etc)
     * @param $coverPath str path to export the front cover artwork to
     */
    function createPdf($dir = null, $src, $path, $chapters = array(), $journalId, $args = array(), $coverPath)
    {
        $mpdf = new mPDF('utf-8');
        $mpdf->useOddEven = 1;
        $htmlEncode = array('title', 'author');
        foreach ($htmlEncode as $encode) {
            $args[$encode] = htmlentities($args[$encode], ENT_QUOTES, "UTF-8");
        }
        isset($args['title']) ? $mpdf->SetTitle($args['title']) : $mpdf->SetTitle("No Title");
        isset($args['description']) ? $mpdf->SetSubject($args['description']) : $mpdf->SetSubject("No description");
        isset($args['author']) ? $mpdf->SetCreator($args['author']) : $mpdf->SetCreator("No author");
        $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
        $imprintType = $CBPPlatformDao->getImprintType($journalId);
        $stylesheet = $CBPPlatformDao->getImprintStylesheet($journalId);
        $stylesheetContents = file_get_contents($this->stylesheetDir . "{$stylesheet}.css");
        $mpdf->WriteHTML($stylesheetContents, 1);
        $mpdf->WriteHTML($this->contentStart . '
			<htmlpagefooter name="myFooter1" style="display:none">
			<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; 
			    color: #000000; font-weight: bold; font-style: italic;"><tr>
			    <td width="33%" style="text-align: right; ">{PAGENO}</td>
			    </tr></table>
			</htmlpagefooter>
			<htmlpagefooter name="myFooter2" style="display:none">
			<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; 
			    color: #000000; font-weight: bold; font-style: italic;"><tr>
			    <td width="33%"><span style="font-weight: bold; font-style: italic;">{PAGENO}</span></td>
			    </tr></table>
			</htmlpagefooter>');
        $imagesize = getimagesize($args['cover']);
        if (substr($imagesize[1] / $imagesize[0], 0, strpos($imagesize[1] / $imagesize[0], '.') + 1 + 2) == 1.41 || substr($imagesize[1] / $imagesize[0], 0, strpos($imagesize[1] / $imagesize[0], '.') + 1 + 2) == 1.53) {
            $pdfContent .= '<div style="position: absolute; left:0; right: 0; top: 0; bottom: 0;"><img src="' . $args['cover'] . '" id="cover" /></div>';
        } else {
            $pdfContent .= "<div style='margin: 0 auto; width: 80%; text-align: center;'>";
            if (isset($args['title'])) {
                $pdfContent .= "<h1>" . $args['title'] . "</h1>";
            }
            if (isset($args['cover'])) {
                $pdfContent .= "<img src=\"" . $args['cover'] . "\" >";
            } else {
                $pdfContent .= "<br/>";
            }
            if (isset($args['author'])) {
                $pdfContent .= "<h2>" . $args['author'] . "</h2>";
            }
            $pdfContent .= "</div>";
        }
        $mpdf->WriteHTML($pdfContent);
        $mpdf->AddPage('', '', '', '', 'Off');
        $copyrightStatement = $CBPPlatformDao->getJournalCopyrightStatement($journalId);
        if (!empty($copyrightStatement)) {
            $copyrightStatement = reset($copyrightStatement);
            $mpdf->AddPage('', '', '', '', 'Off');
            $innerPageConent = "<div style='width: 90%; text-align: center; margin: 0 auto;'><p>" . $copyrightStatement . "</p></div>";
            $mpdf->WriteHTML($innerPageConent);
        }
        if (!empty($chapters)) {
            $mpdf->TOCpagebreakByArray(array('TOCusePaging' => true, 'TOCuseLinking' => true, 'toc_preHTML' => '<h1>Table of Contents</h1>', 'toc_postHTML' => '', 'resetpagenum' => 1, 'suppress' => 'true'));
            $chapterCount = 0;
            $authorBiographies = 0;
            foreach ($chapters as $chapter) {
                if (!isset($chapter['type']) && $chapter['type'] != "supp") {
                    $chapterCount++;
                } else {
                    if ($chapter['desc'] == "Author Biography") {
                        $authorBiographies++;
                    }
                    $suppChapters = true;
                }
            }
            for ($i = 0; $i < count($chapters); $i++) {
                $htmlEncode = array('name', 'author');
                foreach ($htmlEncode as $encode) {
                    $chapters[$i][$encode] = htmlentities($chapters[$i][$encode], ENT_QUOTES, "UTF-8");
                }
                $document = new TransformDoc();
                $document->setStrFile($chapters[$i]['src'], $chapters[$i]['dir']);
                $document->generateXHTML();
                //problem, here
                $document->validatorXHTML();
                if ($chapterCount == 1) {
                    $contentPreg = $this->stripTagsAddChapters($document->getStrXHTML());
                    $contentPreg = ltrim($contentPreg);
                    if (substr($contentPreg, 0, 13) == "<pagebreak />") {
                        $contentPreg = substr_replace($contentPreg, '', 0, 13);
                    }
                    $mpdf->addPage('', '', '', '', 'On');
                    $mpdf->PageNumSubstitutions[] = array('from' => $mpdf->page + 1, 'reset' => 1, 'type' => '1', 'suppress' => 'off');
                    $mpdf->WriteHTML("<div class='content'>", 2);
                    $mpdf->WriteHTML($contentPreg, 2);
                    if ($suppChapters == true) {
                        foreach ($chapters as $chapter) {
                            if (isset($chapter['type']) && $chapter['type'] == "supp") {
                                $document = new TransformDoc();
                                $document->setStrFile($chapter['src'], $chapter['dir']);
                                $document->generateXHTML();
                                $document->validatorXHTML();
                                if ($authorBiographies > 1) {
                                    $contentPreg = $this->stripTags($document->getStrXHTML());
                                    $mpdf->TOC_Entry($chapter['name']);
                                    $mpdf->WriteHTML("<pagebreak />" . $contentPreg, 2);
                                } else {
                                    $addAuthorBiographyToBack = true;
                                    $authorBiography = $this->stripTags($document->getStrXHTML());
                                }
                            }
                        }
                    }
                    break;
                } else {
                    $contentPreg = $this->stripTags($document->getStrXHTML());
                    $contentPreg = ltrim($contentPreg);
                    if (substr($contentPreg, 0, 13) == "<pagebreak />") {
                        $contentPreg = substr_replace($contentPreg, '', 0, 13);
                    }
                    if ($i != 0) {
                        $prepend = "<pagebreak />";
                    } else {
                        $mpdf->addPage('', 'E', '', '', 'On');
                        $mpdf->PageNumSubstitutions[] = array('from' => $mpdf->page + 1, 'reset' => 1, 'type' => '1', 'suppress' => 'off');
                        $mpdf->WriteHTML("<div class='content'>", 2);
                    }
                    if ($imprintType == "atomistic") {
                        $mpdf->WriteHTML($prepend . "<tocentry content='" . $chapters[$i]['name'] . "' level='0' />" . $contentPreg, 2);
                    } elseif ($imprintType == "collection") {
                        if ($chapters[$i]['description'] != "") {
                            $introduction = "<div class='submissionIntro'><h1>" . $chapters[$i]['author'] . "</h1>" . $this->stripTags($chapters[$i]['description'], true) . "</div><pagebreak /><tocentry content='" . $chapters[$i]['name'] . " by " . $chapters[$i]['author'] . "' level='0' />";
                        }
                        $mpdf->WriteHTML($prepend . $introduction . $contentPreg, 2);
                    }
                }
            }
            $mpdf->writeHTML("</div>");
            if (isset($args['description'])) {
                $mpdf->WriteHTML("<pagebreak page-selector='none' odd-footer-value = '' even-footer-value= '' /><pagebreak /><div style='width: 90%; text-align: center; margin: 0 auto;'><p>" . $this->stripTags($args['description'], true) . "</p></div>", 2);
                if ($addAuthorBiographyToBack == true) {
                    $backCoverContent .= "<div style='width: 90%; text-align: center; margin: 0 auto; margin-top: 10px;'><p>" . $authorBiography . "</p></div>";
                }
                $backCoverContent .= "<p style='width: 90%; text-align: center; margin: 0 auto;'><strong>Published " . date("F Y") . ", Scarborough, UK</strong></p>";
                $mpdf->WriteHTML($backCoverContent, 2);
            }
            $mpdf->WriteHTML("</body></html>");
            $pdfData = $mpdf->Output('', 'S');
            $pageCount = $mpdf->page;
            file_put_contents($path, $pdfData);
            if (file_exists($this->stylesheetDir . "{$stylesheet}-FC.css")) {
                $this->createCoverPdf($stylesheet, $pageCount, $args['cover'], $this->stripTags($args['description'], true), $addAuthorBiographyToBack, $authorBiography, $args['title'], $args['imprint'], $coverPath);
            }
            return true;
        } else {
            $document = new TransformDoc();
            $document->setStrFile($src, $dir);
            $document->generateXHTML();
            $document->validatorXHTML();
            $contentPreg = $this->stripTagsAddChapters($document->getStrXHTML());
            $contentPreg = ltrim($contentPreg);
            if (substr($contentPreg, 0, 13) == "<pagebreak />") {
                $contentPreg = substr_replace($contentPreg, '', 0, 13);
            }
            $mpdf->addPage('', 'E', '', '', 'On');
            $mpdf->PageNumSubstitutions[] = array('from' => $mpdf->page + 1, 'reset' => 1, 'type' => '1', 'suppress' => 'off');
            $mpdf->WriteHTML("<div class='content'>", 2);
            $mpdf->WriteHTML($contentPreg, 2);
            $mpdf->WriteHTML("</div></body></html>");
            $pdfData = $mpdf->Output('', 'S');
            file_put_contents($path, $pdfData);
            return true;
        }
    }
Esempio n. 20
0
 public function process(Vtiger_Request $request)
 {
     $response = new Vtiger_Response();
     $debug_fs = $report_chartpdf = "";
     if (vtlib_isModuleActive("PDFMaker") === true && file_exists('modules/PDFMaker/resources/mpdf/mpdf.php')) {
         //$this->checkInstallationMemmoryLimit();
         if (file_exists("modules/ITS4YouReports/classes/Reports4YouDefault.css")) {
             $report_html_style = file_get_contents("modules/ITS4YouReports/classes/Reports4YouDefault.css");
         }
         $report_html = $_REQUEST["form_report_html"];
         $report_head = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n                        <html>\n                          <head>\n                          </head>\n                          <body>";
         //$report_htmlpdf = "<div>$report_html</div>";
         if (isset($_REQUEST["form_chart_canvas"]) && $_REQUEST["form_chart_canvas"] != "") {
             $chart_image = "data:image/png;base64," . $_REQUEST["form_chart_canvas"];
             $report_chartpdf = "\n                <div style='height:21cm;text-align:center;'><img src='" . $chart_image . "'></div>";
         }
         $report_foot = "</body>\n                        </html>";
         require_once 'modules/PDFMaker/resources/mpdf/mpdf.php';
         //                     $mpdf = new mPDF('',    // mode - default ''
         //                      2	 '',    // format - A4, for example, default ''
         //                      3	 0,     // font size - default 0
         //                      4	 '',    // default font family
         //                      5	 15,    // margin_left
         //                      6	 15,    // margin right
         //                      7	 16,     // margin top
         //                      8	 16,    // margin bottom
         //                      9	 9,     // margin header
         //                      10	 9,     // margin footer
         //                      11	 'L');  // L - landscape, P - portrait
         $report_filename = $_REQUEST["form_filename"] . ".pdf";
         $export_pdf_format = $_REQUEST["form_export_pdf_format"];
         // class mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
         $mpdf = new mPDF('utf-8', "{$export_pdf_format}", "", "", "5", "5", "0", "5", "5", "5");
         // Portrait = $mpdf=new mPDF('utf-8', 'A4');
         // Landscape = $mpdf=new mPDF('utf-8', 'A4-L');
         //error_reporting(63);ini_set("display_errors",1);
         $mpdf->keep_table_proportions = true;
         $mpdf->SetAutoFont();
         $mpdf->WriteHTML($report_html_style, 1);
         $mpdf->WriteHTML($report_head);
         if (isset($_REQUEST["form_report_name"]) && $_REQUEST["form_report_name"] != "") {
             $form_report_name = vtlib_purify($_REQUEST["form_report_name"]);
             $return_name = "<table class='rpt4youTableText' width='100%'>";
             $return_name .= "<tr>";
             $return_name .= "<td colspan='1' class='rpt4youGrpHeadInfoText' width='100%' style='border:0px;'>";
             $return_name .= $form_report_name;
             $return_name .= "</td>";
             $return_name .= "</tr>";
             $return_name .= "</table>";
             $mpdf->WriteHTML($return_name);
         }
         //echo "<pre>";print_r($_REQUEST);echo "</pre>";
         //exit;
         $mpdf->WriteHTML($report_html);
         if ($report_chartpdf != "") {
             $mpdf->AddPage('L');
             $mpdf->WriteHTML($report_chartpdf);
         }
         $mpdf->WriteHTML($report_foot);
         $mpdf->Output();
         exit;
     }
 }
Esempio n. 21
0
 function create_pdf($load_id, $bol_number, $pages_number, $doc_type, $json = null)
 {
     $this->load->model('shipment_model');
     if (!$load_id) {
         $load_id = $this->input->post('load_id');
     }
     if (!$bol_number) {
         $bol_number = $this->input->post('bol_number');
     }
     if (!$pages_number) {
         $pages_number = $this->input->post('pages_number');
     }
     if (!$doc_type) {
         $doc_type = $this->input->post('doc_type');
     }
     $shipments = $this->shipment_model->get(['bol_number' => $bol_number]);
     $shipment = $shipments[0];
     if ($doc_type == 'sp') {
         $pages_number = $shipment['pickup_doc_pages'];
     }
     if ($doc_type == 'cs') {
         $pages_number = $shipment['drop_doc_pages'];
     }
     include '../testserver/MPDF53/mpdf.php';
     $mpdf = new mPDF();
     for ($i = 1; $i <= $pages_number; $i++) {
         $mpdf->WriteHTML('');
         if (file_exists(CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '-' . $i . '.jpg')) {
             $mpdf->Image(CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '-' . $i . '.jpg', 0, 0, 210, 297, 'jpg', '', true, false);
             if ($i < $pages_number) {
                 $mpdf->AddPage();
             }
         }
     }
     $url = CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '.pdf';
     $url_view = VIEW_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '.pdf';
     $mpdf->Output($url, 'F');
     if ($json) {
         $this->output->set_output(json_encode(['status' => 1, 'url' => $url_view]));
     }
 }
Esempio n. 22
0
 /**
  *  Save PHPExcel to file
  *
  *  @param     string     $pFilename   Name of the file to save as
  *  @throws    PHPExcel_Writer_Exception
  */
 public function save($pFilename = NULL)
 {
     $fileHandle = parent::prepareForSave($pFilename);
     //  Default PDF paper size
     $paperSize = 'LETTER';
     //    Letter    (8.5 in. by 11 in.)
     //  Check for paper size and page orientation
     if (is_null($this->getSheetIndex())) {
         $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
     } else {
         $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
     }
     $this->setOrientation($orientation);
     //  Override Page Orientation
     if (!is_null($this->getOrientation())) {
         $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation();
     }
     $orientation = strtoupper($orientation);
     //  Override Paper Size
     if (!is_null($this->getPaperSize())) {
         $printPaperSize = $this->getPaperSize();
     }
     if (isset(self::$_paperSizes[$printPaperSize])) {
         $paperSize = self::$_paperSizes[$printPaperSize];
     }
     //  Create PDF
     $pdf = new mPDF();
     $ortmp = $orientation;
     $pdf->_setPageSize(strtoupper($paperSize), $ortmp);
     $pdf->DefOrientation = $orientation;
     $pdf->AddPage($orientation);
     //  Document info
     $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
     $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
     $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
     $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
     $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
     $pdf->WriteHTML($this->generateHTMLHeader(FALSE) . $this->generateSheetData() . $this->generateHTMLFooter());
     //  Write to file
     fwrite($fileHandle, $pdf->Output('', 'S'));
     parent::restoreStateAfterSave($fileHandle);
 }
Esempio n. 23
0
include "../mpdf.php";
$mpdf = new mPDF('win-1252', 'A4', '', '', 42, 15, 57, 57, 20, 17);
$mpdf->useOnlyCoreFonts = true;
$mpdf->displayDefaultOrientation = true;
$mpdf->forcePortraitHeaders = true;
$mpdf->forcePortraitMargins = true;
$mpdf->SetDisplayMode('fullpage', 'two');
$mpdf->mirrorMargins = 1;
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLHeader($headerE, 'E');
$mpdf->SetHTMLFooter($footer);
$mpdf->SetHTMLFooter($footerE, 'E');
$mpdf->WriteHTML($html);
$mpdf->AddPage('L');
$mpdf->WriteHTML($htmlL);
$mpdf->WriteHTML($htmlL);
// Columns
$mpdf->AddPage('L');
$mpdf->SetColumns(3, 'J');
$mpdf->WriteHTML($loremH);
$mpdf->SetColumns(0);
$mpdf->WriteHTML('<hr />');
$mpdf->SetColumns(2, 'J');
$mpdf->WriteHTML($loremH);
$mpdf->WriteHTML('<hr />');
$mpdf->SetColumns(0);
$mpdf->AddPage('L');
$mpdf->WriteHTML($htmlL);
$mpdf->WriteHTML($htmlL);
Esempio n. 24
0
 function recruitment_pdf($id)
 {
     $sess_id = $this->session->userdata('user_id');
     $user_id = $this->db->select('user_id')->from('users_recruitment')->where('id', $id)->get()->row('user_id');
     if (!$this->ion_auth->logged_in()) {
         //redirect them to the login page
         redirect('auth/login', 'refresh');
     } else {
         //$this->get_user_info($user_id);
         //$this->data['comp_session'] = $this->recruitment_model->render_session()->result();
         if (is_admin()) {
             $form_recruitment = $this->data['form_recruitment'] = $this->recruitment_model->recruitment($id);
         } else {
             $form_recruitment = $this->data['form_recruitment'] = $this->recruitment_model->recruitment($id);
         }
         $this->data['recruitment'] = $this->recruitment_model->recruitment($id)->result();
         $this->data['status'] = getAll('recruitment_status', array('is_deleted' => 'where/0'));
         $this->data['urgensi'] = getAll('recruitment_urgensi', array('is_deleted' => 'where/0'));
         $jk = explode(',', getAll('users_recruitment_kualifikasi', array('id' => 'where/' . $id))->row('jenis_kelamin_id'));
         $pendidikan = explode(',', getAll('users_recruitment_kualifikasi', array('id' => 'where/' . $id))->row('pendidikan_id'));
         $komputer = explode(',', getAll('users_recruitment_kemampuan', array('id' => 'where/' . $id))->row('komputer'));
         $this->data['jenis_kelamin'] = $this->recruitment_model->get_jk($jk);
         $this->data['pendidikan'] = $this->recruitment_model->get_pendidikan($pendidikan);
         $this->data['komputer'] = $this->recruitment_model->get_komputer($komputer);
         $this->data['position_pengaju'] = $this->get_user_position(getAll('users_recruitment', array('id' => 'where/' . $id))->row_array()['user_id']);
         //print_mz(getAll('users_recruitment', array('id' => 'where/'.$id))->row_array()['user_id']);
         $this->data['id'] = $id;
         $title = $this->data['title'] = 'Form Permintaan SDM Baru-' . get_name($user_id);
         $this->load->library('mpdf60/mpdf');
         $html = $this->load->view('recruitment_pdf', $this->data, true);
         $mpdf = new mPDF();
         $mpdf = new mPDF('A4');
         $mpdf->AddPage('p', '', '', '', '', 30, 30, 10, 10, 10, 10);
         // margin footer
         $mpdf->WriteHTML($html);
         $mpdf->Output($id . '-' . $title . '.pdf', 'I');
     }
 }
Esempio n. 25
-1
 public function process(Vtiger_Request $request)
 {
     $response = new Vtiger_Response();
     $debug_fs = "";
     $reportsDeleteDenied = array();
     $ReportsTempDirectory = "test/ITS4YouReports/";
     //$path_fix = "../../../";
     $path_fix = "";
     //$filename = $path_fix."test/ITS4YouReports/".$_REQUEST["filename"].".pdf";
     $file_path = $_REQUEST["filepath"];
     // "test/$filename.png"
     if (is_writable($path_fix . $ReportsTempDirectory)) {
         if (isset($_REQUEST["canvasData"]) && $_REQUEST["canvasData"] != "") {
             $unencodedData = $_REQUEST["canvasData"];
             file_put_contents($path_fix . $file_path, base64_decode($unencodedData));
         }
         if (isset($_REQUEST["mode"]) && $_REQUEST["mode"] == "download") {
             if (file_exists($path_fix . 'modules/PDFMaker/resources/mpdf/mpdf.php')) {
                 require_once $path_fix . 'modules/PDFMaker/resources/mpdf/mpdf.php';
                 $export_pdf_format = $_REQUEST['export_pdf_format'];
                 $mpdf = new mPDF('utf-8', "{$export_pdf_format}", "", "", "5", "5", "0", "5", "5", "5");
                 $mpdf->keep_table_proportions = true;
                 $mpdf->SetAutoFont();
                 $filename = $ReportsTempDirectory . $_REQUEST['report_filename'];
                 $filename = html_entity_decode($filename, ENT_COMPAT, $default_charset);
                 $filename = $path_fix . $filename;
                 if (is_file($filename)) {
                     $mpdf->AddPage();
                     $mpdf->SetImportUse();
                     $pagecount = $mpdf->SetSourceFile($filename);
                     if ($pagecount > 0) {
                         for ($i = 1; $i <= $pagecount; $i++) {
                             $tplId = $mpdf->ImportPage($i);
                             $mpdf->UseTemplate($tplId);
                             if ($i < $pagecount) {
                                 $mpdf->AddPage();
                             }
                         }
                     }
                     if (file_exists($path_fix . $file_path) == true) {
                         $mpdf->AddPage('L');
                         $ch_image_html .= "<div style='width:100%;text-align:center;'><table class='rptTable' style='border:0px;padding:0px;margin:auto;width:80%;text-align:center;' cellpadding='5' cellspacing='0' align='center'>\n    \t\t                            <tr>\n    \t\t                                <td class='rpt4youGrpHead0' nowrap='' >";
                         $ch_image_html .= "<img src='{$site_URL}" . $file_path . "' />";
                         $ch_image_html .= "</td>\n    \t\t                            </tr>\n    \t\t                        </table></div>";
                         $mpdf->WriteHTML($ch_image_html);
                     }
                     //$mpdf->Output($filename,'F');
                     $mpdf->Output($_REQUEST['report_filename'], 'D');
                 }
             }
         }
     }
     //$response->setResult(array("done-P"));
     //$response->emit();
 }
Esempio n. 26
-1
 public function _gen_pdf_ijazah_depan($html, $paper, $layoutpage)
 {
     ob_end_clean();
     //	 $mpdf=new mPDF('utf-8', $paper, '', 0, '', 15, 15, 0, 0, 9, 9);
     ini_set('memory_limit', '500000M');
     $mpdf = new mPDF('c', $paper, '', '', 15, 15, 5, 5, 0, 0);
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->debug = true;
     $mpdf->AddPage($layoutpage);
     $mpdf->WriteHTML($html);
     $mpdf->Output();
 }
Esempio n. 27
-1
 /**
  *
  * @param mixed $clients 
  */
 public static function generate($clients)
 {
     include APPLICATION_PATH . '/../library/mpdf/mpdf.php';
     ini_set('memory_limit', '1G');
     if (!is_array($clients)) {
         $clients = array($clients);
     }
     $layoutPath = APPLICATION_PATH . '/modules/client/views/scripts/';
     $layoutView = new Zend_View();
     $layoutView->setScriptPath($layoutPath);
     $layoutView->addHelperPath('App/View/Helpers/', 'App_View_Helper');
     $pdf = new mPDF('', array(86, 55), '', '', 0, 0, 0, 0, 0, 0, 'P');
     $pdf->debug = true;
     foreach ($clients as $client) {
         $layoutView->client = $client;
         $html = $layoutView->render('client/evidence.phtml');
         $pdf->AddPage();
         $pdf->WriteHTML($html);
     }
     $pdf->Output();
     exit;
 }
Esempio n. 28
-1
	/**
	 * Metodo para criar paginas
	 * @param string $html
	 */
	public function setPagina($html){
		$this->mpfd->AddPage();
		$this->mpfd->WriteHTML($html);
	}
Esempio n. 29
-1
 function savepdfcertificate()
 {
     $datac = JRequest::get('post', JREQUEST_ALLOWRAW);
     include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
     $background_color = "";
     $op = JRequest::getVar("op", "");
     if ($op == 9) {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = JRequest::getVar('cn', '', 'get');
         $authorname = JRequest::getVar('an', '', 'get');
         $certificateid = JRequest::getVar('id', '', 'get');
         $completiondate = JRequest::getVar('cd', '', 'get');
         $course_id = JRequest::getVar('ci', '', 'get');
         $sitename = $config->get('sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = @guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         // final quiz --------------------------------------------------
         $sql = "SELECT id, score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc = $scores_avg_quizzes . '%';
             }
         }
         // final quiz --------------------------------------------------
         // regular ----------------------------------------------
         $s = 0;
         $sql = "select mr.`media_id` from #__guru_mediarel mr, #__guru_days d where mr.`type`='dtask' and mr.`type_id`=d.`id` and d.`pid`=" . intval($course_id);
         $db->setQuery($sql);
         $db->query();
         $lessons = $db->loadColumn();
         if (!isset($lessons) || count($lessons) == 0) {
             $lessons = array("0");
         }
         $sql = "select mr.`media_id` from #__guru_mediarel mr where mr.`layout`='12' and mr.`type`='scr_m' and mr.`type_id` in (" . implode(", ", $lessons) . ")";
         $db->setQuery($sql);
         $db->query();
         $all_quizzes = $db->loadColumn();
         if (isset($all_quizzes) && count($all_quizzes) > 0) {
             foreach ($all_quizzes as $key_quiz => $quiz_id) {
                 $sql = "SELECT score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($quiz_id) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
                 $db->setQuery($sql);
                 $db->query();
                 $result_q = $db->loadColumn();
                 $res = @$result_q["0"];
                 $s += $res;
             }
             $avg_certc1 = "N/A";
             if ($s > 0) {
                 $avg_certc1 = $s / count($all_quizzes) . "%";
             }
         }
         // regular ----------------------------------------------
         /*$sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=".intval($user_id)." and quiz_id=".intval($result)." and pid=".intval($course_id )." ORDER BY id DESC LIMIT 0,1";
         			$db->setQuery($sql);
         			$result_q = $db->loadObject();
         	
         			$first= explode("|", @$result_q->score_quiz);
         	
         			@$res = intval(($first[0]/$first[1])*100);
         	
         			if($resulthasq == 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && isset($scores_avg_quizzes)){
         				if($scores_avg_quizzes >= intval($avg_quizzes_cert)){
         					$avg_certc1 =  $scores_avg_quizzes.'%'; 
         				}
         				else{
         					$avg_certc1 = $scores_avg_quizzes.'%';
         				}
         			}*/
         /*if($result !=0 && $res !="" ){
         			if( $res >= $result_maxs){
         				$avg_certc = $res.'%';
         			}
         			elseif($res < $result_maxs){
         				$avg_certc = $res.'%';
         			}
         		}
         		elseif(($result !=0 && $result !="")){
         			$avg_certc = "N/A";
         		}
         		elseif($result ==0 || $result ==""){
         			$avg_certc = "N/A";
         		}*/
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         @($background_color[1] = str_replace("#", "", $background_color[1]));
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require_once JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $pdf = new mPDF('utf-8', 'A4-L', 0, strtolower($imagename[0]["font_certificate"]));
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     } else {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = $datac['cn'];
         $authorname = $datac['an'];
         $certificateid = $datac['id'];
         $completiondate = $datac['cd'];
         $course_id = $datac['ci'];
         $sitename = $config->get('config.sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         $sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             }
         }
         if ($result != 0 && $res != "") {
             if ($res >= $result_maxs) {
                 $avg_certc = $res . '%';
             } elseif ($res < $result_maxs) {
                 $avg_certc = $res . '%';
             }
         } elseif ($result != 0 && $result != "") {
             $avg_certc = "N/A";
         } elseif ($result == 0 || $result == "") {
             $avg_certc = "N/A";
         }
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         $background_color[1] = str_replace("#", "", $background_color[1]);
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     }
 }
Esempio n. 30
-2
 function savecertificatepdf()
 {
     $datac = JRequest::get('post', JREQUEST_ALLOWRAW);
     $db = JFactory::getDBO();
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $user_id = $user->id;
     $sql = "SELECT `name` from #__guru_program WHERE `id` =" . $datac['ci'];
     $db->setQuery($sql);
     $db->query();
     $result = $db->loadResult();
     $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
     $db->setQuery($imagename);
     $db->query();
     $imagename = $db->loadAssocList();
     $authorname = "SELECT name from #__users where id IN (SELECT author_id FROM #__guru_mycertificates WHERE user_id = " . intval($user_id) . " AND course_id =" . $datac['ci'] . " )";
     $db->setQuery($authorname);
     $db->query();
     $authorname = $db->loadResult();
     $date_completed = "SELECT datecertificate FROM #__guru_mycertificates WHERE user_id=" . intval($user_id) . " AND course_id=" . intval($datac['ci']);
     $db->setQuery($date_completed);
     $db->query();
     $date_completed = $db->loadResult();
     $format = "SELECT datetype FROM #__guru_config WHERE id=1";
     $db->setQuery($format);
     $db->query();
     $format = $db->loadResult();
     $date_completed = date($format, strtotime($date_completed));
     $completiondate = $date_completed;
     $sitename = $config->get('sitename');
     $coursename = $result;
     $site_url = JURI::root();
     $certificateid = $datac['id'];
     $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($coursemsg);
     $db->query();
     $coursemsg = $db->loadResult();
     $scores_avg_quizzes = guruModelguruTask::getAvgScoresQ($user_id, $course_id);
     $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($avg_quizzes_cert);
     $db->query();
     $avg_quizzes_cert = $db->loadResult();
     $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($sql);
     $result = $db->loadResult();
     $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($sql);
     $resulthasq = $db->loadResult();
     $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
     $db->setQuery($sql);
     $result_maxs = $db->loadResult();
     $sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($datac['ci']) . " ORDER BY id DESC LIMIT 0,1";
     $db->setQuery($sql);
     $result_q = $db->loadObject();
     $first = explode("|", @$result_q->score_quiz);
     @($res = intval($first[0] / $first[1] * 100));
     if ($resulthasq == 0 && $scores_avg_quizzes == "") {
         $avg_certc1 = "N/A";
     } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
         $avg_certc1 = "N/A";
     } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
         if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
             $avg_certc1 = $scores_avg_quizzes . '%';
         } else {
             $avg_certc1 = $scores_avg_quizzes . '%';
         }
     }
     if ($result != 0 && $res != "") {
         if ($res >= $result_maxs) {
             $avg_certc = $res . '%';
         } elseif ($res < $result_maxs) {
             $avg_certc = $res . '%';
         }
     } elseif ($result != 0 && $result != "") {
         $avg_certc = "N/A";
     } elseif ($result == 0 || $result == "") {
         $avg_certc = "N/A";
     }
     $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
     $db->setQuery($firstnamelastname);
     $db->query();
     $firstnamelastname = $db->loadAssocList();
     $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid . "&ci=" . $datac['ci'];
     $certificate_url = str_replace(" ", "%20", $certificate_url);
     $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
     $datac["content"] = $imagename[0]["templates1"];
     while (ob_get_level()) {
         ob_end_clean();
     }
     header("Content-Encoding: None", true);
     if (strlen($datac["color"]) == 3) {
         $r = hexdec(substr($datac["color"], 0, 1) . substr($datac["color"], 0, 1));
         $g = hexdec(substr($datac["color"], 1, 1) . substr($datac["color"], 1, 1));
         $b = hexdec(substr($datac["color"], 2, 1) . substr($datac["color"], 2, 1));
     } else {
         $r = hexdec(substr($datac["color"], 0, 2));
         $g = hexdec(substr($datac["color"], 2, 2));
         $b = hexdec(substr($datac["color"], 4, 2));
     }
     $datac["bgcolor"] = explode(":", $datac["bgcolor"]);
     $datac["bgcolor"][1] = str_replace("#", "", $datac["bgcolor"][1]);
     if (strlen($datac["bgcolor"][1]) == 3) {
         $rg = hexdec(substr($datac["bgcolor"][1], 0, 1) . substr($datac["bgcolor"][1], 0, 1));
         $gg = hexdec(substr($datac["bgcolor"][1], 1, 1) . substr($datac["bgcolor"][1], 1, 1));
         $bg = hexdec(substr($datac["bgcolor"][1], 2, 1) . substr($datac["bgcolor"][1], 2, 1));
     } else {
         $rg = hexdec(substr($datac["bgcolor"][1], 0, 2));
         $gg = hexdec(substr($datac["bgcolor"][1], 2, 2));
         $bg = hexdec(substr($datac["bgcolor"][1], 4, 2));
     }
     if ($imagename[0]["library_pdf"] == 0) {
         require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
         $pdf = new PDF('L', 'mm', 'A5');
         $pdf->SetFont($datac["font"], '', 12);
         $pdf->SetTextColor($r, $g, $b);
         //set up a page
         $pdf->AddPage();
         if ($datac["image"] != "") {
             $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $datac["image"], -4, -1, 210, 150);
             //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
         } else {
             $pdf->SetFillColor($rg, $gg, $bg);
             //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
         }
         $pdf->Ln(20);
         $pdf->SetXY(100, 50);
         $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
         $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
     } else {
         require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
         $pdf = new mPDF('utf-8', 'A4-L');
         $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($datac["font"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
         //set up a page
         $pdf->AddPage('L');
         if ($datac["image"] != "") {
             $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $datac["image"], 0, 0, 298, 210, 'jpg', '', true, false);
             //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
         } else {
             $pdf->SetFillColor($rg, $gg, $bg);
             //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
         }
         //$pdf->Ln(20);
         $pdf->SetXY(100, 50);
         $pdf->SetDisplayMode('fullpage');
         $pdf->WriteHTML($imagename[0]["templates1"]);
         $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         exit;
     }
 }