The jsPDF html module generates a blank page
See original GitHub issueThe jsPDF module generates a blank page. No matter if it’s an element reference or an HTML string, I always get empty PDFs for some reason.
import jsPDF from 'jspdf';
import html2canvas from 'html2canvas';
window.html2canvas = html2canvas;
var toPdfBtn = document.getElementById('pdf');
toPdfBtn.addEventListener('click', function() {
var doc = new jsPDF();
doc.html(document.body, {
callback: function (doc) {
doc.save();
}
});
});
Note: The above code in the event listener handler is the same one from the documentation.
This doesn’t seem to work either:
import jsPDF from 'jspdf';
import html2canvas from 'html2canvas';
window.html2canvas = html2canvas;
var toPdfBtn = document.getElementById('pdf');
toPdfBtn.addEventListener('click', function() {
var doc = new jsPDF();
doc.html('<h3>Test</h3>', {
callback: function (doc) {
doc.save();
}
});
});
I also tried importing html2canvas from a CDN and excluding it from this file (commenting out the 2nd and 3rd line), but that doesn’t work either. I also tried importing both html2canvas and jsPDF from a CDN and that doesn’t seem to work as well.
I am using the following versions of the packages (excerpt from the packages.json
file):
"dependencies": {
"html2canvas": "^1.0.0-rc.3",
"jspdf": "^1.5.3"
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
The jsPDF html module generates a blank page ... - GitHub
I am using jsPdf v2.5.0 to create pdf from html. use doc.html() ... The jsPDF html module generates a blank page when the...
Read more >JSPDF .html() function returning blank pdf page - Stack Overflow
After trying whole day came with following solution. I think we are getting blank page because of versions of html2canvas.
Read more >The jsPDF html module generates a blank page - Bountysource
The jsPDF module generates a blank page. No matter if it's an element reference or an HTML string, I always get empty PDFs...
Read more >Component generates PDF-file with one blank page. What's ...
I have added the PDF Generator (jsPDF) component to our Web. I have followed the How to of the component but when I...
Read more >Jspdf Always Return Blank In Particular Html File - ADocLib
Convert HTML/CSS Content to a Sleek Multiple Page PDF File Using jsPDF browser based JavaScript web application ... The jsPDF module generates a...
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
sorry I forgot to mention that it work great on Chrome, blank page happens only in Safari
I got the same issue, because my chrome has grammarly extension.