Skip to content

Instantly share code, notes, and snippets.

@HectorBlisS
Created June 3, 2020 01:35
Show Gist options
  • Save HectorBlisS/5f6e84c6cc3c8aae5352d9850b225306 to your computer and use it in GitHub Desktop.
Save HectorBlisS/5f6e84c6cc3c8aae5352d9850b225306 to your computer and use it in GitHub Desktop.
const GeneratePDF = ({ form, name }) => {
const generate = async () => {
//console.log(document.getElementById('createPDF'))
let w = document.body.offsetWidth
let h = document.body.offsetHeight
let canvas = await html2canvas(document.body)
let img = canvas.toDataURL('image/jpeg', 1)
let pdf = new jsPDF('p', 'pt', [w, h])
pdf.addImage(img, 'JPEG', 0, 0, w, h)
pdf.save('contrato.pdf')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment