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

hola juancondarts mira aqui ya hice un ejemplo de lo que necesitas pero un poco mas sencillo este ejemplo me permite actulizar segun el valor que ingrese en las casillas de texto, y genera el pdf a la vez con los datos ingresados en las casllas de texto, obviamente si puede actualizar y generar el pdf a la vez funcionara insertando registros, aca te dejo el ejemplo solo debes agregar tu consulta o consultas, la conexion a tu base de datos.

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

cualquier duda avisas,

saludos!!.