本文整理汇总了PHP中TCPDF::SetTextColor方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::SetTextColor方法的具体用法?PHP TCPDF::SetTextColor怎么用?PHP TCPDF::SetTextColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::SetTextColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: text
/**
* Writes text at the specified x and y coordinates
*
* See {@link Style::munge_color()} for the format of the color array.
*
* @param float $x
* @param float $y
* @param string $text the text to write
* @param string $font the font file to use
* @param float $size the font size, in points
* @param array $color
* @param float $adjust word spacing adjustment
*/
function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0)
{
dompdf_debug("trace", "({$x}, {$y}, {$text}, " . basename($font) . ", {$size}, [{$color['0']}, {$color['1']}, {$color['2']}], {$adjust}, {$angle}, {$blend}, {$opacity})");
list($r, $g, $b) = $this->_get_rgb($color);
$this->_pdf->SetTextColor($r, $g, $b);
$this->_set_line_transparency($blend, $opacity);
$this->_set_fill_transparency($blend, $opacity);
$fontdata = $this->_get_font($font);
$this->_pdf->SetFont($fontdata['family'], $fontdata['style'], $size, $font);
//$this->_pdf->SetFontSize($size);
// ???
if ($adjust > 0) {
$a = explode(' ', $text);
//$this->_pdf->SetXY($x - 3, $y + (self::FONT_HEIGHT_SCALE - 1) * $size);
$this->_pdf->SetXY($x, $y);
//$y += self::FONT_HEIGHT_SCALE * $size + 1;
for ($i = 0; $i < count($a) - 1; $i++) {
$this->_pdf->Write($size, $a[$i] . ' ', '');
//$this->_pdf->Text($x, $y, $a[$i].' ');
$this->_pdf->SetX($this->_pdf->GetX() + $adjust);
//$x += $this->_pdf->GetX() + $adjust;
}
$this->_pdf->Write($size, $a[$i], '');
//$this->_pdf->Text($x, $y, $a[$i].' ');
} else {
if ($angle != 0) {
$this->_pdf->StartTransform();
//$y += self::FONT_HEIGHT_SCALE * $size;
//$y += $size;
$this->_pdf->Rotate(-$angle, $x, $y);
$this->_pdf->Text($x, $y, $text, false, false, true, 0, 0, '', 0, '', 0, false, 'T', 'T');
$this->_pdf->StopTransform();
} else {
//$pippo = $this->_pdf->getFontAscent($fontdata['family'], $fontdata['style'], $size);
//$y += $pippo / 8;
//$y = $y - 0.85 * $size; // + 0.8 * $size;
$this->_pdf->Text($x, $y, $text, false, false, true, 0, 0, '', 0, '', 0, false, 'T', 'T');
}
}
}
示例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 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);
}
示例3: 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);
}
示例4: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(23, 48, 80);
$pdf->SetFont('league-gothic', '', 100, '', true);
$pdf->writeHTMLCell(170, 200, 20, 40, $this->buildHTML('h1', $title), 0, 1, 0, true, 'C');
$pdf->SetTextColor(51, 81, 71);
$pdf->SetFont('AlegreyaSans-MediumItalic', '', 55, '', true);
$pdf->writeHTMLCell(170, 200, 20, 67, $this->buildHTML('p', $slogan, 65), 0, 1, 0, true, 'C');
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 30, '', true);
$pdf->writeHTMLCell(170, 100, 20, 225, $this->buildHTML('h2', $name, 35), 0, 1, 0, true, 'C');
$pdf->SetFont('AlegreyaSans-Regular', '', 18, '', true);
$pdf->writeHTMLCell(170, 100, 20, 245, $this->buildHTML('p', $details, 25), 0, 1, 0, true, 'C');
}
示例5: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(255, 255, 255);
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.5, 'depth_h' => 0.5, 'color' => array(0, 0, 0), 'opacity' => 0.5, 'blend_mode' => 'Multiply'));
$pdf->SetFont('BubblegumSans', '', 85, '', true);
$pdf->writeHTMLCell(170, 200, 20, 35, $this->buildHTML('h1', $title), 0, 1, 0, true, 'C');
$pdf->SetTextColor(247, 220, 102);
$pdf->SetFont('BubblegumSans', '', 48, '', true);
$pdf->writeHTMLCell(80, 200, 110, 55, $this->buildHTML('p', $slogan, 58), 0, 1, 0, true, 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->setTextShadow(array('enabled' => false));
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
$pdf->writeHTMLCell(180, 100, 18, 243, $this->buildHTML('h2', $name, 30), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
$pdf->writeHTMLCell(180, 100, 18, 256, $this->buildHTML('p', $details, 20), 0, 1, 0);
}
示例6: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
$pdf->writeHTMLCell(172, 100, 22, 242, $this->buildHTML('h2', $name, 30), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
$pdf->writeHTMLCell(172, 100, 22, 255, $this->buildHTML('p', $details, 20), 0, 1, 0);
}
示例7: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFont('league-gothic', '', 100, '', true);
$pdf->writeHTMLCell(200, 200, 18, 35, $this->buildHTML('h1', $title), 0, 1, 0);
$pdf->SetFont('league-gothic', '', 70, '', true);
$pdf->writeHTMLCell(80, 200, 130, 135, $this->buildHTML('p', $slogan, 80), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
$pdf->writeHTMLCell(120, 100, 18, 241, $this->buildHTML('h2', $name, 30), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
$pdf->writeHTMLCell(175, 100, 18, 254, $this->buildHTML('p', $details, 20), 0, 1, 0);
}
示例8: prepareDownloadImagePdf
public function prepareDownloadImagePdf($filename, $newfilename, $firstname, $lastname, $title, $description, $code, $date_end)
{
// calculate date
$currentDate = new DateTime();
$currentDate->modify('+ ' . $date_end . ' month');
$date_end = $currentDate->format('Y-m-d');
$this->load->model('tool/image');
require_once DIR_SYSTEM . 'library/tcpdf/tcpdf.php';
$pdf = new TCPDF();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// set image 1
$pdf->AddPage();
$pdf->Image(DIR_IMAGE . $filename, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$pdf->setPageMark();
/*if(stripos('.pdf',$newfilename)===false)
{
$t = explode('.',$newfilename);
array_pop($t);
$newfilename = implode('.',$t).'.pdf';
}*/
$pdf->SetFont('times', '', 13);
$pdf->SetTextColor(50, 50, 50);
for ($i = 0; $i <= 16; $i++) {
$pdf->Ln(10);
}
$pdf->setCellPaddings(90);
$pdf->Ln(10);
$pdf->Write(0, $firstname . ' ' . $lastname);
$pdf->Ln(10);
$pdf->Ln(10);
$pdf->Write(0, $title);
$pdf->Ln(10);
$pdf->SetFont('times', '', 11);
$pdf->Write(0, $description);
$pdf->setCellPaddings(70);
$pdf->Ln(10);
$pdf->Ln(10);
$pdf->Ln(10);
$pdf->Ln(10);
$pdf->Ln(10);
$pdf->SetFont('times', '', 7);
$pdf->Write(0, 'Beauty Center Billstedt');
$pdf->Ln(4);
$pdf->SetFont('times', 'B', 9);
$pdf->Write(0, '#' . $code);
$pdf->Ln(4);
$pdf->SetFont('times', '', 9);
$pdf->Write(0, 'Gültig bis:: ' . $date_end);
$pdf->Output(DIR_IMAGE . $newfilename, 'F');
}
示例9: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(255, 255, 255);
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.5, 'depth_h' => 0.5, 'color' => array(0, 0, 0), 'opacity' => 0.5, 'blend_mode' => 'Multiply'));
$pdf->SetFont('league-gothic', '', 100, '', true);
$pdf->writeHTMLCell(170, 200, 20, 40, $this->buildHTML('h1', $title), 0, 1, 0, true, 'C');
$pdf->SetFont('AlegreyaSans-MediumItalic', '', 55, '', true);
$pdf->writeHTMLCell(170, 200, 20, 63, $this->buildHTML('p', $slogan, 65), 0, 1, 0, true, 'C');
$pdf->setTextShadow(array('enabled' => false));
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
$pdf->writeHTMLCell(180, 100, 18, 241, $this->buildHTML('h2', $name, 30), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
$pdf->writeHTMLCell(180, 100, 18, 254, $this->buildHTML('p', $details, 20), 0, 1, 0);
}
示例10: 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 031');
$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 . ' 031', 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', 'B', 20);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of PieSector() method.');
$xc = 105;
$yc = 100;
$r = 50;
$pdf->SetFillColor(0, 0, 255);
$pdf->PieSector($xc, $yc, $r, 20, 120, 'FD', false, 0, 2);
$pdf->SetFillColor(0, 255, 0);
$pdf->PieSector($xc, $yc, $r, 120, 250, 'FD', false, 0, 2);
$pdf->SetFillColor(255, 0, 0);
$pdf->PieSector($xc, $yc, $r, 250, 20, 'FD', false, 0, 2);
// write labels
$pdf->SetTextColor(255, 255, 255);
$pdf->Text(105, 65, 'BLUE');
$pdf->Text(60, 95, 'GREEN');
$pdf->Text(120, 115, 'RED');
$this->comparePdfs($pdf);
}
示例11: array
// ---------------------------------------------------------
// check also the following methods:
// SetDrawColorArray()
// SetFillColorArray()
// SetTextColorArray()
// set font
$pdf->SetFont('helvetica', 'B', 18);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of CMYK, RGB and Grayscale colours', '', 0, 'L', true, 0, false, false, 0);
// define style for border
$border_style = array('all' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'phase' => 0));
// --- CMYK ------------------------------------------------
$pdf->SetDrawColor(50, 0, 0, 0);
$pdf->SetFillColor(100, 0, 0, 0);
$pdf->SetTextColor(100, 0, 0, 0);
$pdf->Rect(30, 60, 30, 30, 'DF', $border_style);
$pdf->Text(30, 92, 'Cyan');
$pdf->SetDrawColor(0, 50, 0, 0);
$pdf->SetFillColor(0, 100, 0, 0);
$pdf->SetTextColor(0, 100, 0, 0);
$pdf->Rect(70, 60, 30, 30, 'DF', $border_style);
$pdf->Text(70, 92, 'Magenta');
$pdf->SetDrawColor(0, 0, 50, 0);
$pdf->SetFillColor(0, 0, 100, 0);
$pdf->SetTextColor(0, 0, 100, 0);
$pdf->Rect(110, 60, 30, 30, 'DF', $border_style);
$pdf->Text(110, 92, 'Yellow');
$pdf->SetDrawColor(0, 0, 0, 50);
$pdf->SetFillColor(0, 0, 0, 100);
$pdf->SetTextColor(0, 0, 0, 100);
示例12: dirname
$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 default font subsetting mode
$pdf->setFontSubsetting(true);
// set font
$pdf->SetFont('freeserif', '', 12);
// add a page
$pdf->AddPage();
// get esternal file content
$utf8text = file_get_contents('data/utf8test.txt', false);
// set color for text
$pdf->SetTextColor(0, 63, 127);
// Write($h, $txt, $link='', $fill=0, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0)
// write the text
$pdf->Write(5, $utf8text, '', 0, '', false, 0, false, false, 0);
// ---------------------------------------------------------
// Close and output PDF document
$pdf->Output('example_008.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
示例13:
$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', 'B', 20);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Graphic Transformations', '', 0, 'C', 1, 0, false, false, 0);
// set font
$pdf->SetFont('helvetica', '', 10);
// --- Scaling ---------------------------------------------
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(50, 70, 40, 10, 'D');
$pdf->Text(50, 66, 'Scale');
$pdf->SetDrawColor(0);
$pdf->SetTextColor(0);
// Start Transformation
$pdf->StartTransform();
// Scale by 150% centered by (50,80) which is the lower left corner of the rectangle
$pdf->ScaleXY(150, 50, 80);
$pdf->Rect(50, 70, 40, 10, 'D');
$pdf->Text(50, 66, 'Scale');
// Stop Transformation
$pdf->StopTransform();
// --- Translation -----------------------------------------
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
示例14: getReportPDF
function getReportPDF($filterlist = false)
{
require_once 'libraries/tcpdf/tcpdf.php';
$reportData = $this->GenerateReport("PDF", $filterlist);
$arr_val = $reportData['data'];
if (isset($arr_val)) {
foreach ($arr_val as $wkey => $warray_value) {
foreach ($warray_value as $whd => $wvalue) {
if (strlen($wvalue) < strlen($whd)) {
$w_inner_array[] = strlen($whd);
} else {
$w_inner_array[] = strlen($wvalue);
}
}
$warr_val[] = $w_inner_array;
unset($w_inner_array);
}
foreach ($warr_val[0] as $fkey => $fvalue) {
foreach ($warr_val as $wkey => $wvalue) {
$f_inner_array[] = $warr_val[$wkey][$fkey];
}
sort($f_inner_array, 1);
$farr_val[] = $f_inner_array;
unset($f_inner_array);
}
foreach ($farr_val as $skkey => $skvalue) {
if ($skvalue[count($arr_val) - 1] == 1) {
$col_width[] = $skvalue[count($arr_val) - 1] * 50;
} else {
$col_width[] = $skvalue[count($arr_val) - 1] * 10 + 10;
}
}
$count = 0;
foreach ($arr_val[0] as $key => $value) {
$headerHTML .= '<td width="' . $col_width[$count] . '" bgcolor="#DDDDDD"><b>' . $this->getLstringforReportHeaders($key) . '</b></td>';
$count = $count + 1;
}
foreach ($arr_val as $key => $array_value) {
$valueHTML = "";
$count = 0;
foreach ($array_value as $hd => $value) {
$valueHTML .= '<td width="' . $col_width[$count] . '">' . $value . '</td>';
$count = $count + 1;
}
$dataHTML .= '<tr>' . $valueHTML . '</tr>';
}
}
$totalpdf = $this->GenerateReport("PRINT_TOTAL", $filterlist);
$html = '<table border="0.5"><tr>' . $headerHTML . '</tr>' . $dataHTML . '<tr><td>' . $totalpdf . '</td></tr>' . '</table>';
$columnlength = array_sum($col_width);
if ($columnlength > 14400) {
die("<br><br><center>" . $app_strings['LBL_PDF'] . " <a href='javascript:window.history.back()'>" . $app_strings['LBL_GO_BACK'] . ".</a></center>");
}
if ($columnlength <= 420) {
$pdf = new TCPDF('P', 'mm', 'A5', true);
} elseif ($columnlength >= 421 && $columnlength <= 1120) {
$pdf = new TCPDF('L', 'mm', 'A3', true);
} elseif ($columnlength >= 1121 && $columnlength <= 1600) {
$pdf = new TCPDF('L', 'mm', 'A2', true);
} elseif ($columnlength >= 1601 && $columnlength <= 2200) {
$pdf = new TCPDF('L', 'mm', 'A1', true);
} elseif ($columnlength >= 2201 && $columnlength <= 3370) {
$pdf = new TCPDF('L', 'mm', 'A0', true);
} elseif ($columnlength >= 3371 && $columnlength <= 4690) {
$pdf = new TCPDF('L', 'mm', '2A0', true);
} elseif ($columnlength >= 4691 && $columnlength <= 6490) {
$pdf = new TCPDF('L', 'mm', '4A0', true);
} else {
$columnhight = count($arr_val) * 15;
$format = array($columnhight, $columnlength);
$pdf = new TCPDF('L', 'mm', $format, true);
}
$pdf->SetMargins(10, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->setLanguageArray($l);
$pdf->AddPage();
$pdf->SetFillColor(224, 235, 255);
$pdf->SetTextColor(0);
$pdf->SetFont('FreeSerif', 'B', 14);
$pdf->Cell($pdf->columnlength * 50, 10, getTranslatedString($oReport->reportname), 0, 0, 'C', 0);
//$pdf->writeHTML($oReport->reportname);
$pdf->Ln();
$pdf->SetFont('FreeSerif', '', 10);
$pdf->writeHTML($html);
return $pdf;
}
示例15: 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 022');
$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 . ' 022', 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);
// ---------------------------------------------------------
// check also the following methods:
// SetDrawColorArray()
// SetFillColorArray()
// SetTextColorArray()
// set font
$pdf->SetFont('helvetica', 'B', 18);
// add a page
$pdf->AddPage();
$pdf->Write(0, 'Example of CMYK, RGB and Grayscale colours', '', 0, 'L', true, 0, false, false, 0);
// define style for border
$border_style = array('all' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'phase' => 0));
// --- CMYK ------------------------------------------------
$pdf->SetDrawColor(50, 0, 0, 0);
$pdf->SetFillColor(100, 0, 0, 0);
$pdf->SetTextColor(100, 0, 0, 0);
$pdf->Rect(30, 60, 30, 30, 'DF', $border_style);
$pdf->Text(30, 92, 'Cyan');
$pdf->SetDrawColor(0, 50, 0, 0);
$pdf->SetFillColor(0, 100, 0, 0);
$pdf->SetTextColor(0, 100, 0, 0);
$pdf->Rect(70, 60, 30, 30, 'DF', $border_style);
$pdf->Text(70, 92, 'Magenta');
$pdf->SetDrawColor(0, 0, 50, 0);
$pdf->SetFillColor(0, 0, 100, 0);
$pdf->SetTextColor(0, 0, 100, 0);
$pdf->Rect(110, 60, 30, 30, 'DF', $border_style);
$pdf->Text(110, 92, 'Yellow');
$pdf->SetDrawColor(0, 0, 0, 50);
$pdf->SetFillColor(0, 0, 0, 100);
$pdf->SetTextColor(0, 0, 0, 100);
$pdf->Rect(150, 60, 30, 30, 'DF', $border_style);
$pdf->Text(150, 92, 'Black');
// --- RGB -------------------------------------------------
$pdf->SetDrawColor(255, 127, 127);
$pdf->SetFillColor(255, 0, 0);
$pdf->SetTextColor(255, 0, 0);
$pdf->Rect(30, 110, 30, 30, 'DF', $border_style);
$pdf->Text(30, 142, 'Red');
$pdf->SetDrawColor(127, 255, 127);
$pdf->SetFillColor(0, 255, 0);
$pdf->SetTextColor(0, 255, 0);
$pdf->Rect(70, 110, 30, 30, 'DF', $border_style);
$pdf->Text(70, 142, 'Green');
$pdf->SetDrawColor(127, 127, 255);
$pdf->SetFillColor(0, 0, 255);
$pdf->SetTextColor(0, 0, 255);
$pdf->Rect(110, 110, 30, 30, 'DF', $border_style);
$pdf->Text(110, 142, 'Blue');
// --- GRAY ------------------------------------------------
$pdf->SetDrawColor(191);
$pdf->SetFillColor(127);
$pdf->SetTextColor(127);
$pdf->Rect(30, 160, 30, 30, 'DF', $border_style);
$pdf->Text(30, 192, 'Gray');
$this->comparePdfs($pdf);
}