Blank Output PDF using FPDF library - codeigniter

后端 未结 1 1853
甜味超标
甜味超标 2021-01-27 00:48

I\'m going to generate a PDF report using FPDF library, but the output is blank. There is no error displayed, how can I fix this problem?

Anyway, I tried this code in

相关标签:
1条回答
  • 2021-01-27 01:30

    I had the same problem and this was my solution:

    Instead of using

    $this->fpdf =new FPDF() 
    

    I used

    $pdf = new FPDF();
    

    then u can use $pdf->... and not $this->pdf->...

    Here is an example:

    define('FPDF_FONTPATH',$this->config->item('fonts_path'));
    $this->load->library(array('fpdf','fpdf_rotate','pdf'));
    $this->pdf->Open();
    $pdf = new PDF();
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->SetFont('Arial', '', 12);
    $pdf->SetDrawColor(0);
    $pdf->MultiCell(100,5,"Test\n line of text");
    $pdf->Output('test.pdf', 'D');
    

    Works like a charm ;)

    0 讨论(0)
提交回复
热议问题