-
Notifications
You must be signed in to change notification settings - Fork 4.6k
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
.html(), how to fit content to single pdf? My div is printing into 3 total pages? #2911
Comments
I think this issue is related to #2885 . |
Yeah seems somewhat related but already doing the suggested I assumed maybe there was a standard solution for my problem. Trying to get a div to show full screen in the PDF regardless of its original size but maybe not. |
Heres code snippet that only outputs to one page. const quality = 1 // Higher the better but larger file
html2canvas(document.querySelector('#html'),
{ scale: quality }
).then(canvas => {
const pdf = new jsPDF('p', 'mm', 'a4');
pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 211, 298);
pdf.save(filename);
}); |
Thanks, I'll give it a shot! |
Note that this will render the HTML as image and not as text/vector graphics. |
Is there a better solution to use text/vectors? Something similar to the referenced commit earlier? Been trying to utilize .html() and properly scaling but haven't quite been able to get it down. |
Currently, I think you can only try to set the scale appropriately. I created an issue to add a |
Any updates? |
@HackbrettXXX |
Using the latest version, here:
Essentially it is printing this one element out into 3 pages (landscape). I can't figure out how to adjust the sizing properly so everything passed into the first param of html() gets used in one page. Anyone have tips on this?
Below are the results of the html table and then the resulting pdf.
https://i.imgur.com/r60rteJ.png
https://i.imgur.com/aSSBLTu.png
The text was updated successfully, but these errors were encountered: