本文整理汇总了PHP中TCPDF::lastPage方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::lastPage方法的具体用法?PHP TCPDF::lastPage怎么用?PHP TCPDF::lastPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::lastPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPdfOutput
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 017');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 017', PDF_HEADER_STRING);
// 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)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 20);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of independent Multicell() columns', '', 0, 'L', true, 0, false, false, 0);
$pdf->Ln(5);
$pdf->SetFont('times', '', 12);
// create columns content
// create columns content
$left_column = '[LEFT COLUMN] left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column' . "\n";
$right_column = '[RIGHT COLUMN] right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column' . "\n";
// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
// set color for background
$pdf->SetFillColor(255, 255, 200);
// set color for text
$pdf->SetTextColor(0, 63, 127);
// write the first column
$pdf->MultiCell(80, 0, $left_column, 1, 'J', 1, 0, '', '', true, 0, false, true, 0);
// set color for background
$pdf->SetFillColor(215, 235, 255);
// set color for text
$pdf->SetTextColor(127, 31, 0);
// write the second column
$pdf->MultiCell(80, 0, $right_column, 1, 'J', 1, 1, '', '', true, 0, false, true, 0);
// reset pointer to the last page
$pdf->lastPage();
$this->comparePdfs($pdf);
}
示例2: testPdfOutput
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 021');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 021', PDF_HEADER_STRING);
// 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)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 9);
// add a page
$pdf->AddPage();
// create some HTML content
$html = '<h1>Example of HTML text flow</h1>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. <em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> <em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em><br /><br /><b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i><br /><br /><b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u>';
// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);
// reset pointer to the last page
$pdf->lastPage();
$this->comparePdfs($pdf);
}
示例3: order
public function order($order_id)
{
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('KHANSA TRADER');
$pdf->SetTitle('Surat perjanjian');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// 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 dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$html = pdf_view($order_id);
// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, 'J', true);
$pdf->lastPage();
$pdf->Output('KHANSA-TRADER - Surat perjanjian.pdf', 'I');
}
示例4: printTicket
static function printTicket($ticket_html, $order)
{
ob_end_clean();
$config = JComponentHelper::getParams('com_bookpro');
$page_ticket = "<h1 color='Red'> Wellcome to tcpdf </h1>";
$page_ticket = $ticket_html;
// create new PDF document
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$order_number = $order->order_number;
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Joombooking');
$pdf->SetTitle('Travel Ticket ' . $order_number);
$pdf->SetSubject('Travel Ticket');
$pdf->SetKeywords('TCPDF, PDF, ticket, travel, booking');
// set default header data
//$pdf->SetHeaderData($config->get('company_logo'),50, $config->get('company_name'), "Ticket \n www.");
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
//$pdf->setHeaderMargin(10);
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
//$pdf->SetMargins(30, 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
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 11);
// add a page
$pdf->AddPage();
// set JPEG quality
$pdf->setJPEGQuality(75);
$style['position'] = 'R';
/*
* $type type of barcode (see tcpdf_barcodes_1d.php for supported formats).
*
*/
//$pdf->write1DBarcode($order_number, 'C128B','', '', '', 10, 0.4, $style, 'M');
// create some HTML content
//$pdf->writeHTML($htmlcontent, true, 0, true, 0);
//$pdf->WriteHTML(file_get_contents('test.html'));
$pdf->WriteHTML($page_ticket);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
ob_end_clean();
$pdf->Output($order->name . '.pdf', 'I');
//Should use variable to make file name
ob_end_flush();
}
示例5: __construct
/**
* 初始化
*
* @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']);
}
示例6: run
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";
}
示例7:
/**
* Starts a new page
*
* Subsequent drawing operations will appear on the new page.
*/
function new_page()
{
dompdf_debug("trace", "()");
// Add objects to the current page
$this->_place_objects();
//$this->_pdf->endPage();
$this->_pdf->lastPage();
$this->_pdf->AddPage();
//$this->_page_count++;
$this->_pages[] = $this->_pdf->PageNo();
return $this->_pdf->getNumPages();
}
示例8: render
/**
* Render the invoice.
*
* @return mixed
*/
public function render()
{
/* @var $l array */
require_once 'tcpdf/config/lang/eng.php';
require_once 'tcpdf/tcpdf.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('Kimai Timetracking (http://www.kimai.org)');
//$pdf->SetAuthor('Kevin Papst');
//$pdf->SetTitle('Invoice');
//$pdf->SetSubject('Invoice');
//$pdf->SetKeywords('Invoice');
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING);
// 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
$pdf->setLanguageArray($l);
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$html = $this->getHtml();
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// reset pointer to the last page
$pdf->lastPage();
//Close and output PDF document
$pdf->Output('invoice.pdf', 'I');
}
示例9: generatePDF
/**
* Generate the pdf document
*
* @param IsotopeProductCollection $objCollection
* @param array $arrTokens
*
* @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';
// 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(\StringUtil::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;
}
示例10: getPdfFileData
/**
* @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);
}
示例11: invoicedownloadAction
//.........这里部分代码省略.........
}
$iterm_dtppcs[$k] = $tmp;
if ($hasTypeDesktopPublishingWin == 1) {
$subtotal = $subtotal + $iterm_dtppcs[$k]['total'];
}
}
//get iterm iterm_dtpmac
$repository = $entityManager->getRepository('User\\Entity\\Itermdtpmac');
$iterm_dtpmac = $repository->findBy(array('project' => $project));
$iterm_dtpmacs = array();
foreach ($iterm_dtpmac as $k => $v) {
$tmp = $v->getData();
if ($tmp['unit'] == 1) {
$tmp['unit'] = 'Day';
} else {
$tmp['unit'] = 'Half Day';
}
$iterm_dtpmacs[$k] = $tmp;
if ($hasTypeDesktopPublishingMac == 1) {
$subtotal = $subtotal + $iterm_dtpmacs[$k]['total'];
}
}
// Get Interpreting Price
$repository = $entityManager->getRepository('User\\Entity\\Iterminterpreting');
$iterm_interpreting = $repository->findBy(array('project' => $project));
$iterm_interpretings = array();
foreach ($iterm_interpreting as $k => $v) {
$tmp = $v->getData();
if ($tmp['unit'] == 1) {
$tmp['unit'] = 'Day';
} else {
if ($tmp['unit'] == 2) {
$tmp['unit'] = 'Half Day';
}
}
$iterm_interpretings[$k] = $tmp;
if ($hasTypeDesktopPublishingInterpreting == 1) {
$subtotal = $subtotal + $iterm_interpretings[$k]['total'];
}
}
// Get Itermengineering
$repository = $entityManager->getRepository('User\\Entity\\Itermengineering');
$iterm_engineering = $repository->findBy(array('project' => $project));
$iterm_engineerings = array();
foreach ($iterm_engineering as $k => $v) {
$tmp = $v->getData();
if ($tmp['unit'] == 1) {
$tmp['unit'] = 'Hour';
} else {
if ($tmp['unit'] == 2) {
$tmp['unit'] = 'Day';
} else {
if ($tmp['unit'] == 3) {
$tmp['unit'] = 'Month';
} else {
if ($tmp['unit'] == 4) {
$tmp['unit'] = 'Word';
} else {
if ($tmp['unit'] == 5) {
$tmp['unit'] = 'Graphic';
} else {
$tmp['unit'] = 'Page';
}
}
}
}
}
$iterm_engineerings[$k] = $tmp;
if ($hasTypeDesktopPublishingEngineer == 1) {
$subtotal = $subtotal + $iterm_engineerings[$k]['total'];
}
}
$view = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface');
$viewModel = new ViewModel();
$template = '/admin/project/invoicedownload';
$viewModel->setTemplate($template)->setVariables(array('id' => $id, 'lang_code' => $lang_code, 'project' => $project->getData(), 'companyinfo' => $companyinfo->getData(), 'bankinfo' => $bankinfo ? $bankinfo->getData() : null, 'hasTypeTranslationNoTM' => $hasTypeTranslationNoTM, 'hasTypeTranslationUseTM' => $hasTypeTranslationUseTM, 'hasTypeDesktopPublishingWin' => $hasTypeDesktopPublishingWin, 'hasTypeDesktopPublishingMac' => $hasTypeDesktopPublishingMac, 'hasTypeDesktopPublishingEngineer' => $hasTypeDesktopPublishingEngineer, 'hasTypeDesktopPublishingInterpreting' => $hasTypeDesktopPublishingInterpreting, 'iterm_translations' => $iterm_translations, 'iterm_translationtms' => $iterm_translationtms, 'iterm_dtppcs' => $iterm_dtppcs, 'iterm_dtpmacs' => $iterm_dtpmacs, 'iterm_interpretings' => $iterm_interpretings, 'iterm_engineerings' => $iterm_engineerings, 'serviceLevel' => $serviceLevel, 'subtotal' => $subtotal, 'invoices' => $invoices, 'dueDate' => $dueDate, 'invoiceDate' => $invoiceDate))->setTerminal(true);
//return $viewModel;
$content = $view->render($viewModel);
// set array for viewer preferences
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$font = new \TCPDF_FONTS();
//$fontx = $font->addTTFfont('public/fonts/STHeiti-Light.ttc');
//$pdf->SetFont($fontx, '', 12, '', false);
//$pdf->SetFont('microsoftyahei' , '', 12,'',false);
$pdf->SetFont('droidsansfallback', '', 7);
$pdf->setFontSubsetting(true);
$preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2);
// set pdf viewer preferences
$pdf->setViewerPreferences($preferences);
// add a page
$pdf->AddPage();
// output the HTML content
$pdf->writeHTML($content, true, false, true, false, '');
$pdf->lastPage();
$name = "INV-" . $project_data['project_no'] . ".pdf";
ob_end_clean();
$pdf->Output($name, 'D');
//$pdf->Output("pdf-name.pdf", 'D');
exit;
}
示例12: generatePDF
function generatePDF($action = 'return')
{
if (!in_array($action, ['return', 'dump'])) {
throw $this->exception('Please provide action as result or dump');
}
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('xEpan ERP');
$pdf->SetTitle($this['type'] . ' ' . $this['document_no']);
$pdf->SetSubject($this['type'] . ' ' . $this['document_no']);
$pdf->SetKeywords($this['type'] . ' ' . $this['document_no']);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set font
$pdf->SetFont('dejavusans', '', 10);
//remove header or footer hr lines
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// add a page
$pdf->AddPage();
if ($org = $this->ref('contact_id')->get('organization')) {
$this['contact'] = $org;
$this['contact_id'] = '';
}
// getting layouts from config
$layout_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['master' => 'xepan\\base\\RichText', 'detail' => 'xepan\\base\\RichText'], 'config_key' => strtoupper($this['type']) . '_LAYOUT', 'application' => 'commerce']);
$layout_m->tryLoadAny();
$info_config = $layout_m['master'];
$info_layout = $this->add('GiTemplate');
$info_layout->loadTemplateFromString($info_config);
$detail_config = $layout_m['detail'];
$detail_layout = $this->add('GiTemplate');
$detail_layout->loadTemplateFromString($detail_config);
$new = $this->add('xepan\\commerce\\Model_QSP_Master');
$new->addHook('afterLoad', function ($m) {
$m['round_amount'] = abs($m['round_amount']);
});
$new->load($this->id);
$view = $this->app->add('xepan\\commerce\\View_QSP', ['qsp_model' => $new, 'master_template' => $info_layout, 'detail_template' => $detail_layout, 'action' => 'pdf']);
// $view = $this->owner->add('xepan\commerce\View_QSP',['qsp_model'=>$this]);
if ($bar_code = $this->getBarCode()) {
$barcodeobj = new \TCPDFBarcode($bar_code, 'C128');
// $barcode_html = $barcodeobj->getBarcodePNG(2, 30, 'black');
$barcode_html = $barcodeobj->getBarcodePngData(1, 20, array(0, 128, 0));
$info_layout->trySetHtml('dispatch_barcode', '<img src="data:image/png;base64, ' . base64_encode($barcode_html) . '"/>');
}
$html = $view->getHTML();
// echo "string".$html;
// echo $html;
// exit;
// output the HTML content
$pdf->writeHTML($html, false, false, true, false, '');
// set default form properties
$pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
// reset pointer to the last page
$pdf->lastPage();
//Close and output PDF document
switch ($action) {
case 'return':
return $pdf->Output(null, 'S');
break;
case 'dump':
return $pdf->Output(null, 'I');
exit;
break;
}
}
示例13: testPdfOutput
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 054');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 054', PDF_HEADER_STRING);
// 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)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// IMPORTANT: disable font subsetting to allow users editing the document
$pdf->setFontSubsetting(false);
// set font
$pdf->SetFont('helvetica', '', 10, '', false);
// add a page
$pdf->AddPage();
// create some HTML content
$html = <<<EOD
<h1>XHTML Form Example</h1>
<form method="post" action="http://localhost/printvars.php" enctype="multipart/form-data">
<label for="name">name:</label> <input type="text" name="name" value="" size="20" maxlength="30" /><br />
<label for="password">password:</label> <input type="password" name="password" value="" size="20" maxlength="30" /><br /><br />
<label for="infile">file:</label> <input type="file" name="userfile" size="20" /><br /><br />
<input type="checkbox" name="agree" value="1" checked="checked" /> <label for="agree">I agree </label><br /><br />
<input type="radio" name="radioquestion" id="rqa" value="1" /> <label for="rqa">one</label><br />
<input type="radio" name="radioquestion" id="rqb" value="2" checked="checked"/> <label for="rqb">two</label><br />
<input type="radio" name="radioquestion" id="rqc" value="3" /> <label for="rqc">three</label><br /><br />
<label for="selection">select:</label>
<select name="selection" size="0">
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select><br /><br />
<label for="selection">select:</label>
<select name="multiselection" size="2" multiple="multiple">
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select><br /><br /><br />
<label for="text">text area:</label><br />
<textarea cols="40" rows="3" name="text">line one
line two</textarea><br />
<br /><br /><br />
<input type="reset" name="reset" value="Reset" />
<input type="submit" name="submit" value="Submit" />
<input type="button" name="print" value="Print" onclick="print()" />
<input type="hidden" name="hiddenfield" value="OK" />
<br />
</form>
EOD;
// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
$this->comparePdfs($pdf);
}
示例14: _html2pdf_tcpdf
/**
* Convert html to tcpdf.
*
* @param $paper_size
* @param $orientation
* @param $margins
* @param $html
* @param $output
* @param $fileName
* @param $stationery_path
*/
public static function _html2pdf_tcpdf($paper_size, $orientation, $margins, $html, $output, $fileName, $stationery_path)
{
// Documentation on the TCPDF library can be found at: http://www.tcpdf.org
// This function also uses the FPDI library documented at: http://www.setasign.com/products/fpdi/about/
// Syntax borrowed from https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc
require_once 'tcpdf/tcpdf.php';
require_once 'FPDI/fpdi.php';
// This library is only in the 'packages' area as of version 4.5
$paper_size_arr = array($paper_size[2], $paper_size[3]);
$pdf = new TCPDF($orientation, 'pt', $paper_size_arr);
$pdf->Open();
if (is_readable($stationery_path)) {
$pdf->SetStationery($stationery_path);
}
$pdf->SetAuthor('');
$pdf->SetKeywords('CiviCRM.org');
$pdf->setPageUnit($margins[0]);
$pdf->SetMargins($margins[4], $margins[1], $margins[2], TRUE);
$pdf->setJPEGQuality('100');
$pdf->SetAutoPageBreak(TRUE, $margins[3]);
$pdf->AddPage();
$ln = TRUE;
$fill = FALSE;
$reset_parm = FALSE;
$cell = FALSE;
$align = '';
// output the HTML content
$pdf->writeHTML($html, $ln, $fill, $reset_parm, $cell, $align);
// reset pointer to the last page
$pdf->lastPage();
// close and output the PDF
$pdf->Close();
$pdf_file = 'CiviLetter' . '.pdf';
$pdf->Output($pdf_file, 'D');
CRM_Utils_System::civiExit(1);
}
示例15: addressLabelPDF
function addressLabelPDF($outputformat)
{
$pdf = new TCPDF('L', 'mm', 'A4', true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Niels Klazenga');
$pdf->SetTitle('MEL Label');
$pdf->SetSubject('MEL Label');
//set margins
$pdf->SetTopMargin(7.5);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 0);
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// ---------------------------------------------------------
// set font
if ($outputformat == 3) {
$pdf->SetFont('helvetica', '', 12);
} else {
$pdf->SetFont('helvetica', '', 14);
}
// set cell padding
$pdf->setCellPaddings(0, 0, 0, 0);
// set cell margins
$pdf->setCellMargins(0, 0, 0, 0);
$pdf->addPage();
if ($outputformat == 3) {
$x = 135;
$y = 40;
} else {
$x = 165;
$y = 30;
}
$this->Address();
$pdf->MultiCell(100, 5, $this->loan->ShippedTo, 0, 'L', 0, 1, $x, $y, true, false, true);
// move pointer to last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('mellabel.pdf', 'I');
}