Ejemplo n.º 1
6
 /**
  * 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');
         }
     }
 }
Ejemplo n.º 2
1
//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', 'BI', 50);
// add a page
$pdf->AddPage();
// print clipping text
$pdf->Text(20, 40, 'STROKE TEXT', 1, false);
//Start Transformation
$pdf->StartTransform();
// print clipping text
$pdf->Text(20, 70, 'CLIPPING TEXT', 2, true);
// draw jpeg image
$pdf->Image('../images/image_demo.jpg', 20, 45, 170, 40, '', 'http://www.tcpdf.org', '', true, 72);
//Stop Transformation
$pdf->StopTransform();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_026.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
Ejemplo n.º 3
0
 function processing($contextData, $options)
 {
     $prodId = $contextData[0]['id'];
     $prodName = $contextData[0]['name'];
     $unitPrice = $contextData[0]['unitprice'];
     $pFile = $contextData[0]['photofile'];
     $timestamp = new DateTime();
     $tsString = $timestamp->format("Y-m-d H:i:s");
     $fileName = "{$prodId}.pdf";
     require_once './tcpdf/tcpdf.php';
     $pdf = new TCPDF("P", "mm", "A4", true, "UTF-8");
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetMargins(0, 0, 0, 0);
     $pdf->AddPage();
     $pdf->setTextColor(100, 100, 100);
     $pdf->SetFont('', '', 14);
     $pdf->Text(40, 40, "Product ID: {$prodId}");
     $pdf->Text(40, 50, "Product Name: {$prodName}");
     $pdf->Text(40, 60, "Unit Price: {$unitPrice}");
     $pdf->Text(40, 70, "Today: {$tsString}");
     $pdf->Image("../Sample_products/images/{$pFile}", 40, 80, 100);
     header("Content-Type: application/pdf");
     header("Content-Disposition: attachment; filename=\"{$fileName}\"");
     header('X-Frame-Options: SAMEORIGIN');
     $pdf->Output();
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 public function postAdicionar()
 {
     $pdf = new TCPDF();
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('GestBiblio - Sistema de Gestão de Bibliotecas');
     $pdf->SetTitle('Comprovante de Imprestimo');
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     $pdf->AddPage();
     $html = '';
     $pdf->Text(90, 140, 'This is a test');
     $filename = storage_path() . '/test.pdf';
     $pdf->output($filename, 'F');
     return Response::view($filename);
 }
Ejemplo n.º 6
0
// 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', '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');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_031.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
Ejemplo n.º 7
0
//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();
//Scaling
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 19, 'Scale');
$pdf->SetDrawColor(0);
$pdf->SetTextColor(0);
//Start Transformation
$pdf->StartTransform();
//Scale by 150% centered by (50,30) which is the lower left corner of the rectangle
$pdf->ScaleXY(150, 50, 30);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 19, 'Scale');
//Stop Transformation
$pdf->StopTransform();
//Translation
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(125, 20, 40, 10, 'D');
$pdf->Text(125, 19, 'Translate');
Ejemplo n.º 8
0
function pdf($html = null, $logo = null, $nombre = null, $estadistica, $itiniere, $transporte)
{
    //$html= utf8_decode($html);
    //    $html="OOOJHKJHKJH JLH KJH KH KJH";
    ob_clean();
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(210, 272), true, 'UTF-8', false);
    //    $pdf = new TCPDF('P', 'IN', array (8.5,11),true, 'UTF-8', false);
    // set document information
    //$pdf->SetCreator(PDF_CREATOR);
    //$pdf->SetAuthor('Nicola Asuni');
    //$pdf->SetTitle('TCPDF Example 001');
    //$pdf->SetSubject('TCPDF Tutorial');
    //$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    // set default header data
    //$pdf->SetHeaderData($logo, '20', PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
    if (!empty($logo)) {
        $pdf->SetHeaderData($logo, '20', '', '      PLAN ESTRATEGICO DE SEGURIDAD VÍAL       ' . date('d/m/Y'), array(0, 64, 128), array(0, 64, 128));
    }
    $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
    // set header and footer fonts
    //    $pdf->SetMargins(23, 35, 13);
    $pdf->SetMargins(32, 35, 20);
    $pdf->SetHeaderMargin(14);
    $pdf->SetFooterMargin(21);
    $pdf->SetAutoPageBreak(TRUE, 20);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //$pdf->setLanguageArray($l);
    $pdf->setFontSubsetting(false);
    $pdf->SetFont('dejavusans', '', 10, '', true);
    //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', '6'));
    $pdf->AddPage();
    $pdf->writeHTML($html, true, false, true, false, '');
    //    $pdf->AddPage();
    $pdf->SetFillColor(0, 0, 0);
    $pdf->Write(10, '                                                                  ARL');
    //    echo $estadistica[0]->arlnula;die;
    //   GRAFICA No 1
    $xc = $estadistica[0]->arlnula;
    $yc = $estadistica[0]->arlsi;
    $r = $estadistica[0]->arlno;
    //echo "<pre>";
    //    var_dump($estadistica);die();
    $total = $xc + $yc + $r;
    $r1 = $xc * 360 / $total;
    $r2 = $yc * 360 / $total;
    $r3 = $r * 360 / $total;
    $r1 = round($r1);
    $r2 = round($r2);
    $r3 = round($r3);
    $xc1 = 105;
    $yc1 = 120;
    $r11 = 50;
    $pdf->SetFillColor(0, 0, 255);
    $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(0, 255, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2);
    $pdf->SetTextColor(0, 0, 255);
    $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc);
    $pdf->SetTextColor(0, 255, 0);
    $pdf->Text(150, 155, 'SI: ' . $yc);
    $pdf->SetTextColor(255, 0, 0);
    $pdf->Text(150, 160, 'NO: ' . $r);
    $pdf->AddPage();
    //----------------------------------------------------------------
    //   GRAFICA No 2
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Write(10, '                                                             PENSION');
    $xc = $estadistica[0]->pensionnula;
    $yc = $estadistica[0]->pensionsi;
    $r = $estadistica[0]->pensionno;
    $total = $xc + $yc + $r;
    $r1 = $xc * 360 / $total;
    $r2 = $yc * 360 / $total;
    $r3 = $r * 360 / $total;
    $r1 = round($r1);
    $r2 = round($r2);
    $r3 = round($r3);
    $xc1 = 105;
    $yc1 = 100;
    $r11 = 50;
    $pdf->SetFillColor(0, 0, 255);
    $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(0, 255, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2);
    $pdf->SetTextColor(0, 0, 255);
    $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc);
    $pdf->SetTextColor(0, 255, 0);
    $pdf->Text(150, 155, 'SI: ' . $yc);
    $pdf->SetTextColor(255, 0, 0);
    $pdf->Text(150, 160, 'NO: ' . $r);
    $pdf->AddPage();
    //----------------------------------------------------------------
    //   GRAFICA No 3
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Write(10, '                                                                 EPS');
    $xc = $estadistica[0]->epsnula;
    $yc = $estadistica[0]->epssi;
    $r = $estadistica[0]->epsno;
    $total = $xc + $yc + $r;
    $r1 = $xc * 360 / $total;
    $r2 = $yc * 360 / $total;
    $r3 = $r * 360 / $total;
    $r1 = round($r1);
    $r2 = round($r2);
    $r3 = round($r3);
    $xc1 = 105;
    $yc1 = 100;
    $r11 = 50;
    $pdf->SetFillColor(0, 0, 255);
    $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(0, 255, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2);
    $pdf->SetTextColor(0, 0, 255);
    $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc);
    $pdf->SetTextColor(0, 255, 0);
    $pdf->Text(150, 155, 'SI: ' . $yc);
    $pdf->SetTextColor(255, 0, 0);
    $pdf->Text(150, 160, 'NO: ' . $r);
    $pdf->AddPage();
    //----------------------------------------------------------------
    //   GRAFICA No 4
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Write(10, '                                                  CAJA DE COMPENSACIÓN');
    $xc = $estadistica[0]->cajacompensacionnula;
    $yc = $estadistica[0]->cajacompensacionsi;
    $r = $estadistica[0]->cajacompensacionno;
    $total = $xc + $yc + $r;
    $r1 = $xc * 360 / $total;
    $r2 = $yc * 360 / $total;
    $r3 = $r * 360 / $total;
    $r1 = round($r1);
    $r2 = round($r2);
    $r3 = round($r3);
    $xc1 = 105;
    $yc1 = 100;
    $r11 = 50;
    $pdf->SetFillColor(0, 0, 255);
    $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(0, 255, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2);
    $pdf->SetTextColor(0, 0, 255);
    $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc);
    $pdf->SetTextColor(0, 255, 0);
    $pdf->Text(150, 155, 'SI: ' . $yc);
    $pdf->SetTextColor(255, 0, 0);
    $pdf->Text(150, 160, 'NO: ' . $r);
    $pdf->AddPage();
    //----------------------------------------------------------------
    //   GRAFICA No 5
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Write(10, '                                              DESPLAZAMIENTO EN MISIÓN');
    $xc = $estadistica[0]->usu_desplazamiento_misionnula;
    $yc = $estadistica[0]->usu_desplazamiento_misionsi;
    $r = $estadistica[0]->usu_desplazamiento_misionno;
    $total = $xc + $yc + $r;
    $r1 = $xc * 360 / $total;
    $r2 = $yc * 360 / $total;
    $r3 = $r * 360 / $total;
    $r1 = round($r1);
    $r2 = round($r2);
    $r3 = round($r3);
    $xc1 = 105;
    $yc1 = 100;
    $r11 = 50;
    $pdf->SetFillColor(0, 0, 255);
    $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(0, 255, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2);
    $pdf->SetTextColor(0, 0, 255);
    $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc);
    $pdf->SetTextColor(0, 255, 0);
    $pdf->Text(150, 155, 'SI: ' . $yc);
    $pdf->SetTextColor(255, 0, 0);
    $pdf->Text(150, 160, 'NO: ' . $r);
    //    $pdf->Write(0, 'Example of PieSector() method.');
    //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
    //    $pdf->writeHTMLCell(1, 1, '', '', $html, 0, 1, 0, true, '', true);
    $pdf->Output('pesv.pdf', 'I');
}
 public function RenderAsPDF(TCPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
 {
     $bReached = $this->GetProperty('is_reached');
     $oPdf->SetFillColor(255, 255, 255);
     if ($bReached) {
         $aBorderColor = array(100, 100, 100);
     } else {
         $aBorderColor = array(200, 200, 200);
     }
     $oPdf->SetLineStyle(array('width' => 2 * $fScale, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => $aBorderColor));
     $sIconUrl = $this->GetProperty('icon_url');
     $sIconPath = str_replace(utils::GetAbsoluteUrlModulesRoot(), APPROOT . 'env-' . utils::GetCurrentEnvironment() . '/', $sIconUrl);
     $oPdf->SetAlpha(1);
     $oPdf->Circle($this->x * $fScale, $this->y * $fScale, $this->GetWidth() / 2 * $fScale, 0, 360, 'DF');
     if ($bReached) {
         $oPdf->SetAlpha(1);
     } else {
         $oPdf->SetAlpha(0.4);
     }
     $oPdf->Image($sIconPath, ($this->x - 17) * $fScale, ($this->y - 17) * $fScale, 16 * $fScale, 16 * $fScale);
     $oPdf->Image($sIconPath, ($this->x + 1) * $fScale, ($this->y - 17) * $fScale, 16 * $fScale, 16 * $fScale);
     $oPdf->Image($sIconPath, ($this->x - 8) * $fScale, ($this->y + 1) * $fScale, 16 * $fScale, 16 * $fScale);
     $oPdf->SetFont('dejavusans', '', 24 * $fScale, '', true);
     $width = $oPdf->GetStringWidth($this->GetProperty('label'));
     $oPdf->SetTextColor(0, 0, 0);
     $oPdf->Text($this->x * $fScale - $width / 2, ($this->y + 25) * $fScale, $this->GetProperty('label'));
 }
Ejemplo n.º 10
0
    require_once dirname(__FILE__) . '/lang/eng.php';
    $pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// 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, 100);
$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);
$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, 'Pinacho');
$pdf->Text(60, 95, 'Marcelo');
$pdf->Text(120, 115, 'CNC');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_031.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
Ejemplo n.º 11
0
 public function Text($x, $y, $txt, $stroke = 0, $clip = false)
 {
     parent::Text($x, $y, to_utf8($txt), $stroke, $clip);
 }
Ejemplo n.º 12
0
$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);
$pdf->Rect(125, 70, 40, 10, 'D');
$pdf->Text(125, 66, 'Translate');
Ejemplo n.º 13
0
// 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');
Ejemplo n.º 14
0
 /**
  * Prints a character string.
  * The origin is on the left of the first charcter, on the baseline.
  * This method allows to place a string precisely on the page.
  *
  * @param float   $x      Abscissa of the origin
  * @param float   $y      Ordinate of the origin
  * @param string  $txt    String to print
  * @param int     $stroke outline size in points (0 = disable)
  * @param boolean $clip   if true activate clipping mode (you must call StartTransform() before this function and StopTransform() to stop the clipping tranformation).
  *
  * @access public
  * @return null
  * @since 1.0
  * @deprecated deprecated since version 4.3.005 (2008-11-25)
  * @see Cell(), Write(), MultiCell(), WriteHTML(), WriteHTMLCell()
  */
 public function Text($x, $y, $txt, $stroke = 0, $clip = false)
 {
     // replaces some special code to chars
     $txt = str_replace("&nbsp;", " ", $txt);
     $txt = str_replace("&auml;", "ä", $txt);
     $txt = str_replace("&ouml;", "ö", $txt);
     $txt = str_replace("&uuml;", "ü", $txt);
     $txt = str_replace("&Auml;", "Ä", $txt);
     $txt = str_replace("&Ouml;", "Ö", $txt);
     $txt = str_replace("&Uuml;", "Ü", $txt);
     $txt = str_replace("&szlig;", "ß", $txt);
     // replacing html specific codes
     // if this doesn't help, we should create own entity table
     // and replace codes to symbols
     $txt = html_entity_decode($txt);
     // cleaning up possible html code
     $txt = strip_tags($txt);
     //parent::Text($x,$y,$txt, $stroke, $clip);
     parent::Text($x, $y, $txt);
 }
Ejemplo n.º 15
0
$pdf->SetFont('helvetica', '', 10);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set style for barcode
$style = array('border' => true, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1);
// write RAW 2D Barcode
$code = '111011101110111,010010001000010,010011001110010,010010000010010,010011101110010';
$pdf->write2DBarcode($code, 'RAW', 80, 30, 30, 20, $style, 'N');
// write RAW2 2D Barcode
$code = '[111011101110111][010010001000010][010011001110010][010010000010010][010011101110010]';
$pdf->write2DBarcode($code, 'RAW2', 80, 60, 30, 20, $style, 'N');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set style for barcode
$style = array('border' => 2, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1);
// QRCODE,L : QR-CODE Low error correction
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,L', 20, 30, 50, 50, $style, 'N');
$pdf->Text(20, 25, 'QRCODE L');
// QRCODE,M : QR-CODE Medium error correction
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,M', 20, 90, 50, 50, $style, 'N');
$pdf->Text(20, 85, 'QRCODE M');
// QRCODE,Q : QR-CODE Better error correction
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,Q', 20, 150, 50, 50, $style, 'N');
$pdf->Text(20, 145, 'QRCODE Q');
// QRCODE,H : QR-CODE Best error correction
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 20, 210, 50, 50, $style, 'N');
$pdf->Text(20, 205, 'QRCODE H');
// -------------------------------------------------------------------
// PDF417 (ISO/IEC 15438:2006)
/*
 The $type parameter can be simple 'PDF417' or 'PDF417' followed by a
 number of comma-separated options:
 'PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6'
Ejemplo n.º 16
0
$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", 12);
// add a page
$pdf->AddPage();
$pdf->SetLineWidth(1);
$pdf->SetDrawColor(50, 0, 0, 0);
$pdf->SetFillColor(100, 0, 0, 0);
$pdf->SetTextColor(100, 0, 0, 0);
$pdf->Rect(30, 60, 20, 20, 'DF');
$pdf->Text(30, 85, 'Cyan');
$pdf->SetDrawColor(0, 50, 0, 0);
$pdf->SetFillColor(0, 100, 0, 0);
$pdf->SetTextColor(0, 100, 0, 0);
$pdf->Rect(60, 60, 20, 20, 'DF');
$pdf->Text(60, 85, 'Magenta');
$pdf->SetDrawColor(0, 0, 50, 0);
$pdf->SetFillColor(0, 0, 100, 0);
$pdf->SetTextColor(0, 0, 100, 0);
$pdf->Rect(90, 60, 20, 20, 'DF');
$pdf->Text(90, 85, 'Yellow');
$pdf->SetDrawColor(0, 0, 0, 50);
$pdf->SetFillColor(0, 0, 0, 100);
$pdf->SetTextColor(0, 0, 0, 100);
$pdf->Rect(120, 60, 20, 20, 'DF');
$pdf->Text(120, 85, 'Black');
Ejemplo n.º 17
0
         }
         if ($i > 6) {
             $l = 76;
             $h = 10;
         }
         if ($i > 9) {
             $l = 110;
             $h = 10;
         }
         if ($i == 2 || $i == 5 || $i == 8 || $i == 11) {
             $h = 80;
         } elseif ($i == 3 || $i == 6 || $i == 9 || $i == 12) {
             $h = 150;
         }
         $pdf->write1DBarcode($row['kp_sampel_no'], 'C128', $h, $l);
         $pdf->Text($h - 1, $l - 4, $row['kp_sampel_no']);
         $pdf->Text($h - 1, $l + 12, $str1);
         $pdf->Text($h - 1, $l + 15, $str2);
         $pdf->Text($h - 1, $l + 18, $str3);
         $i++;
     }
 } elseif ($rows == 2) {
     $h = 10;
     $l = 42;
     while ($i <= $bil) {
         if ($i > 3) {
             $l = 76;
             $h = 10;
         }
         if ($i > 6) {
             $l = 110;
Ejemplo n.º 18
0
    $pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,20,5,10', 'phase' => 10, 'color' => array(255, 0, 0));
$style2 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0));
$style3 = array('width' => 1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,10', 'color' => array(255, 0, 0));
$style4 = array('L' => 0, 'T' => array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => '20,10', 'phase' => 10, 'color' => array(100, 100, 255)), 'R' => array('width' => 0.5, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(50, 50, 127)), 'B' => array('width' => 0.75, 'cap' => 'square', 'join' => 'miter', 'dash' => '30,10,5,10'));
$style5 = array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 64, 128));
$style6 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,10', 'color' => array(0, 128, 0));
$style7 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 128, 0));
// Line
$pdf->Text(5, 4, 'Line examples');
$pdf->Line(5, 10, 80, 30, $style);
$pdf->Line(5, 10, 5, 30, $style2);
$pdf->Line(5, 10, 80, 10, $style3);
// Rect
$pdf->Text(100, 4, 'Rectangle examples');
$pdf->Rect(100, 10, 40, 20, 'DF', $style4, array(220, 220, 200));
$pdf->Rect(145, 10, 40, 20, 'D', array('all' => $style3));
// Curve
$pdf->Text(5, 34, 'Curve examples');
$pdf->Curve(5, 40, 30, 55, 70, 45, 60, 75, null, $style6);
$pdf->Curve(80, 40, 70, 75, 150, 45, 100, 75, 'F', $style6);
$pdf->Curve(140, 40, 150, 55, 180, 45, 200, 75, 'DF', $style6, array(200, 220, 200));
// Circle and ellipse
$pdf->Text(5, 79, 'Circle and ellipse examples');
$pdf->SetLineStyle($style5);
Ejemplo n.º 19
0
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,20,5,10', 'phase' => 10, 'color' => array(255, 0, 0));
$style2 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0));
$style3 = array('width' => 1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,10', 'color' => array(255, 0, 0));
$style4 = array('L' => 0, 'T' => array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => '20,10', 'phase' => 10, 'color' => array(100, 100, 255)), 'R' => array('width' => 0.5, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(50, 50, 127)), 'B' => array('width' => 0.75, 'cap' => 'square', 'join' => 'miter', 'dash' => '30,10,5,10'));
$style5 = array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 64, 128));
$style6 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,10', 'color' => array(0, 128, 0));
$style7 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 128, 0));
// Line
$pdf->Text(5, 7, 'Line examples');
$pdf->Line(5, 10, 80, 30, $style);
$pdf->Line(5, 10, 5, 30, $style2);
$pdf->Line(5, 10, 80, 10, $style3);
// Rect
$pdf->Text(100, 7, 'Rectangle examples');
$pdf->Rect(100, 10, 40, 20, 'DF', $style4, array(220, 220, 200));
$pdf->Rect(145, 10, 40, 20, 'D', array('all' => $style3));
// Curve
$pdf->Text(5, 37, 'Curve examples');
$pdf->Curve(5, 40, 30, 55, 70, 45, 60, 75, null, $style6);
$pdf->Curve(80, 40, 70, 75, 150, 45, 100, 75, 'F', $style6);
$pdf->Curve(140, 40, 150, 55, 180, 45, 200, 75, 'DF', $style6, array(200, 220, 200));
// Circle and ellipse
$pdf->Text(5, 82, 'Circle and ellipse examples');
$pdf->SetLineStyle($style5);
Ejemplo n.º 20
0
$style = array('border' => true, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1);
// write RAW 2D Barcode
$pdf->SetXY(30, 30);
$code = '111011101110111,010010001000010,010011001110010,010010000010010,010011101110010';
$pdf->write2DBarcode($code, 'RAW', '', '', 30, 20, $style, 'N');
$pdf->SetXY(100, 30);
// write RAW2 2D Barcode
$code = '[111011101110111][010010001000010][010011001110010][010010000010010][010011101110010]';
$pdf->write2DBarcode($code, 'RAW2', '', '', 30, 20, $style, 'N');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set style for barcode
$style = array('border' => 2, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1);
// QRCODE,L : QR-CODE Low error correction
$pdf->SetXY(30, 60);
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,L', '', '', 50, 50, $style, 'N');
$pdf->Text(30, 55, 'QRCODE L');
// QRCODE,M : QR-CODE Medium error correction
$pdf->SetXY(100, 60);
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,M', '', '', 50, 50, $style, 'N');
$pdf->Text(100, 55, 'QRCODE M');
// QRCODE,Q : QR-CODE Better error correction
$pdf->SetXY(30, 120);
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,Q', '', '', 50, 50, $style, 'N');
$pdf->Text(30, 115, 'QRCODE Q');
// QRCODE,H : QR-CODE Best error correction
$pdf->SetXY(100, 120);
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', '', '', 50, 50, $style, 'N');
$pdf->Text(100, 115, 'QRCODE H');
// -------------------------------------------------------------------
// PDF417 (ISO/IEC 15438:2006)
/*
//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();
//Scaling
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 16, 'Scale');
$pdf->SetDrawColor(0);
$pdf->SetTextColor(0);
//Start Transformation
$pdf->StartTransform();
//Scale by 150% centered by (50,30) which is the lower left corner of the rectangle
$pdf->ScaleXY(150, 50, 30);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 16, 'Scale');
//Stop Transformation
$pdf->StopTransform();
//Translation
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(125, 20, 40, 10, 'D');
$pdf->Text(125, 16, 'Translate');
Ejemplo n.º 22
0
$pdf->MultiCell(40, 5, "E test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'L', 0, 1);
$pdf->MultiCell(40, 5, "F test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line\nF test multicell line", 1, 'L', 0, 1);
// reset pointer to the last page
$pdf->lastPage();
// --- START GRAPHIC TRANFORMATIONS TEST -------------------
// Code Provided by Moritz Wagner and Andreas Würmser
$pdf->setPrintHeader(false);
$pdf->AddPage();
$pdf->Bookmark('Transformations', 0, 0);
$pdf->setPrintFooter(false);
//Scaling
$pdf->Bookmark('Scaling', 1, 4);
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 19, 'Scale');
$pdf->SetDrawColor(0);
$pdf->SetTextColor(0);
//Start Transformation
$pdf->StartTransform();
//Scale by 150% centered by (50,30) which is the lower left corner of the rectangle
$pdf->ScaleXY(150, 50, 30);
$pdf->Rect(50, 20, 40, 10, 'D');
$pdf->Text(50, 19, 'Scale');
//Stop Transformation
$pdf->StopTransform();
//Translation
$pdf->Bookmark('Translation', 1, 14);
$pdf->SetDrawColor(200);
$pdf->SetTextColor(200);
$pdf->Rect(125, 20, 40, 10, 'D');
Ejemplo n.º 23
0
 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);
 }
Ejemplo n.º 24
0
$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);
//initialize document
$pdf->AliasNbPages();
// add a page
$pdf->AddPage();
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', 'BI', 50);
// print clipping text
$pdf->Text(20, 40, "STROKE TEXT", 1, false);
//Start Transformation
$pdf->StartTransform();
// print clipping text
$pdf->Text(20, 70, "CLIPPING TEXT", 2, true);
// draw jpeg image
$pdf->Image("../images/image_demo.jpg", 20, 45, 170, 40, '', 'http://www.tcpdf.org', '', true, 72);
//Stop Transformation
$pdf->StopTransform();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_026.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
Ejemplo n.º 25
0
 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 013');
     $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 . ' 013', 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, '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);
     $pdf->Rect(125, 70, 40, 10, 'D');
     $pdf->Text(125, 66, 'Translate');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // Translate 7 to the right, 5 to the bottom
     $pdf->Translate(7, 5);
     $pdf->Rect(125, 70, 40, 10, 'D');
     $pdf->Text(125, 66, 'Translate');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Rotation --------------------------------------------
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(70, 100, 40, 10, 'D');
     $pdf->Text(70, 96, 'Rotate');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // Rotate 20 degrees counter-clockwise centered by (70,110) which is the lower left corner of the rectangle
     $pdf->Rotate(20, 70, 110);
     $pdf->Rect(70, 100, 40, 10, 'D');
     $pdf->Text(70, 96, 'Rotate');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Skewing ---------------------------------------------
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(125, 100, 40, 10, 'D');
     $pdf->Text(125, 96, 'Skew');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // skew 30 degrees along the x-axis centered by (125,110) which is the lower left corner of the rectangle
     $pdf->SkewX(30, 125, 110);
     $pdf->Rect(125, 100, 40, 10, 'D');
     $pdf->Text(125, 96, 'Skew');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Mirroring horizontally ------------------------------
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(70, 130, 40, 10, 'D');
     $pdf->Text(70, 126, 'MirrorH');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // mirror horizontally with axis of reflection at x-position 70 (left side of the rectangle)
     $pdf->MirrorH(70);
     $pdf->Rect(70, 130, 40, 10, 'D');
     $pdf->Text(70, 126, 'MirrorH');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Mirroring vertically --------------------------------
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(125, 130, 40, 10, 'D');
     $pdf->Text(125, 126, 'MirrorV');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // mirror vertically with axis of reflection at y-position 140 (bottom side of the rectangle)
     $pdf->MirrorV(140);
     $pdf->Rect(125, 130, 40, 10, 'D');
     $pdf->Text(125, 126, 'MirrorV');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Point reflection ------------------------------------
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(70, 160, 40, 10, 'D');
     $pdf->Text(70, 156, 'MirrorP');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     // Start Transformation
     $pdf->StartTransform();
     // point reflection at the lower left point of rectangle
     $pdf->MirrorP(70, 170);
     $pdf->Rect(70, 160, 40, 10, 'D');
     $pdf->Text(70, 156, 'MirrorP');
     // Stop Transformation
     $pdf->StopTransform();
     // --- Mirroring against a straigth line described by a point (120, 120) and an angle -20°
     $angle = -20;
     $px = 120;
     $py = 170;
     // just for visualisation: the straight line to mirror against
     $pdf->SetDrawColor(200);
     $pdf->Line($px - 1, $py - 1, $px + 1, $py + 1);
     $pdf->Line($px - 1, $py + 1, $px + 1, $py - 1);
     $pdf->StartTransform();
     $pdf->Rotate($angle, $px, $py);
     $pdf->Line($px - 5, $py, $px + 60, $py);
     $pdf->StopTransform();
     $pdf->SetDrawColor(200);
     $pdf->SetTextColor(200);
     $pdf->Rect(125, 160, 40, 10, 'D');
     $pdf->Text(125, 156, 'MirrorL');
     $pdf->SetDrawColor(0);
     $pdf->SetTextColor(0);
     //Start Transformation
     $pdf->StartTransform();
     //mirror against the straight line
     $pdf->MirrorL($angle, $px, $py);
     $pdf->Rect(125, 160, 40, 10, 'D');
     $pdf->Text(125, 156, 'MirrorL');
     //Stop Transformation
     $pdf->StopTransform();
     $this->comparePdfs($pdf);
 }
Ejemplo n.º 26
0
$pdf->AddSpotColor('Pantone 9060 C', 0, 0, 7, 0);
$pdf->AddSpotColor('Pantone 420 C', 22, 14, 22, 0);
$pdf->AddSpotColor('Pantone 422 C', 39, 24, 34, 0);
$pdf->AddSpotColor('Pantone 433 C', 34, 0, 0, 94);
$pdf->AddSpotColor('NovaSpace-Black', 50, 0, 0, 100);
$pdf->AddSpotColor('Pantone 601 C', 0, 0, 55, 0);
$pdf->AddSpotColor('Pantone 659 C', 50, 20, 0, 10);
// select the spot color
// where tint (the second parameter) is the intensity of the color (full intensity by default).
$pdf->SetTextSpotColor('NovaSpace-Black', 100);
$pdf->SetDrawSpotColor('NovaSpace-Black', 100);
$starty = 30;
// print some spot colors
$pdf->SetFillSpotColor('Pantone 116 C', 100);
$pdf->Rect(30, $starty, 20, 6, 'DF');
$pdf->Text(53, $starty + 4, 'Pantone 116 C');
$starty += 8;
$pdf->SetFillSpotColor('HKS 16 K', 100);
$pdf->Rect(30, $starty, 20, 6, 'DF');
$pdf->Text(53, $starty + 4, 'HKS 16 K');
$starty += 8;
$pdf->SetFillSpotColor('Pantone 505 C', 100);
$pdf->Rect(30, $starty, 20, 6, 'DF');
$pdf->Text(53, $starty + 4, 'Pantone 505 C');
$starty += 8;
$pdf->SetFillSpotColor('Pantone 440 C', 100);
$pdf->Rect(30, $starty, 20, 6, 'DF');
$pdf->Text(53, $starty + 4, 'Pantone 440 C');
$starty += 8;
$pdf->SetFillSpotColor('Pantone 288 C', 100);
$pdf->Rect(30, $starty, 20, 6, 'DF');
Ejemplo n.º 27
0
);

// set the coordinates x1,y1,x2,y2 of the gradient (see
// linear_gradient_coords.jpg)
$coords = array (
		0,
		0,
		1,
		0 
);

// paint a linear gradient
$pdf->LinearGradient ( 20, 45, 80, 80, $red, $blue, $coords );

// write label
$pdf->Text ( 20, 130, 'LinearGradient()' );

// set the coordinates fx,fy,cx,cy,r of the gradient (see
// radial_gradient_coords.jpg)
$coords = array (
		0.5,
		0.5,
		1,
		1,
		1.2 
);

// paint a radial gradient
$pdf->RadialGradient ( 110, 45, 80, 80, $white, $black, $coords );

// write label
Ejemplo n.º 28
0
//initialize document
$pdf->AliasNbPages();
// add a page
$pdf->AddPage();
// ---------------------------------------------------------
// set font
$pdf->SetFont("helvetica", "", 10);
$style = array("width" => 0.5, "cap" => "butt", "join" => "miter", "dash" => "10,20,5,10", "phase" => 10, "color" => array(255, 0, 0));
$style2 = array("width" => 0.5, "cap" => "butt", "join" => "miter", "dash" => 0, "color" => array(255, 0, 0));
$style3 = array("width" => 1, "cap" => "round", "join" => "round", "dash" => "2,10", "color" => array(255, 0, 0));
$style4 = array("L" => 0, "T" => array("width" => 0.25, "cap" => "butt", "join" => "miter", "dash" => "20,10", "phase" => 10, "color" => array(100, 100, 255)), "R" => array("width" => 0.5, "cap" => "round", "join" => "miter", "dash" => 0, "color" => array(50, 50, 127)), "B" => array("width" => 0.75, "cap" => "square", "join" => "miter", "dash" => "30,10,5,10"));
$style5 = array("width" => 0.25, "cap" => "butt", "join" => "miter", "dash" => 0, "color" => array(0, 0, 0));
$style6 = array("width" => 0.5, "cap" => "butt", "join" => "miter", "dash" => "10,10", "color" => array(0, 255, 0));
$style7 = array("width" => 0.5, "cap" => "butt", "join" => "miter", "dash" => 0, "color" => array(200, 200, 0));
// Line
$pdf->Text(5, 7, "Line examples");
$pdf->Line(5, 10, 80, 30, $style);
$pdf->Line(5, 10, 5, 30, $style2);
$pdf->Line(5, 10, 80, 10, $style3);
// Rect
$pdf->Text(100, 7, "Rectangle examples");
$pdf->Rect(100, 10, 40, 20, "DF", $style4, array(220, 220, 200));
$pdf->Rect(145, 10, 40, 20, "D", array("all" => $style3));
// Curve
$pdf->Text(5, 37, "Curve examples");
$pdf->Curve(5, 40, 30, 55, 70, 45, 60, 75, null, $style6);
$pdf->Curve(80, 40, 70, 75, 150, 45, 100, 75, "F", $style6);
$pdf->Curve(140, 40, 150, 55, 180, 45, 200, 75, "DF", $style6, array(200, 220, 200));
// Circle and ellipse
$pdf->Text(5, 82, "Circle and ellipse examples");
$pdf->SetLineStyle($style5);
Ejemplo n.º 29
0
 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 030');
     $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 . ' 030', 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);
     // --- first page ------------------------------------------
     // add a page
     $pdf->AddPage();
     $pdf->Cell(0, 0, 'TCPDF Gradients', 0, 1, 'C', 0, '', 0, false, 'T', 'M');
     // set colors for gradients (r,g,b) or (grey 0-255)
     $red = array(255, 0, 0);
     $blue = array(0, 0, 200);
     $yellow = array(255, 255, 0);
     $green = array(0, 255, 0);
     $white = array(255);
     $black = array(0);
     // set the coordinates x1,y1,x2,y2 of the gradient (see linear_gradient_coords.jpg)
     $coords = array(0, 0, 1, 0);
     // paint a linear gradient
     $pdf->LinearGradient(20, 45, 80, 80, $red, $blue, $coords);
     // write label
     $pdf->Text(20, 130, 'LinearGradient()');
     // set the coordinates fx,fy,cx,cy,r of the gradient (see radial_gradient_coords.jpg)
     $coords = array(0.5, 0.5, 1, 1, 1.2);
     // paint a radial gradient
     $pdf->RadialGradient(110, 45, 80, 80, $white, $black, $coords);
     // write label
     $pdf->Text(110, 130, 'RadialGradient()');
     // paint a coons patch mesh with default coordinates
     $pdf->CoonsPatchMesh(20, 155, 80, 80, $yellow, $blue, $green, $red);
     // write label
     $pdf->Text(20, 240, 'CoonsPatchMesh()');
     // set the coordinates for the cubic Bézier points x1,y1 ... x12, y12 of the patch (see coons_patch_mesh_coords.jpg)
     $coords = array(0.0, 0.0, 0.33, 0.2, 0.67, 0.0, 1.0, 0.0, 0.8, 0.33, 0.8, 0.67, 1.0, 1.0, 0.67, 0.8, 0.33, 1.0, 0.0, 1.0, 0.2, 0.67, 0.0, 0.33);
     //lower left
     $coords_min = 0;
     //minimum value of the coordinates
     $coords_max = 1;
     //maximum value of the coordinates
     // paint a coons patch gradient with the above coordinates
     $pdf->CoonsPatchMesh(110, 155, 80, 80, $yellow, $blue, $green, $red, $coords, $coords_min, $coords_max);
     // write label
     $pdf->Text(110, 240, 'CoonsPatchMesh()');
     // --- second page -----------------------------------------
     $pdf->AddPage();
     // first patch: f = 0
     $patch_array[0]['f'] = 0;
     $patch_array[0]['points'] = array(0.0, 0.0, 0.33, 0.0, 0.67, 0.0, 1.0, 0.0, 1.0, 0.33, 0.8, 0.67, 1.0, 1.0, 0.67, 0.8, 0.33, 1.8, 0.0, 1.0, 0.0, 0.67, 0.0, 0.33);
     $patch_array[0]['colors'][0] = array('r' => 255, 'g' => 255, 'b' => 0);
     $patch_array[0]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255);
     $patch_array[0]['colors'][2] = array('r' => 0, 'g' => 255, 'b' => 0);
     $patch_array[0]['colors'][3] = array('r' => 255, 'g' => 0, 'b' => 0);
     // second patch - above the other: f = 2
     $patch_array[1]['f'] = 2;
     $patch_array[1]['points'] = array(0.0, 1.33, 0.0, 1.67, 0.0, 2.0, 0.33, 2.0, 0.67, 2.0, 1.0, 2.0, 1.0, 1.67, 1.5, 1.33);
     $patch_array[1]['colors'][0] = array('r' => 0, 'g' => 0, 'b' => 0);
     $patch_array[1]['colors'][1] = array('r' => 255, 'g' => 0, 'b' => 255);
     // third patch - right of the above: f = 3
     $patch_array[2]['f'] = 3;
     $patch_array[2]['points'] = array(1.33, 0.8, 1.67, 1.5, 2.0, 1.0, 2.0, 1.33, 2.0, 1.67, 2.0, 2.0, 1.67, 2.0, 1.33, 2.0);
     $patch_array[2]['colors'][0] = array('r' => 0, 'g' => 255, 'b' => 255);
     $patch_array[2]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 0);
     // fourth patch - below the above, which means left(?) of the above: f = 1
     $patch_array[3]['f'] = 1;
     $patch_array[3]['points'] = array(2.0, 0.67, 2.0, 0.33, 2.0, 0.0, 1.67, 0.0, 1.33, 0.0, 1.0, 0.0, 1.0, 0.33, 0.8, 0.67);
     $patch_array[3]['colors'][0] = array('r' => 0, 'g' => 0, 'b' => 0);
     $patch_array[3]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255);
     $coords_min = 0;
     $coords_max = 2;
     $pdf->CoonsPatchMesh(10, 45, 190, 200, '', '', '', '', $patch_array, $coords_min, $coords_max);
     // write label
     $pdf->Text(10, 250, 'CoonsPatchMesh()');
     $this->comparePdfs($pdf);
 }
Ejemplo n.º 30
-1
// set font
$pdf->SetFont('helvetica', 'BI', 8);
// add a page
$pdf->AddPage();
/*
 * setAlpha() gives transparency support. You can set the 
 * alpha channel from 0 (fully transparent) to 1 (fully 
 * opaque). It applies to all elements (text, drawings, 
 * images).
 */
$pdf->SetLineWidth(1.5);
// draw opaque red square
$pdf->SetFillColor(255, 0, 0);
$pdf->Rect(30, 60, 40, 40, 'DF');
// set alpha to semi-transparency
$pdf->SetAlpha(0.5);
// draw green square
$pdf->SetFillColor(0, 255, 0);
$pdf->Rect(40, 70, 40, 40, 'DF');
// draw jpeg image
$pdf->Image('../images/image_demo.jpg', 50, 80, 40, 40, '', 'http://www.tcpdf.org', '', true, 72);
// restore full opacity
$pdf->SetAlpha(1);
// print name
$pdf->Text(55, 85, 'TRANSPARENCY');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_025.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+