Tema: Tcpdf
Ver Mensaje Individual
  #13 (permalink)  
Antiguo 05/11/2010, 10:17
andruxand
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

hola mira es complicado hacer las pruebas con tu formulario ya que realizas varias consultas y pues no tengo la info de base de datos no nada, asi que hice una prueba sencilla que consta de un form de dos textbox y un boton, al hacer clic en el boton envia el valor de los post sin necesidad de ningun insert al pdf y lo crea aqui te dejo el codigo, es lo que puedes hacer, que al hacer clic a parte de que guarde te genere el pdf, claro que te quedaria mas organizado y mas entendible realizar el ingreso de los datos en una funcion para agrgarla en el evento onclic del boton ya que por lo que veo cuando se inserta un registro se actualiza la pagina, bueno aca te dejo el cod. para que te guies. lo puedes probar igual solo cambia el directoria donde se llaman los archivos de tcpdf:

Código PHP:
Ver original
  1. <?php
  2.  
  3. /**
  4.  * Creates an example PDF TEST document using TCPDF
  5.  * @package com.tecnick.tcpdf
  6.  * @abstract TCPDF - Example: Cell stretching
  7.  * @author Nicola Asuni
  8.  * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - [email protected]
  9.  * @link http://tcpdf.org
  10.  * @license http://www.gnu.org/copyleft/lesser.html LGPL
  11.  * @since 2008-03-04
  12.  */
  13.  
  14. require_once('../config/lang/eng.php');
  15. require_once('../tcpdf.php');
  16.  
  17.  
  18.  
  19. // create new PDF document
  20. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  21.  
  22. // set document information
  23. $pdf->SetCreator(PDF_CREATOR);
  24. $pdf->SetAuthor('Nicola Asuni');
  25. $pdf->SetTitle('TCPDF Example 004');
  26. $pdf->SetSubject('TCPDF Tutorial');
  27. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  28.  
  29. // set default header data
  30. $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 004', PDF_HEADER_STRING);
  31.  
  32. // set header and footer fonts
  33. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  34. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  35.  
  36. // set default monospaced font
  37. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  38.  
  39. //set margins
  40. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  41. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  42. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  43.  
  44. //set auto page breaks
  45. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  46.  
  47. //set image scale factor
  48. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  49.  
  50. //set some language-dependent strings
  51. $pdf->setLanguageArray($l);
  52.  
  53. // ---------------------------------------------------------
  54.  
  55. // set font
  56. $pdf->AddPage();
  57. $pdf->SetFont('helvetica','U','14');
  58. $pdf->Cell(30,10,'Asociacion de la Ciudad de Buenos Aires',0,1,'L');
  59. $pdf->Ln(5);
  60. $pdf->SetFont('helvetica','B',10);
  61. if ($_POST['sexo']=='F'){
  62. $pdf->Cell(57,10,'Se deja constancia que la señorita ',0,0,'L');
  63.  
  64. $pdf->Cell(50,10,$_POST['t1']." ".$_POST['t1'],0,1,'L');
  65. }
  66. if ($_POST['sexo']=='M'){
  67. $pdf->Cell(57,10,'Se deja constancia que el señor',0,0,'L');
  68. $pdf->Cell(50,10,$_POST['t1']." ".$_POST['t1'],0,1,'L');
  69. }
  70. $pdf->Cell(54,10,'se ha inscripto para el torneo: ',0,0,'L');
  71. $pdf->Cell(0,10,$_POST['t1'],0,1);
  72. $pdf->Cell(24,10,'Categoria : ',0,0,'L');
  73. $pdf->Cell(0,10,$_POST['t1'],0,1);
  74. $pdf->Cell(24,10,'Arma : ',0,0,'L');
  75. $pdf->Cell(20,10,$_POST['t1'],0,1);
  76. $pdf->Cell(24,10,'Sala : ',0,0,'L');
  77. $pdf->Cell(0,10,$_POST['club'],0,1);
  78. $pdf->Cell(24,10,'Maestro : ',0,0,'L');
  79. $pdf->Cell(0,10,$_POST['profesor'],0,1);
  80. $pdf->Cell(24,10,'Telefono : ',0,0,'L');
  81. $pdf->Cell(0,10,$_POST['telefono'],0,1);
  82. $fecha = date("d-m-y --- h : i : s A");
  83. $pdf->Cell(50,10,'Fecha y hora de inscripcion : ');
  84. $pdf->Cell(40,10,$fecha);
  85.  
  86.  
  87. // ---------------------------------------------------------
  88. if(isset($_POST['crear'])){
  89. //Close and output PDF document
  90. $pdf->Output('C:\Constancia_de_Inscripcion.pdf','I');
  91. }
  92.  
  93. //============================================================+
  94. // END OF FILE
  95. //============================================================+
  96. ?>
  97. <html>
  98. <head></head>
  99. <body>
  100. <form method="post">
  101. <input type="text" name="t1" value="<? echo $_POST['t1']; ?>"/><br />
  102. <input type="submit" name="crear" value="Enviar" onclick="crear()" />
  103. <br />
  104. <input type="text" name="t2" value="<? echo $_POST['t2']; ?>" />
  105.  
  106. </form>
  107. </body>
  108.  
  109.  
  110. </html>

Última edición por andruxand; 05/11/2010 a las 10:25