MPDF class php - How to display images inside Tables

0

In the code below, I wanted to put an image inside the table displayed in PDF , but the image is not displayed and a box with "X" red appears. How do I put the image "inside" of mysqli_fetch_assoc ?

In the current code only the images outside the while appear. There are a few different image paths, as I'm testing - all but a few - all possible paths.

Here is the code:

<?php
    include ('pdf/mpdf.php');
 include('config.php'); session_start();
     $id=$_SESSION['id'];
 $tabela = '<img src=/bimbopnl/logo.png />';
$tabela .= '<br><br><br><br><br><br>';
 $tabela .= '<table  align=left>'; 
 $tabela .= '<tr>';
 $tabela .= '<td colspan="4" align="center"><br>Indicadores<br><br>
 </tr>';
 $tabela .= '</tr>';
 $tabela .= '<tr>';
      $tabela .= '<td><b>  Indicador  </b></td>';
    $tabela .= '<td><b>  Valor  </b></td>';
    $tabela .= '<td><b>  Meta  </b></td>';
    $tabela .= '<td><b>  Otimismo  </b></td>';
 $tabela .= '</tr>';
   $sql = mysqli_query($conexao,"SELECT * FROM tb_indicadores where  id='$id'     and dataIndicador='FEV - 2018' and tipoIndicador=1") or die(mysql_error()); 

 while($dados = mysqli_fetch_assoc($sql))
 { 

 $tabela .= '<tr>'; 

 $id=$dados['id'];
 $nome=$dados['nomeindicador'];
     $idind = $dados['idIndicador']; 
  $meta = $dados['meta']; 
  $otimismo = $dados['otimismo'];
  $dif = $valor/$meta;
imagem='';
   if($valor==''){$imagem= '/bimbopnl/imagens/semvalor.png';}   
   if(($otimismo=='otimista')&&($dif<=0.95)){$imagem= '/miniredup.png';}
    if(($otimismo=='pessimista')&&($dif<=0.95)){$imagem= 'bimbopnl/minireddown.png';}
  if(($otimismo=='otimista')&&($dif>0.9 && $dif<=0.95)){$imagem= 'bimbopnl/miniyellowup.png';}
  if(($otimismo=='pessimista')&&($dif>0.9 && $dif<=0.95)){$imagem= 'bimbopnl/miniyellowdown.png';} 
 if(($otimismo=='otimista')&&($dif>0.95 && $dif<=1.05)){$imagem= 'bimbopnl/minigreenup.png';}

 if(($otimismo=='pessimista')&&($dif>0.95 && $dif<=1.05)){$imagem= 'bimbopnl/minigreendown.png';}
   if(($otimismo=='otimista')&&($dif>1.05)){$imagem= 'bimbopnl/miniblueup.png';}
   if(($otimismo=='pessimista')&&($dif>1.05)){$imagem= 'bimbopnl/minibluedown.png';}       

       $tabela .= '<td>'.$dados['nomeindicador'].'</td>'; $tabela .= '<td>'.$dados['valorIndicador'].'</td>';
             $tabela .= '<td>'.$dados['meta'].'</td>';   $tabela .= '<img             src=/'.'"$imagem"'.'>';
       $tabela .= '</tr>';
 }

 $tabela .= '</table>';
$tabela .= '<img src=/bimbopnl/rent.png>';

  echo '<br>';    echo '<br>';  echo '<br>';
$arquivo = 'Cadastro01.pdf';
$mpdf = new mPDF();
$mpdf->WriteHTML($tabela);
$mpdf->Output($arquivo, 'I');

 ?>

I'm using the MPDF class to produce a pdf .

    
asked by anonymous 15.08.2018 / 00:16

1 answer

0

Friend, create a html as you wish, by querying the information, displaying and mounting the tables, do as follows:

$url = $pastaraiz . "admin/voucher-pdf.php?voucher=" . $_POST["reserva"] .
                    "&voucher_docificado=" . $voucher_docificado;

                $ch = curl_init();
                // set url
                curl_setopt($ch, CURLOPT_URL, $url);

                //return the transfer as a string
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

                // $output contains the output string
                $output1 = utf8_encode(curl_exec($ch));

                // close curl resource to free up system resources
                curl_close($ch);

                define('MPDF_PATH', '../mpdf60/');
                include (MPDF_PATH . 'mpdf.php');
                $mpdf = new mPDF();
                $mpdf->WriteCell($output1);
                $mpdf->WriteHTML($output1);
                $mpdf->Output('../VOUCHERS/' . $voucher_docificado . '.pdf', 'F');
  

    
15.08.2018 / 00:32