Improve pdf quality
See original GitHub issuewhen 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
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
Upgrade Resolution, easily fill and edit PDF online.
Upgrade Resolution. pdfFiller is the best quality online PDF editor and form builder -it's fast, secure and easy to use. Edit, sign, fax...
Read more >Create high-resolution print-ready PDFs using Acrobat
Create high-resolution print-ready PDFs using Acrobat · Open the PDF in Acrobat and go to File > Save as Other > Press-Ready PDF...
Read more >Online PDF Optimizer - PDF Tools - PDFResizer.com
Free online PDF optimizer tool. It allows you to loslessly optimize PDF to reduce file size by stripping unnecessary meta data and applying...
Read more >Clean up PDF Online Quick and Easy With ScanWritr
ScanWritr is an online editor and converter allowing you to clean up PDF, which is stored on your computer, Dropbox or Google Drive....
Read more >PDF Tools Online - PDF Optimizer
Optimize PDF File ; Select PDF file to optimize ; Image Options, Font Options, Structure Options ; 3-Heights™ PDF Optimization Tool product page....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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?
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.