本文整理汇总了PHP中TCPDF::MultiCell方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::MultiCell方法的具体用法?PHP TCPDF::MultiCell怎么用?PHP TCPDF::MultiCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::MultiCell方法的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 035');
$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 . ' 035', 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('times', 'BI', 16);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of SetLineStyle() method', '', 0, 'L', true, 0, false, false, 0);
$pdf->Ln();
$pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 4, 'color' => array(255, 0, 0)));
$pdf->SetFillColor(255, 255, 128);
$pdf->SetTextColor(0, 0, 128);
$text = "DUMMY";
$pdf->Cell(0, 0, $text, 1, 1, 'L', 1, 0);
$pdf->Ln();
$pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 255)));
$pdf->SetFillColor(255, 255, 0);
$pdf->SetTextColor(0, 0, 255);
$pdf->MultiCell(60, 4, $text, 1, 'C', 1, 0);
$pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 255, 0)));
$pdf->SetFillColor(0, 0, 255);
$pdf->SetTextColor(255, 255, 0);
$pdf->MultiCell(60, 4, $text, 'TB', 'C', 1, 0);
$pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 255)));
$pdf->SetFillColor(0, 255, 0);
$pdf->SetTextColor(255, 0, 255);
$pdf->MultiCell(60, 4, $text, 1, 'C', 1, 1);
$this->comparePdfs($pdf);
}
示例3: buildLabel_Barcodes
/**
* @param $lInfo
* @param $newLine
*/
private function buildLabel_Barcodes($lInfo, $newLine)
{
$labelContent = array();
if ($lInfo['barcode'] != '') {
if ($lInfo['barcode_type'] != '') {
$labelContent[] = $this->getTcpdfBarcode($lInfo);
} else {
$labelContent[] = 'Image Not Available';
}
}
$first = 0;
$labelText = '';
foreach ($labelContent as $iLabel) {
if ($first == 1) {
$labelText .= "\n" . ltrim(str_replace('<br>', "\n", str_replace('<br />', "\n", str_replace('<br/>', "\n", preg_replace("/(?:\\s\\s+|\n|\t)/", " ", $iLabel)))));
} else {
$labelText .= ltrim(str_replace('<br>', "\n", str_replace('<br />', "\n", str_replace('<br/>', "\n", preg_replace("/(?:\\s\\s+|\n|\t)/", " ", $iLabel)))));
}
$first++;
}
$this->pdf->MultiCell($this->layoutInfo['labelWidth'], $this->layoutInfo['labelHeight'], $labelText, 0, 'C', 0, $newLine, '', '', true, 0, true, true, $this->layoutInfo['labelHeight'], 'M', true);
if ($newLine == 0) {
$this->pdf->Cell($this->layoutInfo['labelSpacerWidth'], $this->layoutInfo['labelHeight'], '');
}
}
示例4:
// set font
$pdf->SetFont('times', '', 10);
// add a page
$pdf->AddPage();
// set cell padding
$pdf->setCellPaddings(1, 1, 1, 1);
// set cell margins
$pdf->setCellMargins(1, 1, 1, 1);
// set color for background
$pdf->SetFillColor(255, 255, 127);
// 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 some text for example
$txt = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
//$final = $pdf->write2DBarcode('7024736019|3|2104002021751|2015-10-02|30.50|30.50|15451254|0|0|0|0', 'QRCODE,L', '', '', 30, 30, '', 'N');
// Multicell test
$pdf->MultiCell(55, 5, '[LEFT] ' . $txt, 1, 'L', 1, 0, '', '', true);
$pdf->MultiCell(55, 5, '[RIGHT] ' . $txt, 1, 'R', 0, 1, '', '', true);
$pdf->MultiCell(55, 5, '[CENTER] ' . $txt, 1, 'C', 0, 0, '', '', true);
$pdf->MultiCell(55, 5, '[JUSTIFY] ' . $txt . "\n", 1, 'J', 1, 2, '', '', true);
$pdf->MultiCell(55, 5, '[DEFAULT] ' . $txt, 1, '', 0, 1, '', '', true);
$pdf->Ln(4);
// set color for background
$pdf->SetFillColor(220, 255, 220);
// Vertical alignment
$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - TOP] ' . $txt, 1, 'J', 1, 0, '', '', true, 0, false, true, 40, 'T');
$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - MIDDLE] ' . $txt, 1, 'J', 1, 0, '', '', true, 0, false, true, 40, 'M');
$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - BOTTOM] ' . $txt, 1, 'J', 1, 1, '', '', true, 0, false, true, 40, 'B');
$pdf->Ln(4);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set color for background
$pdf->SetFillColor(215, 235, 255);
示例5: 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 033');
$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 . ' 033', 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);
// ---------------------------------------------------------
// add a page
$pdf->AddPage();
// set default font subsetting mode
$pdf->setFontSubsetting(false);
$pdf->SetFont('helvetica', 'B', 20);
$pdf->Write(0, 'Font Types', '', 0, 'C', 1, 0, false, false, 0);
$pdf->Ln(10);
$pdf->SetFont('times', '', 10);
$pdf->MultiCell(80, 0, "[Core font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0);
$pdf->Ln(2);
$pdf->SetFont('dejavusans', '', 10);
$pdf->MultiCell(80, 0, "[True Type Unicode font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0);
$pdf->Ln(2);
$pdf->SetFont('cid0jp', '', 9);
$pdf->MultiCell(80, 0, "[CID-0 font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0);
$this->comparePdfs($pdf);
}
示例6: testPdfOutput
public function testPdfOutput()
{
$this->markTestIncomplete('Travis failure needs further investigation. ');
// 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 042');
$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 . ' 042', 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 JPEG quality
//$pdf->setJPEGQuality(75);
$pdf->SetFont('helvetica', '', 18);
// add a page
$pdf->AddPage();
// create background text
$background_text = str_repeat('TCPDF test PNG Alpha Channel ', 50);
$pdf->MultiCell(0, 5, $background_text, 0, 'J', 0, 2, '', '', true, 0, false);
// --- Method (A) ------------------------------------------
// the Image() method recognizes the alpha channel embedded on the image:
$pdf->SetAlpha(0.71);
$pdf->Image('tests/images/image_with_alpha.png', 50, 50, 100, '', '', 'http://www.tcpdf.org', '', false, 300);
$pdf->SetAlpha(1);
// --- Method (B) ------------------------------------------
// provide image + separate 8-bit mask
// first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size)
$mask = $pdf->Image('tests/images/alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true);
// embed image, masked with previously embedded mask
$pdf->Image('tests/images/img.png', 50, 140, 100, '', '', 'http://www.tcpdf.org', '', false, 300, '', false, $mask);
$this->comparePdfs($pdf);
}
示例7: pdf
function pdf($kul)
{
require "/opt/tcpdf/tcpdf.php";
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetTitle('OMU UZEM 2010-2011 ÖN KAYIT FORMU');
$pdf->SetAuthor('Anonim');
$pdf->SetFont('dejavusans', '', 12);
$pdf->SetMargins(20, 60, 20);
$pdf->SetHeaderMargin(10);
$pdf->SetFooterMargin(10);
$pdf->SetHeaderData('uzem-head.jpg', 170, '', '');
$pdf->AddPage();
$pdf->SetFont('dejavusans', 'B', 18);
$pdf->Cell(0, 5, "2010-2011 Ebelik Lisans Tamamlama", 0, 1, 'C');
$pdf->Cell(0, 5, "Ön Kayıt Başvurusu", 0, 1, 'C');
$pdf->Ln(5);
$bilgiler = array('Kişisel Bilgiler' => array('tc' => 'TC Kimlik No', 'ad' => 'Ad', 'soyad' => 'Soyad', 'kizliksoyad' => 'Kızlık Soyadı', 'babaad' => 'Baba Adı', 'anaad' => 'Ana Adı', 'dogumil' => 'Doğum Yeri', 'dogumyil' => 'Doğum Yılı'), 'İletişim Bilgileri' => array('ceptel' => 'Cep Tel', 'evtel' => 'Ev Tel', 'email' => 'Email', 'evadres' => 'Ev Adres', 'il' => 'İl', 'ilce' => 'İlçe', 'uni' => 'Üniversite'), 'İş Bilgileri' => array('calismakurum' => 'Kurum', 'calismabirim' => 'Birim', 'isil' => 'İl', 'isilce' => 'İlçe'), 'Diğer Bilgiler' => array('tarih' => 'Ön Kayıt Tarihi'));
foreach ($bilgiler as $kesim => $bilgi) {
$pdf->SetFont('dejavusans', 'B', 14);
$pdf->Cell(0, 5, $kesim, 0, 1, 'L');
$pdf->SetFont('dejavusans', '', 10);
foreach ($bilgi as $alan => $baslik) {
$deger = $kul->{$alan};
$pdf->MultiCell(30, 1, $baslik . ':', 0, 'L', 0, 0, '25', '', true);
$pdf->MultiCell(180, 1, $deger, 0, 'L', 0, 0, '', '', true);
$pdf->Ln(5);
}
$pdf->Ln(5);
}
$pdf->Ln(15);
$pdf->Cell(0, 5, "Yukarıda vermiş olduğum bilgilerin doğruluğunu kabul ediyorum.", 0, 1, 'T');
$pdf->Ln(5);
$pdf->MultiCell(50, 1, 'Tarih:', 0, 'L', 0, 1, '120', '', true);
$pdf->MultiCell(50, 1, 'Ad Soyad:', 0, 'L', 0, 1, '120', '', true);
$pdf->MultiCell(50, 1, 'İmza:', 0, 'L', 0, 1, '120', '', true);
$pdf->Output();
}
示例8: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
// Set document information dictionary in unicode mode
$pdf->SetDocInfoUnicode(true);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni [€]');
$pdf->SetTitle('TCPDF Example 019');
$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 . ' 019', 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 data:
$lg = array();
$lg['a_meta_charset'] = 'ISO-8859-1';
$lg['a_meta_dir'] = 'ltr';
$lg['a_meta_language'] = 'en';
$lg['w_page'] = 'page';
// set some language-dependent strings (optional)
$pdf->setLanguageArray($lg);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 12);
// add a page
$pdf->AddPage();
// set color for background
$pdf->SetFillColor(200, 255, 200);
$txt = 'An alternative configuration file is used on this example.
Check the definition of the K_TCPDF_EXTERNAL_CONFIG constant on the source code.';
// print some text
$pdf->MultiCell(0, 0, $txt . "\n", 1, 'J', 1, 1, '', '', true, 0, false, true, 0);
$this->comparePdfs($pdf);
}
示例9: printPost
/**
* [พิมพ์ post]
* @param [type] $id [description]
* @return [type] [description]
*/
public function printPost($id)
{
if (Session::get('c3') == 1) {
$sql = ' select c.*, concat(n.pname,n.fname," ",n.lname) as fullname from c_blog_posts c left join n_datageneral n on n.cid=c.created_by';
$sql .= ' where postID =' . e($id) . ' ';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// set header and footer fonts
$pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(15, 15, 15);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->AddPage();
$pdf->SetFont('angsanaupc', 'B', 16, '', true);
$pdf->SetXY(15, 15);
$pdf->MultiCell(180, 0, 'ใบประสานงานขอรถ', 0, 'C', 0, 1, '', '', true);
$data = DB::select($sql);
$pdf->SetFont('angsanaupc', '', 14, '', true);
$tbl = '<br /><br /><table style="width: 100%; padding:2px;" cellspacing="0">';
foreach ($data as $key => $value) {
$tbl = $tbl . '<tr>
<td style="border: 0px solid #000000; text-align:left"> เรื่อง ' . $value->postTitle . '</td>
</tr>';
$tbl = $tbl . '<tr>
<td style="border: 0px solid #000000; text-align:left"> สร้างโดย ' . $value->fullname . ' วันที่ ' . date("d-m", strtotime($value->postDate)) . '-' . (date("Y", strtotime($value->postDate)) + 543) . ' เวลา ' . date("H:i:s", strtotime($value->postDate)) . '</td>
</tr>';
$tbl = $tbl . '<tr>
<td style="border: 0px solid #000000; text-align:left"> ' . $value->postDesc . '</td>
</tr>';
}
$tbl = $tbl . '</table>';
$pdf->writeHTML($tbl, true, false, false, false, '');
$filename = storage_path() . '/report_post.pdf';
$contents = $pdf->output($filename, 'I');
$headers = array('Content-Type' => 'application/pdf');
return Response::make($contents, 200, $headers);
} else {
return Redirect::to('contact');
}
}
示例10: initialize_pdf
/**
* Sets up a new PDF object with the necessary settings
*
* @return FPDF A new PDF object
*/
protected function initialize_pdf()
{
global $CFG;
require_once $CFG->dirroot . '/local/elisreports/lib/tcpdf/tcpdf.php';
$newpdf = new TCPDF('L', 'in', 'letter');
//prevent the library from automatically outputting
//header or footer bars
$newpdf->SetPrintHeader(false);
$newpdf->SetPrintFooter(false);
$newpdf->setMargins(self::marginx, self::marginy);
$newpdf->SetFont('freesans', '', 9);
$newpdf->AddPage();
$newpdf->SetFont('freesans', '', 16);
$newpdf->MultiCell(0, 0.2, $this->report->title, 0, 'C');
$newpdf->Ln(0.2);
$newpdf->SetFont('freesans', '', 8);
$newpdf->SetFillColor(225, 225, 225);
return $newpdf;
}
示例11: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', true);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 043');
$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 . ' 043', 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', '', 16);
// add a page
$pdf->AddPage();
// Multicell test
$pdf->MultiCell(0, 0, 'DISK CACHING TEST: check the parameters of the class constructor.', 1, 'L', 0, 0, '', '', true);
$this->comparePdfs($pdf);
}
示例12: checkoverflow
public function checkoverflow($arraydata, $txt = "")
{
$this->print_expression($arraydata);
if ($this->print_expression_result == true) {
if ($arraydata["link"]) {
$arraydata["link"] = $this->analyse_expression($arraydata["link"], "");
}
if ($arraydata["writeHTML"] == 1 && $this->pdflib == "TCPDF") {
$this->pdf->writeHTML($txt);
} elseif ($arraydata["poverflow"] == "true" && $arraydata["soverflow"] == "false") {
$this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], "", $arraydata["align"], $arraydata["fill"], $arraydata["link"]);
} elseif ($arraydata["poverflow"] == "false" && $arraydata["soverflow"] == "false") {
while ($this->pdf->GetStringWidth($txt) > $arraydata["width"]) {
$txt = substr_replace($txt, "", -1);
}
$this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], "", $arraydata["align"], $arraydata["fill"], $arraydata["link"]);
} elseif ($arraydata["poverflow"] == "false" && $arraydata["soverflow"] == "true") {
$this->pdf->MultiCell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], $arraydata["align"], $arraydata["fill"]);
} else {
$this->pdf->MultiCell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], $arraydata["align"], $arraydata["fill"]);
}
}
$this->print_expression_result = false;
}
示例13: array
$pdf->Cell(170, 5, 'Employee\'s Main Name: ' . $emp->lname);
$pdf->Ln(5);
$pdf->Cell(170, 5, "Employee's Other Names: {$emp->fname} {$emp->lname}");
$pdf->Cell(50, 5, 'Employee\'s PIN:');
for ($i = 0; $i < strlen($emp->pin); ++$i) {
$pdf->Cell(5, 5, $emp->pin[$i], 1, 0, "C");
}
$pdf->Ln(7);
$headers = array('MONTH', 'Basic Salary Kshs.', "Benefits - Non - Cash Kshs.", 'Value of Quarters Kshs.', 'Total Gross Pay <br> Kshs.', 'Defined Contribution Retirement Scheme <br> Kshs.', 'Owner - Occupied Interest Kshs.', 'Retirement Contribution & Owner Occupied Interest Kshs.', 'Chargeable Pay <br>Kshs.', 'Tax Charged Kshs.', 'Personal Relief + Insurance Relief <br>Kshs.', 'PAYE Tax (J-K) <br>Kshs.');
$width = array(20, 20, 17, 17, 20, 51, 20, 35, 20, 20, 20, 20, 20, 20);
$headers2 = array('', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L');
$h = 23;
$i = 0;
$pdf->SetFont('', '', 10);
foreach ($headers as $head) {
$pdf->MultiCell($width[$i], $h, $head, 1, 'C', false, 0, '', '', true, 0, true);
++$i;
}
$pdf->Ln();
$h = 7;
$i = 0;
foreach ($headers2 as $head) {
$pdf->MultiCell($width[$i], $h, $head, "TRL", 'C', false, 0);
++$i;
}
$pdf->Ln();
$i = 0;
$h = 10;
for ($i = 0; $i < 14; $i++) {
if ($i == 5) {
$pdf->MultiCell(17, $h, "E1 30% of A", 1, 'C', false, 0);
示例14: isset
$pdf->writeHTMLCell(0, 0, '', '', $cover, 0, 1, 0, true, 'C', true);
for ($i = 0; $i < $numChapter; $i++) {
$title = isset($story["chapters"]["title"][$i]) ? $story["chapters"]["title"][$i] : "";
$content = isset($story["chapters"]["content"][$i]) ? $story["chapters"]["content"][$i] : "";
if (!empty($content) && !empty($title)) {
$title = formatTitle($title, $i);
$pdf->AddPage();
$pdf->Bookmark($title, 0, 0, '', 'B', array(0, 0, 0));
$pdf->writeHTMLCell(0, 0, '', '', "<h2>{$title}</h2>", 0, 1, 0, true, 'C', true);
$html = $content_start . $content . $bookEnd;
$pdf->writeHTML($html, true, false, true, false, '');
}
}
$pdf->addTOCPage();
$pdf->SetFont('helvetica', 'B', 16);
$pdf->MultiCell(0, 0, 'Table Of Contents', 0, 'C', 0, 1, '', '', true, 0);
$pdf->Ln();
$pdf->SetFont('helvetica', '', 12);
$pdf->addTOC(2, 'helvetica', '.', 'TOC', 'B', array(0, 0, 0));
$pdf->endTOCPage();
$pdf->Output("./tmp/" . $filename, 'F');
if (!empty($email)) {
mailAttachment($filename, "./tmp/", $email, $uniqid);
}
} else {
if ($format == "epub") {
require_once "epub/EPub.php";
$book = new EPub();
$book->setTitle($story["title"]);
$book->setIdentifier($story["story_url"], EPub::IDENTIFIER_URI);
$book->setDescription($story["desc"]);
示例15:
$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', '', 10);
// add a page
$pdf->AddPage();
// set color for filler
$pdf->SetFillColor(255, 255, 0);
// Multicell test
$pdf->MultiCell(40, 5, 'A test multicell line 1 test multicell line 2 test multicell line 3', 1, 'L', 1, 0, '', '', true);
$pdf->MultiCell(40, 5, 'B test multicell line 1 test multicell line 2 test multicell line 3', 1, 'R', 0, 1, '', '', true);
$pdf->MultiCell(40, 5, 'C test multicell line 1 test multicell line 2 test multicell line 3', 1, 'C', 0, 0, '', '', true);
$pdf->MultiCell(40, 5, 'D test multicell line 1 test multicell line 2 test multicell line 3' . "\n", 1, 'J', 1, 2, '', '', true);
$pdf->MultiCell(40, 5, 'E test multicell line 1 test multicell line 2 test multicell line 3', 1, 'L', 0, 1, '', '', true);
$pdf->SetFillColor(255, 200, 200);
$pdf->MultiCell(40, 5, 'F test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line test multicell line' . "\n", 1, 'J', 1, 1, '', '', true);
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_005.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+