spatie/laravel-pdf

[Bug]: header and footer image not loading

RVP04 opened this issue · 0 comments

RVP04 commented

What happened?

header blade

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        .header {
            font-family: "Courier New";
            position: fixed;
            top: 10px;
            left: 0;
            right: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
<div class="header">
    <img src="{{ asset('img/gray-logo.png') }}" width="160" height="70" style="float: right" alt="">
    <p style="display: flex;margin-top: 40px; font-size: 12pt;font-weight: bold;align-items: center;justify-content: center">{{ $reportTitle ?? '' }}</p>
</div>
</body>
</html>

footer.blade.php

<!DOCTYPE html>
<html>

<head>
    <style>
        .footer {
            position: absolute;
            left: 0px;
            right: 0px;
            height: 10px;
            float: left;
            font-size: 7pt;
            border-top: 1px solid black;
            padding-top: 10px;
            font-family: 'Courier New';
        }

        .page-number {
            overflow: hidden;
            float: right;
            margin-right: 40px;
        }

        .report {
            overflow: hidden;
            width: 250px;
            float: left;
            margin-left: 10px;
        }
    </style>
</head>

<body>
<div class="footer">
    <div class="report">Page @pageNumber of @totalPages</div>
    <div class="page-number"><img src="{{public_path('img/broad-logo.png')}}" width="100" height="20"></div>
</div>
</body>
</html>

How to reproduce the bug

PDF budlider

return Pdf::view('reports.pdf.status_subject_wise', [
            'subjects' => $subjects
        ])->headerView('layout.reports.header', ['reportTitle' => 'Feed Back Status - Subject Wise'])
            ->footerView('layout.reports.footer')
            ->format('a4')
            ->orientation(Orientation::Landscape)
            ->margins(2.5, 0.5, 1.2, 0.5, 'cm')
            ->name('Feedback Status - Subject Wise.pdf');
  1. Image is not loading using asset() helper or public_path() there is no sign of image in the document. When use alt attribute it is not showing image not loaded
  2. when use asset() first page logo not showing (image not loaded it is not coming see the image) and if public path is use just a box appears

asset
Screenshot 2024-02-03 at 4 34 56 AM
public_path
Screenshot 2024-02-03 at 4 35 21 AM

need a solution for this isseues

Package Version

1.1.2

PHP Version

8.3.0

Laravel Version

10.40

Which operating systems does with happen with?

macOS

Notes

No use of #44 discussion

No response