PHP - HTML2PDF no me permite vizualizar imagen en BD tipo BLOB

 
Vista:

HTML2PDF no me permite vizualizar imagen en BD tipo BLOB

Publicado por Iram Garcia (4 intervenciones) el 28/04/2020 22:01:00
Hola chicos buenas tardes. espero y me puedan ayudar llevo semanas intentando solucionar este problema pero no logro darle solucion. mi porblema esta cuando convierto a pdf un html en el cual tengo una imagen que esta almacenada en mi bd y es tipo blob. me arroja el siguiente error

Html2Pdf Error [2]
Unable to get the size of the image [data:image/jpeg; base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCEUGhvdG9zaG9wIDMuMAA4Qkl..............


este es mi index...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require __DIR__.'/vendor/autoload.php';
 
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
 
if(isset($_POST['crear'])){
//recoger el contentenido del otro fichero
ob_start();
require_once 'print_view.php';
$html = ob_get_clean();
 
try {
    $html2pdf = new Html2Pdf('L', 'A4', 'es', 'true', 'UTF-8');
    $html2pdf->writeHTML($html);
    $img = file_get_contents($row['empleadoFoto']);
    $pdf->Image('@' . $img);
    $html2pdf->output("archivo.pdf");
 
}catch(Html2PdfException $e) {
    $html2pdf->clean();
 
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
}
?>

y aqui es como visualizo la imagen:

1
2
<?php
		echo "<img width='110' height='120' src='data:image/jpeg; base64," . base64_encode($foto) ."' alt='Image'><br>"?>

y esta es mi conexion y consulta

1
2
3
4
5
6
7
8
9
$conexion = mysqli_connect('localhost', 'root', '', 'portal');
 
$sql = "SELECT * FROM empleados";
$result = mysqli_query($conexion, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
 
$count = mysqli_num_rows($result);
 
$foto = $row['empleadoFoto'];

porfavor ayudaaaaa.... estoy desesperado xd xd....
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder