PhpChromeToPdf icon indicating copy to clipboard operation
PhpChromeToPdf copied to clipboard

Print current and total page number value in repeatable custom header at custom position

Open wpteam4 opened this issue 4 years ago • 1 comments

Hello Team,

How can we print current and total page number value in the repeatable custom header at custom position.

Thanks sample

wpteam4 avatar Mar 05 '21 06:03 wpteam4

Code I'm using:

use dawood\phpChrome\Chrome;

$chrome=new Chrome('https://youtube.com','/usr/bin/google-chrome'); $chrome->setOutputDirectory(DIR); //not necessary to set window size $chrome->setWindowSize($width=1477,$height=768); print "Pdf successfully generated :".$chrome->getPdf().PHP_EOL;

wpteam4 avatar Mar 05 '21 06:03 wpteam4

Hello, although this is a bit old, I'm answering it anyway as it might be useful for others.

Directly setting headers and footers with this library is not possible, but it can be achieved using CSS print queries. Here's an example:

<head>
    <style>
        @media print {
            .header {
                position: fixed;
                top: 0;
                width: 100%;
                text-align: center;
            }
            .footer {
                position: fixed;
                bottom: 0;
                width: 100%;
                text-align: center;
            }
        }
    </style>
</head>
<body>
    <div class="header">This is the header</div>
    <div class="content">Your page content here</div>
    <div class="footer">This is the footer</div>
</body>
</html>

daudmalik06 avatar Jan 10 '24 15:01 daudmalik06