function convertHtmlToPdf($html) { if (!$html) { throw new \Exception("Html Not Given"); } $pagelayout = array($this->options['width'], $this->options['height']); // or array($width,$height) $pdf = new \TCPDF('l', 'px', $pagelayout, true, 'UTF-8', false); $pdf->SetMargins(0, 0, 0); $pdf->SetHeaderMargin(0); $pdf->SetFooterMargin(0); // $pdf = new \TCPDF_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetAutoPageBreak(false); if ($this->options['header_font_family']) { $pdf->SetFont($this->options['header_font_family']); } // add a page $pdf->AddPage(); $pdf->WriteHTML($html, true, false, true, false); $this->pdf = $pdf->Output(null, 'S'); //for test // $this->pdf = $pdf->Output(null); // echo $this->pdf; // exit; }
/** * @param TicketsOrder $order * @param string $format 'S': data string - 'I' to see in browser * @return string */ public function getPdfFileData(TicketsOrder $order, $format = 'S') { $pdf = new \TCPDF(); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Billets du Louvre'); $pdf->SetTitle('Commande ' . $order->getRef()); $pdf->setPrintHeader(false); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set style for barcode $style = array('border' => 0, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1); /** @var Ticket $ticket */ foreach ($order->getTickets() as $ticket) { $pdf->AddPage(); $html = $this->renderTicket(array('visit_date' => $order->getVisitDate()->format('d/m/Y'), 'visit_duration' => $order->getVisitDuration(), 'code' => $order->getRef(), 'ticket_name' => $ticket->getName(), 'price' => $ticket->getPrice(), 'details' => $ticket->getTicketDetails())); $pdf->writeHTML($html, true, false, true); $pdf->write2DBarcode($order->getRef(), 'QRCODE,H', 150, 10, 50, 50, $style, 'N'); $pdf->lastPage(); } return $pdf->Output('tickets.pdf', $format); }
/** * 初始化 * * @access public * @param array $params 初始化参数 * @return void */ public function __construct($params) { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($this->pdf_author); $pdf->SetTitle($this->pdf_title); $pdf->SetSubject($this->pdf_subject); $pdf->SetKeywords($this->pdf_keywords); // 不显示头部和底部 $pdf->setPrintHeader(FALSE); $pdf->setPrintFooter(FALSE); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings require TCPDF_BASE_PATH . 'tcpdf/config/lang/eng.php'; $pdf->setLanguageArray($l); // set font $pdf->SetFont('stsongstdlight', '', 10); $pdf->AddPage(); $pdf->writeHTML($params['content'], true, false, true, false, ''); $pdf->lastPage(); // 输出方式 I:浏览器直接输出 D:文件下载 如果需要浏览器输出或者下载的同时生成文件请在前面加上F $pdf->Output($params['filename'], $params['flag']); }
function __construct() { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $this->pdf = $pdf; $this->widths = new stdClass(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetAutoPageBreak(false); $pdf->AddPage(); }
function display($tpl = null) { $mainframe =& JFactory::getApplication(); $dispatcher =& JDispatcher::getInstance(); /* Load the event details */ $course = $this->get('Details'); $venue = $this->get('Venue'); $pdf = new TCPDF("P", "mm", "A4", true); $pdf->SetCreator($mainframe->getCfg('sitename')); $pdf->SetAuthor($mainframe->getCfg('sitename')); $pdf->SetTitle($course->title); $pdf->SetSubject($course->title); $pdf->setHeaderFont(array('freesans', '', 8)); $pdf->setFooterFont(array('freesans', '', 8)); $pdf->setFont('freesans'); // disable header and footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(true); //set the display mode $pdf->SetDisplayMode('default'); //initialize document $pdf->AliasNbPages(); // add a page $pdf->AddPage(); $pdf->SetFontSize(10); /* This loads the tags replacer */ JView::loadHelper('tags'); $tags = new redEVENT_tags(); $tags->setXref(JRequest::getInt('xref')); $message = $tags->ReplaceTags($course->submission_type_email_pdf); // convert urls $htmlmsg = REOutput::ImgRelAbs($message); $pdf->WriteHTML($message, true); // add the form data if requested if ($course->pdf_form_data) { JRequest::setVar('pdfform', $pdf); JPluginHelper::importPlugin('content'); $form = new stdClass(); $form->text = '{redform}' . $course->redform_id . ',1{/redform}'; $form->eventid = $course->did; $form->task = 'userregister'; $results = $dispatcher->trigger('onPrepareEvent', array(&$form, array(), 0)); $pdf->WriteHTML($form->text, true); } // output the file $pdf->Output($course->title . ".pdf", "I"); exit; }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $loggedInUserId = $session->get('user/id'); $pageId = $request->get('id'); $page = $this->getRepository(Entity::class)->getById($pageId, $loggedInUserId); // create new PDF document $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->setPrintHeader(false); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set font $pdf->SetFont('dejavusans', '', 10); // add a page $pdf->AddPage(); $html = $page['content']; $pdf->writeHTML($html, true, false, true, false, ''); // Close and output PDF document $pdf->Output('./../../' . $page['name'] . '.pdf', 'D'); }
/** * Render a PDF file and show in browser or save to disk * If save to disk return file location */ public function renderRfqRequest($quote, $saveToDisk = false) { $storeid = $quote->getStoreId(); if ($storeid) { $appEmulation = Mage::getSingleton('core/app_emulation'); $initial = $appEmulation->startEnvironmentEmulation($storeid, Mage_Core_Model_App_Area::AREA_FRONTEND, true); } $pdf = new TCPDF(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); $pdf->SetAutoPageBreak(true, 30); $pdf->setHeaderMargin(20); $pdf->setFooterMargin(20); $pdf->setImageScale(1.5); $emailtext = Mage::helper('request4quote/email')->sendRequestProposalNotification($quote, false, true); $pdf->writeHTML(Mage::helper('cms')->getBlockTemplateProcessor()->filter($emailtext), false); $pdf->endPage(); if ($storeid) { $appEmulation->stopEnvironmentEmulation($initial); } $rfqfilename = 'rfq_' . $quote->getId() . '.pdf'; if (!$saveToDisk) { return $pdf->Output($rfqfilename); } else { if ($saveToDisk) { $filePath = $this->getFilePath() . $rfqfilename; $pdf->Output($filePath, 'F'); return $filePath; } } exit; }
function processing($contextData, $options) { $prodId = $contextData[0]['id']; $prodName = $contextData[0]['name']; $unitPrice = $contextData[0]['unitprice']; $pFile = $contextData[0]['photofile']; $timestamp = new DateTime(); $tsString = $timestamp->format("Y-m-d H:i:s"); $fileName = "{$prodId}.pdf"; require_once './tcpdf/tcpdf.php'; $pdf = new TCPDF("P", "mm", "A4", true, "UTF-8"); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetMargins(0, 0, 0, 0); $pdf->AddPage(); $pdf->setTextColor(100, 100, 100); $pdf->SetFont('', '', 14); $pdf->Text(40, 40, "Product ID: {$prodId}"); $pdf->Text(40, 50, "Product Name: {$prodName}"); $pdf->Text(40, 60, "Unit Price: {$unitPrice}"); $pdf->Text(40, 70, "Today: {$tsString}"); $pdf->Image("../Sample_products/images/{$pFile}", 40, 80, 100); header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=\"{$fileName}\""); header('X-Frame-Options: SAMEORIGIN'); $pdf->Output(); }
public function run() { include getcwd() . '/vendor/autoload.php'; $navStructure = (include getcwd() . '/docs/navigation.php'); echo "Loading markdown...\n"; $markdown = $this->findMarkdown($navStructure); echo "Converting markdown to html...\n"; $Parsedown = new \Parsedown(); $html = $Parsedown->text($markdown); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); #$pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('My Documentation'); #$pdf->SetSubject('TCPDF Tutorial'); #$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetFont('helvetica', '', 20); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->AddPage(); $pdf->writeHTML($html, true, 0, true, 0); $pdf->lastPage(); echo "Writing PDF...\n"; $pdf->Output($this->config['output'], 'F'); echo "Complete.\n"; }
/** * @param string $html 要转为pdf的内容 * @param string $filename 文件名 * @param string $type 'I'在页面中显示;'D'直接下载 */ public static function pdf($html, $filename = 'hzd.pdf', $type = 'I') { import("Tools.TCPDF.TCPDF"); import("Tools.TCPDF.config.tcpdf_config.php"); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('HZD'); $pdf->SetTitle('HZD'); $pdf->SetSubject('HZD'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->setPrintHeader(false); //不显示头部 $pdf->setPrintFooter(false); //不显示底部 // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set font $pdf->SetFont('stsongstdlight', '', 20); // add a page $pdf->AddPage(); // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // --------------------------------------------------------- //Close and output PDF document $pdf->Output($filename, $type); }
/** * Class constructor * * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or * an array(xmin,ymin,xmax,ymax) * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') * @param DOMPDF $dompdf */ function __construct($paper = "letter", $orientation = "portrait", DOMPDF $dompdf) { //*** if (is_array($paper)) { $size = $paper; } else { if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) { $size = self::$PAPER_SIZES[mb_strtolower($paper)]; } else { $size = self::$PAPER_SIZES["letter"]; } } $ori = 'P'; // *** if (mb_strtolower($orientation) === "landscape") { list($size[2], $size[3]) = array($size[3], $size[2]); $ori = 'L'; // *** } $this->_width = $size[2] - $size[0]; $this->_height = $size[3] - $size[1]; $this->_dompdf = $dompdf; //***$this->_pdf = new My_TCPDF('P', 'pt', $paper, true, 'UTF-8', false); $this->_pdf = new My_TCPDF($ori, 'pt', $paper, true, 'UTF-8', false); // *** $this->_pdf->SetCreator("DOMPDF Converter"); // CreationDate and ModDate info are added by TCPDF itself // don't use TCPDF page defaults $this->_pdf->SetAutoPageBreak(false); $this->_pdf->SetMargins(0, 0, 0, true); $this->_pdf->setPrintHeader(false); // remove default header/footer $this->_pdf->setPrintFooter(false); $this->_pdf->setHeaderMargin(0); $this->_pdf->setFooterMargin(0); $this->_pdf->SetCellPadding(0); $this->_pdf->AddPage(); $this->_pdf->SetDisplayMode('fullpage', 'continuous'); $this->_page_number = $this->_page_count = 1; $this->_page_text = array(); $this->_pages = array($this->_pdf->PageNo()); $this->_image_cache = array(); // other TCPDF stuff... $this->_objs = array(); // for templating support $this->_nameddest = array(); // for internal link support $this->_internal_links = array(); // " " " $this->_pdf->setAlpha(1.0); $this->_currentLineTransparency = array("mode" => "Normal", "opacity" => 1.0); $this->_currentFillTransparency = array("mode" => "Normal", "opacity" => 1.0); $this->_last_fill_color = $this->_last_stroke_color = null; //dompdf_debug("trace", "Exit"); }
private function getPdfData() { $pdf = new \TCPDF(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetFont('times', 'BI', 12); $pdf->AddPage(); $pdf->Write(0, 'Fichier pdf', '', 0, 'C', true, 0, false, false, 0); return $pdf->Output('fichier.pdf', 'S'); }
function Adresaro() { $pdf = new TCPDF(); $tiparo = "freesans"; $pdf->AddFont($tiparo, '', $tiparo . ".php"); $pdf->AddFont($tiparo, 'B', $tiparo . "b.php"); $pdf->setFont($tiparo); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setAutoPageBreak(false); $pdf->Open(); $this->pdf =& $pdf; }
/** * 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(); } // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; } // Override Paper Size if (!is_null($this->getPaperSize())) { $printPaperSize = $this->getPaperSize(); } if (isset(self::$paperSizes[$printPaperSize])) { $paperSize = self::$paperSizes[$printPaperSize]; } // Create PDF $pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf->setFontSubsetting(false); // Set margins, converting inches to points (using 72 dpi) $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72); $pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); // Set the appropriate font $pdf->SetFont($this->getFont()); $pdf->writeHTML($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter()); // 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()); // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); parent::restoreStateAfterSave($fileHandle); }
function orderViewPDF() { $l = null; require_once OSEMSC_F_PATH . DS . 'libraries' . DS . 'tcpdf' . DS . 'tcpdf.php'; require_once OSEMSC_F_PATH . DS . 'libraries' . DS . 'tcpdf' . DS . 'config' . DS . 'lang' . DS . 'eng.php'; $order_id = JRequest::getInt('order_id', 0); //$my = JFactory::getUser(); $member_id = JRequest::getInt('member_id', 0); $where = array(); $where[] = " `order_id` = {$order_id}"; $where[] = " `user_id` = {$member_id}"; $orderInfo = oseRegistry::call('payment')->getOrder($where, 'obj'); if (empty($orderInfo)) { $result = array(); $result['title'] = 'Error'; $result['content'] = 'Error'; oseExit('Error'); } $receipt = oseRegistry::call('member')->getReceipt($orderInfo); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('OSEMSC'); $pdf->SetTitle('Invoice #' . $order_id); $pdf->SetSubject('Invoice'); $pdf->SetKeywords('invoice'); // set default header data $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->SetMargins(30, 18, 30); //set some language-dependent strings $pdf->setLanguageArray($l); $pdf->SetAutoPageBreak(TRUE, 10); $pdf->AddPage(); //ob_get_clean(); $pdf->WriteHTML($receipt->body, true); $pdf->Output("Invoice-#{$order_id}.pdf", "I"); oseExit(); /* //$receipt = self::orderView(); $order_id = JRequest::getInt('order_id'); $app = JFactory::getApplication('SITE'); //oseExit('dfdf'); $app->redirect( JRoute::_('index.php?option=com_osemsc&view=member&format=pdf&memberTask=generateOrderView&order_id='.$order_id)); */ }
public function __construct() { // $orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false $pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont('courier'); $pdf->SetMargins(10, 10, 7, true); $pdf->SetAutoPageBreak(true, 5); $pdf->setImageScale(1); $pdf->SetFont('freeserif', '', 12, '', false); $pdf->SetLineWidth(0.05); $this->pdf = $pdf; $this->cell = new cell($this->pdf); }
public function create_pdf_from_eml($piler_id = '', $text = '', $images = array()) { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetAuthor('Yourcompany Ltd'); $pdf->SetTitle('EML email title'); $pdf->SetSubject('EML email subject'); //$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,190,255), array(0,64,128)); //$pdf->setFooterData($tc=array(0,64,0), $lc=array(0,64,128)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); //$pdf->SetMargins(10, 25, 10); $pdf->SetMargins(10, 5, 10); //$pdf->SetHeaderMargin(120); //$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); //set auto page breaks //$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetAutoPageBreak(TRUE, 20); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings //$pdf->setLanguageArray($l); // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 8, '', true); $pdf->AddPage(); $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $text, $border = 0, $ln = 1, $fill = 0, $reseth = true, 'L', $autopadding = true); $i = 0; foreach ($images as $img) { if ($i > 0) { $pdf->AddPage(); } $pdf->Image(DIR_BASE . 'tmp/' . $img['id']); $i++; } $pdf->Output(DIR_BASE . 'tmp/' . $piler_id . '.pdf', 'F'); }
/** * * @param string $orientation P / L * @param string $size paper size * @param string $title document title * @return \TCPDF model */ public function initializePdf($orientation, $size, $title) { Yii::createComponent('ext.tcpdf.TcPdf', 'P', 'cm', 'A4', true, 'UTF-8'); spl_autoload_unregister(array('YiiBase', 'autoload')); $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); spl_autoload_register(array('YiiBase', 'autoload')); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetTitle($title); //no headers and footers $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); //automatically insert page break bottom $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->addPage($orientation, $size); return $pdf; }
function exportDataToPDF($content) { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Matija Lovreković'); $pdf->SetTitle('Rezultati pretrage'); $pdf->SetSubject('DWA Lab 4'); $pdf->SetKeywords('DWA'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->SetFont('dejavusans', '', 20, '', true); $pdf->AddPage(); $pdf->writeHTML($content); ob_end_clean(); $pdf->Output('rezultati_pretrage.pdf', 'I'); }
/** * Generate the pdf document * @param IsotopeProductCollection * @param array * @return \TCPDF */ protected function generatePDF(IsotopeProductCollection $objCollection, array $arrTokens) { // TCPDF configuration $l = array(); $l['a_meta_dir'] = 'ltr'; $l['a_meta_charset'] = $GLOBALS['TL_CONFIG']['characterSet']; $l['a_meta_language'] = substr($GLOBALS['TL_LANGUAGE'], 0, 2); $l['w_page'] = 'page'; // Include TCPDF config require_once TL_ROOT . '/system/config/tcpdf.php'; if (version_compare(VERSION, '3.3', '<')) { require_once TL_ROOT . '/system/modules/core/vendor/tcpdf/tcpdf.php'; } // Create new PDF document $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // Set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetTitle(\String::parseSimpleTokens($this->documentTitle, $arrTokens)); // Prevent font subsetting (huge speed improvement) $pdf->setFontSubsetting(false); // Remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // Set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // Set auto page breaks $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); // Set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // Set some language-dependent strings $pdf->setLanguageArray($l); // Initialize document and add a page $pdf->AddPage(); // Set font $pdf->SetFont(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN); // Write the HTML content $pdf->writeHTML($this->generateTemplate($objCollection, $arrTokens), true, 0, true, 0); $pdf->lastPage(); return $pdf; }
function generate_product_report_pdf($data = null) { App::import('Vendor', 'tcpdf/tcpdf'); $tcpdf = new TCPDF(); $textfont = 'helvetica'; $tcpdf->SetAutoPageBreak(true); $tcpdf->setPrintHeader(false); $tcpdf->setPrintFooter(false); $tcpdf->SetTextColor(0, 0, 0); $tcpdf->SetFont($textfont, '', 10); $tcpdf->AddPage(); // session details $htmlcontent = "<html><body>"; $htmlcontent .= "<strong><h2>Product Report</h2></strong>"; $htmlcontent .= "<br/>"; // table start $htmlcontent .= "<table border=\".5\" >\r\r\n <tr>\r\r\n <td align='left' valign='top'><strong>Product</strong></td>\r\r\n\t\t\t<td align='left' valign='top'><strong>Product Code</strong></td>\r\r\n\t\t\t<td align='left' valign='top'><strong>Status</strong></td>\r\r\n\t\t\t<td align='left' valign='top'><strong>Created</strong></td>\r\r\n </tr>"; $charges = "No"; if (count($data) > 0) { $status = array('Deactive', 'Active'); foreach ($data as $result) { $htmlcontent .= "<tr><td align='left' valign='top'>"; $htmlcontent .= $result['Product']['title']; $htmlcontent .= "</td><td align='left' valign='top'>"; $htmlcontent .= $result['Product']['product_code']; $htmlcontent .= "</td><td align='left' valign='top'>"; $htmlcontent .= $status[$result['Product']['is_active']]; $htmlcontent .= "</td><td align='left' valign='top'>"; $htmlcontent .= $result['Product']['created']; $htmlcontent .= "</td></tr>"; } } else { $htmlcontent .= "<tr><td colspan='4' style='border-bottom:0px' class='tc'>No records found</td></tr>"; } $htmlcontent .= "</table></body></html>"; // output the HTML content $tcpdf->writeHTML($htmlcontent, true, 0, true, 0); $tcpdf->Output('product_report.pdf', 'D'); exit; }
function generate_pdf($start, $end, $userid, $courseid, $method = 'I', $base = '', $timesheetid = -1, $unsignedonly = false) { global $CFG, $DB; $htmlpages = generate_html($start, $end, $userid, $courseid, $timesheetid, $unsignedonly); // Collect Data $conf = get_timetracker_config($courseid); $month = userdate($start, "%m"); $year = userdate($start, "%Y"); $workerrecord = $DB->get_record('block_timetracker_workerinfo', array('id' => $userid)); if (!$workerrecord) { print_error('usernotexist', 'block_timetracker', $CFG->wwwroot . '/blocks/timetracker/index.php?id=' . $courseid); } // ********** BEGIN PDF ********** // // Create new PDF $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $fn = $year . '_' . ($month < 10 ? '0' . $month : $month) . 'Timesheet_' . substr($workerrecord->firstname, 0, 1) . $workerrecord->lastname . '_' . $workerrecord->mdluserid; // Set Document Data $pdf->setCreator(PDF_CREATOR); $pdf->SetFont('helvetica', '', 8); $pdf->SetCellPadding(0); $pdf->SetTitle($fn); $pdf->SetAuthor('TimeTracker'); $pdf->SetSubject(' '); $pdf->SetKeywords(' '); // Remove Default Header/Footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); foreach ($htmlpages as $page) { $pdf->AddPage(); $pdf->writeHTML($page); } //create the filename $fn .= '.pdf'; //Close and Output PDF document //change the $method from 'I' to $method -- allow more than just a single file //to be created $pdf->Output($base . '/' . $fn, $method); return $fn; }
public function testPdfOutput() { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 002'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set font $pdf->SetFont('times', 'BI', 20); // add a page $pdf->AddPage(); // set some text to print $txt = <<<EOD TCPDF Example 002 Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods. EOD; // print a block of text using Write() $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); $this->comparePdfs($pdf); }
/** * Saves as a PDF to a file. * * @param string $file_name File name * * @return void * @access public */ public function toFileAsPdf($file_name) { $this->init(); include_once './libraries/tcpdf/tcpdf.php'; // create pdf $pdf = new TCPDF('', 'pt', $GLOBALS['cfg']['PDFDefaultPageSize'], true, 'UTF-8', false); // disable header and footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); //set auto page breaks $pdf->SetAutoPageBreak(false); // add a page $pdf->AddPage(); $scale_data = $this->_scaleDataSet($this->_data); $pdf = $this->_prepareDataSet($this->_data, $scale_data, 'pdf', $pdf); // sanitize file name $file_name = $this->_sanitizeName($file_name, 'pdf'); $pdf->Output($file_name, 'D'); }
<?php // require_once('loaddata.php'); // print_r($response[0]['firstname']); // Include the main TCPDF library (search for installation path). require_once 'tcpdf_include.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator('JBIMS'); $pdf->SetAuthor('JBIMS'); $pdf->SetTitle('Jamnalal Bajaj Institute of Management Studies Online Application Form 2015-2017'); $pdf->SetSubject('Jamnalal Bajaj Institute of Management Studies Online Application Form 2015-2017'); // set default header data // $pdf->SetHeaderData('', '0', 'Jamnalal Bajaj Institute of Management Studies Online Application Form 2015-2017'); $pdf->setPrintHeader(false); // set header and footer fonts // $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once 'conectado.php'; $mis_pines = $_SESSION['codigos']; $pdf = new TCPDF('P', 'mm', 'Letter', true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Tramas'); $pdf->SetTitle('Generacion_de_contraseñas'); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetHeaderMargin(1); $pdf->SetMargins(10, 47, 10); $pdf->SetFooterMargin(7); $pdf->SetAutoPageBreak(TRUE, 15); //$pdf->setFontSubsetting(true); $pdf->SetFont('Helvetica', '', 8, '', true); $pdf->setPrintHeader(true); //no imprime la cabecera ni la linea $pdf->setPrintFooter(true); // imprime el pie ni la linea $pdf->SetHeaderData('img1.png', 180, "", "", array(0, 64, 255), array(0, 64, 128)); $pdf->AddPage(); // set cell padding $pdf->setCellPaddings(0, 0, 2, 0); // set cell margins $pdf->setCellMargins(0.5, 0.5, 0.5, 0.5); //************* ob_end_clean(); //rompimiento de pagina //************* $cadena = ''; //$cadena .= '<center><div><img src="img10.png" alt="attribute" width="500" height="150" border="0" ></div></center>';
public function bend29() { $id = Input::get('nomor'); if (substr($id, 0, 3) == 'ALO') { $data = DB::table('pkm_alokasi')->where('nomor', $id)->first(); $dtl = DB::table('pkm_alokasidtl')->join('aset_data', 'pkm_alokasidtl.id_inventori', '=', 'aset_data.id')->where('nomor', $id)->where('tipe', 'aset')->get(); } else { $data = DB::table('aset_keluar')->where('nomor', $id)->first(); $dtl = DB::table('aset_keluardtl')->join('aset_data', 'aset_keluardtl.id_inventori', '=', 'aset_data.id')->where('nomor', $id)->select('aset_data.*')->get(); } $ka1 = DB::table('pkm_pegawai')->where('id_unit', $data->id_puskesmas)->where('jabatan', 1)->first(); $ka2 = DB::table('pkm_pegawai')->where('id_unit', $data->id_unit)->where('jabatan', 1)->first(); $pb1 = DB::table('pkm_pegawai')->where('id', Input::get('pihak1'))->first(); $pb2 = DB::table('pkm_pegawai')->where('id', Input::get('pihak2'))->first(); $header = ' <table> <tr style="font-weight: bold"> <td colspan="7" style="text-align: left"><br><br><br><br><br><br><br><br><br></td> </tr> <tr style="font-weight: bold"> <td colspan="4" style="text-align: left">PEMERINTAH KOTA SURABAYA</td> <td colspan="3" style="text-align: right">BEND. 29</td> </tr> <tr style="font-weight: bold"> <td colspan="4" style="text-align: left"> </td> <td colspan="3" style="text-align: right">NOMOR JURNAL : ' . $id . '</td> </tr> <tr style="font-size: large;font-weight: bold"> <td colspan="7" style="text-align: center">BUKTI PENYERAHAN BARANG DARI DAERAH/UNIT: ' . $data->nama_puskesmas . '</td> </tr> <tr style="font-size: large;font-weight: bold"> <td colspan="7" style="text-align: center">KEPADA DAERAH:UNIT : ' . $data->nama_unit . '</td> </tr> <tr style="font-size: large;font-weight: bold"> <td colspan="7" style="text-align: center">NO BERITA ACARA SERAH TERIMA: 028/ .24/436.6.3/2014</td> </tr> <tr style="font-size: large;font-weight: bold"> <td colspan="7" style="text-align: center"> </td> </tr> </table> <table border="1" cellspacing="3"> <thead> <tr style="font-weight: bold;text-align: center;"> <th rowspan="2" style="width: 10%">NO</th> <th rowspan="2" style="width: 10%">TANGGAL</th> <th rowspan="2" style="width: 30%">Nama & Spesifikasi Barang <br> (Merk, Tipe, Kode, Kode Neraca, No Reg Induk)</th> <th rowspan="2" style="width: 10%">SATUAN</th> <th colspan="2" style="width: 20%">JUMLAH</th> <th rowspan="2" style="width: 20%">NILAI (Rp)</th> </tr> <tr style="font-weight: bold;text-align: center;"> <th style="width: 10%">ANGKA</th> <th style="width: 10%">HURUF</th> </tr> </thead> '; $footer = '</table>'; $content = ''; for ($i = 0; $i < count($dtl); $i++) { $jml = $dtl[$i]->jumlah * $dtl[$i]->h_satuan; $content .= ' <tr style="text-align: center;"> <td style="width: 10%">' . ($i + 1) . '</td> <td style="width: 10%">' . $data->tanggal . '</td> <td style="width: 30%;text-align: left;"> ' . $dtl[$i]->nama . '<br> ' . $dtl[$i]->kode_bidang . '<br> ' . $dtl[$i]->kode_perwali . '<br> ' . $dtl[$i]->no_register . '</td> <td style="width: 10%">' . $dtl[$i]->satuan . '</td> <td style="width: 10%">' . $dtl[$i]->jumlah . '</td> <td style="width: 10%">' . Terbilang::rupiah($dtl[$i]->jumlah) . '</td> <td style="width: 20%;text-align: right;">' . number_format($jml + $jml * $dtl[$i]->ppn / 100) . '</td> </tr> '; } //$peg1 = DB::table('pkm_pegawai')->where('id_unit', $data->id_unit)->where('jabatan', 2)->first(); if (Auth::user()->id_puskesmas == '0999') { $tt = '<tr> <td style="width: 20%"></td> <td style="width: 60%"> <table cellpadding="5"> <tr><td colspan="3"> </td></tr> <tr> <td style="text-align: right">Mengetahui,</td> <td style="width: 2%"></td> <td></td> </tr> <tr><td colspan="3"> </td></tr> <tr><td colspan="3"> </td></tr> <tr><td colspan="3"> </td></tr> <tr> <td>Tanda Tangan</td> <td style="width: 2%">:</td> <td>............................</td> </tr> <tr> <td>NAMA</td> <td style="width: 2%">:</td> <td>NANIK SUKRISTINA, SKM</td> </tr> <tr> <td>NIP</td> <td style="width: 2%">:</td> <td>19700117 199403 2 008</td> </tr> <tr> <td>PANGKAT</td> <td style="width: 2%">:</td> <td>PEMBINA / IV A</td> </tr> </table> </td> <td style="width: 20%"></td> </tr>'; } else { $tt = '<tr> <td colspan="3" style="width: 48%"> <table cellpadding="5"> <tr> <td colspan="3">Mengetahui,</td> </tr> <tr> <td>Tanda Tangan</td> <td style="width: 2%">:</td> <td>............................</td> </tr> <tr> <td>NAMA</td> <td style="width: 2%">:</td> <td>' . $ka2->nama_pegawai . '</td> </tr> <tr> <td>NIP</td> <td style="width: 2%">:</td> <td>' . $ka2->nip . '</td> </tr> <tr> <td>PANGKAT</td> <td style="width: 2%">:</td> <td>' . $ka2->pangkat . '</td> </tr> </table> </td> <td style="width: 5%"> </td> <td colspan="3" style="width: 47%"> <table cellpadding="5"> <tr> <td colspan="3">Yang Menyerahkan,</td> </tr> <tr> <td>Tanda Tangan</td> <td style="width: 2%">:</td> <td>............................</td> </tr> <tr> <td>NAMA</td> <td style="width: 2%">:</td> <td>' . $ka1->nama_pegawai . '</td> </tr> <tr> <td>NIP</td> <td style="width: 2%">:</td> <td>' . $ka1->nip . '</td> </tr> <tr> <td>PANGKAT</td> <td style="width: 2%">:</td> <td>' . $ka1->pangkat . '</td> </tr> </table> </td> </tr>'; } $ttd = ' <table> <tr><td colspan="7"> </td></tr> <tr><td colspan="7"> </td></tr> <tr> <td colspan="3" style="width: 48%"> <table cellpadding="5"> <tr> <td>DAERAH</td> <td style="width: 2%">:</td> <td style="width: 90%">KOTA SURABAYA</td> </tr> <tr> <td>UNIT</td> <td style="width: 2%">:</td> <td>' . $data->nama_puskesmas . '</td> </tr> <tr> <td>TANGGAL</td> <td style="width: 2%">:</td> <td>' . date("d/m/Y") . '</td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3">Yang Menerima,</td> </tr> <tr> <td>Tanda Tangan</td> <td style="width: 2%">:</td> <td>............................</td> </tr> <tr> <td>NAMA</td> <td style="width: 2%">:</td> <td>' . $pb2->nama_pegawai . '</td> </tr> <tr> <td>NIP</td> <td style="width: 2%">:</td> <td>' . $pb2->nip . '</td> </tr> <tr> <td>PANGKAT</td> <td style="width: 2%">:</td> <td>' . $pb2->pangkat . '</td> </tr> </table> </td> <td style="width: 5%"> </td> <td colspan="3" style="width: 47%"> <table cellpadding="5"> <tr> <td></td><td></td><td></td> </tr> <tr> <td>Dibuat di</td> <td style="width: 2%">:</td> <td>SURABAYA</td> </tr> <tr> <td>TANGGAL</td> <td style="width: 2%">:</td> <td>' . date("d/m/Y") . '</td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3">Yang Menyerahkan,</td> </tr> <tr> <td>Tanda Tangan</td> <td style="width: 2%">:</td> <td>............................</td> </tr> <tr> <td>NAMA</td> <td style="width: 2%">:</td> <td>' . $pb1->nama_pegawai . '</td> </tr> <tr> <td>NIP</td> <td style="width: 2%">:</td> <td>' . $pb1->nip . '</td> </tr> <tr> <td>PANGKAT</td> <td style="width: 2%">:</td> <td>' . $pb1->pangkat . '</td> </tr> </table> </td> </tr> ' . $tt . ' </table> '; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetTitle('Gudang DKK'); $pdf->SetSubject('Laporan Penerimaan Barang Pengadaan'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, 8); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // CONTENT------------------------------------------- $pdf->AddPage('P', 'A4'); /*$pdf->SetFont('helvetica', 'B', 10); $pdf->Write(0, "PEMERINTAH KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0); $pdf->SetFont('helvetica', 'B', 12); $pdf->Write(0, "DINAS KESEHATAN KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0); $pdf->SetFont('helvetica', 'U', 10); $pdf->Write(0, "JL. JEMURSARI NO 197 Tlp (031)8439473, 8439372, Fax. (031)8494965", '', 0, 'C', true, 0, false, false, 0); $pdf->SetFont('helvetica', 'B', 10); $pdf->Write(0, , '', 0, 'C', true, 0, false, false, 0);*/ $pdf->ln(); $pdf->SetFont('helvetica', '', 8); $pdf->writeHTML($header . $content . $footer . $ttd, true, false, false, false, ''); $pdf->Output('ben29' . date('d-m-Y') . ' . pdf', 'I'); }
public function print_pdf($text, $title = 'PDF Document') { require_once '../backend/tcpdf/tcpdf.php'; $pdf = new TCPDF(); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); $pdf->writeHTML($text, true, false, true, false, ''); $pdf->Output($title, 'I'); }
public function save($file) { $orientation = $this->_getOrientation(); $size = $this->_getSize(); /* @TODO Not sure if this works either, in comparison with $pdf->AddPage() */ $pdf = new TCPDF($orientation, 'mm', $size, true, $this->_page['encoding'], false); if (is_array($this->_page['size'])) { list($width, $height) = $this->_page['size']; $orientation = $height > $width ? 'P' : 'L'; $pdf->addFormat("custom", $width, $height); $pdf->reFormat("custom", $orientation); } $pdf->SetAutoPageBreak(TRUE, $this->_page['margin'][2]); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $tagvs = array('p' => array(array('h' => 0, 'n' => 1), array('h' => '', 'n' => 1)), 'hr' => array(array('h' => 0, 'n' => 0), array('h' => 0, 'n' => 0))); $pdf->setHtmlVSpace($tagvs); // $pdf->SetHeaderMargin(0); // $pdf->SetFooterMargin(0); call_user_func_array(array($pdf, 'SetMargins'), $this->_page['margin']); foreach ($this->_html as $i => $page) { $page = (strpos($page, '<style') !== FALSE && strpos($page, '<style') < strpos($page, '<body') ? substr($page, strpos($page, '<style'), strpos($page, '</style') - strpos($page, '<st') + 8) : '') . preg_replace('/<body[^>]+>/i', '', substr($page, strpos($page, '<body'), strpos($page, '</body') - strpos($page, '<body'))); $page = str_replace(array("\r", "\n"), "", $page); if (!is_array($size)) { $pdf->AddPage(); } else { $pdf->AddPage($orientation, $size); // @TODO must verify if this is correct } $pdf->writeHTML($page, true, false, true, false); $pdf->lastPage(); } // $pdf->Output($file, 'I'); die(); $pdf->Output($file, 'F'); }
function output($html, $title = 'document', $pFilename = 'doc.pdf') { require_once '../classes/PHPExcel/Shared/PDF/tcpdf.php'; require_once "../classes/Settings.php"; require_once "../classes/SettingsQuery.php"; // Create PDF $pdf = new TCPDF('P', 'pt', 'A4'); $pdf->SetMargins(56.7, 56.7); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setTitle($title); $pdf->AddPage(); // Set the appropriate font $setQ = new SettingsQuery(); $setQ->connect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $setQ->execSelect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $set = $setQ->fetchRow(); $pdf->setFont($set->getFontNormal()); $pdf->writeHTML($html); $pdf->SetTitle($title); return $pdf->output($pFilename, 'S'); }