Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate document from PDFBytes received in call back? #255

Open
krrajiv opened this issue Jun 26, 2021 · 2 comments
Open

How to generate document from PDFBytes received in call back? #255

krrajiv opened this issue Jun 26, 2021 · 2 comments

Comments

@krrajiv
Copy link

krrajiv commented Jun 26, 2021

We need to publish the completed to s3, in the callback response, I see the value of the document in
req.body.envelopeDocuments[0].PDFBytes
Can someone help me with how to convert this to file? Tried using
fs.writeFileSync('random.pdf',req.body.envelopeDocuments[0].PDFBytes) and
fs.writeFileSync('random.pdf',Buffer.from(req.body.envelopeDocuments[0].PDFBytes)) and
fs.writeFileSync('random.pdf',Buffer.from(req.body.envelopeDocuments[0].PDFBytes, 'base64'))
all of this seems to generate empty PDF only. how to get the actual completed document?

@LarryKlugerDS
Copy link
Contributor

See https://github.com/docusign/code-examples-node/blob/master/lib/eSignature/eg007EnvelopeGetDoc.js#L108

That example shows you how to download the document. Remember that it is a binary file.
If you have trouble uploading it to S3, I suggest asking on StackOverflow.

@judemcenerny
Copy link

judemcenerny commented Mar 20, 2024

Answer to original question is still needed. I do not need to implement downloading the file another way. I have the file contents, pushed via web hook. I tried decoding it as base64 and writing that as binary, but the file is not openable, says "damaged."

How does one take the string contents of the PDFBytes and convert and write to a file which can then be opened as PDF file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants