Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/12/2014, 21:13
marisanjr03
 
Fecha de Ingreso: diciembre-2014
Ubicación: Cali
Mensajes: 20
Antigüedad: 12 años
Puntos: 0
Pregunta Notice: Undefined offset en tcpdf

Buenas noches. He echo varias reportes en pdf usando la libreria TCPDF. Todo me funcionaba muy bien hasta que cambie de MySQL a MySQLI. Lo que antes me funcinaba con las consultas MySQL ya no me funciona: Me aparece el siguiente mensaje:
Notice: Undefined offset para o , 1,2,3...

en estas líneas

Código PHP:
    $this->Cell($w[0], 6, $row[0], 'LR', 0, 'L', $fill);
            
$this->Cell($w[1], 6, $row[1], 'LR', 0, 'L', $fill);
            
$this->Cell($w[2], 6, utf8_encode($row[2]), 'LR', 0, 'L', $fill);
            
$this->Cell($w[3], 6, $row[3], 'LR', 0, 'L', $fill);
            
$this->Cell($w[4], 6, number_format($row[4]), 'LR', 0, 'R', $fill);
            
$this->Cell($w[5], 6, $row[5], 'LR', 0, 'L', $fill);
            
$this->Cell($w[6], 6, $row[6], 'LR', 0, 'L', $fill);
            
$this->Cell($w[7], 7, $row[7], 'LR', 0, 'L', $fill); 
Por favor me pueden ayudar. Este mismo mensaje me lo muestra en las paginas php y he solucionado colocando el campo. $fila[0] lo cambio por $fila['nombre_campo']. Pero en el archivo que convierte a pdf no lo hace.
me sale: TCPDF ERROR: Some data has already been output, can't send PDF file

Anexo código

Código PHP:
require_once('/config/eng.php');
require_once(
'../tcpdf/tcpdf.php');
class 
MYPDF extends TCPDF {

    
// Colored table
    
public function ColoredTable($header,$data) {
        
// Colors, line width and bold font
        
$this->SetFillColor(255, 0, 0);
        
$this->SetTextColor(255);
        
$this->SetDrawColor(128, 0, 0);
        
$this->SetLineWidth(0.3);
        
$this->SetFont('', 'B');
        
// Header
        
$w = array(13, 18, 32, 40, 18, 50, 20,20);
        
$num_headers = count($header);
        for(
$i = 0; $i < $num_headers; ++$i) {
          
$this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
        }
        
$this->Ln();
        
// Color and font restoration
        
$this->SetFillColor(224, 235, 255);
        
$this->SetTextColor(0);
        
$this->SetFont('');
        
// Data
        
$fill = 0;
        foreach(
$data as $row) {
            
$this->Cell($w[0], 6, $row['codcomuna'], 'LR', 0, 'L', $fill);
            
$this->Cell($w[1], 6, $row['nrodoc'], 'LR', 0, 'L', $fill);
            
$this->Cell($w[2], 6, utf8_encode($row['nomcor']), 'LR', 0, 'L', $fill);
            
$this->Cell($w[3], 6, $row['apecor'], 'LR', 0, 'L', $fill);
            
$this->Cell($w[4], 6, number_format($row['vofcor']), 'LR', 0, 'R', $fill);
            
$this->Cell($w[5], 6, $row['dircor'], 'LR', 0, 'L', $fill);
            
$this->Cell($w[6], 6, $row['telcor'], 'LR', 0, 'L', $fill);
            
$this->Cell($w[7], 7, $row['celcor'], 'LR', 0, 'L', $fill);
            
$this->Ln();
            
$fill=!$fill;
        }
        
$this->Cell(array_sum($w), 0, '', 'T');
    }
}

// create new PDF document
$pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Jordi Girones');
$pdf->SetTitle('TCPDF Tutorial - TCPDF + MySQL');
$pdf->SetSubject('TCPDF Tutorial - TCPDF + MySQL');
$pdf->SetKeywords('TCPDF, PDF, example, test, mysql');

// set default header data
$pdf->SetHeaderData('', PDF_HEADER_LOGO_WIDTH,PDF_HEADER_TITLE.'', 'LISTADO DE COORDINADORES --TOTAL VOTOS OFRECIDOS: '.$totalv);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica', '', 7);

// add a page
$pdf->AddPage();

//Column titles
$header = array('COMUNA', 'CEDULA', 'NOMBRE', 'APELLIDO', 'V. OFREC', 'DIRECCION', 'TELEFONO', 'CELULAR');

//Data loading
$query="SELECT coordinazona.codcomuna, coordinador.nrodoc, coordinador.nomcor, coordinador.apecor, coordinador.vofcor, coordinador.dircor, coordinador.telcor, coordinador.celcor
FROM coordinazona INNER JOIN coordinador ON coordinazona.codcor = coordinador.codcor ORDER BY coordinazona.codcomuna ASC"
;
$rs=$conexion->query($query);
while(
$rw = mysqli_fetch_assoc($rs)){
        
$data[] = $rw;
 }


// print colored table
$pdf->ColoredTable($header, $data);

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('listado01.pdf', 'I');