0

In my view page, I have called this function

<a href="<?php echo base_url();?>verify/pdf/<?php echo $row>invoice_no;?>" ><button>Generated Pdf</button></a>

My controller

<?php

function pdf($id)
{
    $data = [];
    $this->load->database();
    $this->load->model('useradmin');
    $data['dealer'] = $this->useradmin->selectdealer($id);
    $data['dealerdes'] = $this->useradmin->selectdealer1($id);

    // load the view and saved it into $html variable

    $html = $this->load->view('envoice', $data, true);

    // this the the PDF filename that user will get to download

    $pdfFilePath = "output_pdf_name.pdf";

    // load mPDF library

    $this->load->library('m_pdf');

    // generate the PDF from the given html

    $this->m_pdf->pdf->WriteHTML($html);

    // download it.

    $this->m_pdf->pdf->Output($pdfFilePath, "D");
}

This is not working if I have passed function pdf(); without argument its working but dynamic content does not show in my PDF.

Please suggest how to pass id to my function.

Abhishek
  • 539
  • 5
  • 25
Adi Singh
  • 57
  • 9
  • you can use **TCPDF** :: http://www.onlinecode.org/codeigniter-create-pdf-file-tcpdf-codeigniter/ – Dave Nov 07 '17 at 05:42
  • what is `dynamic content`?, do you mean contents that is loaded with ajax calls? – am05mhz Nov 07 '17 at 05:42
  • my html page content foreach loop like this foreach($dealer as $row) – Adi Singh Nov 07 '17 at 05:55
  • show your routes $route['verify/pdf/(:any)'] = 'controller/pdf/$1'; – Vivek ab Nov 07 '17 at 06:39
  • mPDF error: Some data has already been output to browser, can't send PDF file if i pass function pdf($id) – Adi Singh Nov 07 '17 at 06:52
  • there seems to have an answer already: https://stackoverflow.com/questions/20146967/tcpdf-mpdf-error-some-data-has-already-been-output-to-browser-cant-send-pdf?rq=1 – Kevin Nov 07 '17 at 08:55

0 Answers0