I'm trying to generate PDF with content of a view in Laravel application using spatie/browsershot & laravel-browsershot wrapper; I am using svg as my letterhead background and would like to place content of the view in within certain area of the SVG on every page. Unfortunately the margins ->margins(40, 20, 40, 30)
makes my #watermark
div to shift with the margin - it is not in fixed 0,0 position anymore.
Could you help me to setup the watermark div correctly please? So it is not affected by page margins
in controller
return PDF::loadView('pdf.letter', compact('letter'))
->showBackground()
->waitUntilNetworkIdle()
->margins(40, 20, 40, 30)
->format('A4')
->inline();
in my blade I setup following css
#watermark {
position: fixed;
top: 0px;
left: 0px;
width: 21cm;
height: 29.7cm;
z-index: -1000;
}
<body>
<div id="watermark">
<img src="{{ asset('/img/a4.svg') }}" height="100%" width="100%" />
</div>
<div>
<!-- The content of PDF here -->
</div>
</body>
The best what I achieved is this
where dash line rectangle is the area in the SVG file where I wish all content of the view, to flow in through all the pages, respecting set margins
I achieved it with removal of ->margins(....)
in php and adding style to the <body>
tag
body {
margin-top: 4cm;
margin-right: 2cm;
margin-bottom: 4cm;
margin-left: 3cm;
}
as you see the margin of the page seems to be 0 on the bottom of the 1st page and on top of next page
SomeText
however if I don't chain `headerHtml` method standard chrome header is printed with the page print date in my case. Could you advice how $someHtml shall be structured to include said image? – dascorp May 03 '20 at 19:05header