Esempio n. 1
25
 /**
  * Handle handler
  *
  * @return void
  */
 public function handle()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml($this->input);
     $dompdf->setPaper('letter');
     $dompdf->render();
     //Page numbers
     $font = $dompdf->getFontMetrics()->getFont("Arial", "bold");
     $dompdf->getCanvas()->page_text(16, 770, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 8, array(0, 0, 0));
     echo $dompdf->output();
 }
Esempio n. 2
2
 /**
  * Load a HTML string
  *
  * @param string $string
  * @param string $encoding Not used yet
  * @return static
  */
 public function loadHTML($string, $encoding = null)
 {
     $string = $this->convertEntities($string);
     $this->dompdf->loadHtml($string, $encoding);
     $this->rendered = false;
     return $this;
 }
 public function pdf($vendaId)
 {
     $this->loadModel('Venda');
     $this->loadModel('VendaItensProduto');
     $dompdf = new Dompdf();
     $dadosVenda = $this->Venda->find('all', array('conditions' => array('Venda.id' => $vendaId)));
     $produtosVenda = $this->VendaItensProduto->find('all', array('conditions' => array('VendaItensProduto.venda_id' => $vendaId)));
     $html = $this->pegar_venda_como_html($dadosVenda, $produtosVenda);
     $dompdf->loadHtml($html);
     $dompdf->set_paper('a4');
     $dompdf->render();
     $dompdf->stream();
     exit;
 }
Esempio n. 4
1
 public function actionPdf()
 {
     $data = $this->getData();
     $searchModel = $data['searchModel'];
     $dataProvider = $data['dataProvider'];
     $title = $data['title'];
     $modelName = $data['modelName'];
     $fields = $this->getFieldsKeys($searchModel->exportFields());
     $options = new Options();
     $options->set('defaultFont', 'times');
     $dompdf = new Dompdf($options);
     $html = '<html><body>';
     $html .= '<h1>' . $title ? $title : $modelName . '</h1>';
     $html .= '<table width="100%" cellspacing="0" cellpadding="0">';
     $html .= '<tr style="background-color: #ececec;">';
     foreach ($fields as $one) {
         $html .= '<td style="border: 2px solid #cccccc; text-align: center; font-weight: 500;">' . $searchModel->getAttributeLabel($one) . '</td>';
     }
     $html .= '</tr>';
     foreach ($dataProvider->getModels() as $model) {
         $html .= '<tr>';
         foreach ($searchModel->exportFields() as $one) {
             if (is_string($one)) {
                 $html .= '<td style="border: 1px solid #cccccc; text-align: left; font-weight: 300; padding-left: 10px;">' . $model[$one] . '</td>';
             } else {
                 $html .= '<td style="border: 1px solid #cccccc; text-align: left; font-weight: 300; padding-left: 10px;">' . $one($model) . '</td>';
             }
         }
         $html .= '</tr>';
     }
     $html .= '</table>';
     $html .= '</body></html>';
     $dompdf->loadHtml($html);
     $dompdf->setPaper('A4', 'landscape');
     $dompdf->render();
     $dompdf->stream($modelName . '_' . time());
 }
Esempio n. 5
0
 public function testRender()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml('<strong>Hello</strong>');
     $dompdf->render();
     $dom = $dompdf->getDom();
     $this->assertEquals('', $dom->textContent);
 }
Esempio n. 6
0
 public function renderControllerAction($controller)
 {
     $this->assertNoHeadersSent();
     ini_set('memory_limit', '384M');
     ini_set('max_execution_time', 300);
     $viewRenderer = $controller->getHelper('viewRenderer');
     $controller->render($viewRenderer->getScriptAction(), $viewRenderer->getResponseSegment(), $viewRenderer->getNoController());
     $layout = $controller->getHelper('layout')->setLayout('pdf');
     $layout->content = $controller->getResponse();
     $html = $layout->render();
     $imgDir = Url::fromPath('img');
     $html = preg_replace('~src="' . $imgDir . '/~', 'src="' . Icinga::app()->getBootstrapDirectory() . '/img/', $html);
     $options = new Options();
     $options->set('defaultPaperSize', 'A4');
     $dompdf = new Dompdf($options);
     $dompdf->loadHtml($html);
     $dompdf->render();
     $request = $controller->getRequest();
     $dompdf->stream(sprintf('%s-%s-%d', $request->getControllerName(), $request->getActionName(), time()));
 }
Esempio n. 7
0
<?php

// include autoloaders and helper functions
require_once 'dompdf/src/functions.inc.php';
require_once 'dompdf/src/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>Hello world!</h1>');
// (Optional) Setup the paper size and orientation
//$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Get the generated PDF file contents
$pdf = $dompdf->output();
// Output the generated PDF to Browser
$dompdf->stream();
 public function baixar_estoque_minimo_pdf()
 {
     $this->loadModel('Produto');
     $this->loadModel('Usuario');
     $dompdf = new Dompdf();
     $usuario = $this->Usuario->find('all', array('conditions' => array('Usuario.id' => $this->instancia)))[0]['Usuario'];
     $conditions = array('conditions' => array('ativo' => 1, 'id_usuario' => $this->instancia, 'Produto.estoque < ' => 'Produto.quantidade_minima'));
     $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1");
     $html = $this->getProdutosEstoqueMinimoComoHtml($produtos);
     $dompdf->loadHtml($html);
     $dompdf->set_paper(array(0, 0, 595.28, count($produtos) * 25));
     $dompdf->render();
     $dompdf->stream();
     exit;
 }
Esempio n. 9
0
<?php

// reference the Dompdf namespace
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(file_get_contents("../scripts/tl/MBAppForm.php?leadid=26"));
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream();
Esempio n. 10
0
 function add_user_payment($activity)
 {
     if ($activity->pstatus == 0) {
         $courseid = $this->get_course_id($activity->courseid);
         $userid = $this->get_user_id_by_uid($activity->uid);
         if (strtolower($activity->ptype) != 'cc') {
             $invoice_status = $this->is_invoice_exists($courseid, $userid);
             //echo "Invoice exists: " . $invoice_status . "<br>";
             if ($invoice_status == 0) {
                 $invoice_credentials = $this->get_invoice_credentials();
                 $invoice_num = $this->get_invoice_num();
                 $user_data = $this->get_invoice_user_data($userid);
                 switch (strtolower($activity->ptype)) {
                     case 'cash':
                         $ptype = 1;
                         break;
                     case 'cheque':
                         $ptype = 2;
                         break;
                     case 'free':
                         $ptype = 3;
                         break;
                     default:
                         $ptype = 1;
                 }
                 if ($ptype == 3) {
                     $activity->amount = 0;
                 }
                 // ********************  Make invoice *********************
                 $list = "";
                 $list .= "<html>";
                 $list .= "<body>";
                 $list .= "<p></p>";
                 $list .= "<br/><br/><table border='0' align='center' style='width:100%;table-layout:fixed;'>";
                 $list .= "<tr>";
                 $list .= "<td colspan='2' width='55%' style=''><img src='" . $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/5.png' width='350' height=90></td><td  style='padding-left:10px;padding-right:10px;border-left:1px solid;' width='45%'>Phone: {$invoice_credentials->phone}<br/>Fax: {$invoice_credentials->fax}</td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td colspan='3' style='border-bottom:1px solid;padding-top:1px;height:10px;'></td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td style='padding-top:6px;' colspan='2'>No: {$invoice_num}</td><td  style='padding-left:10px;'>Date: " . $activity->regdate . "</td>";
                 $list .= "</tr>";
                 $list .= "<tr style=''>";
                 $list .= "<td colspan='3' style='padding-top:1px;height:35px;'></td>";
                 $list .= "</tr>";
                 $list .= "<tr bgcolor='black'>";
                 $list .= "<td style='text-align:center;color:black;' width='15' height='15'>&nbsp;</td><td style='padding-left:15px;text-align:left;' width='10%' bgcolor='white'><span style='color:#ff8000;font-weight:bolder;'>INVOICE TO </span></td><td style='text-align:left;color:black;padding-left:15px;'>&nbsp;</td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td colspan='3'>{$user_data->firstname} {$user_data->lastname}<br/>{$user_data->address}<br/> {$user_data->state}" . "/" . $user_data->city . "<br/>{$user_data->zip}</td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td colspan='3' style='border-bottom:0px solid;padding-top:1px;height:40px;'></td>";
                 $list .= "</tr>";
                 $list .= "<tr bgcolor='black'>";
                 $list .= "<td style='color:white;text-align:center' width='10%'>No</td><td style='padding-left:15px;text-align:left;color:white' width='60%'>Description</td><td style='text-align:left;color:white;padding-left:15px;' width='5%'>Amount</td>";
                 $list .= "</tr>";
                 $grand_total = $activity->amount;
                 $item_name = $this->get_course_name($courseid);
                 $item_block = "{$user_data->firstname} {$user_data->lastname}<br/> payment for {$item_name}";
                 $list .= "<tr bgcolor='#FAF7F5'>";
                 $list .= "<td style='text-align:center;color:black;' width='10%' height='55'>1</td><td style='padding-left:15px;text-align:left;color:black' width='60%'>{$item_block}</td><td style='text-align:left;color:black;padding-left:15px;' width='5%'>\${$grand_total} </td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td></td><td style='padding:10px;' align='right'>Tax</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$0</td>";
                 $list .= "</tr>";
                 $list .= "<tr>";
                 $list .= "<td></td><td style='padding:10px;' align='right'>Total</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$" . $grand_total . "</td>";
                 $list .= "</tr>";
                 $list .= "<tr bgcolor='#ff8000'>";
                 $list .= "<td colspan='3' height='35px' style='color:white;fonr-weight:bold;' align='center'>email: " . $invoice_credentials->email . "&nbsp;&nbsp;&nbsp; " . $invoice_credentials->site . "<br>Mailing Address: Medical2 1830A North Gloster St,  Tupelo, MS 38804 </td>";
                 $list .= "</tr>";
                 $list .= "</table>";
                 $list .= "</body>";
                 $list .= "</html>";
                 $dompdf = new Dompdf();
                 $dompdf->loadHtml($list);
                 // (Optional) Setup the paper size and orientation
                 $dompdf->setPaper('A4', 'portrait');
                 // Render the HTML as PDF
                 $dompdf->render();
                 $output = $dompdf->output();
                 $file_path = $this->invoice_path . "/{$invoice_num}.pdf";
                 file_put_contents($file_path, $output);
                 $query = "insert into mdl_invoice " . "(i_num," . "userid," . "courseid," . "renew," . "i_sum," . "i_status," . "i_file," . "i_ptype," . "i_date," . "i_pdate) " . "values('{$invoice_num}'," . "'{$userid}'," . "'{$courseid}'," . "'0'," . "'{$activity->amount}'," . "'1'," . "'{$file_path}'," . "'{$ptype}'," . "'" . strtotime($activity->regdate) . "'," . "'" . strtotime($activity->pdate) . "')";
                 $this->db->query($query);
                 echo "<br>Payment data for user ({$activity->uid}) was created<br>";
             } else {
                 echo "<br>Invoice data for for user ({$activity->uid}) already exists  <br>";
             }
         } else {
             $card_payment_exists = $this->is_card_payment_exists($courseid, $userid);
             //echo "Card Payment status: " . $card_payment_exists . "<br>";
             if ($card_payment_exists == 0) {
                 $query = "insert into mdl_card_payments" . "(userid," . "courseid," . "psum," . "trans_id," . "auth_code," . "pdate) " . "values('{$userid}'," . "'{$courseid}'," . "'{$activity->amount}'," . "'imported'," . "'00'," . "'" . strtotime($activity->pdate) . "')";
                 $this->db->query($query);
                 echo "<br>Payment data for user ({$activity->uid}) was created<br>";
             } else {
                 echo "<br>Credit card payment data for user ({$activity->uid}) already exists  <br>";
                 echo "Echo Credit Card payment date: " . $activity->pdate . "<br>";
             }
         }
         // end else payment made by CC card
     }
     // end if $activity->pstatus==0
 }
Esempio n. 11
0
 function create_assignment_pdf($moduleid)
 {
     $query = "select * from mdl_course_modules where id={$moduleid}";
     $result = $this->db->query($query);
     while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
         $instanceid = $row['instance'];
     }
     $query = "select * from mdl_assign where id={$instanceid}";
     $result = $this->db->query($query);
     while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
         $html = $row['intro'];
     }
     $dompdf = new Dompdf();
     $dompdf->loadHtml($html);
     // (Optional) Setup the paper size and orientation
     $dompdf->setPaper('A4', 'portrait');
     // Render the HTML as PDF
     $dompdf->render();
     $output = $dompdf->output();
     $file_path = $this->assesment_path . "/assesment_{$instanceid}.pdf";
     file_put_contents($file_path, $output);
     $path = "https://" . $_SERVER['SERVER_NAME'] . "/lms/custom/my/assesment_{$instanceid}.pdf";
     return $path;
 }
Esempio n. 12
0
 /**
  * Renders the Dompdf instance.
  *
  * @param CakePdf $Pdf The CakePdf instance that supplies the content to render.
  * @param Dompdf $DomPDF The Dompdf instance to render.
  * @return Dompdf
  */
 protected function _render($Pdf, $DomPDF)
 {
     $DomPDF->loadHtml($Pdf->html());
     $DomPDF->render();
     return $DomPDF;
 }
Esempio n. 13
0
 function create_user_invoice($user, $group, $participants)
 {
     $late = new Late();
     $user_installment_status = $this->is_installment_user($user->id, $user->courseid);
     if ($user_installment_status == 0) {
         if ($group == null) {
             $cost = $this->get_personal_course_cost($user->courseid);
             // cost, discount
             $item_name = $this->get_course_name($user->courseid);
             $tax_status = $this->is_course_taxable($user->courseid);
             // Get invoice user data
             $user_data = $this->get_invoice_user_data($user->id);
             if ($tax_status == 1) {
                 $user_state = $this->get_user_state($user->id);
                 $tax = $this->get_state_taxes($user_state);
             } else {
                 $tax = 0;
             }
             // end else
             if (!property_exists($user, 'slotid')) {
                 $user->slotid = 0;
             }
             $apply_delay_fee = $late->is_apply_delay_fee($user->courseid, $user->slotid);
             $late_fee = $late->get_delay_fee($user->courseid);
         } else {
             $group_data = $_SESSION['group_common_section'];
             $participants = $participants == null ? $_SESSION['tot_participants'] : $participants;
             $cost = $this->get_course_group_discount($group_data->courseid, $participants);
             // cost, discount
             $item_name = $this->get_course_name($group_data->courseid);
             $tax_status = $this->is_course_taxable($group_data->courseid);
             if ($tax_status == 1) {
                 $user_state = $group_data->statename;
                 $tax = $this->get_state_taxes($user_state);
             } else {
                 $tax = 0;
             }
             // end else
             if (!property_exists($group_data, 'slotid')) {
                 $group_data->slotid = 0;
             }
             $apply_delay_fee = $late->is_apply_delay_fee($group_data->courseid, $group_data->slotid);
             $late_fee = $late->get_delay_fee($group_data->courseid);
             // Get invoice user data
             $user_data = new stdClass();
             $user_data->group_name = $group_data->group_name;
             $user_data->address = $group_data->addr;
             $user_data->city = $group_data->city;
             $user_data->state = $group_data->statename;
             $user_data->zip = $group_data->zip;
         }
         // end else when it is group members
     } else {
         $installment = $this->get_user_installment_payments($user->id, $user->courseid);
         $cost['cost'] = $installment->sum;
         $cost['discount'] = 0;
         $item_name = $this->get_course_name($user->courseid);
         $tax_status = $this->is_course_taxable($user->courseid);
         if ($tax_status == 1) {
             $user_state = $this->get_user_state($user->id);
             $tax = $this->get_state_taxes($user_state);
         } else {
             $tax = 0;
         }
         // end else
         $user->slotid = 0;
         // It is always 0 for installment users
         $apply_delay_fee = $late->is_apply_delay_fee($user->courseid, $user->slotid);
         $late_fee = $late->get_delay_fee($user->courseid);
         // Get invoice user data
         $user_data = $this->get_invoice_user_data($user->id);
     }
     // end else when installment is active
     if ($cost['discount'] > 0) {
         $amount = '$' . $cost['cost'] . '&nbsp;(discount is ' . $cost['discount'] . '%)';
     } else {
         $amount = '$' . $cost['cost'];
     }
     $invoice_credentials = $this->get_invoice_credentials();
     $invoice_num = $this->get_invoice_num();
     $list = "";
     $list .= "<html>";
     $list .= "<body>";
     $list .= "<p></p>";
     $list .= "<br/><br/><table border='0' align='center' style='width:100%;table-layout:fixed;'>";
     $list .= "<tr>";
     $list .= "<td colspan='2' width='55%' style=''><img src='" . $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/5.png' width='350' height=90></td><td  style='padding-left:10px;padding-right:10px;border-left:1px solid;' width='45%'>Phone: {$invoice_credentials->phone}<br/>Fax: {$invoice_credentials->fax}</td>";
     $list .= "</tr>";
     $list .= "<tr>";
     $list .= "<td colspan='3' style='border-bottom:1px solid;padding-top:1px;height:10px;'></td>";
     $list .= "</tr>";
     $list .= "<tr>";
     $list .= "<td style='padding-top:6px;' colspan='2'>No: {$invoice_num}</td><td  style='padding-left:10px;'>Date: " . date('Y/m/d', time()) . "</td>";
     $list .= "</tr>";
     $list .= "<tr style=''>";
     $list .= "<td colspan='3' style='padding-top:1px;height:35px;'></td>";
     $list .= "</tr>";
     $list .= "<tr bgcolor='black'>";
     $list .= "<td style='text-align:center;color:black;' width='15' height='15'>&nbsp;</td><td style='padding-left:15px;text-align:left;' width='10%' bgcolor='white'><span style='color:#ff8000;font-weight:bolder;'>INVOICE TO </span></td><td style='text-align:left;color:black;padding-left:15px;'>&nbsp;</td>";
     $list .= "</tr>";
     // Calculate item block
     if ($user_data->group_name == '') {
         // Single registration
         $item_block = "{$user_data->firstname} {$user_data->lastname}<br/> payment for {$item_name}";
         $list .= "<tr>";
         $list .= "<td colspan='3'>{$user_data->firstname} {$user_data->lastname}<br/>{$user_data->address}<br/> {$user_data->state}" . "/" . $user_data->city . "<br/>{$user_data->zip}</td>";
         $list .= "</tr>";
     } else {
         // Group registration
         $item_block = "{$user_data->group_name}<br/> payment for {$item_name}";
         //$item_block = "$user_data->firstname $user_data->lastname<br/> payment for $item_name";
         $list .= "<tr>";
         $list .= "<td colspan='3'>{$user_data->group_name}<br/>{$user_data->address}<br/> {$user_data->state}" . "/" . $user_data->city . "<br/>{$user_data->zip}</td>";
         $list .= "</tr>";
     }
     // end else
     $list .= "<tr>";
     $list .= "<td colspan='3' style='border-bottom:0px solid;padding-top:1px;height:40px;'></td>";
     $list .= "</tr>";
     $list .= "<tr bgcolor='black'>";
     $list .= "<td style='color:white;text-align:center' width='10%'>No</td><td style='padding-left:15px;text-align:left;color:white' width='60%'>Description</td><td style='text-align:left;color:white;padding-left:15px;' width='5%'>Amount</td>";
     $list .= "</tr>";
     $list .= "<tr bgcolor='#FAF7F5'>";
     $grand_total = $apply_delay_fee == true ? $cost['cost'] + $late_fee : $cost['cost'];
     if ($apply_delay_fee) {
         $list .= "<td style='text-align:center;color:black;' width='10%' height='55'>1</td><td style='padding-left:15px;text-align:left;color:black' width='60%'>{$item_block}</td><td style='text-align:left;color:black;padding-left:15px;' width='5%'>\${$grand_total} (late fee of \${$late_fee} is applied)</td>";
     } else {
         $list .= "<td style='text-align:center;color:black;' width='10%' height='55'>1</td><td style='padding-left:15px;text-align:left;color:black' width='60%'>{$item_block}</td><td style='text-align:left;color:black;padding-left:15px;' width='5%'>\${$grand_total} </td>";
     }
     $list .= "</tr>";
     $list .= "<tr>";
     $list .= "<td></td><td style='padding:10px;' align='right'>Subtotal</td><td bgcolor='black' style='color:white;padding-left:15px;'>\$" . $grand_total . "</td>";
     $list .= "</tr>";
     if ($tax == 0) {
         $list .= "<tr>";
         $list .= "<td></td><td style='padding:10px;' align='right'>Tax</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$0</td>";
         $list .= "</tr>";
         $list .= "<tr>";
         $list .= "<td></td><td style='padding:10px;' align='right'>Total</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$" . $grand_total . "</td>";
         $list .= "</tr>";
     } else {
         $tax_sum = round($cost['cost'] * $tax / 100, 2);
         $grand_total = round($cost['cost'] + $tax_sum, 2);
         $grand_total2 = $apply_delay_fee == true ? $grand_total + $late_fee : $grand_total;
         $list .= "<tr>";
         $list .= "<td></td><td style='padding:10px;' align='right'>Tax</td><td bgcolor='black' style='padding-left:15px;color:white;'>\${$tax_sum}</td>";
         $list .= "</tr>";
         $list .= "<tr>";
         $list .= "<td></td><td style='padding:10px;' align='right'>Total</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$" . $grand_total2 . "</td>";
         $list .= "</tr>";
     }
     // end else when tax is not null
     $list .= "<tr>";
     $list .= "<td colspan='3' style='border-bottom:0px solid;padding-top:1px;height:55px;'></td>";
     $list .= "</tr>";
     /*
     $list.="<tr bgcolor='#ff8000'>";
     $list.="<td colspan='3' height='35px' style='color:white;fonr-weight:bold;' align='center'>Mailing Address: Medical2 1830A North Gloster St,  Tupelo, MS 38804 </td>";
     $list.="</tr>";
     */
     $list .= "<tr bgcolor='#ff8000'>";
     $list .= "<td colspan='3' height='35px' style='color:white;fonr-weight:bold;' align='center'>email: " . $invoice_credentials->email . "&nbsp;&nbsp;&nbsp; " . $invoice_credentials->site . "<br>Mailing Address: Medical2 1830A North Gloster St,  Tupelo, MS 38804 </td>";
     $list .= "</tr>";
     $list .= "</table>";
     $list .= "</body>";
     $list .= "</html>";
     // instantiate and use the dompdf class
     $dompdf = new Dompdf();
     $dompdf->loadHtml($list);
     // (Optional) Setup the paper size and orientation
     $dompdf->setPaper('A4', 'portrait');
     // Render the HTML as PDF
     $dompdf->render();
     $output = $dompdf->output();
     $file_path = $this->invoice_path . "/{$invoice_num}.pdf";
     file_put_contents($file_path, $output);
     return $invoice_num;
 }
Esempio n. 14
0
    /**
     * Background image Size: 1343x929 (Aspect ratio: 1.45:1)
     * 
     * 
     * @param \stdClass $obj
     * @param string $dateFrom
     * @param string $dateTo
     * @param string $bgImage
     * @param string $tpl
     * @param string $paperSize
     * @param string $paperOrientation
     * @return Dompdf
     */
    protected function makeCert($obj, $dateFrom = '', $dateTo = '', $bgImage = '', $tpl = '', $paperSize = 'A4', $paperOrientation = 'landscape')
    {
        $now = \Tk\Date::create();
        if (!$dateFrom) {
            $dateFrom = \Tk\Date::create($now->getYear() . '-01-01')->floor()->toString(\Tk\Date::LONG_DATE);
        }
        if (!$dateTo) {
            $dateTo = \Tk\Date::create($now->getYear() . '-12-31')->ceil()->toString(\Tk\Date::LONG_DATE);
        }
        if (!$bgImage) {
            $bgImage = \Tk\Url::create('/data/pdfTestBg.png')->toString();
        }
        if (!$tpl) {
            $tpl = '<div class="content">
  <p class="med">Certificate of Appreciation</p>
  <p class="med">The Faculty of Veterinary Science gratefully acknowledges the support of</p>
  <p class="lg bld">{name}</p>
  <p class="med">for mentoring and training veterinary students from</p>
  <p class="med">The University of Melbourne</p>
  <p class="med">{dateFrom} - {dateTo}</p>
</div>';
        }
        // Format content template
        $tpl = str_replace('{name}', $obj->name, $tpl);
        $tpl = str_replace('{date}', $now->format(\Tk\Date::LONG_DATE), $tpl);
        $tpl = str_replace('{dateFrom}', $dateFrom, $tpl);
        $tpl = str_replace('{dateTo}', $dateTo, $tpl);
        $tpl = str_replace('{year}', $now->toString('Y'), $tpl);
        $tpl = str_replace('{totalUnits}', $obj->totalUnits, $tpl);
        $tpl = str_replace('{totalPlaces}', $obj->totalPlaces, $tpl);
        $html = <<<ENDHTML
<html>
<head>
  <title>Test HTML2PDF</title>
  <style>
@page { margin: 0px; }
body {
  font-family: sans-serif;
  font-size: 10pt;
  margin: 0px;
}
div.cert {
  width: 1122px;
  position: absolute;
  top: 0;
  left: 0;
}
div.cert img {
  width: 100%;
}
div.content {
  position: absolute;
  top: {$this->setup->pdfTopMargin}px;
  left: 0;
  line-height: 1.2em;
  text-align: center;
}
.lg {
  font-size: 20pt;
}
.med {
  font-size: 16pt;
}
.sml {
  font-size: 8pt
}
.bld {
  font-weight: bold;
}
  </style>
</head>
<body>
  <div class="cert">
    <img src="{$bgImage}" alt="" />
  </div>
  {$tpl}
</body>
</html>
ENDHTML;
        set_time_limit(300);
        ini_set('memory_limit', '-1');
        $dompdf = new Dompdf(array('enable_remote' => true));
        $dompdf->setPaper($paperSize, $paperOrientation);
        $dompdf->loadHtml($html);
        $dompdf->render();
        return $dompdf;
    }
Esempio n. 15
0
 /**
  * Capture the invoice as a PDF and return the raw bytes.
  *
  * @param  array  $data
  * @return string
  */
 public function pdf(array $data)
 {
     if (!defined('DOMPDF_ENABLE_AUTOLOAD')) {
         define('DOMPDF_ENABLE_AUTOLOAD', false);
     }
     if (file_exists($configPath = base_path() . '/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
         require_once $configPath;
     }
     $dompdf = new Dompdf();
     $dompdf->loadHtml($this->view($data)->render());
     $dompdf->render();
     return $dompdf->output();
 }
Esempio n. 16
0
<?php

$OrderNo = $_POST['inputOrderNo'];
$html = $_POST['submitContent'];
$chargebackFolder = '../../public/chargebacks';
$workingFolder = $chargebackFolder . '/' . $OrderNo;
if (!file_exists($workingFolder)) {
    mkdir($workingFolder, 0777, true);
}
// include autoloader
require_once '../../php/plugins/dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$Letter1 = '1_Letter_' . $OrderNo . '.pdf';
file_put_contents($workingFolder . '/' . $Letter1, $dompdf->output());
// Output the generated PDF to Browser
//$dompdf->stream();
$Invoice2 = '';
//inputFileInvoice
if (isset($_FILES['inputFileInvoice']) && $_FILES['inputFileInvoice']['error'] == UPLOAD_ERR_OK) {
    $info = pathinfo($_FILES['inputFileInvoice']['name']);
    $ext = $info['extension'];
    // get the extension of the file
    $newname = '2_Invoice_' . $OrderNo . '.' . $ext;
Esempio n. 17
0
 function create_registration_data_details($user)
 {
     $dompdf = new Dompdf();
     $message = $this->get_account_confirmation_message($user, true);
     $dompdf->loadHtml($message);
     $dompdf->setPaper('A4', 'portrait');
     $dompdf->render();
     $output = $dompdf->output();
     $file_path = $this->registration_path . "/{$user->email}.pdf";
     file_put_contents($file_path, $output);
 }
Esempio n. 18
-1
 /**
  * Capture the invoice as a PDF and return the raw bytes.
  *
  * @param  array  $data
  * @return string
  */
 public function pdf(array $data = array())
 {
     if (!defined('DOMPDF_ENABLE_AUTOLOAD')) {
         define('DOMPDF_ENABLE_AUTOLOAD', false);
     }
     //  if (file_exists($configPath = base_path().'/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
     // 		 require_once $configPath;
     //  }
     $options = new Options();
     $options->set('isRemoteEnabled', true);
     $dompdf = new Dompdf($options);
     $dompdf->loadHtml($this->view($data)->render());
     $dompdf->render();
     return $dompdf->output();
 }
Esempio n. 19
-2
 public function printTest()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml('Hello world');
     $dompdf->setPaper('A4', 'Landscape');
     $dompdf->render();
     $dompdf->stream();
 }