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);
}
}
});
}
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);
}
}
});
}
Share
Improve this question
edited Oct 10, 2014 at 22:04
gab06
asked Oct 8, 2014 at 5:16
gab06gab06
6108 silver badges24 bronze badges
7
- 2 Hi! Sorry, but this question is much too unspecific to be answerable. Which one exactly is the "latest" version of your FF? What do you do to "download the PDF"? What error messages do you get? Do you have any code to show us how you are using jspdf? – Bergi Commented Oct 10, 2014 at 5:56
-
So, are there any errors when this runs in FF? What kind of debugging have you done, is
div.length
really0
anddoc.save()
actually executed? – Bergi Commented Oct 11, 2014 at 15:32 - @Bergi Yes, they're actually executed. I placed an alert inside that if, before the doc.save() function. What's weird is that after I placed the alert, it started to download the pdf, but not always... Sometimes it shows the dialogue to save the pdf, sometimes not.. – gab06 Commented Oct 13, 2014 at 0:05
- Now i placed the alert after the doc.save(), and it always downloads... – gab06 Commented Oct 13, 2014 at 0:06
- Should I give U the +50 rep? :P – gab06 Commented Oct 13, 2014 at 0:11
3 Answers
Reset to default 6The issue lies within the execution of the doc.save()
. The document is not ready yet, when the save()
mand is invoked. Try to set a timeout and it should work.
setTimeout(function() {
doc.save(filename);
}, timeout);
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.
One thread is going on related this issue, may be you will get fix here. https://github./parallax/jsPDF/issues/3391