0

The following code works fine and generating PDF on the front end and downloading it successfully. But I am confused about how to send it to the server in API using fetch or Axios. Couldn't find any documentation regarding this to send it though API and save it as PDF from server-side into s3.

                    const input = document.getElementById('divToPrint');
                    html2canvas(input)
                    .then((canvas) => {
                        const imgData = canvas.toDataURL('image/png');
                        const pdf = new jsPDF();
                        pdf.addImage(imgData, 'PNG', 0, 0);
                        pdf.save("download.pdf");
                    }); 
                })
Praveen George
  • 9,237
  • 4
  • 26
  • 53

1 Answers1

-1

Just get your PDF in a File object and send it to your API. Here is anoher thread about it : Send File to API By the way, there is a more upvoted answer below the one I linked, both are relevant, butthe second may be easier.

Quentin Grisel
  • 4,794
  • 1
  • 10
  • 15