Hi I have converted my html page to canvas image and then turned that image to pdf using jspdf library. Now I want to call the ajax function POST
or $.post
function and send that pdf file link to backend and send it to email using our own email template. In that email template, I have using <a>
which should contain the url of that pdf that was passed from front-end. Following is some line of code I have used in my function.
Index.php
<script type="text/javascript">
html2canvas(document.querySelector(".certificate_holder")).then(canvas => {
image.src = canvas.toDataURL("image/png");
pdf.addImage(image.src, 'PNG', 0, 0);
sendEmail(image.src)
function sendEmail(pdflink){
$.post("/pdfController/sendEmail",{link:pdflink}, function(data){
console.log(data);
})
}
</script>
In the above code, I am getting the image link using toDataUrl
which is in Basecode(which is very long), instead I want actual link that I can use in <a href="pdflink">
. Is there any way where I can generate or get a pdf-link using jspdf library?. Another alternative is getting a short actual link from Basecode URL that I have in above code which is image.src
. Help is appreciated.