0

I'm fetching a pdf using API call which return it in byte array format.

I need to convert it to base64, so that the same can be shared over email as an attachment.

The API call returns something like this: "%PDF-1.5 ... %EOF"

A direct base64 conversion results in an empty pdf file.

The code used:

var returnedValues = await requestPDF(url, "get", headersvalue, "");
base64data = Buffer.from(returnedValues,'binary').toString('base64')
var toReturn =  {"status": true,"data": base64data};
return toReturn;

When I pass the returned value to my third party mail service as an attachment, the resultant mail contains a pdf but a blank one.

Srish Das
  • 1
  • 1

0 Answers0