Foros del Web » Programando para Internet » PHP »

Tcpdf

Estas en el tema de Tcpdf en el foro de PHP en Foros del Web. Buen día, me pasa lo siguiente. Tengo un codigo php en el que quiero generar un pdf con ciertos datos de un formulario. El problema ...
  #1 (permalink)  
Antiguo 05/11/2010, 08:11
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Tcpdf

Buen día, me pasa lo siguiente.
Tengo un codigo php en el que quiero generar un pdf con ciertos datos de un formulario.
El problema se presenta cuando quiero hacer el output.

Cuando pongo :
$pdf->Output('C:\Constancia_de_Inscripcion.pdf','F');
se genera el archivo llamado "Constancia_de_Inscripcion" y se guarda en la raiz del C:

Hasta aca todo bien, el problema es cuando quiero que me muestre el pdf.

Cuando pongo :

$pdf->Output('C:\Constancia_de_Inscripcion.pdf','I');

me muestra en pantalla el codigo de la pagina (?¿?¿)

Alguien me puede ayudar con esto?



PD: lo que me muestra en pantalla es (solo una parte) :

e {
font-family: Arial, Helvetica, sans-serif;
color: #666;
}
.REALIZARINSCRIPCION {
color: #FFF;
}
#apDiv1 {
position:absolute;
left:810px;
top:11px;
width:60px;
height:20px;
z-index:1;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


y asi sigue ...
  #2 (permalink)  
Antiguo 05/11/2010, 08:38
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

prueba con:

$pdf->Output('C:\Constancia_de_Inscripcion.pdf', 'I'); 'I' mayuscula.

cualquier cosa avisas, saludos.
  #3 (permalink)  
Antiguo 05/11/2010, 08:40
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Esta escrito en mayuscula.
Lo probe con mayuscula y con minuscula y no funciona de ninguna de las dos maneras.

Sabes donde puedo bajar un manual de tcpdf?
  #4 (permalink)  
Antiguo 05/11/2010, 08:42
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

ok perfecto entonces mira AQUI hay muchos ejemplos para el uso de tcpdf, cualquier duda avisas bueno.

saludos
  #5 (permalink)  
Antiguo 05/11/2010, 08:44
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

El codigo completo de la creacion del pdf es asi :

require_once('/tcpdf_5_9_011/tcpdf/tcpdf.php');
require_once('/tcpdf_5_9_011/tcpdf/config/lang/spa.php');


$pdf=new TCPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('helvetica','U','14');
$pdf->Cell(30,10,'Asociacion de la Ciudad de Buenos Aires',0,1,'L');
$pdf->Ln(5);
$pdf->SetFont('helvetica','B',10);
if ($_POST['sexo']=='F'){
$pdf->Cell(57,10,'Se deja constancia que la señorita ',0,0,'L');

$pdf->Cell(50,10,$_POST['Nombre']." ".$_POST['Apellido'],0,1,'L');
}
if ($_POST['sexo']=='M'){
$pdf->Cell(57,10,'Se deja constancia que el señor',0,0,'L');
$pdf->Cell(50,10,$_POST['Nombre']." ".$_POST['Apellido'],0,1,'L');
}
$pdf->Cell(54,10,'se ha inscripto para el torneo: ',0,0,'L');
$pdf->Cell(0,10,$_POST['nombretorneo'],0,1);
$pdf->Cell(24,10,'Categoria : ',0,0,'L');
$pdf->Cell(0,10,$_POST['categoria'],0,1);
$pdf->Cell(24,10,'Arma : ',0,0,'L');
$pdf->Cell(20,10,$_POST['deporte'],0,1);
$pdf->Cell(24,10,'Sala : ',0,0,'L');
$pdf->Cell(0,10,$_POST['club'],0,1);
$pdf->Cell(24,10,'Maestro : ',0,0,'L');
$pdf->Cell(0,10,$_POST['profesor'],0,1);
$pdf->Cell(24,10,'Telefono : ',0,0,'L');
$pdf->Cell(0,10,$_POST['telefono'],0,1);
$fecha = date("d-m-y --- h : i : s A");
$pdf->Cell(50,10,'Fecha y hora de inscripcion : ');
$pdf->Cell(40,10,$fecha);
$pdf->Output('C:\Constancia_de_Inscripcion.pdf','I');
  #6 (permalink)  
Antiguo 05/11/2010, 08:59
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

antes del Output prueba colocar de nuevo $pdf->AddPage(); y por cierto como recibes esas variables $_POST???? por que parametro ???, AQUI te dejo un ejemplo de como trabajar con cell en tcpdf.

saludos
  #7 (permalink)  
Antiguo 05/11/2010, 09:07
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Las $_POST son todas las variables que fueron ingresadas al formulario de inscripcion y enviadas a la base de datos.
Lo que me extraña es que se genera bien el pdf, porque con el output con 'F' se graba correctamente el pdf como quiero, pero no lo muestra en pantalla.
  #8 (permalink)  
Antiguo 05/11/2010, 09:20
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

ok dejame yo hago algunas pruebas con tu codigo y te aviso, pero la pregunta de nuevo, se qu esas variables $_POST es la informacion que traes de la base de datos, pero donde esta el query? o la consulta??? mandame todo el codigo para hacer las pruebas correctamente.

saludos
  #9 (permalink)  
Antiguo 05/11/2010, 09:28
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Esta es la primer mitad del codigo , a continuacion te mando la segunda mitad



<?php require_once('Connections/ingresotiradores.php'); ?>
<?php require_once('Connections/admin_fecba.php'); ?>
<?php
//require('/fpdf16/fpdf.php');
require_once('/tcpdf_5_9_011/tcpdf/tcpdf.php');
require_once('/tcpdf_5_9_011/tcpdf/config/lang/spa.php');

//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "inicio.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "loginainscripcion.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}


$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO inscripciones (nombretorneo, Apellido, sexo, mail, categoria, arma, sala, maestro, provincia, telefono, Nombre) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombretorneo'], "text"),
GetSQLValueString($_POST['Apellido'], "text"),
GetSQLValueString($_POST['sexo'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['categoria'], "text"),
GetSQLValueString($_POST['arma'], "text"),
GetSQLValueString($_POST['sala'], "text"),
GetSQLValueString($_POST['maestro'], "text"),
GetSQLValueString($_POST['provincia'], "text"),
GetSQLValueString($_POST['telefono'], "text"),
GetSQLValueString($_POST['Nombre'], "text"));

mysql_select_db($database_ingresotiradores, $ingresotiradores);
$Result1 = mysql_query($insertSQL, $ingresotiradores) or die(mysql_error());



$insertGoTo = "inicio.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}






// class PDF extends FPDF
// {
// //Cabecera de página
// function Header()
// {
// $this->Image('Logo_Fecba.jpg',10,10,100);
// $this->SetFont('Arial','','14');
// $this->Cell(0,10,'Federación de Esgrima mde la Ciudad de Buenos Aires',1,0,'R');
// }
// }



$pdf=new TCPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('helvetica','U','14');
$pdf->Cell(30,10,'Federacion de Esgrima de la Ciudad de Buenos Aires',0,1,'L');
$pdf->Ln(5);
$pdf->SetFont('helvetica','B',10);
if ($_POST['sexo']=='F'){
$pdf->Cell(57,10,'Se deja constancia que la tiradora ',0,0,'L');

$pdf->Cell(50,10,$_POST['Nombre']." ".$_POST['Apellido'],0,1,'L');
}
if ($_POST['sexo']=='M'){
$pdf->Cell(57,10,'Se deja constancia que el tirador ',0,0,'L');
$pdf->Cell(50,10,$_POST['Nombre']." ".$_POST['Apellido'],0,1,'L');
}
$pdf->Cell(54,10,'se ha inscripto para el torneo: ',0,0,'L');
$pdf->Cell(0,10,$_POST['nombretorneo'],0,1);
$pdf->Cell(24,10,'Categoria : ',0,0,'L');
$pdf->Cell(0,10,$_POST['categoria'],0,1);
$pdf->Cell(24,10,'Arma : ',0,0,'L');
$pdf->Cell(20,10,$_POST['arma'],0,1);
$pdf->Cell(24,10,'Sala : ',0,0,'L');
$pdf->Cell(0,10,$_POST['sala'],0,1);
$pdf->Cell(24,10,'Maestro : ',0,0,'L');
$pdf->Cell(0,10,$_POST['maestro'],0,1);
$pdf->Cell(24,10,'Telefono : ',0,0,'L');
$pdf->Cell(0,10,$_POST['telefono'],0,1);
$fecha = date("d-m-y --- h : i : s A");
$pdf->Cell(50,10,'Fecha y hora de inscripcion : ');
$pdf->Cell(40,10,$fecha);
$pdf->AddPage();


$pdf->Output('C:\Constancia_de_Inscripcion.pdf' , 'F');





header(sprintf("Location: %s", $insertGoTo));



















}


mysql_select_db($database_ingresotiradores, $ingresotiradores);
$query_Seleccionartorneos = "SELECT * FROM basetorneos WHERE habilitada = 'Y'";
$Seleccionartorneos = mysql_query($query_Seleccionartorneos, $ingresotiradores) or die(mysql_error());
$row_Seleccionartorneos = mysql_fetch_assoc($Seleccionartorneos);
$totalRows_Seleccionartorneos = mysql_num_rows($Seleccionartorneos);

$colname_quienentro = "-1";
if (isset($_GET['id'])) {
$colname_quienentro = $_GET['id'];
}
mysql_select_db($database_ingresotiradores, $ingresotiradores);
$query_quienentro = sprintf("SELECT Apellido, sexo, mail, numdoc, Nombre FROM basetiradores WHERE numdoc = %s", GetSQLValueString($colname_quienentro, "int"));
$quienentro = mysql_query($query_quienentro, $ingresotiradores) or die(mysql_error());
$row_quienentro = mysql_fetch_assoc($quienentro);
$totalRows_quienentro = mysql_num_rows($quienentro);

mysql_select_db($database_admin_fecba, $admin_fecba);
$query_salas = "SELECT * FROM basesalas";
$salas = mysql_query($query_salas, $admin_fecba) or die(mysql_error());
$row_salas = mysql_fetch_assoc($salas);
$totalRows_salas = mysql_num_rows($salas);


?>
  #10 (permalink)  
Antiguo 05/11/2010, 09:29
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Esta es la segunda mitad, gracias por la ayuda





!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inscripcion a Competencias</title>
<style type="text/css">
<!--
body,td,th {
color: #900;
}
body {
background-color: #999;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#form1 table tr td h2 {
font-family: Arial, Helvetica, sans-serif;
}
#form1 table {
font-family: Arial, Helvetica, sans-serif;
color: #666;
}
.REALIZARINSCRIPCION {
color: #FFF;
}
#apDiv1 {
position:absolute;
left:810px;
top:11px;
width:60px;
height:20px;
z-index:1;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
//-->
</script>
</head>

<body onload="MM_preloadImages('Volver_down.gif','Volver _over.gif')">
<div id="apDiv1"><a href="inicio.php" target="barrabotones" onclick="MM_nbGroup('down','group1','Volver','Volv er_down.gif',1)" onmouseover="MM_nbGroup('over','Volver','Volver_ov er.gif','',1)" onmouseout="MM_nbGroup('out')"><img src="Volver.gif" alt="" name="Volver" width="60" height="20" border="0" id="Volver" onload="" /></a><br />
</div>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="82%" border="0" align="center">
<tr>
<td colspan="7" align="center"><h2>INSCRIPCION A COMPETENCIAS

</h2></td>
</tr>
<tr>
<td colspan="7" bgcolor="#999999">Tirador :
<input name="apenom" type="text" id="apenom" value="<?php echo $row_quienentro['Apellido'].", ".$row_quienentro['Nombre'] ; ?>" size="50" />
N° Documento : <?php echo number_format($row_quienentro['numdoc'],0,".",","); ?></td>
</tr>
<tr>
<td width="8%">&nbsp;</td>
<td width="13%"><input name="sexo" type="hidden" id="sexo" value="<?php echo $row_quienentro['sexo']; ?>" />
<input name="mail" type="hidden" id="mail" value="<?php echo $row_quienentro['mail']; ?>" />
<input name="Apellido" type="hidden" id="Apellido" value="<?php echo $row_quienentro['Apellido']; ?>" />
<input name="Nombre" type="hidden" id="Nombre" value="<?php echo $row_quienentro['Nombre']; ?>" /></td>
<td width="50%">&nbsp;</td>
<td width="10%">&nbsp;</td>
<td width="3%">&nbsp;</td>
<td width="6%">&nbsp;</td>
<td width="10%">&nbsp;</td>
</tr>
<tr>
<td colspan="7" align="center"><select name="nombretorneo" id="nombretorneo">
<option value="">Seleccione el torneo en el que desea inscribirse</option>
<?php
do {
?>
<option value="<?php echo $row_Seleccionartorneos['nombretorneo']?>"><?php echo $row_Seleccionartorneos['nombretorneo']?></option>
<?php
} while ($row_Seleccionartorneos = mysql_fetch_assoc($Seleccionartorneos));
$rows = mysql_num_rows($Seleccionartorneos);
if($rows > 0) {
mysql_data_seek($Seleccionartorneos, 0);
$row_Seleccionartorneos = mysql_fetch_assoc($Seleccionartorneos);
}
?>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Promocional </td>
<td><input type="radio" name="categoria" id="categoria" value="Promocional" /></td>
<td>Espada</td>
<td><input type="radio" name="arma" id="espada" value="Espada" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Pre-Mini</td>
<td><input type="radio" name="categoria" id="categoria2" value="Pre-mini" /></td>
<td>Florete</td>
<td><input type="radio" name="arma" id="florete" value="Florete" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Mini</td>
<td><input type="radio" name="categoria" id="categoria3" value="Mini" /></td>
<td>Sable</td>
<td><input type="radio" name="arma" id="sable" value="Sable" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Menores</td>
<td><input type="radio" name="categoria" id="categoria4" value="Menores" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Mayores</td>
<td><input type="radio" name="categoria" id="categoria5" value="Mayores" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Sala :</td>
<td><label>
<select name="sala" id="sala">
<?php
do {
?>
<option value="<?php echo $row_salas['nombresala']?>"><?php echo $row_salas['nombresala']?></option>
<?php
} while ($row_salas = mysql_fetch_assoc($salas));
$rows = mysql_num_rows($salas);
if($rows > 0) {
mysql_data_seek($salas, 0);
$row_salas = mysql_fetch_assoc($salas);
}
?>
</select>
</label></td>
<td colspan="4" align="center" bgcolor="#000066" class="REALIZARINSCRIPCION">REALIZAR INSCRIPCION</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Maestro :</td>
<td><input name="maestro" type="text" id="maestro" size="30" maxlength="30" /></td>
<td colspan="4" rowspan="3" align="center" bgcolor="#000066"><input type="submit" name="INSCRIBIR" id="INSCRIBIR" value="INSCRIBIR EN COMPETENCIA" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Provincia :</td>
<td><select name="provincia" id="provincia">
<option value="C.A.B.A." selected="selected">C.A.B.A.</option>
<option value="Buenos Aires">Buenos Aires</option>
<option value="Cordoba">Cordoba</option>
<option value="Mendoza">Mendoza</option>
<option value="Santa Fé">Santa Fé</option>
<option value="Tierra del Fuego">Tierra del Fuego</option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Teléfono :</td>
<td><input name="telefono" type="text" id="telefono" size="20" maxlength="20" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
<a href="<?php echo $logoutAction ?>">Desconectar</a>
</form>
<script type="text/javascript">
<!--

//-->
</script>
</body>
</html>
<?php
mysql_free_result($Seleccionartorneos);

mysql_free_result($quienentro);

mysql_free_result($salas);
?>
  #11 (permalink)  
Antiguo 05/11/2010, 09:41
 
Fecha de Ingreso: marzo-2010
Ubicación: Cali
Mensajes: 203
Antigüedad: 14 años, 1 mes
Puntos: 5
Respuesta: Tcpdf

lo que quieres es que al ingresar los datos o darle clic al boton incribir en competencia automaticamente te abra el pdf?
  #12 (permalink)  
Antiguo 05/11/2010, 09:59
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Exacto, luego del insert quiero que arme el pdf y me lo muestre.
Ese pdf se podra guardar como constancia de inscripcion.

Como ves este codigo?

Independientemente de que funciona, lo ves bien armado?
  #13 (permalink)  
Antiguo 05/11/2010, 10:17
 
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
  #14 (permalink)  
Antiguo 05/11/2010, 10:40
 
Fecha de Ingreso: julio-2010
Mensajes: 70
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Tcpdf

Muchisimas gracias, ahora voy a dedicarme a entender el codigo asi empiezo a mejorar en mi trabajo.
Gracias de nuevo
  #15 (permalink)  
Antiguo 05/11/2010, 11:35
 
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!!.

Etiquetas: tcpdf
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:00.