the code works only by starting it from the browser, while in the phone the button does not generate pdf ...
I state that I've been using Cordova recently and maybe I can't set the plugins well .. any information, even trivial, can be useful.
the cart table is generated by a javascript code that uses the dom on another hatml page, I think that something is almost certainly missing to make the app store the file on the device but I don't know what to insert .. also which plug in to refer to possibly ..
Thanks in advance to everyone
<strike>
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script src="js/carrello.js"></script>
</HEAD>
<BODY>
<div>
<h2>Il tuo Ordine</h2>
<script language=javascript >
carrello = eval(localStorage.carrello);
document.write("<div id=elenco>");
tabella();
document.write("</div>");
totali();
</script>
</div>
<br>
<br>
<a class="pTab" href=prodotti.html style="text-decoration: none;">Torna ad ordinare</a>
<br>
<br>
<a class="pTab" href=javascript:svuota() style="text-decoration: none;">Svuota ordine</a>
<br>
<br>
<br>
<button onclick="scaricaPdf()">crea PDF</button>
<br>
<br>
<a href="index.html" style="text-decoration: none;">
<div class="mybutton1">HOME</div>
</a>
</BODY>
<script>
function scaricaPdf() {
var doc = new jsPDF();
var spesaTotale= document.getElementById("totale").innerHTML;
var x=20; //variabile per i margini
var y=35; //variabile per le righe
doc.setFontSize(15);
doc.text(20,20,'Questo è il tuo ordine:');
doc.setFontSize(10);
doc.text(20,30,'Codice'+' Descrizione Prodotto' +' Prezzo'+' Quantità'+' Totale');
for(var i=0; i<carrello.length; i++){
y=y+5;
var codiceProdotto=carrello[i].codice;
doc.text(x,y,' '+codiceProdotto);
var descrizioneProdotto = carrello[i].descr;
doc.text(33,y,''+descrizioneProdotto);
var prezzoProdotto = carrello[i].prezzo;
doc.text(68,y,''+prezzoProdotto);
var quantitaProdotto =carrello[i].qnt;
doc.text(83,y,''+quantitaProdotto);
var totProdEuro=carrello[i].prezzo * carrello[i].qnt;
doc.text(100,y,''+totProdEuro);
}
doc.text(20,200, 'Totale '+spesaTotale);
doc.save('Ordine.pdf');
}
</script>
<script src="cordova.js"></script>
<script src="js/index.js"></script>
</HTML>
</strike>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…