title: Put image in pdf TCPDF
body: <p>I am trying to generate a pdf that shows also the image. So my image is stored in the database and I have a working code that generates the data in my database into a PDF file.</p>
  
  <p>This is the code that views my image from my database to the datatable</p>
  
  <pre><code>&lt;td &gt;&lt;img  onclick="onClick(this)" class="w3-hover-opacity" src="&lt;?php echo base_url('uploads/'.$report["attachment"].'.png'); ?&gt;"  style="width:100%;max-width:200px;border-radius: 5px" &gt;&lt;/td&gt; 
  </code></pre>
  
  <p>this is what i did but it only prints the img filename</p>
  
  <pre><code>if(isset($_POST["generate_pdf"]))  
   {  
  
  
        require_once('tcpdf/tcpdf.php');  
        $obj_pdf = new TCPDF('L', 'mm', 'LETTER', true, 'UTF-8', false);
        $obj_pdf-&gt;SetCreator(PDF_CREATOR);  
        $obj_pdf-&gt;SetAuthor('Nicola Asuni');
        $obj_pdf-&gt;SetSubject('TCPDF Tutorial');
        $obj_pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');
        $obj_pdf-&gt;SetTitle("Incident Report");  
        $obj_pdf-&gt;SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);  
        $obj_pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));  
        $obj_pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));  
        $obj_pdf-&gt;SetDefaultMonospacedFont('helvetica');  
        $obj_pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);  
        $obj_pdf-&gt;SetMargins(2, '7', PDF_MARGIN_RIGHT, '10');  
        $obj_pdf-&gt;setPrintHeader(false);  
        $obj_pdf-&gt;setPrintFooter(false);  
         $obj_pdf-&gt;setPrintFooter(false);
        $obj_pdf-&gt;SetFont('helvetica', '', 5);  
        $obj_pdf-&gt;AddPage();  
  
        date_default_timezone_set("Asia/Manila");
        $content = '';  
          $content2 = date("F d, Y h:i:s A",mktime());
        $content .= '
        &lt;h4 align="center"&gt;Incident Report&lt;/h4&gt; &lt;br /&gt; 
  
        &lt;table align="center" border="1" cellspacing="0" cellpadding="3"&gt;  
             &lt;tr&gt;  
  
                  &lt;th width="8%"&gt;School&lt;/th&gt;  
                  &lt;th width="5%"&gt;Grade/Level&lt;/th&gt; 
                   &lt;th width="6%"&gt;Section&lt;/th&gt; 
                  &lt;th width="7%"&gt;Date and Time&lt;/th&gt;  
                  &lt;th width="6%"&gt;Incident Type&lt;/th&gt;  
                  &lt;th width="7%"&gt;Incident Description&lt;/th&gt;
                     &lt;th width="6%"&gt;Sender&lt;/th&gt;  
                  &lt;th width="10%"&gt;Person Involved&lt;/th&gt;   
                     &lt;th width="14%"&gt;Students that tagged safe&lt;/th&gt; 
                     &lt;th width="14%"&gt;Students that tagged unsafe&lt;/th&gt; 
                        &lt;th width="4%"&gt;Male Count&lt;/th&gt; 
                        &lt;th width="5%"&gt;Female Count&lt;/th&gt; 
                     &lt;th width="5%"&gt;Number of involved people&lt;/th&gt;
                    if(isset($_POST["generate_pdf"]))  
   {  
  
  
        require_once('tcpdf/tcpdf.php');  
        $obj_pdf = new TCPDF('L', 'mm', 'LETTER', true, 'UTF-8', false);
        $obj_pdf-&gt;SetCreator(PDF_CREATOR);  
        $obj_pdf-&gt;SetAuthor('Nicola Asuni');
        $obj_pdf-&gt;SetSubject('TCPDF Tutorial');
        $obj_pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');
        $obj_pdf-&gt;SetTitle("Incident Report");  
        $obj_pdf-&gt;SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);  
        $obj_pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));  
        $obj_pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));  
        $obj_pdf-&gt;SetDefaultMonospacedFont('helvetica');  
        $obj_pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);  
        $obj_pdf-&gt;SetMargins(2, '7', PDF_MARGIN_RIGHT, '10');  
        $obj_pdf-&gt;setPrintHeader(false);  
        $obj_pdf-&gt;setPrintFooter(false);  
         $obj_pdf-&gt;setPrintFooter(false);
        $obj_pdf-&gt;SetFont('helvetica', '', 5);  
        $obj_pdf-&gt;AddPage();  
  
        date_default_timezone_set("Asia/Manila");
        $content = '';  
          $content2 = date("F d, Y h:i:s A",mktime());
        $content .= '
        &lt;h4 align="center"&gt;Incident Report&lt;/h4&gt; &lt;br /&gt; 
  
        &lt;table align="center" border="1" cellspacing="0" cellpadding="3"&gt;  
             &lt;tr&gt;  
  
                  &lt;th width="8%"&gt;School&lt;/th&gt;  
                  &lt;th width="5%"&gt;Grade/Level&lt;/th&gt; 
                   &lt;th width="6%"&gt;Section&lt;/th&gt; 
                  &lt;th width="7%"&gt;Date and Time&lt;/th&gt;  
                  &lt;th width="6%"&gt;Incident Type&lt;/th&gt;  
                  &lt;th width="7%"&gt;Incident Description&lt;/th&gt;
                     &lt;th width="6%"&gt;Sender&lt;/th&gt;  
                  &lt;th width="10%"&gt;Person Involved&lt;/th&gt;   
                     &lt;th width="14%"&gt;Students that tagged safe&lt;/th&gt; 
                     &lt;th width="14%"&gt;Students that tagged unsafe&lt;/th&gt; 
                        &lt;th width="4%"&gt;Male Count&lt;/th&gt; 
                        &lt;th width="5%"&gt;Female Count&lt;/th&gt; 
                     &lt;th width="5%"&gt;Number of involved people&lt;/th&gt;
                    &lt;th width="5%"&gt;Attachment&lt;/th&gt;
             &lt;/tr&gt;';  
        $content .= fetch_data();  
        $content .= '&lt;/table&gt;';  
  
  
        $obj_pdf-&gt;writeHTML($content);  
        $obj_pdf-&gt;writeHTML($content2);
        $obj_pdf-&gt;Output('report.pdf', 'I');  
   }  
   ?&gt;  
             &lt;/tr&gt;';  
        $content .= fetch_data();  
        $content .= '&lt;/table&gt;';  
  
  
        $obj_pdf-&gt;writeHTML($content);  
        $obj_pdf-&gt;writeHTML($content2);
        $obj_pdf-&gt;Output('report.pdf', 'I');  
   }  
   ?&gt;  
  </code></pre>
  
  <p>Do i need to add another $obj_pdf? and I know the line <code>&lt;th width="5%"&gt;Attachment&lt;/th&gt;</code> only prints the filename. I'm just testing waters</p>