I used Laravel-Snappy to generate Pdf with large data. I want to add page count and many more things in 'footer.php'. I used below code from https://wkhtmltopdf.org/usage/wkhtmltopdf.txt.
<!DOCTYPE html>
<html><head><script>
function subst() {
var vars = {};
var query_strings_from_url = document.location.search.substring(1).split('&');
for (var query_string in query_strings_from_url) {
if (query_strings_from_url.hasOwnProperty(query_string)) {
var temp_var = query_strings_from_url[query_string].split('=', 2);
vars[temp_var[0]] = decodeURI(temp_var[1]);
}
}
var css_selector_classes = ['page', 'frompage', 'topage', 'webpage', 'section', 'subsection', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'];
for (var css_class in css_selector_classes) {
if (css_selector_classes.hasOwnProperty(css_class)) {
var element = document.getElementsByClassName(css_selector_classes[css_class]);
for (var j = 0; j < element.length; ++j) {
element[j].textContent = vars[css_selector_classes[css_class]];
}
}
}
}
</script></head><body style="border:0; margin: 0;" onload="subst()">
<table style="border-bottom: 1px solid black; width: 100%">
<tr>
<td class="section"></td>
<td style="text-align:right">
Page <span class="page"></span> of <span class="topage"></span>
</td>
</tr>
</table>
</body></html>
I got this below error --
The exit status code '-1073741819' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% [==============================> ] 50% [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) [> ] 1% [=> ] 3% [===> ] 5% [===> ] 6% [====> ] 8% [======> ] 10% [=======> ] 12% " stdout: "" command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf" --lowquality --margin-bottom "30mm" --margin-top "40mm" --page-size "a4" --encoding "UTF-8" --enable-javascript --javascript-delay "13500" --enable-local-file-access --enable-smart-shrinking --no-stop-slow-scripts --footer-html "C:\Users\RAGINE1\AppData\Local\Temp\knp_snappy64b90da61bd510.93606603.html" --header-html "C:\Users\RAGINE1\AppData\Local\Temp\knp_snappy64b90da61bf1d8.66548341.html" "C:\Users\RAGINE1\AppData\Local\Temp\knp_snappy64b90da61baf51.08168467.html" "C:\Users\RAGINE1\AppData\Local\Temp\knp_snappy64b90da61bcec9.78969162.pdf".
I tried the below:
$pdf = PDF::loadView('report.pdf.Report', $data=['Products'=>$Products])
->setOption('margin-top', '40mm')
->setOption('margin-bottom', '30mm')
->setOption('enable-javascript', true)
->setOption('javascript-delay', 13500)
->setOption('enable-smart-shrinking', true)
->setOption('no-stop-slow-scripts', true)
->setOption('header-html', $headerHtml)
->setOption('footer-html', $footerHtml)
->setPaper('a4');
return $pdf->inline();
Also tried in snappy.php
'pdf' => [
'enabled' => true,
'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"',
'timeout' => 3600,
'options' => [
'enable-local-file-access' => true,
'encoding' => 'UTF-8'
],
'env' => [],
],
Still, I can't able to find the solution.