Create pdf and upload it to AWS S3 (React, NodeJS)

Fred Wong
fredwong-it
Published in
2 min readMar 6, 2019

I would need to create a pdf file from taking screen shot of the react application (div element), then upload the pdf to AWS S3 through NodeJS.

It is straight forward for uploading the file/image to AWS S3 from nodeJS, but there are some challenges on creating pdf and convert it to the right format in order for the uploading.

React

  • use html2canvas to capture the screen shot of an div element.
  • convert it to dataURL
  • create a pdf by jsPDF
  • convert it back to dataURL (pdf version)

NodeJS

The rest is just the regular upload file to AWS S3 from NodeJS. (need buffer in the body)

Here are a few reference

https://medium.com/@Keithweaver_/uploading-a-file-to-amazon-web-services-aws-s3-bucket-with-node-js-133b0a1af2b9

https://stackoverflow.com/questions/13807339/upload-a-binary-file-to-s3-using-aws-sdk-for-node-js

--

--