dompdf / dompdf

HTML to PDF converter for PHP
https://dompdf.github.io/
GNU Lesser General Public License v2.1
10.57k stars 1.8k forks source link

show the Header and footer on all pages of PDF because I'm Generating a PDF in Laravel using DOMPdf #3459

Open arslankhan0123 opened 6 months ago

arslankhan0123 commented 6 months ago

By using this css I'm getting the header and footer on all pages of PDF.

Here;s the HTML with include Header and Footer file:

<html>

<head>
</head>

<body style="cursor: auto;box-sizing:border-box;padding:0px;margin:0px;font-family:-apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;color:rgb(54, 65, 82);font-size:14px;font-weight:400;line-height:18.676px;background-color:rgb(255, 255, 255);">
    @include('agreements.header')
    @include('agreements.footer')
    <div class="content">
        <div style="box-sizing:border-box;">
            <div style="box-sizing:border-box;padding:32px 88px;">
                <h4 style="box-sizing:border-box;margin:8px 0px 5.6px;font-size:16px;color:rgb(18, 25, 38);font-weight:600;font-family:Roboto, sans-serif;line-height:19.76px;text-align:center;text-decoration:underline solid rgb(18, 25, 38);">INDEPENDENT CONTRACTOR STATEMENT</h4>
                <p style="box-sizing:border-box;margin:16px 0px 0px;line-height:20.01px;font-family:Roboto, sans-serif;font-size:15px;font-weight:500;">I, the undersigned Contractor, understand that I have entered into a Contract Delivery Service Agreement (the “Contractor Agreement”) with American Dedicated Logistics. I confirm that I have read the full terms of the Contractor Agreement and the Contractor Engagement Addendum. To further clarify my business relationship with American Dedicated Logistics, I acknowledge and agree as follows:</p>
                <div style="box-sizing:border-box;margin-top:16px;"><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">1.</span>I am an independent contractor and NOT employed by American Dedicated Logistics, or any of its customers.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">2.</span>I am responsible for paying my own federal, state, and local taxes, and I understand American Dedicated Logistics will not withhold or pay my taxes but will instead report my income on a Form 1099.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">3.</span>I am responsible for my own work expenses</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">4.</span>I am not eligible for, nor will I participate in any employee pension plan, health or other fringe benefit plan of American Dedicated Logistics.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">5.</span>I am responsible for my own workers’ compensation insurance where applicable.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">6.</span>I understand that I am not eligible for unemployment insurance based upon my independent contractor status.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">7.</span>I am responsible for my own automotive insurance and must provide proof of the agreed upon coverage when requested.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">8.</span>I am responsible for supplying my own vehicle to perform delivery services.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">9.</span>I am responsible for choosing my own engagements and, once accepted, I am responsible for completing my engagements as agreed.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">10.</span>I have the right to use my own contractors or employees to complete my work, but I understand I am ultimately responsible for ensuring the work is completed as agreed.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">11.</span>I have the right to work for companies other than American Dedicated Logistics.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">12.</span>I agree to notify American Dedicated Logistics in writing immediately if I have reason to believe my status as an independent contractor may be in question so that appropriate corrections can be made.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">13.</span>I will not represent to any third-party that I am employed by American Dedicated Logistics; I am a self-employed contractor.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">14.</span>I am responsible for my own safety, the safety of any of my contractors and employees, and for the safe operation of the vehicle(s) used in my work.</span></span><span style="box-sizing:border-box;margin:0px;font-family:Roboto, sans-serif;display:flex;line-height:22.5px;font-size:15px;font-weight:500;"><span style="box-sizing:border-box;margin:0px;font-size:14px;line-height:18.676px;font-family:Roboto, sans-serif;text-indent:40px;font-weight:500;"><span style="box-sizing:border-box;margin:0px 40px 0px 0px;font-size:14px;font-weight:400;line-height:18.676px;font-family:Roboto, sans-serif;display:inline;">15.</span>I am responsible for lost packages, damaged packages or any money lost once it has been placed in my care.</span></span></div>
                <div style="box-sizing:border-box;margin-top:32px;">
                    <div style="box-sizing:border-box;display:flex;flex-flow:row wrap;margin-top:-160px;width: calc(100% + 160px);margin-left:-160px;">
                        <div style="flex-basis:50%;-webkit-box-flex:0;flex-grow:0;max-width:50%;box-sizing:border-box;margin:0px;flex-direction:row;padding-left:160px;padding-top:160px;"><span style="box-sizing:border-box;margin:0px;color:rgb(18, 25, 38);font-family:Roboto, sans-serif;padding-left:16px;display:block;border-bottom:1px solid rgb(18, 25, 38);line-height:15px;font-size:15px;font-weight:500;min-height:15px;">{{ $signature }}</span>
                            <h6 style="box-sizing:border-box;margin:0px;color:rgb(18, 25, 38);font-family:Roboto, sans-serif;line-height:13px;font-weight:500;font-size:13px;">Signature of Contractor</h6>
                        </div>
                        <div style="flex-basis:41.6667%;-webkit-box-flex:0;flex-grow:0;max-width:41.6667%;box-sizing:border-box;margin:0px;flex-direction:row;padding-left:160px;padding-top:160px;"><span style="box-sizing:border-box;margin:0px;color:rgb(18, 25, 38);font-family:Roboto, sans-serif;padding-left:4px;display:block;border-bottom:1px solid rgb(18, 25, 38);line-height:15px;font-size:15px;font-weight:500;min-height:15px;">{{ date('d/m/Y') }}</span>
                            <h6 style="box-sizing:border-box;margin:0px;color:rgb(18, 25, 38);font-family:Roboto, sans-serif;line-height:13px;font-weight:500;font-size:13px;">Date</h6>
                        </div>
                    </div>
                </div>
                <h6 style="box-sizing:border-box;margin:60px 0px 4.2px;font-weight:500;color:rgb(18, 25, 38);font-family:Roboto, sans-serif;line-height:21px;text-align:center;font-size:12px;">American Dedicated Logistics, Inc. / Midlothian, VA 23112 /804-836-3612</h6>
            </div>
        </div>
    </div>
</body>

</html>

Here;s the header code with css:

<style>
    @page {
        margin-top: 100px;
        /* Adjust as needed to accommodate the header */
        margin-bottom: 50px;
        margin-left: 50px;
        margin-right: 50px;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .content {
        margin-top: 10px;
        /* Adjust this to prevent content overlap with the header */
    }

    .header {
        position: fixed;
        top: -80px;
        /* Adjust based on the header height */
        left: 0;
        right: 0;
        height: 80px;
        /* Adjust based on the header height */
        text-align: center;
    }

    .header img {
        height: 100%;
    }
</style>

<?php
// Assuming this code is in your controller
$imagePath = public_path('logo/adl-logo.png'); // Adjust the path to your image
$imageData = base64_encode(file_get_contents($imagePath));
$src = 'data:image/png;base64,' . $imageData;
?>
<div class="header">
    <img src="{{ $src }}">
</div>

this is the footer file code:-

<style>
    .footer {
        position: fixed;
        bottom: -80px;
        /* Adjust based on the header height */
        left: 0;
        right: 0;
        height: 80px;
        /* Adjust based on the header height */
        text-align: center;
    }
</style>
<div class="footer">
    <p>American Dedicated Logistics, Inc. / Midlothian, VA 23112 /804-836-3612</p>
</div>
bsweeney commented 6 months ago

Sorry what kind of help do you need?