/** * 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(); }
/** * Output the PDF as a string. * * @return string The rendered PDF as string */ public function output() { if (!$this->rendered) { $this->render(); } return $this->dompdf->output(); }
/** * Generates Pdf from html * * @return string raw pdf data */ public function output() { $DomPDF = new Dompdf(); $DomPDF->set_paper($this->_Pdf->pageSize(), $this->_Pdf->orientation()); $DomPDF->load_html($this->_Pdf->html()); $DomPDF->render(); return $DomPDF->output(); }
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; $target = $workingFolder . '/' . $newname; move_uploaded_file($_FILES['inputFileInvoice']['tmp_name'], $target); $Invoice2 = $newname; } $WebAdmin3 = ''; //inputFileWebAdmin
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); }
$escolaJSONController = new EscolaJSONController(); if ($_GET["idesc"]) { if (function_exists("curl_init")) { $dompdf = new Dompdf(); $host = $_SERVER["HTTP_HOST"]; $folder = $_SERVER["HTTP_HOST"] == "187.73.149.26:8080" ? "" : "Hospital/"; //$url = "http://{$host}/{$folder}pesquisa_pdf.php?idesc=".$_GET["idesc"]; $url = gerarPDF(); // Carrega o conteúdo da página $dompdf->load_html($url); // Define o tamanho da página para A4 e orientação para retrato $dompdf->setPaper('A4', 'portrait'); // Gera a visualização do arquivo $dompdf->render(); // Exporta o arquivo $arquivo = $dompdf->output("arquivo.pdf", ["Attachment" => true]); // Gera um nome criptografado para o arquivo $rand = rand(1, 500); $rand2 = rand(1, 500); $nomeCrip = md5("arquivo" . $rand . $rand2); if ($arquivo) { file_put_contents($path['arquivos'] . $nomeCrip . '.pdf', $arquivo); $env = new EnvioDocumento(); $env->setEnv_idEscola($_GET['idesc']); $env->setEnv_idRemetente(1); $env->setEnv_idDestinatario(1); $env->setEnv_url($nomeCrip . '.pdf'); $env->setVisto(0); $envioDocumentoControler->insert($env); echo json_encode(["status" => "Arquivo gerado com sucesso", "arquivo" => $nomeCrip . ".pdf"]); } else {
// reference the Dompdf namespace use Dompdf\Dompdf; // instantiate and use the dompdf class $dompdf = new Dompdf(); $param = $_SERVER['QUERY_STRING']; $host = $_SERVER["HTTP_HOST"]; $opts = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($param) . "\r\n", "content" => $param)); $context = stream_context_create($opts); $folder = substr($_SERVER["HTTP_HOST"], 0, 5) == "local" ? "Hospital/" : ""; $file = file_get_contents("http://{$host}/{$folder}pesquisa_pdf.php", false, $context); $dompdf->load_html($file); // (Optional) Setup the paper size and orientation $dompdf->setPaper('A4', 'portrait'); // Render the HTML as PDF $dompdf->render(); $arquivo = $dompdf->output("arquivo.pdf", array("Attachment" => true)); $rand = rand(1, 500); $rand2 = rand(1, 500); $nomeCrip = md5("arquivo" . $rand . $rand2); if ($arquivo) { file_put_contents($path['arquivos'] . $nomeCrip . '.pdf', $arquivo); $env = new EnvioDocumento(); $env->setEnv_idEscola($_SESSION['idEscolaPre']); $env->setEnv_idRemetente(1); $env->setEnv_idDestinatario(4); $env->setEnv_url($nomeCrip . '.pdf'); $env->setVisto(0); $envioDocumentoControler->insert($env); echo json_encode(["status" => "Arquivo gerado com sucesso"]); } else { throw new Exception("Ocorreu um erro ao gerar o arquivo pdf.");
/** * Generates the PDF output. * * @param Dompdf $DomPDF The Dompdf instance from which to generate the output from. * @return string */ protected function _output($DomPDF) { return $DomPDF->output(); }
<?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();
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'] . ' (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'> </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;'> </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 . " " . $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; }
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'> </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;'> </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 . " " . $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 }
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; }
/** * 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(); }
/** * 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(); }