jsPDF-AutoTable
jsPDF-AutoTable copied to clipboard
Saving to server
var doc = new jsPDF('p', 'pt');
var res = doc.autoTableHtmlToJson(table, true);
doc.autoTable(res.columns, res.data);
var pdf =doc.output();
console.log(pdf)
var data = new FormData();
data.append("data" , pdf);
var xhr = new XMLHttpRequest();
xhr.open( 'post', 'upload.php', true );
xhr.send(data);
Works.
Sweet!
when i use this method, the PDF file saved is corrupted and only 3Kb of size, but when i choose to download that same file with doc.save() i get a file with ~6Mb. this is the php file i'm using:
'<?php
if(!empty($_POST['data'])){
$data = $_POST['data'];
$fname = "certificado.pdf";
$file = fopen("certificado/" .$fname, 'w');
fwrite($file, $data);
fclose($file);
?>
any ideas?
bryann-and
If your pdf design has any lines or graphics from jspdf like. doc.line(10,100,200,100) the pdf will get corrupted when trying to send it this way.
I have been looking for a solution as well with no luck. Hope someone can figure out a solution.