Javascript Not Working
wichaksono opened this issue · comments
i trying to write some javascript on my code
`<?php
require DIR . '/vendor/autoload.php';
use Knp\Snappy\Pdf;
header('Content-Type: application/pdf');
#header('Content-Disposition: attachment; filename="file.pdf"');
$snappy = new Pdf();
$snappy->setBinary(DIR . '/wkhtmltox/bin/wkhtmltopdf.exe');
$snappy->setOption('enable-javascript', true);
$snappy->setOption('javascript-delay', 13500);
$snappy->setOption('enable-smart-shrinking', true);
$snappy->setOption('no-stop-slow-scripts', true);
echo $snappy->getOutput('http://localhost/cv/tpl/test.html', [
'margin-top' => 0,
'margin-right' => 0,
'margin-bottom' => 0,
'margin-left' => 0,
'orientation' => 'portrait',
'page-size' => 'A4',
'no-outline' => true,
]);
`
`<script type="text/javascript">
var elm = document.getElementById("body");
let h = elm.offsetHeight;
document.getElementById("iii").innerHTML += h;
</script>
whats wrong in my code?
Hello,
Can you please provide a full reproducible example and explain what do you expect as output and what do you get instead?
hi, thank for reply.
in my project i want to make some pretty pdf reporting, where the report is to long, the pdf output will be create new page, but now the page is not pretty.
i think can use javascript to count page height and comparing with total height of divs, when total height > page height, last div will be move to new page.
iwant
I think your issue is more of a CSS issue. I'm not a CSS master but having done a quick search on Google I found that you have the break-inside
property that might help you achieving what you want.
See https://stackoverflow.com/questions/907680/css-printing-avoiding-cut-in-half-divs-between-pages.
I'm gonna close the issue as this is not really a Snappy issue but more an issue in your CSS or, in case, a wkhtmltopdf issue.