rpula123 | Posts: 23

Retrieve PDF Document

0 votes
Hi, We are calling the OneSpan API to retrieve a single PDF document. In the response we are getting a byte stream for the pdf document. Our requirement is to download PDF from onespan and upload it to our backend repository. We are converting the byte stream response from onespan to base64Encoded as it is expected in base64 format in our backend request. Once the document is uploaded it will be available for the user to view the PDF document. Our problem we are unable to open the PDF document. Can you please help with this issue. Please find the attached onespan response from the API call.

Duo_Liang | Posts: 3776

Reply to: Retrieve PDF Document

0 votes
Hey rpula123, Here's a quick demo I did: (1)Use Java REST code download a signed PDF as byte array (2)call library to convert this byte array into base 64 string (3)manually set this string to an HTML PDF viewer replying on base64 string input.(google doc viewer in my example) And the flows works fine at my side. (see attachment) So to troubleshooting your issue, you could (1)zip and reupload the "pdfresponseFromOnespan.txt" file (2)share more information to me like which programming language you are using, which PDF viewer you are using and possibly upload the code snippet you are using now (3)Could you kindly try another way to encode base 64 string? Duo

Attachments
5-2-1.zip1.35 KB
rpula123 | Posts: 23

Reply to: Retrieve PDF Document

0 votes
Hi Duo, Thank you for the example. I used the same example . I used the generated encoded String in the html file you sent . When i ran it i get "Failed to load PDF document." error in the browser. Please find the attached html file.

Attachments
Duo_Liang | Posts: 3776

Reply to: Retrieve PDF Document

0 votes
Hey rpula123, I decoded your base64 string, and it shows up an HTML page instead of PDF byte array. Did you replaced the API KEY, Package Id and Document Id in my example code? Duo

rpula123 | Posts: 23

Reply to: Retrieve PDF Document

0 votes
Yes Duo, now i tried with a different package and documentId. Can you please from your end. https://sandbox.esignlive.com/api/packages/iUIj7pdXJPeZskbfi3EPupFyc6I=/documents/e7dcfc7138902f876cd3b5682fa3125e3e6996637b3e023d/pdf Below is encoded string PCFET0NUWVBFIGh0bWw+CjxodG1sIGNsYXNzPSJ0b3VjaCIgbGFuZz0iZGEiPgoKPGhlYWQ+CiAgPG1ldGEgY2hhcnNldD0idXRmLTgiPgogIDxtZXRhIGh0dHAtZXF1aXY9IlgtVUEtQ29tcGF0aWJsZSIgY29udGVudD0iSUU9ZWR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3d3dy5nb29nbGV0YWdtYW5hZ2VyLmNvbS9ndGFnL2pzP2lkPVVBLTI5NTAzMTAtMTQiPjwvc2NyaXB0PgogICAgPHNjcmlwdD4KICAgICAgd2luZG93LmRhdGFMYXllciA9IHdpbmRvdy5kYXRhTGF5ZXIgfHwgW107CiAgICAgIGZ1bmN0aW9uIGd0YWcoKXtkYXRhTGF5ZXIucHVzaChhcmd1bWVudHMpO30KICAgICAgZ3RhZygnanMnLCBuZXcgRGF0ZSgpKTsKCiAgICAgIGd0YWcoJ2NvbmZpZycsICdVQS0yOTUwMzEwLTE0JywgewogICAgICAgICdhbm9ueW1pemVfaXAnOiB0cnVlLAogICAgICAgICdzZW5kX3BhZ2Vfdmlldyc6IGZhbHNlCiAgICAgIH0pOwogICAgPC9zY3JpcHQ+CiAgCgogIDxzY3JpcHQgc3JjPSIvYS92ZW5kb3JzL3BvbHlmaWxsLm1pbi43NWI0ZmY2LmpzIj48L3NjcmlwdD4KICA8c2NyaXB0IHNyYz0iL2Evc2NyaXB0cy92ZW5kb3JzLmNodW5rLmQ4NGFlYTMuanMiPjwvc2NyaXB0PgogIDxzY3JpcHQgc3JjPSIvYS9zY3JpcHRzL2NsaWVudC5kN2Y3ZmY2LmpzIj48L3NjcmlwdD4KCjwvYm9keT4KPC9odG1sPgo=

Duo_Liang | Posts: 3776

Reply to: Retrieve PDF Document

0 votes
Hi rpula123, I've checked and it seems that your account is under US1 Sandbox with url of "https://sandbox.e-signlive.com/api/", that's why you can't download the PDF. Duo

rpula123 | Posts: 23

Reply to: Retrieve PDF Document

0 votes
sorry Duo, i didn't understand what you said. Are you saying if i use sandbox url i cannot download? Can you please be more clear.

Duo_Liang | Posts: 3776

Reply to: Retrieve PDF Document

0 votes
Hi, I meant that your url should be "https://sandbox.e-signlive.com/api/" instead of "https://sandbox.esignlive.com/api/" by changing the code as below:
	private String url = "https://sandbox.e-signlive.com/api/";
Duo

rpula123 | Posts: 23

Reply to: Retrieve PDF Document

0 votes
Sorry if i confused you. I am able to download the PDF from onespan. I am able to perform the 3 steps you mentioned earlier. Now in the 3 step i am having issues when i open the html file to view the PDF. it says Failed to load the pdf document. (1)Use Java REST code download a signed PDF as byte array (2)call library to convert this byte array into base 64 string (3)manually set this string to an HTML PDF viewer replying on base64 string input.(google doc viewer in my example)

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