1

I am using input type=file to upload and send files to the server. I am converting the file as base64 string and then sending to the server. Now i have a requirement in my project to reduce the size of the file on client end and send it to the server. File types being uploaded are images(jpeg and png) and pdf. I have tried finding solution online but didn't get any solid solution. One solution is their for images where we can put image on an canvas and reduce width and height of that particular canvas. But for pdf i am not able to find any solution. I Know this is a repeated question but I am not able to find a working solution. For images alone I have a working solution that putting on canvas and reducing height and width of that canvas but for pdf I am not able to find anything. Is their a common solution for both file types i.e. pdf and images. Please guide Thank you in advance for help.

vadivel a
  • 1,620
  • 1
  • 6
  • 17
ishaan Gupta
  • 141
  • 8
  • 1
    Does this answer your question? [How to compress an image via Javascript in the browser?](https://stackoverflow.com/questions/14672746/how-to-compress-an-image-via-javascript-in-the-browser) – TheMisir Mar 03 '20 at 04:22
  • @MisirJafarov thank you for reply and yes it helps alot. And also is their a similar way to reduce size of pdf files also. – ishaan Gupta Mar 03 '20 at 04:31
  • pdf files doesn't support compression. but you can use compression algorithms (gzip, zip, lzma, ...) (google for js libraries) to create compressed archives (you will also need to decompress on server side). – TheMisir Mar 03 '20 at 04:35
  • @MisirJafarov ok I will look into into it. Thank you for guiding. – ishaan Gupta Mar 03 '20 at 04:39

0 Answers0