Skip to content

Instantly share code, notes, and snippets.

@davidnormo
Last active May 17, 2022 16:56
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidnormo/5e39fb9bbe026e12c3da to your computer and use it in GitHub Desktop.
Save davidnormo/5e39fb9bbe026e12c3da to your computer and use it in GitHub Desktop.
jsPDF as email attachment
var pdf = new jsPDF();
pdf.text(0, 0, 'Hello World!');
var pdfBase64 = pdf.output('datauristring');
window.plugin.email.open({
to: ['to@email.com'],
subject: 'New PDF!',
body: 'Hi there, here is that new PDF you wanted!',
isHTML: false,
attachments: [pdfBase64]
});
@ajdeguzman
Copy link

Thanks for this code..Do you know how to use the jspdf output pdf file as an attachment in an email using phpmailer?

@maiarar
Copy link

maiarar commented Dec 26, 2016

Thanks for this code! :)

@magesh7j
Copy link

magesh7j commented Feb 6, 2017

This Code will not send any mail. Let me explain little briefly

@florisdegraaff
Copy link

windows.plugin is now deprecated. How can I add the pdf as a attachment at this moment?

@sunny7899
Copy link

Yes, windows.plugin is deprecated. what are the alternatives of this please anyone can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment