Welcome Guest, Not a member yet? Register   Sign In
File name problem with DOMPDF
#1

[eluser]bhakti.thakkar[/eluser]
Hello all,
I am displaying the output to the user in PDF format. Its working fine. when the user clicks on the Preview button, there is a prompt asking the user to Open or Save the PDF file. I am passing to the controller the naming convention that is followed by my application. But somehow the filename in the prompt box is not the one that i am sending. It takes some other parameter from the function and is passing that as the file name. i have done through check of all the possible things i could. but this is not getting solved
COntroller:
Code:
function PreviewCertificatePDF($TransactionCertificate_ID , $ITCType_TI) {
        
        $this->load->plugin('to_pdf');
        $this->load->helper('file');
        $data['TransactionCertificate_ID'] = $TransactionCertificate_ID;

        $query = $this->db->query("Exec up_parmsel_rpt_TempTransactionCertificate @TransactionCertificate_ID='$TransactionCertificate_ID' , @Company_ID='' ");

        $data['pgdata'] =$query->result_array();
        if ($ITCType_TI=="1") {
            $pg="PreviewCertificate";
        } else {
            $pg="PreviewImportCertificate";
        }
        $html = $this->load->view('certificates/'.$pg ,$data,TRUE);
        $fname='TR'.$TransactionCertificate_ID."_".date('mYdHs');            
        pdf_create($html,$fname,TRUE);
    }

plugins/to_pdf_pi.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* Try increasing memory available, mostly for PDF generation
*/
ini_set("memory_limit","100M");
function pdf_create($html, $filename, $stream=TRUE)
{
    require_once(BASEPATH."plugins/dompdf/dompdf_config.inc.php");
    $dompdf = new DOMPDF();
    $dompdf->set_paper("a4", "portrait");
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    }
    write_file("./tmp/".$filename.".pdf", $dompdf->output());
}
?>
$fname='TR'.$TransactionCertificate_ID."_".date('mYdHs');
I have even printed the variable $filename in the controller and plugin file, it gives me the correct convention. but in the prompt, it takes $ITCType_TI.php. I dont know from where do it get $ITCType_TI. I am also storing the file in my remote server. There the naming is correct. Only in the prompt, there is a problem

what could be the issue? Excuse me if the problem sounds stupid :roll:

Thanks
#2

[eluser]bhakti.thakkar[/eluser]
To my surprise, I passed a test name ("abc") in the to_pdf_pi.php

Something like:

if ($stream) {
$dompdf->stream("abc.pdf");
}
write_file("./tmp/abc.pdf", $dompdf->output());

while saving on the server, the name was abc.php. But in the prompt it was wrong
#3

[eluser]bhakti.thakkar[/eluser]
Still no break through this
Plz Plz help




Theme © iAndrew 2016 - Forum software by © MyBB