AyshaSingh

Retrieve PDF document to convert image Base64

0 votes

Hello,

I am calling OneSpan API to fetch pdf using  {onepanurl}/api/packages/{packageID}/documents/{documentId}/pdf. But I am receiving the response in PDF binary string. I want to convert the response to a single base64 image which can be shown on a html page? I am using NodeJs. Can you please help with this issue. 


Attachments

Reply to: Retrieve PDF document to convert image Base64

0 votes

Hi AyshaSingh,

 

The only response type for this API is "application/pdf", therefore I believe to use a third party library to convert PDF to base64 string, for example pdf-to-base64, would be the easiest approach.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Retrieve PDF document to convert image Base64

0 votes

Thanks Duo for quick response.

I came across an API to fetch document in page format which would help with my implementation.

GET  /api/packages/{packageId}/documents/{documentId}/pages/0

I wanted to confirm if is it possible to use this API to fetch multiple pages at once?

 

Aysha


Reply to:

0 votes

Hi Aysha,

 

Yeah, this API returns flattened PDF page in image format. However, as you have noticed, it won't fetch multiple pages at once.

Actually if it's just for preview purpose, you can download the flattened PDF instead, which is in smaller size:
GET /api/packages/{packageID}/documents/{documentId}/pdf?flatten=true

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off