Welcome folks today in this blog post we will be auto print the full page of the pdf document using the jspdf library in javascript. All the full source code of the application is shown below.
Get Started
In order to get started you need to make an index.html
file and copy paste the cdn of jspdf
as shown below
index.html
1 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script> |
And now we will be writing the javascript
code to to get the print window when the pdf document is opened. We can use the autoPrint()
method of the jspdf library and here we need to pass the non-conform
variant as shown below
1 2 3 4 5 6 7 |
var doc = new jsPDF() doc.text("hello world",10,10) doc.autoPrint({variant:'non-conform'}) doc.save("output.pdf") |