Why you don't use a blade for that?
Jan 12, 2021
6
Level 2
Remove header and footer from the last page of pdf using css
Hi, I'm using laravel dompdf and I have a cover page that is generated at the end of my pdf. But I don't want header and footer to appear on the last page.
Here is my code:
$output='<html><body>
<div class="firstpage">
<img src="...">
</div>
<div id="header">
<img src="..." width="700px" height="104px">
</div>
<div id="content">';
$output .= '
<html>
<head>
<style>
@page { margin: 180px 60px;}
#header { position: fixed; left: 0px; top: -150px; right: 0px; height: 100px; text-align: center; }
#footer{ position: fixed; left: -20px; bottom: -150px; right: 0px; height: 100px; }
.firstpage {
page-break-after: always;
}
.lastpage{
//Which css attribute can I have here to remove header and footer?
}
</style>
</head>
<body>
<div id="content">
......
</div>
</body>
</html>
$output .= '<div id="footer">
<img src="...." width="700px" height="104px">
</div>';
$output .= '
<div class="lastpage">
// I want to remove the header and footer from this page
<img src="..." height="740px" width="521px">
</div>
</body>
</html>';
return $output;
All the pages except the first page has header and footer in it. But I want to remove them from the div which has "lastpage" as class. How can I do it using css? Thanks in advance
Please or to participate in this conversation.