User1185448985 posted
i want to know if i can attach jspdf output to email
for now i am creating jsPDF file with an image of the current page using dom-to-image to capture the images along with text
and i would like to open new mail window on the client side with the file attached where he/she can select a receiver and type the subject etc.. is it possible ?
my cshtml page have a div that contains a table with images and texts, the div id = "pdfImg"
script:
function sendEmail() {
domtoimage.toPng(document.getElementById('pdfImg'))
.then(function (blob) {
var pdf = new jsPDF('l', 'pt', [$('#pdfImg').width(), $('#pdfImg').height()]);
pdf.addImage(blob, 'PNG', 0, 0, $('#pdfImg').width(), $('#pdfImg').height());
pdf.save("story.pdf");
});
the button that fires the function:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"></script>
<a href="javascript:pdf()" type="button" class="btn btn-outline-secondary btn-sm"><i class="fa fa-file-pdf-o"></i> PDF</a>
thank you