How to use wkhtmltopdf page option: --run-script inside of exec()
exec(path/to/wkhtmltopdf --run-script(???) path/to/pdf-ed/doc path-to-output-pdf))
How to use wkhtmltopdf page option: --run-script inside of exec()
exec(path/to/wkhtmltopdf --run-script(???) path/to/pdf-ed/doc path-to-output-pdf))
The --run-script
argument takes JavaScript passed at the command line. NOT a script file, but actual script content.
$jsCode = '/* JavaScript code that manipulates the DOM... */';
$webURL = 'http://example.com';
$pdfFile = '/tmp/output.pdf';
exec('wkhtmltopdf '.
'--run-script '.escapeshellarg($jsCode).' '.
escapeshellarg($webURL).' '.
escapeshellarg($pdfFile));