Foros del Web » Programando para Internet » PHP »

Php a pdf - error?

Estas en el tema de Php a pdf - error? en el foro de PHP en Foros del Web. Warning: Cannot modify header information - headers already sent by (output started at E:\practica\certificados\certificado3.ph… in E:\practica\certificados\fpdf\fpdf.php on line 1017 FPDF error: Some data has already ...
  #1 (permalink)  
Antiguo 25/01/2011, 11:54
 
Fecha de Ingreso: octubre-2010
Mensajes: 20
Antigüedad: 13 años, 6 meses
Puntos: 0
Php a pdf - error?

Warning: Cannot modify header information - headers already sent by (output started at E:\practica\certificados\certificado3.ph… in E:\practica\certificados\fpdf\fpdf.php on line 1017
FPDF error: Some data has already been output, can't send PDF file


<html>
<head>
<title> CERTIFICADO </title>
<style type = "text/css">
<!--
.Estilo1 {
font-size: 12px;
font-weight: bold;
}
.Estilo3 {font-size: 12; font-weight: bold; }
.Estilo5 {color: #FFFFFF}
.Estilo7 {font-size: 24px}
.Estilo8 {font-size: 14px}
.Estilo9 {font-size: 14px; color: #FFFFFF; }
.Estilo10 {color: #000000}
.Estilo11 {font-size: 14px; color: #000000; }
.Estilo12 {font-size: 14px; color: #000000; font-weight: bold; }
.Estilo13 {
font-size: 14;
color: #FFFFFF;
}
-->
form
{
height:750px;
width: 580px;
border: 1px solid black;
background: white;
align: justify;
}
#trd
{
margin: 10px 6px 6px 2px;
padding-left:30PX;
padding-RIGHT:30PX;
align: center;
}
p
{
align: justify;
}
#parrafo
{

padding-left:470px;
align: right;
}
#texto
{ padding-left:280px;
align: right;
padding-right:20px;
font-size = '2.5';
align: justify;
}
#texto1
{ padding-left:70px;
align: justify;
padding-right:80px;
font-size = '2.5';
}
#texto3
{ padding-left:285px;
align: justify;
padding-right:90px;

}
#centrar
{
padding-left: 62px;
}
</style>
</head>
<body>
<form>
<table id = "trd" align= "center">
<tr>
<td> <p id = "centrar"><img src = "municipalidad.jpg" ></img></td>
<td>
</td>
<td><H3><center>CERTIFICADO</center></…
</tr>
</table>
<table id = "trd" CENTER>
<tr>
<td>
<?php
require('fpdf/fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10, 'LUCIA X. MULET MARTINEZ, JEFE DE PERSONAL DEL DEPARTAMENTO ADMINISTRACION DE DEDUCACION MUNICIPAL, CERTIFICA QUE:<br><br> DON (A)');
$pdf->Cell(40,10, $_REQUEST['txtTrabajador']);
$pdf->Cell(40,10,'Rut Nº ');
$pdf->Cell(40,10,$_REQUEST['txtRutTrab…
$pdf->Cell(40,10,'DESEMPEÑA FUNCIONES DE');
$pdf->Cell(40,10, $_REQUEST['txtFuncion']);
$pdf->Cell(40,10,', EN EL');
$pdf->Cell(40,10, $_REQUEST['txtLiceo']);
$pdf->Cell(40,10,', A CONTAR DEL ');
$pdf->Cell(40,10, $_REQUEST['txtFecha']);
$pdf->Cell(40,10,' Y EN FORMA INDEFINIDA.');
$pdf->Cell(40,10,'SE EXTIENDE EL PRESENTE CERTIFICADO A PETICION DEL INTERESADO, PARA LOS FINES QUE SE ESTIME CONVENIENTES SIN ULTERIOR RESPONSABILIDAD DE ESTA SECCION.');
$pdf-> Cell(40,10,'En Vallenar,');
$pdf->Cell(40,10,$_REQUEST['txtFechaAc…
$pdf->Output();
?>
</td>
</tr>
</table>
</FORM>
</body>
</html>
  #2 (permalink)  
Antiguo 25/01/2011, 12:04
Avatar de eits  
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 18 años, 10 meses
Puntos: 88
Respuesta: Php a pdf - error?

tuve un problema similar y no se si fue la mejor manera de resolverlo pero me funcionó y fue colocar ob_start() al principio de la página y ob_end_flush al final, esto con el fin de que la página sea almacena de en el buffer y hasta que termine todo el prceso sea liberada, de esta manera sí se puede modificar las cabeceras.
saludos.
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.
  #3 (permalink)  
Antiguo 25/01/2011, 12:26
 
Fecha de Ingreso: octubre-2010
Mensajes: 20
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Php a pdf - error?

ALGO ASI?

O COMO


<html>
<head>
<title> CERTIFICADO </title>
<style type = "text/css">
<!--
.Estilo1 {
font-size: 12px;
font-weight: bold;
}
.Estilo3 {font-size: 12; font-weight: bold; }
.Estilo5 {color: #FFFFFF}
.Estilo7 {font-size: 24px}
.Estilo8 {font-size: 14px}
.Estilo9 {font-size: 14px; color: #FFFFFF; }
.Estilo10 {color: #000000}
.Estilo11 {font-size: 14px; color: #000000; }
.Estilo12 {font-size: 14px; color: #000000; font-weight: bold; }
.Estilo13 {
font-size: 14;
color: #FFFFFF;
}
-->
form
{
height:750px;
width: 580px;
border: 1px solid black;
background: white;
align: justify;
}
#trd
{
margin: 10px 6px 6px 2px;
padding-left:30PX;
padding-RIGHT:30PX;
align: center;
}
p
{
align: justify;
}
#parrafo
{

padding-left:470px;
align: right;
}
#texto
{ padding-left:280px;
align: right;
padding-right:20px;
font-size = '2.5';
align: justify;
}
#texto1
{ padding-left:70px;
align: justify;
padding-right:80px;
font-size = '2.5';
}
#texto3
{ padding-left:285px;
align: justify;
padding-right:90px;

}
#centrar
{
padding-left: 62px;
}
</style>
</head>
<body>
<form>
<table id = "trd" align= "center">
<tr>
<td> <p id = "centrar"><img src = "municipalidad.jpg" ></img></td>
<td>
</td>
<td><H3><center>CERTIFICADO</center></H3></td>
</tr>
</table>
<table id = "trd" CENTER>
<tr>
<td>
<?php
require('fpdf/fpdf.php');
ob_start();
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Este es un ejemplo de creación de un documento PDF con PHP');
$pdf->Cell(40,10, 'LUCIA X. MULET MARTINEZ, JEFE DE PERSONAL DEL DEPARTAMENTO ADMINISTRACION DE DEDUCACION MUNICIPAL, CERTIFICA QUE:<br><br> DON (A)');
$pdf->Cell(40,10, $_REQUEST['txtTrabajador']);
$pdf->Cell(40,10,'Rut Nº ');
$pdf->Cell(40,10,$_REQUEST['txtRutTrabajador']);
$pdf->Cell(40,10,'DESEMPEÑA FUNCIONES DE');
$pdf->Cell(40,10, $_REQUEST['txtFuncion']);
$pdf->Cell(40,10,', EN EL');
$pdf->Cell(40,10, $_REQUEST['txtLiceo']);
$pdf->Cell(40,10,', A CONTAR DEL ');
$pdf->Cell(40,10, $_REQUEST['txtFecha']);
$pdf->Cell(40,10,' Y EN FORMA INDEFINIDA.');
$pdf->Cell(40,10,'SE EXTIENDE EL PRESENTE CERTIFICADO A PETICION DEL INTERESADO, PARA LOS FINES QUE SE ESTIME CONVENIENTES SIN ULTERIOR RESPONSABILIDAD DE ESTA SECCION.');
$pdf-> Cell(40,10,'En Vallenar,');
$pdf->Cell(40,10,$_REQUEST['txtFechaActual']);
ob_end_flush();
?>
</td>
</tr>
</table>
</FORM>
</body>
</html>

  #4 (permalink)  
Antiguo 25/01/2011, 12:33
Avatar de eits  
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 18 años, 10 meses
Puntos: 88
Respuesta: Php a pdf - error?

así
<?php ob_start() ?>
<html>
....
</html>
<?php ob_end_flush() ?>
saludos.
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.
  #5 (permalink)  
Antiguo 25/01/2011, 12:37
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Php a pdf - error?

Si lo que quieres es mostrar un archivo PDF, ¿cual es la necesidad de imprimir etiquetas HTML?
El error te lo da porque haz impreso algo antes de enviar cabeceras. Quita todo el codigo HTML innecesario y solo deja el codigo PHP.
  #6 (permalink)  
Antiguo 25/01/2011, 12:38
 
Fecha de Ingreso: octubre-2010
Mensajes: 20
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Php a pdf - error?

me tira este error.... :/
FPDF error: Some data has already been output, can't send PDF file
  #7 (permalink)  
Antiguo 25/01/2011, 12:40
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Php a pdf - error?

Lee mi post mas arriba.
  #8 (permalink)  
Antiguo 25/01/2011, 12:41
 
Fecha de Ingreso: octubre-2010
Mensajes: 20
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Php a pdf - error?

Warning: Cannot modify header information - headers already sent by (output started at E:\practica\certificados\certificado3(1).php:2) in E:\practica\certificados\fpdf\fpdf.php on line 1017
FPDF error: Some data has already been output, can't send PDF file


__________________________________________________ ________________________


<?php
require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Este es un ejemplo de creación de un documento PDF con PHP');
$pdf->Cell(40,10, 'LUCIA X. MULET MARTINEZ, JEFE DE PERSONAL DEL DEPARTAMENTO ADMINISTRACION DE DEDUCACION MUNICIPAL, CERTIFICA QUE:<br><br> DON (A)');
$pdf->Cell(40,10, $_REQUEST['txtTrabajador']);
$pdf->Cell(40,10,'Rut Nº ');
$pdf->Cell(40,10,$_REQUEST['txtRutTrabajador']);
$pdf->Cell(40,10,'DESEMPEÑA FUNCIONES DE');
$pdf->Cell(40,10, $_REQUEST['txtFuncion']);
$pdf->Cell(40,10,', EN EL');
$pdf->Cell(40,10, $_REQUEST['txtLiceo']);
$pdf->Cell(40,10,', A CONTAR DEL ');
$pdf->Cell(40,10, $_REQUEST['txtFecha']);
$pdf->Cell(40,10,' Y EN FORMA INDEFINIDA.');
$pdf->Cell(40,10,'SE EXTIENDE EL PRESENTE CERTIFICADO A PETICION DEL INTERESADO, PARA LOS FINES QUE SE ESTIME CONVENIENTES SIN ULTERIOR RESPONSABILIDAD DE ESTA SECCION.');
$pdf-> Cell(40,10,'En Vallenar,');
$pdf->Cell(40,10,$_REQUEST['txtFechaActual']);
$pdf->Output();
?>
  #9 (permalink)  
Antiguo 25/01/2011, 12:42
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Php a pdf - error?

Asegurate que no quede ni un pequeñito espacio antes de <?php
  #10 (permalink)  
Antiguo 25/01/2011, 12:45
 
Fecha de Ingreso: octubre-2010
Mensajes: 20
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Php a pdf - error?

influye que mi pc no tenga permisos de administrador?
llevo como una semana y tanto peliando con esto :(

Etiquetas: pdf
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 16:32.