I am working on a project where we need to save the iframe content as a PDF or an image. Currently, I getting issue where the PDF is just blank.
Does anyone has any solution for this ?
Thanks in advance.
Here is my code:
<html>
<head>
<script src="jspdf.umd.min.js"></script>
<script src="html2canvas.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.8.1/html2pdf.bundle.min.js" ></script>
<script >
function createPdf(){
window.jsPDF = window.jspdf.jsPDF
var pdf = new jsPDF()
var element = document.getElementById("capture")
pdf.save("output.pdf")
}
</script>
</head>
<body>
<iframe id="capture" src="https://wikipedia.org/wiki/Main_Page" style=" width: 100%; height: 600px" frameborder="0"></iframe>
<button onclick="createPdf()">create pdf </button>
</body>
</html>