FPDF problem to open PDF

software development

#1

Hi everybody…

I’m new using FPDF and at this moment I have a serious problem.
I create content PDF with FPDF and send to DB into MEDIUMBLOB type.

After that I want retrieve from database and I use the following code for that:

<?php ob_start(); ?> <?php require("config.php"); if(isset($_GET['nomeVoucher'])) { $nomeVoucher = $_GET['nomeVoucher']; } else { die("nomeVoucher missing."); } $query = "select filePDF from historico Where nomeVoucher = ? AND confirmacao = 'a confirmar' "; $stmt = $mybd->prepare($query); $stmt->bind_param('s', $_GET['nomeVoucher']); $stmt->execute(); $stmt->bind_result($filePDF); if($stmt->fetch()) { ob_clean(); header('Content-Type: application/pdf'); header('Accept-Ranges: bytes'); header('Content-Transfer-Encoding: binary'); header("Content-Disposition: inline; filename=" . $nomeVoucher .'.pdf'); echo $filePDF; ob_end_flush(); die(); } else { die("something broke"); } ?>

But the problem it seems the browser says: "Fail to load PDF document"
And I try lot of solutions and I need this quickly!

Anyone had this error?

Thank you for all


#2

Your script is generating an “Accept-Ranges: bytes” header, but is not actually handling Range requests. You will need to either remove this header or update your script to handle this correctly.