Programación Web y Scripting > PHP

 Problemas para centrar texto???

(1/1)

Leonardo241:
Tengo un problema con una tabla que se genera en un pdf, ya que no he podido centrar el texto que aparece en ella, ni los valores de alguna variables que deben aparecer, si alguien me puede ayudar muchas gracias, dejo el código que tengo:

.
.
.
$titles = array('1'=> "<b>                                                         ASIGNATURA - DOCENTE</b>",'2'=>"<b>  PROM.\nPERIODO</b>",'3'=>"<b>DESEMPEÑO  </b>",'4'=>"<b>PROM\n AÑO</b>");
.
.
.
$data[] = array('1'=>$nombre_ejeT.". Docente: ".$nomDocente." ".$apeDocente."\n\n<b>*SER: </b>".$ser."\n\n<b>*SABER: </b>".$saber."\n\n<b>*HACER: </b>".$hacer,
                     '2'=>"\n\n".$prom_periodo, (array('justification' => 'center')),
                     '3'=>"\n\n".$desem,array('justification' => 'center'),
                     '4'=>"\n\n".$prom_anio);array('justification' => 'center');
.
.
.

RadicalEd:
no especificas muy bien cómo creas el pdf, si estás usando una libreria con sus clases, cómo es la abstracción de esa clase

Leonardo241:
Este es el código que tengo:

<?php
 header("Content-type: text/html; charset=iso-8859-1");  // español
 include_once "../db/base_anotador.php";
 include_once "../db/table.php";
 include_once "../db/admin.php";
require_once('class.ezpdf.php');
$pdf =& new Cezpdf('a4');
$pdf->selectFont('../fonts/Helvetica-Bold.afm');
$pdf->ezSetCmMargins(1,1,1.5,1.5);

$id_est = $_REQUEST['idEst'];

//$id_est = 14;

$tbl = new table('pensum', $base);
$tbl2 = new table('matricula', $base);
$tbl3 = new table('curso', $base);
$tbl4 = new table('grado', $base);
$tbl5 = new table('valoracion', $base);
$tbl6 = new table('estudiante', $base);
$tbl7 = new table('plan_area', $base);
$tbl8 = new table('desempenio', $base);
$tbl9 = new table('eje_tematico', $base);
$tb2 = new table('escala_valoracion', $base);
$tableasig = new table('asignacion', $base);
$tableDocente = new table('docente', $base);

$tbl6->Select('nombre_estudiante, apellido', "id_estudiante = '$id_est'");
$nombre = $tbl6->nombre_estudiante;
$apellido = $tbl6->apellido;
$nombreEst = $nombre." ".$apellido; // nombre del estudiante

$tbl2->Select('id_curso', "id_estudiante = '$id_est'");
$id_cursoM = $tbl2->id_curso;

$tbl3->Select('id_grado,seccion', "id_curso = '$id_cursoM'");
$id_gradoC = $tbl3->id_grado;
$seccion = $tbl3->seccion;

$tbl4->Select('grado', "id_grado = '$id_gradoC'");
$curso_name = $tbl4->grado." ".$seccion;

$pdf->ezImage("images/enc_notas.jpg", 0, 500, 'none', 'left');
$pdf->ezText("ESTUDIANTE: ".$nombreEst."\t\t\t\t\t\t\t\t\t\t\t\t"."CURSO: ".$curso_name, 8, array('justification' => 'left'));
$pdf->ezText("\n\nPERIODO: "."PRIMERO"."\t\t\t\t\t\t\t\t\t\t\t\t"."AÑO LECTIVO: ".date("Y"), 8, array('justification' => 'left'));
$pdf->ezText("\n", 10);

$titles = array('1'=> "<b>                                                         ASIGNATURA - DOCENTE</b>",'2'=>"<b>  PROM.\nPERIODO</b>",'3'=>"<b>DESEMPEÑO  </b>",'4'=>"<b>PROM\n AÑO</b>");
$options = array('showLines'=>3,
                'lineCol' => array(0.4,0.4,0.4),
            'titleFontSize' => 8,
            'showHeadings'=>1,
            'shaded'=>0,
            'shadeCol'=>array(0.9,0.9,0.9),
            'rowGap'=>5,
            'colGap'=>5,
            'xPos'=>'center',
            'xOrientation'=>'center',
            'yPos'=>'center',
            'yOrientation' => 'center',
            'width'=>500,
            'fontSize'=>8);

$tbl->Select('*'); $pensum = $tbl->rs; //tomo las materias que mira el estudiante segun el grado
$cont = 1;
while(!$pensum->EOF)
{
   $id_gradoP = $pensum->fields['id_grado'];
   $periodo = $pensum->fields['periodo'];
   if(($id_gradoP == $id_gradoC) and ($periodo == 1)) // tomo grado de est y periodo 1
   {
      $id_ejeP = $pensum->fields['id_eje_tematico'];
      $id_pensum = $pensum->fields['id_pensum'];
      
      $tbl9->Select('nombre_eje_tematico', "id_eje_tematico = '$id_ejeP'");
      $nombre_ejeT = $tbl9->nombre_eje_tematico;
      
      $tableasig->Select('id_docente', "((id_curso = '$id_cursoM') AND (id_eje_tematico = '$id_ejeP'))");
      $id_docente = $tableasig->id_docente;
      
      $tableDocente->Select('nombre_docente, apellido_docente', "id_docente = '$id_docente'");
      $nomDocente = $tableDocente->nombre_docente;
      $apeDocente = $tableDocente->apellido_docente;
      
      $id_planP = $pensum->fields['id_plan_area'];
      $tbl7->Select('id_desempenio', "id_plan_area = '$id_planP'"); //para sacar ser saber y hacer
      $id_des = $tbl7->id_desempenio;
      $tbl8->Select('ser,saber,hacer', "id_desempenio = '$id_des'");
      $ser = $tbl8->ser;
      $saber = $tbl8->saber;
      $hacer = $tbl8->hacer;
      
      $tbl5->Select('*', "((id_pensum = '$id_pensum') AND (id_estudiante = '$id_est'))");
      $prom_periodo = $tbl5->prom_periodo;
      $id_escala = $tbl5->id_escala;
      $prom_anio = $tbl5->prom_anio;
      
      $tb2->Select('desempenio', "id_escala = '$id_escala'");
      $desem = $tb2->desempenio;
      
      $data[] = array('1'=>$nombre_ejeT.". Docente: ".$nomDocente." ".$apeDocente."\n\n<b>*SER: </b>".$ser."\n\n<b>*SABER: </b>".$saber."\n\n<b>*HACER: </b>".$hacer,
                     '2'=>"\n\n".$prom_periodo, (array('justification' => 'center')),
                     '3'=>"\n\n".$desem,array('justification' => 'center'),
                     '4'=>"\n\n".$prom_anio);array('justification' => 'center');
   }
   $pensum->MoveNext();
}

$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n\n", 10);
$pdf->ezText("OBSERVACIÓN: ________________________________________________________________________________________________", 8);
$pdf->ezText("\n  _____________________________________________________________________________________________________________", 8);
$pdf->ezText("\n\n\n\n", 10);
$pdf->ezText("             __________________________"."                                      "."__________________________", 8,array('justification' => 'center'));
$pdf->ezText("DIRECTOR(A) DE GRUPO"."                                                         "."RECTOR(A)", 8,array('justification' => 'center'));
$pdf->ezText("\n\n\n", 10);
$pdf->ezText("<b>Fecha:</b> ".date("d/m/Y"), 10);
$pdf->ezStream();

?>

RadicalEd:
no he usado la libreria, pero veo que puedes usar etiquetas HTML, por que en vez de usar 'justificacion'=>'center', no lo haces con <center></center> o <div align="center"></div>, prueba con eso a ver si te funciona, cualquier cosa avisas

Navegación

[0] Índice de Mensajes

Ir a la versión completa