'jsPDF - compatibility issues in Firefox
jsPDF doesn't work well with the latest version of Firefox. It does not let me to download the PDF. Is there a fix on this? I tried downloading the latest version of jsPDF.
EDIT:
- My FF version is 32.0.3
- I don't get any error messages.
This is the code that "downloads" the pdf. It works well in IE and Chrome:
So I think it has nothing to do with the code. What I want to know is how can I download the pdf in Firefox.
function appendDataToPDF(div, doc, top)
{
html2canvas(div, {
background: '#fff',
onrendered: function(canvas) {
var img = canvas.toDataURL();
doc.addImage(img, 'JPEG', 10, top, parseInt($(div).css("width"), 10), parseInt($(div).css("height"), 10));
if(top > 240)
{
doc.addPage();
top = 27;
}
div = $(div).next();
if(div.length === 0)
{
doc.save('doc.pdf');
}
else
{
if(div.get(0).nodeName === 'BR')
div = $(div).next();
appendDataToPDF(div, doc, top);
}
}
});
}
Solution 1:[1]
The issue lies within the execution of the doc.save()
. The document is not ready yet, when the save()
command is invoked. Try to set a timeout and it should work.
setTimeout(function() {
doc.save(filename);
}, timeout);
Solution 2:[2]
I just placed an alert()
after the doc.save()
function and now the download works. You could try this solution if you run into the same problem.
Solution 3:[3]
One thread is going on related this issue, may be you will get fix here. https://github.com/parallax/jsPDF/issues/3391
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | LuÃs Cruz |
Solution 2 | gab06 |
Solution 3 | Dinesh Satpute |