Ver Mensaje Individual
  #12 (permalink)  
Antiguo 14/03/2012, 14:52
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Centrar tabla en XHTML

Cita:
Iniciado por zerart245 Ver Mensaje
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
  1. <?php
  2.  
  3. require_once('../config/lang/eng.php');
  4. require_once('../tcpdf.php');
  5.  
  6. // create new PDF document
  7. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  8.  
  9. // set document information
  10. $pdf->SetCreator(PDF_CREATOR);
  11. $pdf->SetAuthor('Nicola Asuni');
  12. $pdf->SetTitle('TCPDF Example 061');
  13. $pdf->SetSubject('TCPDF Tutorial');
  14. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  15.  
  16. // set default header data
  17. //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING);
  18.  
  19. // set header and footer fonts
  20. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  21. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  22.  
  23. // set default monospaced font
  24. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  25.  
  26. //set margins
  27. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  28. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  29. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  30.  
  31. //set auto page breaks
  32. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  33.  
  34. //set image scale factor
  35. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  36.  
  37. //set some language-dependent strings
  38. $pdf->setLanguageArray($l);
  39.  
  40. // ---------------------------------------------------------
  41.  
  42. // set font
  43. $pdf->SetFont('helvetica', '', 10);
  44.  
  45. // add a page
  46. $pdf->AddPage();
  47.  
  48. /* NOTE:
  49.  * *********************************************************
  50.  * You can load external XHTML using :
  51.  *
  52.  * $html = file_get_contents('/path/to/your/file.html');
  53.  *
  54.  * External CSS files will be automatically loaded.
  55.  * Sometimes you need to fix the path of the external CSS.
  56.  * *********************************************************
  57.  */
  58.  
  59. // define some HTML content with style
  60. $html = <<<EOF
  61. <!-- EXAMPLE OF CSS STYLE -->
  62. <style>
  63. html,body{
  64. height: 100%;
  65. }
  66.  
  67. p {
  68. height: 300px;
  69. }
  70. </style>
  71. <table>
  72. <tr><td>
  73. <p><br /><!-- s --><br /><!-- s --><br /><br /><br /><br /></p>
  74. </td></tr></table>
  75. <table style="height:100%; width: 100%;margin-top: 200px;" border="1">
  76. <tr>
  77.     <td align="center" valign="middle">
  78.  
  79. <table cellpadding="8" cellspacing="0" border="0" style="text-align:left; width:640px">
  80. <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">
  81. <table id="tabla" cellpadding="0" cellspacing="0" border="0" style="text-align:left; width:500px">
  82. <tr><td  style="padding:6px;" width="135">Apellidos y nombres </td><td style="padding:6px;" width="350"><strong>'.$nom.'</strong></td></tr>
  83. <tr><td  style="padding:6px;" width="135">'.$tip_doc.'</td><td style="padding:6px;" width="350"><strong>'.$dni.'</strong></td></tr>
  84. <tr><td  style="padding:6px;" width="135">Fecha de nacimiento </td><td style="padding:6px;" width="350"><strong>'.$fec_nac.'</strong></td></tr>
  85. <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>
  86. <tr><td  style="padding:6px;" width="135">Tel&eacute;fonos</td><td style="padding:6px;" width="350"><strong>'.$telefonos.'</strong></td></tr>
  87. <tr><td  style="padding:6px;" width="135">Correos electr&oacute;nicos </td><td   style="padding:6px;" width="350"><strong>'.$correos.'</strong></td></tr>
  88. </table></td></tr></table>
  89.  
  90. </td>
  91. </tr>
  92. </table>  
  93. EOF;
  94.  
  95. // output the HTML content
  96. $pdf->writeHTML($html, true, false, true, false, '');
  97.  
  98. *******************************************************************
  99.  
  100. // reset pointer to the last page
  101. $pdf->lastPage();
  102.  
  103. // ---------------------------------------------------------
  104.  
  105. //Close and output PDF document
  106. $pdf->Output('example_061.pdf', 'I');
  107.  
  108. ?>
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.