question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve pdf quality

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
Uzlopakcommented, Oct 5, 2017

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?

3reactions
Uzlopakcommented, Oct 5, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found