Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AriAris's avatar

dompdf does not recognize my html image laravel adminlte

I have an html where I want to insert an image which is displayed when downloading the pdf, but it doesn't show it to me, I already tried public_path() and other solutions and it still doesn't work, my html looks like this:

img src="/assets/imagen.png" style="max-width: 100px;" Reporte de Documentaciones Completas e Incompletas por Año Proceso "A"

<table>
    <thead>
        <tr>
            <th>Año</th>
            <th>Documentaciones Completas</th>
            <th>Documentaciones Incompletas</th>
        </tr>
    </thead>
    <tbody>
        @foreach ($anioCompletas as $anio => $completas)
            <tr>
                <td>{{ $anio }}</td>
                <td>{{ $completas }}</td>
                <td>{{ $anioIncompletas[$anio] }}</td>
            </tr>
        @endforeach
    </tbody>
</table>

and the method like this

public function generarPDF() { $datos = $this->graficaDocumentacionCompletaPorAnio();

    // Aquí deberías pasar las variables en un array asociativo
    $viewData = [
        'anioCompletas' => $datos['anioCompletas'],
        'anioIncompletas' => $datos['anioIncompletas'],
        // ... Otras variables que necesites pasar
    ];

    $html = view('procesoA.reporteA', $viewData)->render();

    $dompdf = new Dompdf();
    $dompdf->loadHtml($html);
    $dompdf->render();

    return $dompdf->stream("reporte.pdf");
}

Currently I am only occupying that

0 likes
7 replies
vincent15000's avatar

Try this.

<img src="{{ assets('imagen.png') }}">

You have the idea, but you will probably have to customize the path, it depends on the folder in which the image is.

vincent15000's avatar

@AriAris What have you tried ? Exactly this ? <img src="{{ assets('imagen.png') }}"> ? Or have you customized the path ?

I can only answer you according to the informations you give.

johndivam's avatar

use public_path

{{public_path('assets/images/image.jpg')}}"
1 like
AriAris's avatar

@jonhyknid Now it only shows me the path of where the image is located but it does not show the image

1 like
johndivam's avatar

@AriAris

    $dompdf = new Dompdf();

    // Set options directly on the Dompdf instance
    $dompdf->set_option('isHtml5ParserEnabled', true);
    $dompdf->set_option('isRemoteEnabled', true);

1 like

Please or to participate in this conversation.