Cita:
Iniciado por zerart245 Probé por todos los métodos que pude el centrado vertical pero en TCPDF no lo hace.
Lo qu pasa es que esa librería tiene tres millones de opciones, no alcanza con el html.
Algo se puede lograr, pero no dispongo de tiempo para estudiar todas las opciones
Código PHP:
Ver original<?php
require_once('../config/lang/eng.php');
require_once('../tcpdf.php');
// 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 061');
$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.' 061', 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
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
/* NOTE:
* *********************************************************
* You can load external XHTML using :
*
* $html = file_get_contents('/path/to/your/file.html');
*
* External CSS files will be automatically loaded.
* Sometimes you need to fix the path of the external CSS.
* *********************************************************
*/
// define some HTML content with style
$html = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
html,body{
height: 100%;
}
p {
height: 300px;
}
</style>
<table>
<tr><td>
<p><br /><!-- s --><br /><!-- s --><br /><br /><br /><br /></p>
</td></tr></table>
<table style="height:100%; width: 100%;margin-top: 200px;" border="1">
<tr>
<td align="center" valign="middle">
<table cellpadding="8" cellspacing="0" border="0" style="text-align:left; width:640px">
<tr><td width="40" ></td><td align="center" border="1" style="padding:6px; text-align:center " width="115"></td><td border="1" style="padding:6px;" width="485">
<table id="tabla" cellpadding="0" cellspacing="0" border="0" style="text-align:left; width:500px">
<tr><td style="padding:6px;" width="135">Apellidos y nombres </td><td style="padding:6px;" width="350"><strong>'.$nom.'</strong></td></tr>
<tr><td style="padding:6px;" width="135">'.$tip_doc.'</td><td style="padding:6px;" width="350"><strong>'.$dni.'</strong></td></tr>
<tr><td style="padding:6px;" width="135">Fecha de nacimiento </td><td style="padding:6px;" width="350"><strong>'.$fec_nac.'</strong></td></tr>
<tr><td style="padding:6px;" width="135">Estado civil </td><td style="padding:6px;" width="350"><strong>'.$estado.'</strong></td></tr><tr><td style="padding:6px;" width="135">Sexo</td><td style="padding:6px;" width="350"><strong>'.$sexo.'</strong></td></tr>
<tr><td style="padding:6px;" width="135">Teléfonos</td><td style="padding:6px;" width="350"><strong>'.$telefonos.'</strong></td></tr>
<tr><td style="padding:6px;" width="135">Correos electrónicos </td><td style="padding:6px;" width="350"><strong>'.$correos.'</strong></td></tr>
</table></td></tr></table>
</td>
</tr>
</table>
EOF;
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
*******************************************************************
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_061.pdf', 'I');
?>