I'm working with an office system, where the user will enter the legal number, the person to which the document will be directed and the message, and would like that, if the data were successfully added to the bank, a PDF with the information entered would be generated through the DOMPDF library. However, when executing, the following error is returned: "Failed to load PDF document". The code is this:
<?php
include_once("../conexao.php");
$numero = $_POST["numero"];
$interessado = $_POST["interessado"];
$assunto = $_POST["assunto"];
$query = mysqli_query($conexao, "INSERT INTO oficio VALUES ('$numero','$interessado','$assunto');");
use Dompdf\Dompdf;
require_once ("../dompdf/autoload.inc.php");
if(mysqli_affected_rows($conexao) != 0){
$html = "<p>".$numero."</p>";
$html .= "<p>".$interessado."</p>";
$html .= "<p>".$assunto."</p>";
$dompdf = new DOMPDF();
//echo $html;
$dompdf->load_html("<h1 style='text-align: center;'>Teste - Gerar PDF</h1>".$html);
$dompdf->render();
$dompdf->stream("teste_pdf.pdf",array("Attachment" => false));
}
else{
echo "<META HTTP-EQUIV=REFRESH CONTENT = '0;URL=http://localhost/principal.php?link=01'>
<script type=\"text/javascript\">
alert(\"Não foi possível realizar a abertura do ofício!\");
</script>";
}
?>
What could be done for the document to be created?