Ive been stuck here for hours trying to figure out whats wrong with this thing. It works when I exclude/comment out the javascript part but not when its uncommented. Another problem I faced is adding external assets to the view using {{ asset('js/app.js') }}. I tried {{ url(...) }}, {{ public_path(...) }} since it worked on some people after my research but chrome returns an error Not allowed to load local resource, i just need this to add jquery. If theres an alternative way to adding jquery pls tell me, tried CDN to no avail
I switched from dompdf to snappy BECAUSE I heard it works with javascript but now im stuck. I really need help.
version:
Windows 64-bit: wkhtmltopdf 0.12.6 (with patched qt)
Controller
<?php
namespace App\Http\Controllers;
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
class AsdController extends Controller
{
public function index()
{
$pdf = PDF::loadView('asd.index');
$pdf->setOption('enable-javascript', true);
$pdf->setOption('javascript-delay', 13500);
$pdf->setOption('enable-smart-shrinking', true);
$pdf->setOption('no-stop-slow-scripts', true);
return $pdf->download('asd.pdf');
}
}
VIEW
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1 id="sss">This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
<script>
document.getElementById('sss').innerHTML = 'HAHA';
</script>
</html>
the error WITHOUT external assets but with javascript
The exit status code '-1073741819' says something went wrong: stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==============================> ] 50%
" stdout: "" command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"
--lowquality --enable-javascript --javascript-delay "13500" --enable-smart-shrinking
--no-stop-slow-scripts
the error WITH external assets and javascript
The exit status code '-1073741819' says something went wrong: stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==============================> ] 50%
Warning: Failed to load http://localhost:8000/js/app.js (ignore)
" stdout: "" command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"
--lowquality --enable-javascript --javascript-delay "13500"
--enable-smart-shrinking --no-stop-slow-scripts