Using the jsPDF plugin, I create a .pdf file and create a download based on a button click. I would like to save the file on my server and not initiate the download. Therefore, when the button is pressed, I want the file to be saved in:
/tmp/uploads/pdf/example.pdf
I know that I need to use Jquery.Ajax to publish the file to the server. However, looking at the documentation, I did not see .pdf support as a data type.
My code is:
$(document).on("click", "#PDF", function () { var table = document.getElementById("result"); var tbl = window.sessionStorage.getItem("tbl"); var cols = [], data = []; function html() { var doc = new jsPDF('p', 'pt'); var res = doc.autoTableHtmlToJson(table, true); doc.autoTable(res.columns, res.data); doc.save( tbl+".pdf"); } html(); });
Based on this xml document saving , I tried the following:
var pdfDocument = doc.save( tbl+".pdf"); var pdfRequest = $.ajax({ url: "/tmp/uploads/pdf", processData: false, data: pdfDocument });
Download the file, not save it. How to save a file?
source share