Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/03/2009, 10:59
Koden
 
Fecha de Ingreso: marzo-2005
Mensajes: 197
Antigüedad: 19 años, 2 meses
Puntos: 1
Respuesta: Problema con ezPDF

Solucionado una vez más.

Veréis, me extrañaba sobremanera el tag <c> (del que no había escuchado nada en la vida y del que desconfiaba por aquello de que Google no sabía decirme nada sobre él)

Husmeando por el código de class.ezpdf.php encontré que se hacía alusión a él como callback function, así que busqué una función que se llamase uline (al fin y al cabo la función que yo buscaba se referenciaba así "c:uline")

Y la encontré, era una función tal que así:

Código PHP:
function uline($info){
  
// a callback function to support underlining
  
$lineFactor=0.05// the thickness of the line as a proportion of the height. also the drop of the line.
  
switch($info['status']){
    case 
'start':
    case 
'sol':
    
      
// the beginning of the underline zone
      
if (!isset($this->ez['links'])){
        
$this->ez['links']=array();
      }
      
$i $info['nCallback'];
      
$this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height']);
      
$this->saveState();
      
$thick $info['height']*$lineFactor;
      
$this->setLineStyle($thick);
      break;
    case 
'end':
    case 
'eol':
      
// the end of the link
      // assume that it is the most recent opening which has closed
      
$i $info['nCallback'];
      
$start $this->ez['links'][$i];
      
// add underlining
      
$a deg2rad((float)$start['angle']-90.0);
      
$drop $start['height']*$lineFactor*1.5;
      
$dropx cos($a)*$drop;
      
$dropy = -sin($a)*$drop;
      
$this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
      
$this->restoreState();
      break;
  }

Fué facil percatarse de que tanto los casos start como end del bucle switch eran las acciones que la función tomaba en caso de abrir o cerrar el tag <u>, y como yo lo que quería era poner el texto rojo, simplemente se lo indiqué con la función de la clase setColor. Al final la dejé así:

Código PHP:
function uline($info){
  
// a callback function to support underlining
  
$lineFactor=0.05// the thickness of the line as a proportion of the height. also the drop of the line.
  
switch($info['status']){
    case 
'start':
                
//Indico que de comenzar el tag, lo escriba todo en rojo
        
$this->setColor(255,0,0);
        break;
    case 
'sol':
    
      
// the beginning of the underline zone
      
if (!isset($this->ez['links'])){
        
$this->ez['links']=array();
      }
      
$i $info['nCallback'];
      
$this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height']);
      
$this->saveState();
      
$thick $info['height']*$lineFactor;
      
$this->setLineStyle($thick);
      break;
    case 
'end':
                
//Al cerrar el tag, le indico que pinte el resto del documento negro
        
$this->setColor(0,0,0);
        break;
    case 
'eol':
      
// the end of the link
      // assume that it is the most recent opening which has closed
      
$i $info['nCallback'];
      
$start $this->ez['links'][$i];
      
// add underlining
      
$a deg2rad((float)$start['angle']-90.0);
      
$drop $start['height']*$lineFactor*1.5;
      
$dropx cos($a)*$drop;
      
$dropy = -sin($a)*$drop;
      
$this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
      
$this->restoreState();
      break;
  }

Así podréis conseguir pintar solo ciertas celdas de una tabla generada con ezpdf en el color que queráis, siempre y cuando defináis un tag que no vayáis a usar (en mi caso la letra subrayada)

¡Un saludo a todos!