In most of the browsers the iframe tag shows the pdf file based on the data i submit on select option , in the fpdf file code page i used the output as 'I' to show , but it download automatically
<iframe src="../admin/customer_ledger_report.php?sel_customer=<?php echo $_REQUEST['sel_customer'];?>&financial_id=<?php echo $_REQUEST['financial_id'];?>&sel_company=<?php echo $_REQUEST['sel_company'];?> " width="100%" style="min-height: 768px;overflow-y: scroll;"></iframe>
<script>
$(function () {
$('#jvalidate').submit(function (e) {
e.preventDefault();
// Get the selected values
var financial_id = $('#financial_id').val();
var sel_company = $('#sel_company').val();
var sel_customer = $('#sel_customer').val();
// Construct the URL for the iframe
var iframeUrl = "../admin/customer_ledger_report.php?sel_customer=" + sel_customer + "&financial_id=" + financial_id + "&sel_company=" + sel_company;
// Set the iframe source
$('#pdf-iframe iframe').attr('src', iframeUrl);
if (financial_id && sel_company && sel_customer) {
// Show the iframe
$('#pdf-iframe').show();
displayPieChart(sel_company, sel_customer, financial_id);
}
return false;
});
});
</script>
In the customer_ledger_report.php file i used
<?php
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="output.pdf"');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
require('session.php');
require('pdf-generate/fpdf.php');
extract($_REQUEST);
$pdf->Ln();
$pdf->Output('output.pdf', 'I');
$pdf->Close();
what i am excepting is that the pdf need to be support all type of browser to show the pdf file instead of auto downloading
From what I remember FPDF is the base to the most complete library TCPDF. On TCPDF, I do not need to setup any headers when I do the output. It just output to the client. It goes like this:
This is a simplified version as there a more required setting for the PDF (creator, author, title, subject, display mode, ...). Adding a page and a line of text should be enough to generate a PDF.
A detail, TCPDF do not need to
Closethe PDF as it will do it automatically whenOutputis called.After checking the status an documentation for FPDF, it looks like this library is abandoned and no more updates. Also the documentation mention that the
Outputfunction signature is this:So that means, if you are using the original FPDF then the parameters are in different position.
However, it looks like there is another version from
SetaSignwhich is a drop-in replacement ofFPDFwithTCPDF.