Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:21:10+00:00 2026-06-13T23:21:10+00:00

I want to create a pdf based on one view, generated by Codeigniter. However,

  • 0

I want to create a pdf based on one view, generated by Codeigniter. However, this view has a lot of styled elements, and media queries associated with them, so the rendered pdf doesn’t correspond at all, with the desired final document.

What’s the best way to acomplish this? Right now I’m using mPDF. Is there anyway to take a snapshot of the view and then generate a pdf with it, so the associated styles render correctly on the document?

Right now my code looks like this

public function generatePDF()
    {
        $this->session_expire();
    $this->load->helper('url');
    $user_id=$this->session->userdata('user_id');
    $this->user_model=$this->db_interface->db_get_user($user_id);
    //  $this->load->helper('url');


        //echo('error aki <br />');
        $data['user'] = $this->user_model;
        $data['objective'] = $this->db_interface->db_get_objectives($this->user_model->get_id());
        $data['list_work'] = $this->db_interface->db_get_list_work_experience($this->user_model->get_id());
        $data['list_education'] = $this->db_interface->db_get_list_education($this->user_model->get_id());
        $data['list_skills'] = $this->db_interface->db_get_skills($this->user_model->get_id());
        $data['list_personal'] = $this->db_interface->db_get_personal_skills($this->user_model->get_id());
        $data['list_links'] = $this->db_interface->get_user_links($this->user_model->get_id());


        $html = $this->load->view('display_user',$data,TRUE);
        //$html = $this->load->view('display_user',$data,TRUE);
       // $this->load->view('display_user',  $html);
        $this->mpdf->WriteHTML($html);
        $this->mpdf->Output();

    }

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:21:11+00:00Added an answer on June 13, 2026 at 11:21 pm

    Short answer: kind of.

    Long answer: you have 2 options. You can a) take a screenshot (See Website screenshots using PHP ); or b) you can create a custom stylesheet for print.

    The latter will likely be much easier to do. There are limits on what the library you are using can do insofar as CSS is concerned, so read up: http://www.mpdf1.com/mpdf/enhancements

    Best bet is probably to create separate stylesheets for screen and printing:

    <link rel="stylesheet" href="screen.css" type="text/css" media="screen">
    

    for viewing, and

    <link rel="stylesheet" href="print.css" type="text/css" media="print">
    

    for printing.

    Style print.css to look good. It is highly unlikely you will be able to mimic the screen exactly, but it should be easy enough to present the information you need to print coherently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create and insert a lot of images into a PDF and
I want to create a PDF file using zend_pdf. But this way seems not
I want to create a PDF that will bring up a typical OK/Cancel alert
I am using ASP.NET and I want to create a barcode in a pdf
I have a pdf file on my server. I want to create such link
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
So I got a problem with saving my pdf. I want to create an
I want to create PDF file using IO.popen command with wkhtmltopdf . I successfully
I want to create a PDF where a single page contains multiple EPS(AI) files.
I want to create a PDF file from my PHP (HTML+CSS) but I positioning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.