splitTextToSize uses inverse scale factor
See original GitHub issueThe documentation of splitTextToSize
states it uses “measurement units declared as default for the jsPDF instance”.
Thus when I define the constructor
let doc = new jsPDF('p', 'px', 'a4');
a line that spans the entire page should be 595.28pt * 96 / 72 = ~793.7 pixels wide. One would then expect that
let splitText = doc.splitTextToSize(longText, 793.7);
doc.text(splitText, 0, 0)
produces lines that spans the entire page, but this not the case.
A page-spanning line is achieved at ~446 pixels like so
let splitText = doc.splitTextToSize(longText, 446);
doc.text(splitText, 0, 0)
Now, 446 happens to be 595.28 / (96 / 72), or 595.28 * (72/96), leading me to conclude that, somehow, an inverse scale factor is being applied between pt and px when adding text
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
The Inverse Scale Factor in Isotropic Quantum Geometry - arXiv
This procedure results in a bounded operator which is diagonalizable simultaneously with the volume operator and whose eigenvalues are ...
Read more >How do I use Text Scale Factor property in flutter
You can use MediaQuery.of(context).textScaleFactor but I think using auto_size_text is more efficient. EDIT 2 :
Read more >jspdf.js - Documentation
@param unit {String} Measurement unit to be used when coordinates are specified. ... gStatesMap = {}, // see fonts; activeGState = null,; k,...
Read more >Calculate the Inverse of a Combined Scale Factor
I have a drawing that needs to be scaled (using the scale command) by a global scale factor of 0.99975185, so I need...
Read more >jspdf.js - Documentation - GitHub Pages
If you want to use your own format just pass instead of one of the above ... var activeGState = null;; var k;...
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 FreeTop 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
Top GitHub Comments
The ‘px’ scaling factor is wrong per default. Try enabling the px_scaling hotfix and see if this gives the expected result.
It’s documented in the jsPDF constructor API doc: http://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html, but yeah, mentioning it in the readme as well is probably a good idea.