0
page:
<?php
header("Content-Type: text/html; charset=utf-8");
?>
<html>
<head>
<title>Gceu IMW Muriaé - São Cristóvão </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
require_once "../_scripts/_php/_configuracoes/erros.php";
require_once "fpd181/PDF.php";
$html = "<div><h1>Hoje é o dia " . date( "Y-m-d" ) . "</h1></div>";
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->WriteHTML($html);
$pdf->Output();
?>
</body>
</html>
You’re making the following mistake:
Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file in D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\pdf\fpd181\fpdf.php:271 Stack trace: #0 D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\pdf\fpd181\fpdf.php(1063): FPDF->Error('Some data has a...') #1 D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\pdf\fpd181\fpdf.php(999): FPDF->_checkoutput() #2 D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\pdf\pdf.php(29): FPDF->Output() #3 {main} thrown in D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\pdf\fpd181\fpdf.php on line 271
But if I remove the HTML
and leave only the PHP
<?php
header("Content-Type: text/html; charset=utf-8");
?>
<?php
require_once "../_scripts/_php/_configuracoes/erros.php";
require_once "fpd181/PDF.php";
$html = "<div><h1>Hoje é o dia " . date( "Y-m-d" ) . "</h1></div>";
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->WriteHTML($html);
$pdf->Output();
?>
The error disappears and the pdf
displays. But with accent errors.
Obs.: All files involved are UTF-8 unsigned GOOD
Try it here Change the line
$pdf->WriteHTML($html);
for$pdf->WriteHTML(utf8_decode($html));
– Bulfaitelo
I think I got it. To generate the pdf, you need to use the pdf header. Right? Hence the problem when I enter another header. It worked. But it is necessary to remove the HTML from there. Valeu1 But it will not display in the browser. Just download. Wanted to display in the browser!
– Carlos Rocha