0
Good afternoon, I am breaking my head, I need to display images from my bank, in a PDF.
The name of the field in the bank is called foto
, it keeps the path of the images that are in a directory.
WITHOUT THE DOMPDF
, I can display the images like this in PHP:
echo"<td><img src='http://www.meusite.com/".$row_transacoes['foto']."' width='50'></td>";
However, with the DOMPDF
, I can’t, maybe because I’m changing some accents, to "recognize", so I left it like this:
$html .= '<td><img src="http://www.meusite.com/'.$row_transacoes['foto'].'" width="50"></td>';
And is not working, appears that the image was not found...
I’ll be dropping the code, I appreciate any kind of help, I’ve been trying for a long time...
<?php
// CONEXÃO
$host = "exemplo";
$user = "exemplo";
$key = "exemplo";
$bd = "exemplo";
$con = new mysqli($host, $user, $key, $bd);
if ($con->connect_errno) {
echo "Falha ao conectar ao banco: (" . $con->connect_errno . ") " . $con->connect_error;
}
$html .= '<center><h3>Prontuário</h3></center>';
$html .= '<table class="table">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>Nome</th>';
$html .= '<th>Foto</th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
// SELECT NOS CAMPOS A SEREM EXIBIDOS
$result_transacoes = "SELECT nome, foto FROM clientes";
$resultado_trasacoes = mysqli_query($con, $result_transacoes);
while($row_transacoes = mysqli_fetch_assoc($resultado_trasacoes)){
$html .= '<tr><td>'.$row_transacoes['nome'] . "</td>";
$html .= '<td><img src="http://www.meusite.com/'.$row_transacoes['foto'].'" width="50"></td>';
}
$html .= '</tbody>';
$html .= '</table';
//referenciar o DomPDF com namespace
use Dompdf\Dompdf;
// include autoloader
require_once("dompdf/autoload.inc.php");
//Criando a Instancia
$dompdf = new DOMPDF();
// Carrega seu HTML
$dompdf->load_html('
<div class="header">
<img src="timbrado.png" height="100%" width="100%">
</div>
'. $html .'
');
//Renderizar o html
$dompdf->render();
//Exibibir a página
$dompdf->stream(
"Prontuario.pdf",
array(
"Attachment" => false //Para realizar o download somente alterar para true
)
);
?>
I can display image on
DOMPDF
, thus:echo"<td><img src='http://www.meusite.com/uploads_foto/imagem.png' width='50'></td>";
Only I’m not getting through with the
while
($row_transacoes['foto']
)
That... worked, thank you very much for the attention, sorry anything. Can I ask you to edit and change the name of my site? if possible...
– user184532
@Samuel done and comments removed ;)
– Guilherme Nascimento