New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print a generated pdf via embedded javascript #713
Comments
You're in luck. dompdf (as of v0.6.0) has the ability to embed JavaScript into a PDF. The JS functionality is somewhat limited in that you can't tie the JS to events. But in the case of telling the PDF to print you can just tack the necessary JS to the end of the document. First, set DOMPDF_ENABLE_JAVASCRIPT to true. Then place the JS that calls the print dialog at the bottom of your HTML document: <html>
<head>
<title>Javascript test</title>
</head>
<body>
<h1>PDF JS Test</h1>
<p>This page will call the print dialog on load.</p>
<script type="text/javascript">
try {
this.print();
}
</script>
</body>
</html> |
To make it work, you need to use this JS bloc inside your PDF Blade :
I hope it helps ! |
Thank you this script was working fine |
Thank you so much. Worked for me too. |
|
It appears that it may be technically possible to embed some javascript inside the generated pdf that could automatically load the pdf viewer's print dialog upon load.
Is there any way to embed javascript into the pdf with DOMPDF, or can this only be done if you have implemented your own web-based PDF Viewer?
References:
The text was updated successfully, but these errors were encountered: