And if it is not possible then what are the other alternatives?
I tried to convert a complete html page to pdf with dynamic values but I can't .
But I saw some API like jspdf but it is not useful for me.
Is it possible to save a HTML page as PDF file using JavaScript or jQuery?
In Detail:
I generated one HTML Page which contains a list grid which populated all the available reports dynamically. It has one button 'save as PDF'. If the user clicks this button then the HTML page will be converted to a PDF file.
Is it possible using JavaScript or jquery?
Generate PDF using JavaScript The following example shows how to use the jsPDF library to generate PDF file using JavaScript. Specify the content in text() method of jsPDF object. Use the addPage() method to add new page to PDF. Use the save() method to generate and download PDF file.
Explanation: The Export Button has been assigned a jQuery click event handler. When the Export Button is clicked, the HTML Table is converted into a HTML5 Canvas using html2canvas plugin and then the HTML5 Canvas will be exported to PDF using the pdfmake plugin.
To save HTML page as PDF using JavaScript, we can use the html2pdf library. const element = document. getElementById("element-to-print"); const opt = { margin: 1, filename: "myfile.
jsPDF has a HTML renderer but it is in the early stages:
https://github.com/mrrio/jsPDF
http://parall.ax/products/jspdf
Another solution might be https://github.com/eKoopmans/html2pdf.js
But the best solution is the one from mujaffars. User AJAX and a stable PDF library written in PHP like FPDF, PDFLib, TCPDF and others.
Well, if I have got your question properly then u need to Export a Table Data as PDF
?
If Yes, then please see datatables.js with simple example here.
Also, look into use BytescoutPDF.js (Bytescout PDF Generator for JavaScript) to draw PDF invoice and JSPDF you can get the details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With