当我生成PDF时,文本有效,但图像未显示。我该如何解决?

时间:2019-04-28 07:51:58

标签: codeigniter

当我生成PDF时,文本有效,但是图像未显示图像。我该如何解决?如何在PDF中使用图像?在下面,我给出了一些有关我的问题的代码。

这是视图代码:所有代码都包含在数据库的一个字段中。

查看代码:

<div class="tab-pane" id="sixweekletterwithauto" role="tabpanel" aria-labelledby="sixweekletterwithauto-tab">
                             <form  action="patient/addcaseHistory" method="post" enctype="multipart/form-data">
                                <center>
                                  <h2 style="margin-top: 0;color:#55518a">Case Notes</h2>
                                  <textarea name="editor1" class="ckeditor">
                                    <img src="../uploads/pic.jpg" width="1000px" height="200px">

                                      <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>

                                      <table align="right" style="width:200px">
                                        <tbody>
                                          <tr>
                                            <td>&nbsp;Dr M Takla</td>
                                          </tr>
                                          <tr>
                                            <td>&nbsp;621 Boronia Rd Wantirna South</td>
                                          </tr>
                                          <tr>
                                            <td>&nbsp;VIC 3152</td>
                                          </tr>
                                          <tr>
                                            <td>&nbsp;Ph 97380009 Fax</td>
                                          </tr>
                                        </tbody>
                                     </table>
                                      <p>&nbsp;</p>
                                      <p>&nbsp;</p>
                                      <p>&nbsp;</p>
                                      <p>&nbsp;</p>
                                      <p>&nbsp;</p>
                                      <p>Dear Dr M Takla,,</p>
                                      <p><strong>Re: Aryan Karat (DOB : 9/12/2008)</strong></p>
                                      <p>Thank you for referring Aryan Karat, for assistance with &ldquo;behaviour problems, hyperactivity and phobias&rdquo;.</p>

                                      <p>The therapeutic process with Aryan has focussed on reducing anxiety and improving self confidence and self esteem. I have worked on a number of cognitive and behavioural strategies to assist Aryan in managing his worry. His teacher and parents have reported some positive changes, however they continue to be concerned about his constant need for reassurance by adults and anxiety in some situations.</p>

                                      <p>Further sessions with Aryan are recommended in order to ensure that the skills and strategies imparted can be reinforced and fully assimilated.</p>
                                      <p>If you wish to discuss this matter further, I may be contacted at 0419 489 333.</p>
                                      <p>Thank you again for your referral, and I look forward to your reply.</p>
                                      <p>Yours Sincerely</p>
                                      <p>&nbsp;</p>
                                      <p>Ms Angela Delle-Vergini,<br />
                                      Psychologist<br />
                                      M.A.P.S (B.A, Grad Dip Psych, M.Psych (Counselling).</p>
                                      <p>&nbsp;</p>
                                  </textarea>
                                  <script>
                                          CKEDITOR.replace( 'editor2' );
                                          CKEDITOR.add
                                  </script>
                                </center>
                                <input type="hidden" name="patient_id" value='<?php echo $patient->id; ?>'>
                                  <input type="hidden" name="date" value='<?php echo date('m-d-Y') ?>'>
                                <div style="margin-bottom: 30px;">
                                  <button class="btn btn-blue">Save & Finalise</button>
                                </div>
                              </form>
                          </div>

控制器代码:

function addcaseHistory() {
        $id = $this->input->post('id');
        $patient_id = $this->input->post('patient_id');

        $date = $this->input->post('date');
        $description = $this->input->post('editor1');

        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        $redirect = $this->input->post('redirect');
        if (empty($redirect)) {
            $redirect = 'patient/medicalHistory?id=' . $patient_id;
        }

        // Validating Name Field
        $this->form_validation->set_rules('date', 'Date', 'trim|required|min_length[5]|max_length[100]|xss_clean');
        // Validating Password Field

        $this->form_validation->set_rules('editor1', 'Description', 'trim|required|min_length[5]|max_length[10000]|xss_clean');
        if ($this->form_validation->run() == FALSE) {
            if (!empty($id)) {
                redirect("patient/editMedicalHistory?id=$id");
            } else {
                $this->load->view('home/dashboard'); // just the header file
                $this->load->view('add_new');
                $this->load->view('home/footer'); // just the header file
            }
        } else {

            if (!empty($patient_id)) {
                $patient_details = $this->patient_model->getPatientById($patient_id);
                $patient_name = $patient_details->name;
                $patient_phone = $patient_details->phone;
                $patient_address = $patient_details->address;
            } else {
                $patient_name = 0;
                $patient_phone = 0;
                $patient_address = 0;
            }
            //$error = array('error' => $this->upload->display_errors());
            $data = array();
            $data = array(
                'patient_id' => $patient_id,
                'date' => $date,
                'description' => $description,
                'patient_name' => $patient_name,
                'patient_phone' => $patient_phone,
                'patient_address' => $patient_address,
            ); 

            if (empty($id)) {     // Adding New department
                $this->patient_model->insertMedicalHistory($data);
                $this->session->set_flashdata('feedback', 'Added');
            } else { // Updating department
                $this->patient_model->updateMedicalHistory($id, $data);
                $this->session->set_flashdata('feedback', 'Updated');
            }
            // Loading View
            $data['settings'] = $this->settings_model->getSettings();
         $this->load->view('home/dashboard2',$data); // just the header file
        $this->load->view('medical_history', $data);
        $this->load->view('home/footer'); // just the footer file
        }
    }

public function pdfdetails()
     {
      $id = $this->input->get('id');


       $html_content .= $this->patient_model->getMedicalHistoryByPatientId2($id);


       $this->pdf->loadHtml($html_content);
       $this->pdf->render();
       $this->pdf->stream("".$id.".pdf", array("Attachment"=>0));    
     }

型号代码:

function getMedicalHistoryByPatientId2($id)
 {
  $this->db->where('id', $id);
  $data = $this->db->get('medical_history');

  foreach($data->result() as $row)
  {
   $output .= '<p>'."<img src='../uploads/'".$row->img_url."/>".$row->description.'</p>';
  }

  return $output;
 }

0 个答案:

没有答案