-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc.internal.pageSize.getWidth()
doesn't match measured value
#2927
Comments
And the media box is printed to the PDF like this (in pdf units/`pt) (the media box is basically the page size):
So the value returned from |
Digging in to the code I found this
I don't think this simplistic approach works 🙁 The amount of pixels needed to represent an inch (or pt for that matter) is going to depend on the monitor PPI |
Yeah, accidentally hit "comment" there..., it's fixed, now. |
I have a related question up on StackOverflow: https://stackoverflow.com/questions/64035751/how-do-i-properly-set-the-image-size-in-jspdf-so-that-the-image-isnt-blurry |
By |
Creating an "a4" pdf with "pt" size the width is 595.28. Taking a screenshot (at 100% zoom) on my display (Dell XPS 9550, 1920x1080) the page is 793 px. So here the scale factor is ~1.33. But creating an "a4" pdf with "px" size the size is reported as 446.46, implying that the scale factor is ~0.75. So probably related to this: What is that hotfix thing? |
Enabling the |
Yeah, for myself and for future reference, I did the math once again:
Which means we have to multiply each pixel by Thanks for bringing that up ;) |
Is this still working? I am using jsPDF 2.3.1 and trying to put images inside a pdf, but they get blurry. When i try to enable "px_scaling" mentioned here, and https://github.com/MrRio/jsPDF/blob/master/HOTFIX_README.md the code won't compile. After checking the package, there is no "hotfix" in the code, and the jsPDF constructor only takes "jsPDFOptions"
Edit: I had to pass it in as a constructor parameter, and surpress the statement with // @ts-ignore. It works now properly. |
You can run the above code here: https://jsfiddle.net/6htnzja8/1/
Running the example code and looking in the console jsPDF says the page width is 446.46 pixels. If I take a screenshot of the generated PDF and measure the size it's actually 793 pixels wide.
I think the value reported by jsPDF is wrong. Is it, or am I misunderstanding something?
The text was updated successfully, but these errors were encountered: