public function pdfskiniMobilno($id, $idvrstaDok) { $vrstaDok = $this->dokumenti->vrstaDokumenta($idvrstaDok); $oznaka = $vrstaDok->vd_oznaka; $opis = $vrstaDok->vd_oznaka; ob_start(); $fiID = $this->session->userdata('firmaID'); $broj = $this->dokumenti->getById("dokument", "do_id", $id); $firma = $this->dokumenti->getById("firma", "fi_id", $fiID); $data = array('prikaziStavke' => $this->dokumenti->getstavke($id), 'firma' => $this->dokumenti->getById("firma", "fi_id", $fiID), 'zaglavlje' => $this->dokumenti->getDokumentZag($id), 'vrstaDokumenta' => $this->dokumenti->vrstaDokumenta($idvrstaDok), 'rekapitualcijaporeza' => $this->dokumenti->rekapitulacijaporeza($id)); $data['firma'] = $firma; if ($broj->Partner_pa_id) { $data['partner'] = $this->dokumenti->getById("partner", "pa_id", $broj->Partner_pa_id); } $data['sume'] = $this->dokumenti->sume($id); if ($oznaka == "ponuda") { $html = $this->load->view('sifarnici/dokument/PDF/pdf_ponuda', $data, true); } else { if ($this->session->userdata('UsustavuPDV') == 1) { $html = $this->load->view('sifarnici/dokument/PDF/pdf_racunPDV', $data, true); } else { $html = $this->load->view('sifarnici/dokument/PDF/pdf_racun', $data, true); } } // render the view into HTML //$html = 'asdasd asd asd as a '; $this->load->library('mpdf'); $mpdf = new mPDF('utf-8', 'A4'); $mpdf->SetHTMLFooter(' <table width="100%" style="border-top: 1px solid; vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000;"><tr> <td width="10%"></span></td> <td width="80%" align="center" style="font-style: italic;">' . $firma->fi_opis . '</td> <td width="10%" style="text-align: right; ">{PAGENO}/{nbpg}</td> </tr></table> '); $mpdf->setHeader('{DATE d.m.Y H:i:s}'); $mpdf->allow_charset_conversion = true; //$mpdf -> debug = true; $stylesheet = file_get_contents(base_url() . 'assets/css/bootstrap.css'); $mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html, 2); $mpdf->Output($opis . "_broj_" . $broj->do_broj . '.pdf', D); //$mpdf->Output(); ob_end_flush(); }
$html .= $w; } } else { $html .= '<' . $e . '>'; } } //============================================================== //============================================================== 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>
$longfooterE = ' <table width="100%" style="border-bottom: 1px solid #000000; vertical-align: bottom; font-family: serif; font-size: 9pt; color: #000088;"><tr> <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} » {PAGENO} » 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} » {PAGENO} » 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);
function mpdf_output($wp_content = '', $do_pdf = false, $outputToBrowser = true, $pdfName = '', $templatePath = '') { global $post; $pdf_ofilename = $post->post_name . '.pdf'; if (!empty($pdfName)) { $pdf_filename = $pdfName . '.pdf'; } else { $pdf_filename = $pdf_ofilename; } /** * Allow to override the pdf file name */ $pdf_filename = apply_filters('mpdf_output_pdf_filename', $pdf_filename); /** * Geshi Support */ if (get_option('mpdf_geshi') == true) { require_once dirname(__FILE__) . '/geshi.inc.php'; $wp_content = ParseGeshi($wp_content); } /** * Run the content default filter */ $wp_content = apply_filters('the_content', $wp_content); /** * Run the mpdf filter */ $wp_content = mpdf_filter($wp_content, $do_pdf); if ($do_pdf === false) { echo $wp_content; } else { $cacheDirectory = mpdf_getcachedir(); if (!is_dir($cacheDirectory . 'tmp')) { @mkdir($cacheDirectory . 'tmp'); } define('_MPDF_PATH', dirname(__FILE__) . '/mpdf/'); define('_MPDF_TEMP_PATH', $cacheDirectory . 'tmp/'); define('_MPDF_TTFONTDATAPATH', _MPDF_TEMP_PATH); require_once _MPDF_PATH . 'mpdf.php'; global $pdf_margin_left; global $pdf_margin_right; global $pdf_margin_top; global $pdf_margin_bottom; global $pdf_margin_header; global $pdf_margin_footer; global $pdf_html_header; global $pdf_html_footer; if ($pdf_margin_left !== 0 && $pdf_margin_left == '') { $pdf_margin_left = 15; } if ($pdf_margin_right !== 0 && $pdf_margin_right == '') { $pdf_margin_right = 15; } if ($pdf_margin_top !== 0 && $pdf_margin_top == '') { $pdf_margin_top = 16; } if ($pdf_margin_bottom !== 0 && $pdf_margin_bottom == '') { $pdf_margin_bottom = 16; } if ($pdf_margin_header !== 0 && $pdf_margin_header == '') { $pdf_margin_header = 9; } if ($pdf_margin_footer !== 0 && $pdf_margin_footer == '') { $pdf_margin_footer = 9; } if (empty($pdf_html_header)) { $pdf_html_header = false; } if (empty($pdf_html_footer)) { $pdf_html_footer = false; } global $pdf_orientation; if ($pdf_orientation == '') { $pdf_orientation = 'P'; } $cp = 'utf-8'; if (get_option('mpdf_code_page') != '') { $cp = get_option('mpdf_code_page'); } $mpdf = new mPDF($cp, 'A4', '', '', $pdf_margin_left, $pdf_margin_right, $pdf_margin_top, $pdf_margin_bottom, $pdf_margin_header, $pdf_margin_footer, $pdf_orientation); $mpdf->SetUserRights(); $mpdf->title2annots = false; //$mpdf->annotMargin = 12; $mpdf->use_embeddedfonts_1252 = true; // false is default $mpdf->SetBasePath($templatePath); //Set PDF Template if it's set global $pdf_template_pdfpage; global $pdf_template_pdfpage_page; global $pdf_template_pdfdoc; if (isset($pdf_template_pdfdoc) && $pdf_template_pdfdoc != '') { $mpdf->SetImportUse(); $mpdf->SetDocTemplate($templatePath . $pdf_template_pdfdoc, true); } else { if (isset($pdf_template_pdfpage) && $pdf_template_pdfpage != '' && isset($pdf_template_pdfpage_page) && is_numeric($pdf_template_pdfpage_page)) { $mpdf->SetImportUse(); $pagecount = $mpdf->SetSourceFile($templatePath . $pdf_template_pdfpage); if ($pdf_template_pdfpage_page < 1) { $pdf_template_pdfpage_page = 1; } else { if ($pdf_template_pdfpage_page > $pagecount) { $pdf_template_pdfpage_page = $pagecount; } } $tplId = $mpdf->ImportPage($pdf_template_pdfpage_page); $mpdf->UseTemplate($tplId); } } $user_info = get_userdata($post->post_author); $mpdf->SetAuthor($user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_login . ')'); $mpdf->SetCreator('wp-mpdf'); //The Header and Footer global $pdf_footer; global $pdf_header; $mpdf->startPageNums(); // Required for TOC use after AddPage(), and to use Headers and Footers if ($pdf_html_header) { $mpdf->SetHTMLHeader($pdf_header); } else { $mpdf->setHeader($pdf_header); } if ($pdf_html_footer) { $mpdf->SetHTMLFooter($pdf_footer); } else { $mpdf->setFooter($pdf_footer); } if (get_option('mpdf_theme') != '' && file_exists($templatePath . get_option('mpdf_theme') . '.css')) { //Read the StyleCSS $tmpCSS = file_get_contents($templatePath . get_option('mpdf_theme') . '.css'); $mpdf->WriteHTML($tmpCSS, 1); } //My Filters require_once dirname(__FILE__) . '/myfilters.inc.php'; $wp_content = mpdf_myfilters($wp_content); if (get_option('mpdf_debug') == true) { if (!is_dir(dirname(__FILE__) . '/debug/')) { mkdir(dirname(__FILE__) . '/debug/'); } file_put_contents(dirname(__FILE__) . '/debug/' . get_option('mpdf_theme') . '_' . $pdf_ofilename . '.html', $wp_content); } //die($wp_content); $mpdf->WriteHTML($wp_content); /** * Allow to process the pdf by an 3th party plugin */ do_action('mpdf_output', $mpdf, $pdf_filename); if (get_option('mpdf_caching') == true) { file_put_contents(mpdf_getcachedir() . get_option('mpdf_theme') . '_' . $pdf_ofilename . '.cache', $post->post_modified_gmt); $mpdf->Output(mpdf_getcachedir() . get_option('mpdf_theme') . '_' . $pdf_ofilename, 'F'); if ($outputToBrowser == true) { $mpdf->Output($pdf_filename, 'I'); } } else { if ($outputToBrowser == true) { $mpdf->Output($pdf_filename, 'I'); } } } }
public function rekapituliraj($datOD, $datDO, $pmID, $nuID, $vpID = NULL) { //$id = $this->input->post('id'); ob_start(); $fiID = $this->session->userdata('firmaID'); $firma = $this->dokumenti->getById("firma", "fi_id", $fiID); $prodajnomjesto = $this->dokumenti->getById("prodajnomjesto", "pm_id", $pmID); $naplatniuredjaj = $this->dokumenti->getById("naplatniuredjaj", "nu_id", $nuID); $id = $this->input->post('id'); $datOD = date('Y-m-d', strtotime($datOD)); $datDO = date('Y-m-d', strtotime($datDO)); $tablica = $this->pregled_model->getRekapitulacija($datOD, $datDO, $pmID, $nuID, $vpID); $data = array('table' => $tablica, 'datOD' => $datOD, 'datDO' => $datDO, 'prodajnomjesto' => $prodajnomjesto, 'naplatniuredjaj' => $naplatniuredjaj); $data['firma'] = $firma; $html = $this->load->view('pregled/pdf_rekapitualcija', $data, true); // render the view into HTML //$html = 'asdasd asd asd as a '; $this->load->library('mpdf'); $mpdf = new mPDF('utf-8', 'A4'); $mpdf->SetHTMLFooter(' <table width="100%" style="border-top: 1px solid; vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000;"><tr> <td width="10%" style="text-align: right; ">{PAGENO}/{nbpg}</td> </tr></table> '); $mpdf->setHeader('{DATE d.m.Y H:i:s}'); //$mpdf -> allow_charset_conversion = true; //$mpdf -> debug = true; $stylesheet = file_get_contents(base_url() . 'assets/css/bootstrap.css'); $mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html, 2); //$mpdf -> Output('file.pdf', D); $mpdf->Output('asd.pdf', I); ob_end_flush(); }