when we use addHTML(), generated pdf quality is poor.
To improve quality, I write this code.
var pdf = new jsPDF('l', 'in', 'a4');
pdf.internal.scaleFactor = 30;
pdf.addHTML($('#print-area')[0], function () {
pdf.save(calendarName);
});
This may help someone
LOL
De facto you are messing up pdf generation.
But this work for me.
Any better suggestion from your side.
Yes it works, but atleast explain what happens so that others can decide if this is a fitting solution for their PDF generation or not.
When you have on the fly created elements(Html element like img tag, text content in other element),
from this when you generated pdf, text gets blurry. To solve this problem I used above code.
So if I understand you correctly, you are saying: content gets blurry =>you do some black box hacking, which you dont understand => content gets non-blurry.
What really happens:
In your code snippet initialize your jsPDF with the scaleSystem inch. So every content you put on your pdf is set by inch-values. jsPDF has to convert the values to points, because PDF-Readers can only handle point-values. So internally jsPDF calculates the scaleFactor so that the values given in the scale-System are converted into pointValues.
If you select "in" for inch, then your scaleFactor is set to 72. If you select "mm" your scaleFactor is set to about 2,83.
So now my question is:
Why 30. Why not 31? Why not 29?
And does it work with every html-code you supply?
If I write 30 with pt the small pdf generate with lot of white space.
In professional softwaredevelopment we call this a magic number. Even though I told you what the function of the internal generated scaleFactor is, you can not explain what the 30 is doing in the background. You just argue, that if you change to pt it would look different.
Magic numbers are any numbers in the source code that just appears without any explanation.
http://www.thinkcode.se/blog/2011/07/28/magic-numbers
The question is: Are you ready to give support to your "solution"? Other people will come and will ask or complain about this "solution". If you are ready to give to all these people support, than I think, that this thread should stay.
But if you think, that the receiver of your solution should figure it out by himself/herself, I think you should close this thread.
So if I understand you correctly, you are saying: content gets blurry =>you do some black box hacking, which you dont understand => content gets non-blurry.
What really happens:
In your code snippet initialize your jsPDF with the scaleSystem inch. So every content you put on your pdf is set by inch-values. jsPDF has to convert the values to points, because PDF-Readers can only handle point-values. So internally jsPDF calculates the scaleFactor so that the values given in the scale-System are converted into pointValues.If you select "in" for inch, then your scaleFactor is set to 72. If you select "mm" your scaleFactor is set to about 2,83.
So now my question is:
Why 30. Why not 31? Why not 29?
And does it work with every html-code you supply?
So Please add some light how to consciously we can manipulate with this number.
So if I understand you correctly, you are saying: content gets blurry =>you do some black box hacking, which you dont understand => content gets non-blurry.
What really happens:
In your code snippet initialize your jsPDF with the scaleSystem inch. So every content you put on your pdf is set by inch-values. jsPDF has to convert the values to points, because PDF-Readers can only handle point-values. So internally jsPDF calculates the scaleFactor so that the values given in the scale-System are converted into pointValues.If you select "in" for inch, then your scaleFactor is set to 72. If you select "mm" your scaleFactor is set to about 2,83.
So now my question is:
Why 30. Why not 31? Why not 29?
And does it work with every html-code you supply?
u are very stupid !