Example #1
11
 private function printPDF($customer_id, $post_device, $post_user, $comment, $username, $randomcode, $date)
 {
     require_once Mage::getBaseDir('lib') . '/tcpdf/tcpdf.php';
     // create new PDF docume, nt
     $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     // set font
     $pdf->SetFont('helvetica', '', 11);
     // add a page
     $pdf->AddPage();
     $pdf->setJPEGQuality(100);
     // set cell padding
     $pdf->setCellPaddings(0, 0, 0, 0);
     $pdf->SetLineWidth(0.2);
     // set cell margins
     $pdf->setCellMargins(0, 0, 0, 0);
     $pdf->setCellHeightRatio(1);
     // set color for background
     $pdf->SetFillColor(255, 255, 255);
     // Multicell
     // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
     // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
     $pdf->SetFont('helvetica', '', 11);
     $pdf->MultiCell(50, 0, 'SERVISNI LIST - REVERS', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->MultiCell(100, 0, 'GAMEBOX, Cara Dušana 47, Niš - tel 018/514-666 - 060/514-666-0', 0, 'L', 1, 0, 80, $pdf->getY() + 1, true, 0, false);
     // Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false)
     // $pdf->Image(dirname(__FILE__). '/bcimages/'. $randkey . '.png',80,8,100,8,'','','',true);
     $pdf->Image(Mage::getBaseDir('media') . '/pdf/gbr.png', 182, 10, 20, 60, '', '', '', true);
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetFont('helvetica', '', 8);
     $pdf->Cell(70, 6, 'Naziv uredjaja', 0, 0, 'L', 0);
     $pdf->Cell(40, 6, 'Serijski broj', 0, 0, 'L', 0);
     $pdf->Cell(60, 6, 'Opis kvara', 0, 0, 'L', 0);
     $pdf->Ln();
     $i = 1;
     foreach ($post_device as $key => $post) {
         if ($i == 1) {
             $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'LT', 'L', 1, 0, 10, '', true, 0, false);
             $pdf->MultiCell(40, 6, $post['sn'], 'T', 'L', 1, 0, 80, '', true, 0, false);
             $pdf->MultiCell(60, 6, $post['description'], 'TR', 'L', 1, 0, 120, '', true, 0, false);
         } else {
             $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'L', 'L', 1, 0, '', '', true, 0, false);
             $pdf->MultiCell(40, 6, $post['sn'], 0, 'L', 1, 0, '', '', true, 0, false);
             $pdf->MultiCell(60, 6, $post['description'], 'R', 'L', 1, 0, '', '', true, 0, false);
         }
         $pdf->Ln();
         ++$i;
     }
     //$pdf->MultiCell(70, 15, ' 1. ' . $naziv1, 'LT', 'L', 1, 0, 10, '', true, 0, false);
     //$pdf->MultiCell(40, 15, $_POST['sn1'], 'T', 'L', 1, 0, 80, '', true, 0, false);
     //$pdf->MultiCell(60, 15, $opis1, 'TR', 'L', 1, 0, 120, '', true, 0, false);
     //$pdf->Ln();
     $pdf->MultiCell(70, 1, ' ', 'LB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(40, 1, ' ', 'B', 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(60, 1, ' ', 'RB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->Ln();
     $pdf->Cell(70, 6, 'Dodatna uputstva / komentari', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->MultiCell(170, 5, $comment, 'TRLB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->Ln();
     $pdf->Cell(70, 6, 'Na servis predao', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Ime:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['name'], 0, 'L', 1, 0, 25, '', true, 0, false);
     $pdf->MultiCell(50, 6, 'Datum i vreme prijema:', 0, 'L', 1, 0, 70, '', true, 0, false);
     $pdf->MultiCell(50, 6, $date, 0, 'L', 1, 0, 100, '', true, 0, false);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Email:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['email'], 0, 'L', 1, 0, 25, '', true, 0, false);
     $pdf->MultiCell(50, 6, 'Kontrolni kod:', 0, 'L', 1, 0, 70, '', true, 0, false);
     $pdf->MultiCell(50, 6, $randomcode, 0, 'L', 1, 0, 100, '', true, 0, false);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Telefon:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['phone'], 0, 'L', 1, 0, 25, '', true, 0, false);
     $pdf->MultiCell(120, 6, 'Pratite stanje Vašeg uredjaja na servisu.<br>Posetite <b>http://proveraservisa.gamebox.co.rs/</b> i unesite Vaš kontrolni kod<br />ili skenirajte <b>QR</b> kod pomocu Vašeg mobilnog telefona', 0, 'L', 1, 0, 70, '', true, 0, true);
     $pdf->Ln();
     $pdf->Ln(3);
     $pdf->MultiCell(110, 10, "\n" . Mage::getStoreConfig('servisnilist/text/upozorenje'), 1, 'C', 1, 0, 50, '', true, 0, false);
     $pdf->Ln();
     if (count($post_device) == 1) {
         $pdf->Ln();
     }
     $pdf->Ln(5);
     $pdf->Image(Mage::getBaseDir('media') . '/pdf/cut-here.png', 3, '', 250, 3, '', '', '', false, 300, '', false, false, 0, true);
     $pdf->Ln(9);
     $x = $pdf->GetX();
     $y = $pdf->GetY();
     // bottom part
     $pdf->SetFont('helvetica', '', 11);
     $pdf->MultiCell(50, 8, 'SERVISNI LIST - REVERS', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->MultiCell(100, 0, 'GAMEBOX, Cara Dušana 47, Niš - tel 018/514-666 - 060/514-666-0', 0, 'L', 1, 0, 80, '', true, 0, false);
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetFont('helvetica', '', 8);
     $pdf->Cell(70, 6, 'Naziv uredjaja', 0, 0, 'L', 0);
     $pdf->Cell(40, 6, 'Serijski broj', 0, 0, 'L', 0);
     $pdf->Cell(60, 6, 'Opis kvara', 0, 0, 'L', 0);
     $pdf->Ln();
     $i = 1;
     foreach ($post_device as $key => $post) {
         if ($i == 1) {
             $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'LT', 'L', 1, 0, 10, '', true, 0, false);
             $pdf->MultiCell(40, 6, $post['sn'], 'T', 'L', 1, 0, 80, '', true, 0, false);
             $pdf->MultiCell(60, 6, $post['description'], 'TR', 'L', 1, 0, 120, '', true, 0, false);
         } else {
             $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'L', 'L', 1, 0, '', '', true, 0, false);
             $pdf->MultiCell(40, 6, $post['sn'], 0, 'L', 1, 0, '', '', true, 0, false);
             $pdf->MultiCell(60, 6, $post['description'], 'R', 'L', 1, 0, '', '', true, 0, false);
         }
         $pdf->Ln();
         ++$i;
     }
     $pdf->MultiCell(70, 1, ' ', 'LB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(40, 1, ' ', 'B', 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(60, 1, ' ', 'RB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->Ln();
     $pdf->Cell(70, 6, 'Dodatna uputstva / komentari', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->MultiCell(170, 5, $comment, 'TRLB', 'L', 1, 0, '', '', true, 0, false);
     $pdf->Ln();
     $pdf->Cell(70, 6, 'Obracun', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->Cell(90, 6, 'Materijal', 0, 0, 'L', 0);
     $pdf->Cell(20, 6, 'j. mere', 0, 0, 'L', 0);
     $pdf->Cell(15, 6, 'kolicina', 0, 0, 'L', 0);
     $pdf->Cell(20, 6, 'cena', 0, 0, 'L', 0);
     $pdf->Cell(25, 6, 'UKUPNO', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->Cell(90, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(15, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(25, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Ln();
     $pdf->Cell(90, 6, 'Opis usluge', 0, 0, 'L', 0);
     $pdf->Cell(20, 6, 'j. mere', 0, 0, 'L', 0);
     $pdf->Cell(15, 6, 'kolicina', 0, 0, 'L', 0);
     $pdf->Cell(20, 6, 'cena', 0, 0, 'L', 0);
     $pdf->Cell(25, 6, 'UKUPNO', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->Cell(90, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(15, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Cell(25, 5, ' ', 'TRLB', 0, 'L', 0);
     $pdf->Ln();
     $pdf->MultiCell(60, 6, 'SVEGA:', 'B', 'L', 1, 0, 120, $pdf->getY() + 1, true, 0, false);
     $pdf->Ln();
     $pdf->Cell(70, 6, 'Na servis predao', 0, 0, 'L', 0);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Ime:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['name'], 0, 'L', 1, 0, 25, '', true, 0, false);
     $pdf->MultiCell(50, 6, 'Datum i vreme prijema:', 0, 'L', 1, 0, 70, '', true, 0, false);
     $pdf->MultiCell(50, 6, $date, 0, 'L', 1, 0, 100, '', true, 0, false);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Email:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['email'], 0, 'L', 1, 0, 25, '', true, 0, false);
     $pdf->MultiCell(50, 6, 'Kontrolni kod:', 0, 'L', 1, 0, 70, '', true, 0, false);
     $pdf->MultiCell(50, 6, $randomcode, 0, 'L', 1, 0, 100, '', true, 0, false);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Telefon:', 0, 'L', 1, 0, '', '', true, 0, false);
     $pdf->MultiCell(50, 6, $post_user['phone'], 0, 'L', 1, 0, 25, '', true, 0, false);
     //$pdf->Image(dirname(__FILE__) . '/bcimages/' . $randkey . '.png', 66, $pdf->getY() - 2, 100, 8, '', '', '', true, 300, '', false, false, 0, false);
     // $pdf->MultiCell(120, 6, 'Pratite stanje Vaseg uredjaja na servisu.<br>Posetite <b>http://bengazi.com/proveraservisa</b> i unesite Vas kontrolni kod' ,0, 'L', 1, 0, 70, '', true, 0, true);
     $pdf->Ln();
     $pdf->MultiCell(20, 6, 'Potpis:', 0, 'L', 1, 0, '', '', true, 0, false);
     // CODE 128 B
     // define barcode style
     $style1d = array('position' => 'S', 'align' => 'C', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => '', 'border' => false, 'hpadding' => '35', 'vpadding' => '30', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'text' => false, 'font' => 'helvetica', 'fontsize' => 8, 'stretchtext' => 4);
     $pdf->setXY(180, $y + 35);
     //155
     $pdf->StartTransform();
     $pdf->Rotate(90);
     $pdf->write1DBarcode($randomcode, 'C128B', '', '', '', 14, 0.5, $style1d, 'T');
     $pdf->StopTransform();
     // new style
     $styleQR = array('border' => false, 'padding' => 0, 'fgcolor' => array(0, 0, 0), 'bgcolor' => false);
     // QRCODE,H : QR-CODE Best error correction
     $pdf->write2DBarcode('http://proveraservisa.gamebox.co.rs/?kk=' . $randomcode, 'QRCODE,H', 184, 75, 50, 50, $styleQR, 'N');
     // QRCODE,H : QR-CODE Best error correction
     $pdf->write2DBarcode(Mage::getBaseUrl() . 'servisnilist/status/qr/slid/' . $customer_id, 'QRCODE,H', 184, $y + 65, 50, 50, $styleQR, 'N');
     // Close and output PDF document
     $pdf->IncludeJS('print();');
     // die('y');
     //ob_clean(); //stupid tcpdf need this
     $pdf->Output('trt.pdf', 'I');
     exit;
 }
 /**
  * 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');
         }
     }
 }
Example #3
0
 /**
  * Create a table structure for TCPDF.
  *
  * @param \TCPDF $pdf
  * @param string $cacheDir If the cache directory is given, resized images could be cached.
  */
 public function __construct(\TCPDF $pdf, $cacheDir = null)
 {
     $this->pdf = $pdf;
     $this->cacheDir = $cacheDir;
     $this->xPosition = $pdf->GetX();
     $this->setBorderWidth($pdf->GetLineWidth());
     $this->setFontFamily($pdf->getFontFamily());
     $this->setFontSize($pdf->getFontSizePt());
     // FontSizePT is in points (not in user unit)
     $this->setFontWeight(strpos($pdf->getFontStyle(), 'B') !== false ? self::FONT_WEIGHT_BOLD : self::FONT_WEIGHT_NORMAL);
 }
/**
 * Draws a multichoice question with many options on the TCPDF object.
 * It relies on the current X,Y pointer of the TCPDF context.
 * 
 * Generates some metrics about the layout.
 * retuns an object with the following structure:
 * object->coords[]->X
 *                 ->Y
 *                 ->H
 *                 ->W
 *        ->marks[]->X
 *                 ->Y
 *                 ->H
 *                 ->W
 * 
 * @param $pdf
 * @param $question
 * @param $columnsWidth
 * @param $ln  Indicates where the current position should go after the call. Possible values are:
 *				0: to the right
 *				1: to the beginning of the next line
 *				2: below
 * @param $markSize
 * @param $fillMarks
 * @param $numcols
 * @param $border draws a border
 * @return object with a coords and marks properties
 */
function draw_multichoice_question(TCPDF $pdf, &$dims, $question, $columnsWidth, $ln, $markSize = 4, $fillMarks = false, $numcols = 2, $border = true)
{
    $borderDescription = false;
    $borderOption = false;
    $Xorigin = $pdf->GetX();
    $maxY = 0;
    //$lastH=$pdf->getLastH();
    $pdf->setLastH(1);
    //output question
    saveXY($dims, $pdf, $question->id);
    $pdf->writeHTMLCell($columnsWidth, 1, '', '', $question->textHtml, $borderDescription, 0, 0, false);
    saveWH($dims, $pdf, $question->id);
    $pdf->Ln();
    $pdf->SetX($Xorigin);
    $name = $question->id;
    //oputput options
    for ($i = 0; $i < count($question->options); $i++) {
        $option = $question->options[$i];
        //circulo para marcar
        draw_mark($pdf, $markSize, $dims, $i, $name, $fillMarks);
        saveXY($dims, $pdf);
        $pdf->writeHTMLCell($columnsWidth / 2 - $markSize, 0, '', '', $option, $borderOption, 0, false);
        saveWH($dims, $pdf);
        $coord = $dims->coords[(int) (count($dims->coords) - 1)];
        $renderedY = $coord->Y + $coord->H;
        $maxY = max($maxY, $renderedY);
        if ($i % $numcols == 1) {
            $pdf->SetY($maxY);
            $pdf->SetX($Xorigin);
        }
    }
    //register global dimensions
    $coord = new stdClass();
    $coord->X = $dims->coords[$question->id]->X;
    $coord->Y = $dims->coords[$question->id]->Y;
    $coord->W = $columnsWidth;
    $coord->H = $dims->coords[count($dims->coords) - 1]->Y + $dims->coords[count($dims->coords) - 1]->H - $coord->Y;
    $dims->coords[$question->id] = $coord;
    switch ($ln) {
        case 0:
            $pdf->SetXY($coord->X + $coord->W, $coord->Y);
            break;
        case 1:
            $margins = $pdf->getMargins();
            $pdf->SetXY($margins['left'], $coord->Y + $coord->H);
            break;
        case 2:
            $pdf->SetXY($coord->X + $coord->W, $coord->Y, $coord->Y + $coord->H);
            break;
    }
    if ($border) {
        $pdf->Rect($coord->X, $coord->Y, $coord->W, $coord->H);
    }
    $pdf->setLastH($coord->H);
    /*
    //circulo para marcar
    saveXY(&$coords,$pdf);
    draw_mark($pdf,$markSize);
    saveWH(&$coords,$pdf);
    
    saveXY(&$coords,$pdf);
    $pdf->writeHTMLCell($columnsWidth/2-$markSize,'','','',$question->options[0],1,0,0,0,'L');
    saveWH(&$coords,$pdf);
    
    //circulo para marcar
    saveXY(&$coords,$pdf);
    draw_mark($pdf,$markSize);
    saveWH(&$coords,$pdf);
    
    saveXY(&$coords,$pdf);
    $pdf->writeHTMLCell($columnsWidth/2-$markSize,'','','',$question->options[1],1,1,0,0,'L');
    saveWH(&$coords,$pdf);
    
    //circulo para marcar
    saveXY(&$coords,$pdf);
    draw_mark($pdf,$markSize);
    saveWH(&$coords,$pdf);
    
    saveXY(&$coords,$pdf);
    $pdf->writeHTMLCell($columnsWidth/2-$markSize,'','','',$question->options[2],1,0,0,0,'L');
    saveWH(&$coords,$pdf);
    
    //circulo para marcar
    saveXY(&$coords,$pdf);
    draw_mark($pdf,$markSize);
    saveWH(&$coords,$pdf);
    
    saveXY(&$coords,$pdf);
    $pdf->writeHTMLCell($columnsWidth/2-$markSize,'','','',$question->options[3],1,2,0,0,'L');
    saveWH(&$coords,$pdf);
    */
    //Close and output PDF document
}
Example #5
0
 public function add_table($table)
 {
     $absolute_position = $this->is_absolute($table);
     if (!$absolute_position) {
         $this->validate_position($table->ancho);
     }
     if ($table->fondo) {
         $this->choose_color();
     }
     $this->SetLineWidth(0.3);
     // set the width of the table
     $margins = parent::getMargins();
     if ($table->ancho == 0) {
         if (parent::GetX() == $margins['left']) {
             $table->ancho = $this->document_width;
         } elseif (isset($table->x)) {
             $table->ancho = $this->document_width - $table->x;
         } else {
             $table->ancho = $this->document_width - $this->last_width;
         }
     }
     // get the widths of the headers
     $encabezados = (array) $table->encabezados;
     $string_widths = 0;
     $has_superheaders = false;
     foreach ($encabezados as $key => $cell) {
         if (is_array($cell)) {
             $has_superheaders = true;
             foreach ($cell as $value) {
                 $string_widths += parent::GetStringWidth($value);
             }
         } else {
             $string_widths += parent::GetStringWidth($cell);
         }
     }
     if ($table->borde == 0) {
         $header_border = 'B';
         $data_border = 0;
     } else {
         $header_border = 1;
         $data_border = 'LR';
     }
     // print headers
     $x = parent::GetX();
     $y = parent::GetY();
     $widths = array();
     $i = 0;
     if ($has_superheaders) {
         $cell_h = 26;
     } else {
         $cell_h = 13;
     }
     foreach ($encabezados as $index => $cell) {
         if (is_array($cell)) {
             $super_w = 0;
             $super_x = parent::GetX();
             foreach ($cell as $key => $value) {
                 array_push($widths, $this->GetStringWidth($value) / $string_widths * $table->ancho);
                 parent::WriteHTMLCell($widths[$i + $key], $cell_h / 2, parent::GetX(), $y + $cell_h / 2, "<b>" . $value . "</b>", $header_border, 0, $table->fondo, true, 'C');
                 $super_w += $widths[$i + $key];
             }
             parent::WriteHTMLCell($super_w, $cell_h / 2, $super_x, $y, "<b>" . $index . "</b>", $header_border, 0, $table->fondo, true, 'C');
             parent::SetXY(parent::GetX(), $y + $cell_h / 2);
         } else {
             array_push($widths, $this->GetStringWidth($cell) / $string_widths * $table->ancho);
             parent::WriteHTMLCell($widths[$index], $cell_h, parent::GetX(), $y, "<b>" . $cell . "</b>", $header_border, 0, $table->fondo, true, 'C');
         }
         $i++;
     }
     parent::Ln();
     parent::SetX($x);
     // print data
     $fill = false;
     foreach ($table->datos as $row) {
         foreach ($row as $i => $field) {
             $this->WriteHTMLCell($widths[$i], 6, '', '', $field, $data_border, 0, $fill, true, 'L', true);
         }
         if (parent::GetY() + 20 > parent::getPageHeight() - PDF_MARGIN_BOTTOM) {
             parent::AddPage();
         }
         $height = parent::getLastH();
         $this->Ln();
         if ($table->fondo) {
             $fill = !$fill;
         }
     }
     $this->Cell(array_sum($widths), 0, '', 'T', $table->salto);
     // set document positions
     parent::SetXY(parent::GetX() + $this->separator, parent::GetY());
     if ($absolute_position) {
         $this->last_width = parent::GetX();
     }
     $y = parent::GetY();
     if ($y > $this->last_height) {
         $this->last_height = $y;
     }
 }
 public function display($arraydata, $y_axis = 0, $fielddata = false)
 {
     //print_r($arraydata);echo "<br/>";
     //    $this->pdf->Cell(10,10,"SSSS");
     $this->Rotate($arraydata["rotation"]);
     if ($arraydata["rotation"] != "") {
         if ($arraydata["rotation"] == "Left") {
             $w = $arraydata["width"];
             $arraydata["width"] = $arraydata["height"];
             $arraydata["height"] = $w;
             $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY());
         } elseif ($arraydata["rotation"] == "Right") {
             $w = $arraydata["width"];
             $arraydata["width"] = $arraydata["height"];
             $arraydata["height"] = $w;
             $this->pdf->SetXY($this->pdf->GetX(), $this->pdf->GetY() - $arraydata["height"]);
         } elseif ($arraydata["rotation"] == "UpsideDown") {
             //soverflow"=>$stretchoverflow,"poverflow"
             $arraydata["soverflow"] = true;
             $arraydata["poverflow"] = true;
             //   $w=$arraydata["width"];
             // $arraydata["width"]=$arraydata["height"];
             //$arraydata["height"]=$w;
             $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY() - $arraydata["height"]);
         }
     }
     if ($arraydata["type"] == "SetFont") {
         if ($arraydata["font"] == 'uGB') {
             $this->pdf->isUnicode = true;
         } else {
             $this->pdf->isUnicode = false;
         }
         $this->pdf->SetFont($arraydata["font"], $arraydata["fontstyle"], $arraydata["fontsize"]);
     } elseif ($arraydata["type"] == "subreport") {
         $this->runSubReport($arraydata);
     } elseif ($arraydata["type"] == "MultiCell") {
         $currenty = $this->pdf->GetY();
         if ($fielddata == false) {
             if ($this->allowprintuntill >= $currenty) {
                 $this->checkoverflow($arraydata, $this->updatePageNo($arraydata["txt"]));
             }
         } elseif ($fielddata == true) {
             if ($this->allowprintuntill >= $currenty) {
                 $this->checkoverflow($arraydata, $this->updatePageNo($this->analyse_expression($arraydata["txt"], $arraydata["isPrintRepeatedValues"])));
             } elseif ($this->parentcurrentband == "detail") {
                 $this->pdf->Cell(40, 10, "SADSD");
             }
             //                  echo $arraydata["txt"]."+\"|(".$y_axis.",".print_r($arraydata,true)."),$this->allowprintuntill,$newy\"<br/><br/>";
         }
     } elseif ($arraydata["type"] == "SetXY") {
         $this->pdf->SetXY($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis);
     } elseif ($arraydata["type"] == "Cell") {
         $currenty = $this->pdf->GetY();
         if ($this->allowprintuntill >= $currenty) {
             $this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->updatePageNo($arraydata["txt"]), $arraydata["border"], $arraydata["ln"], $arraydata["align"], $arraydata["fill"], $arraydata["link"]);
         } elseif ($this->parentcurrentband == "detail") {
             $this->pdf->Cell(40, 10, "SADSD");
         }
     } elseif ($arraydata["type"] == "Rect") {
         $this->pdf->Rect($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]);
     } elseif ($arraydata["type"] == "Image") {
         $path = $this->analyse_expression($arraydata["path"]);
         $imgtype = substr($path, -3);
         if ($imgtype == 'jpg' || right($path, 3) == 'jpg' || right($path, 4) == 'jpeg') {
             $imgtype = "JPEG";
         } elseif ($imgtype == 'png' || $imgtype == 'PNG') {
             $imgtype = "PNG";
         }
         if (file_exists($path) || left($path, 4) == 'http') {
             $this->pdf->Image($path, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $imgtype, $arraydata["link"]);
         } elseif (left($path, 22) == "data:image/jpeg;base64") {
             $imgtype = "JPEG";
             $img = str_replace('data:image/jpeg;base64,', '', $path);
             $imgdata = base64_decode($img);
             $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]);
             //,$imgtype,$arraydata["link"]);
         } elseif (left($path, 22) == "data:image/png;base64,") {
             $imgtype = "PNG";
             // $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
             $img = str_replace('data:image/png;base64,', '', $path);
             $imgdata = base64_decode($img);
             $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]);
             //,$imgtype,$arraydata["link"]);
         }
     } elseif ($arraydata["type"] == "SetTextColor") {
         $this->pdf->SetTextColor($arraydata["r"], $arraydata["g"], $arraydata["b"]);
     } elseif ($arraydata["type"] == "SetDrawColor") {
         $this->pdf->SetDrawColor($arraydata["r"], $arraydata["g"], $arraydata["b"]);
     } elseif ($arraydata["type"] == "SetLineWidth") {
         $this->pdf->SetLineWidth($arraydata["width"]);
     } elseif ($arraydata["type"] == "Line") {
         $this->pdf->Line($arraydata["x1"] + $this->arrayPageSetting["leftMargin"], $arraydata["y1"] + $y_axis, $arraydata["x2"] + $this->arrayPageSetting["leftMargin"], $arraydata["y2"] + $y_axis);
     } elseif ($arraydata["type"] == "SetFillColor") {
         $this->pdf->SetFillColor($arraydata["r"], $arraydata["g"], $arraydata["b"]);
     } elseif ($arraydata["type"] == "lineChart") {
         $this->showLineChart($arraydata, $y_axis);
     } elseif ($arraydata["type"] == "barChart") {
         $this->showBarChart($arraydata, $y_axis, 'barChart');
     } elseif ($arraydata["type"] == "stackedBarChart") {
         $this->showBarChart($arraydata, $y_axis, 'stackedBarChart');
     } elseif ($arraydata["type"] == "stackedAreaChart") {
         $this->showAreaChart($arraydata, $y_axis, $arraydata["type"]);
     } elseif ($arraydata["type"] == "Barcode") {
         $this->showBarcode($arraydata, $y_axis);
     }
 }
 public function pruebapdfAction()
 {
     // Include the main TCPDF library (search for installation path).
     require_once 'tcpdf/examples/tcpdf_include.php';
     ob_clean();
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', 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(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
         require_once dirname(__FILE__) . '/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // ---------------------------------------------------------
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont('helvetica', '', 9, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     $pdf->SetFillColor(224, 235, 255);
     $pdf->SetTextColor(0);
     $pdf->SetFont('');
     $fill = 0;
     $pdf->Cell(10, 6, 'Nro', 1, 0, 'L', $fill);
     $pdf->Cell(30, 6, 'Ubicación', 1, 0, 'L', $fill);
     $pdf->Cell(30, 6, 'Sector', 1, 0, 'R', $fill);
     $pdf->Cell(30, 6, 'Fecha', 1, 0, 'R', $fill);
     $pdf->Cell(90, 6, 'Descripción', 1, 0, 'R', $fill);
     $pdf->Ln();
     $sum = 0;
     $sw = 0;
     for ($i = 1; $i < 100; $i++) {
         $maxnocells = 0;
         $cellcount = 0;
         //write text first
         $startX = $pdf->GetX();
         $startY = $pdf->GetY();
         //draw cells and record maximum cellcount
         //cell height is 6 and width is 80
         $cellcount = $pdf->MultiCell(10, 6, $i, 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(30, 6, 'Cochabamba', 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(30, 6, 'Sector', 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(30, 6, 'Sector', 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(90, 6, ' fjalañsdklfjalskd ', 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $pdf->SetXY($startX, $startY);
         //now do borders and fill
         //cell height is 6 times the max number of cells
         $pdf->MultiCell(10, $maxnocells * 5, '', 'LB', 'L', $sw, 0);
         $pdf->MultiCell(30, $maxnocells * 5, '', 'LB', 'L', $sw, 0);
         $pdf->MultiCell(30, $maxnocells * 5, '', 'LB', 'L', $sw, 0);
         $pdf->MultiCell(30, $maxnocells * 5, '', 'LB', 'L', $sw, 0);
         $pdf->MultiCell(90, $maxnocells * 5, '', 'LRB', 'L', $sw, 0);
         $pdf->Ln();
         $sw = !$sw;
         $sum += $maxnocells;
         if ($sum > 42) {
             $pdf->AddPage();
             $sum = 0;
         }
     }
     // ---------------------------------------------------------
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     // $pdf->Output('example_001.pdf', 'I');
     $pdf->Output('/var/www/html/comercializacion/public/file/example_001.pdf', 'F');
     exit;
     //============================================================+
     // END OF FILE
     //============================================================+
     // $this->view->disable();
 }
Example #8
0
 public function checkoverflow($arraydata, $txt = "", $maxheight = 0)
 {
     $newfont = $this->recommendFont($txt, $arraydata["font"], $arraydata["pdfFontName"]);
     $this->pdf->SetFont($newfont, $this->pdf->getFontStyle(), $this->pdf->getFontSize());
     $this->print_expression($arraydata);
     if ($this->print_expression_result == true) {
         // echo $arraydata["link"];
         if ($arraydata["link"]) {
             //print_r($arraydata);
             //$this->debughyperlink=true;
             //  echo $arraydata["link"].",print:".$this->print_expression_result;
             $arraydata["link"] = $this->analyse_expression($arraydata["link"], "");
             //$this->debughyperlink=false;
         }
         //print_r($arraydata);
         if ($arraydata["writeHTML"] == 1 && $this->pdflib == "TCPDF") {
             $this->pdf->writeHTML($txt);
             $this->pdf->Ln();
             if ($this->currentband == 'detail') {
                 if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') {
                     $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                 } else {
                     if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) {
                         $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                     }
                 }
             }
         } elseif ($arraydata["poverflow"] == "false" && $arraydata["soverflow"] == "false") {
             if ($arraydata["valign"] == "M") {
                 $arraydata["valign"] = "C";
             }
             if ($arraydata["valign"] == "") {
                 $arraydata["valign"] = "T";
             }
             while ($this->pdf->GetStringWidth($txt) > $arraydata["width"]) {
                 if ($txt != $this->pdf->getAliasNbPages() && $txt != ' ' . $this->pdf->getAliasNbPages()) {
                     $txt = substr_replace($txt, "", -1);
                 }
             }
             $x = $this->pdf->GetX();
             $y = $this->pdf->GetY();
             $text = $this->formatText($txt, $arraydata["pattern"]);
             $this->pdf->Cell($arraydata["width"], $arraydata["height"], $text, $arraydata["border"], "", $arraydata["align"], $arraydata["fill"], $arraydata["link"], 0, true, "T", $arraydata["valign"]);
             //                if($arraydata["link"]) { //
             //                    $tmpalign="Left";
             //                    if($arraydata["valign"]=="R")
             //                        $tmpalign="Right";
             //                    elseif($arraydata["valign"]=="C")
             //                        $tmpalign="Center";
             //                    $textlen=strlen($text);
             //                    $hidetxt="";
             //                    for($l=0;$l<$textlen*2;$l++)
             //                    $hidetxt.="&nbsp;";
             //                              $imagehtml='<a style="text-decoration: none;" href="'.$arraydata["link"].'">'.
             //                                      '<div style="text-decoration: none;text-align:$tmpalign;float:left;width:'.$arraydata["width"].';margin:0px">'.$hidetxt.'</div></a>';
             //                         //     $this->pdf->writeHTMLCell($arraydata["width"],$arraydata["height"], $x,$y-$arraydata["height"],$imagehtml);//,1,0,true);
             //                }
             //
             $this->pdf->Ln();
             if ($this->currentband == 'detail') {
                 if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') {
                     $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                 } else {
                     if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) {
                         $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                     }
                 }
             }
         } elseif ($arraydata["soverflow"] == "true") {
             if ($arraydata["valign"] == "C") {
                 $arraydata["valign"] = "M";
             }
             if ($arraydata["valign"] == "") {
                 $arraydata["valign"] = "T";
             }
             if ($maxheight == 0) {
                 $maxheight = $this->pdf->getNumLines($txt, $arraydata["width"]) * ($this->pdf->GetFontSize() * $this->pdf->getCellHeightRatio() + 2 * 1);
                 $maxheight = max($maxheight, $arraydata["height"]);
                 //FIXED para poder alinear verticalmente
             }
             $x = $this->pdf->GetX();
             //if($arraydata["link"])   echo $arraydata["linktarget"].",".$arraydata["link"]."<br/><br/>";
             $this->pdf->MultiCell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], $arraydata["align"], $arraydata["fill"], 1, '', '', true, 0, false, true, $maxheight, $arraydata["valign"]);
             //,$arraydata["valign"]);
             if ($this->pdf->balancetext == '' && $this->currentband == 'detail') {
                 if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') {
                     $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                 } else {
                     if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) {
                         $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                     }
                 }
             }
             //$this->pageFooter();
             if ($this->pdf->balancetext != '') {
                 $this->continuenextpageText = array('width' => $arraydata["width"], 'height' => $arraydata["height"], 'txt' => $this->pdf->balancetext, 'border' => $arraydata["border"], 'align' => $arraydata["align"], 'fill' => $arraydata["fill"], 'ln' => 1, 'x' => $x, 'y' => '', 'reset' => true, 'streth' => 0, 'ishtml' => false, 'autopadding' => true);
                 $this->pdf->balancetext = '';
                 $this->forcetextcolor_b = $this->textcolor_b;
                 $this->forcetextcolor_g = $this->textcolor_g;
                 $this->forcetextcolor_r = $this->textcolor_r;
                 $this->forcefillcolor_b = $this->fillcolor_b;
                 $this->forcefillcolor_g = $this->fillcolor_g;
                 $this->forcefillcolor_r = $this->fillcolor_r;
                 if ($this->continuenextpageText) {
                     $this->printlongtext($this->pdf->getFontFamily(), $this->pdf->getFontStyle(), $this->pdf->getFontSize());
                 }
             }
         } elseif ($arraydata["poverflow"] == "true") {
             if ($arraydata["valign"] == "M") {
                 $arraydata["valign"] = "C";
             }
             if ($arraydata["valign"] == "") {
                 $arraydata["valign"] = "T";
             }
             $this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], "", $arraydata["align"], $arraydata["fill"], $arraydata["link"] . "", 0, true, "T", $arraydata["valign"]);
             $this->pdf->Ln();
             if ($this->currentband == 'detail') {
                 if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') {
                     $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                 } else {
                     if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) {
                         $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                     }
                 }
             }
         } else {
             //MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0) {
             $this->pdf->MultiCell($arraydata["width"], $arraydata["height"], $this->formatText($txt, $arraydata["pattern"]), $arraydata["border"], $arraydata["align"], $arraydata["fill"], 1, '', '', true, 0, true, true, $maxheight);
             if ($this->pdf->balancetext == '' && $this->currentband == 'detail') {
                 if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') {
                     $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                 } else {
                     if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) {
                         $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY();
                     }
                 }
             }
             if ($this->pdf->balancetext != '') {
                 $this->continuenextpageText = array('width' => $arraydata["width"], 'height' => $arraydata["height"], 'txt' => $this->pdf->balancetext, 'border' => $arraydata["border"], 'align' => $arraydata["align"], 'fill' => $arraydata["fill"], 'ln' => 1, 'x' => $x, 'y' => '', 'reset' => true, 'streth' => 0, 'ishtml' => false, 'autopadding' => true);
                 $this->pdf->balancetext = '';
                 $this->forcetextcolor_b = $this->textcolor_b;
                 $this->forcetextcolor_g = $this->textcolor_g;
                 $this->forcetextcolor_r = $this->textcolor_r;
                 $this->forcefillcolor_b = $this->fillcolor_b;
                 $this->forcefillcolor_g = $this->fillcolor_g;
                 $this->forcefillcolor_r = $this->fillcolor_r;
                 $this->gotTextOverPage = true;
                 if ($this->continuenextpageText) {
                     $this->printlongtext($this->pdf->getFontFamily(), $this->pdf->getFontStyle(), $this->pdf->getFontSize());
                 }
             }
         }
     }
     $this->print_expression_result = false;
 }
Example #9
0
/**
 * Draws a simple question on the TCPDF object.
 * It relies on the current X,Y pointer of the TCPDF context.
 *
 * Generates some metrics about the layout.
 * retuns an object with the following structure:
 * object->coords[]->X
 *                 ->Y
 *                 ->H
 *                 ->W
 *        ->marks[]->X
 *                 ->Y
 *                 ->H
 *                 ->W
 *
 * @param $pdf
 * @param $question
 * @param $columnsWidth
 * @param $ln  Indicates where the current position should go after the call. Possible values are:
 *				0: to the right
 *				1: to the beginning of the next line
 *				2: below
 * @param $markSize
 * @param $fillMarks
 * @param $numcols
 * @param $border draws a border
 * @return object with a coords and marks properties and TCPDF object.
 */
function blended_draw_description_question(TCPDF $pdf, &$dims, $question, $columnsWidth, $ln, $markSize = 4, $fillMarks = false, $numcols = 2, $border = true)
{
    $borderDescription = true;
    $borderOption = false;
    $Xorigin = $pdf->GetX();
    $maxY = 0;
    //$lastH=$pdf->getLastH();
    $pdf->setLastH(1);
    //output question
    blended_saveXY($dims, $pdf, $question->id);
    $pdf->writeHTMLCell($columnsWidth, 1, '', '', $question->questiontext, $borderDescription, 0, 0, false);
    blended_saveWH($dims, $pdf, $question->id);
    $pdf->Ln();
    $pdf->SetX($Xorigin);
    $name = $question->id;
    blended_saveXY($dims, $pdf);
    $pdf->Cell($columnsWidth, 40, '', $borderOption, 0, '');
    blended_saveWH($dims, $pdf);
    $coord = $dims->coords[(int) (count($dims->coords) - 1)];
    $renderedY = $coord->Y + $coord->H;
    //register global dimensions
    $coord = new stdClass();
    $coord->X = $dims->coords[$question->id]->X;
    $coord->Y = $dims->coords[$question->id]->Y;
    $coord->W = $columnsWidth;
    $desc = $coord + 40;
    $coord->H = $desc;
    $dims->coords[$question->id] = $coord;
    switch ($ln) {
        case 0:
            $pdf->SetXY($coord->X + $coord->W, $coord->Y);
            break;
        case 1:
            $margins = $pdf->getMargins();
            $pdf->SetXY($margins['left'], $coord->Y + $coord->H);
            break;
        case 2:
            $pdf->SetXY($coord->X + $coord->W, $coord->Y, $coord->Y + $coord->H);
            break;
    }
    if ($border) {
        $pdf->Rect($coord->X, $coord->Y, $coord->W, $coord->H);
    }
    $pdf->setLastH($coord->H);
}