Welcome Guest, Not a member yet? Register   Sign In
Generating a PHP and HTML page to PDF using mPDF
#4

[eluser]TheFuzzy0ne[/eluser]
Instead of:
Code:
public function pdf_report($user_id){
    $this->load->helper(array('pdfexport'));
    $data = file_get_contents(base_url('profile/show_profile/'.$user_id)); // here is the page that i call, the page information changes according to id (user_id)...simply its a profile page that changes according to which user is logged in
    $filename = 'profile'.$user_id.'_'.date('dMY');
    create_pdf($data, $filename);
}

Do something like:
Code:
public function pdf_report($user_id){
    $this->load->helper('pdfexport');

    $data['page_title'] = 'User Profile';
    $data['content'] = 'profile_view';
$data['user_results'] = $this->users_model->select_user_by_id($this->session->userdata('id'));

    $filename = 'profile'.$user_id.'_'.date('dMY');
    create_pdf($this->load->view('includes/template', $data, TRUE), $filename);
}

Now you aren't making an extra HTTP request to get the profile markup (as you were with file_get_contents()Wink. Instead you're just loading a view and passing the output from that into create_pdf().


Messages In This Thread
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 11:17 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 11:47 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 11:53 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 12:46 PM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 01:46 PM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-21-2013, 03:01 PM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-22-2013, 03:15 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-22-2013, 09:14 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-22-2013, 01:16 PM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-23-2013, 06:01 AM
Generating a PHP and HTML page to PDF using mPDF - by El Forum - 05-23-2013, 06:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB