cathrop | Posts: 7

Can't find the documentid

0 votes
I am new to the eSign process and need to be able to download a completed PDF document not a zip file with the document in it. I see the process to do that is: byte[] pdfDocumentBytes = eslClient.downloadDocument(packageId, documentId); But I have found no way to get the documentid. Could you please help me with the process of getting the documentid.

harishaidary | Posts: 1812

Reply to: Can't find the documentid

0 votes
Hi Paul, You can get the documentId by first retrieving the DocumentPackage object:
eslClient.PackageService.GetPackage(packageId);
and then looking into the Document object. Alternatively, you can set your own custom documentId during package creation:
.WithDocument(DocumentBuilder.NewDocumentNamed("sampleAgreement")
                        .WithId(documentId)
                    	.FromStream(fs, DocumentType.PDF)
                    	.WithSignature(SignatureBuilder
                    	.SignatureFor("[email protected]")
                       	.OnPage(0)
                       	.AtPosition(175, 165))
                   	.WithSignature(SignatureBuilder
                   	.SignatureFor("[email protected]")
                       	.OnPage(0)
                       	.AtPosition(550, 165))
                   	)

cathrop | Posts: 7

Reply to: Can't find the documentid

0 votes
Haris, Thank you for your quick reply. The .WithId(documentId) worked quite well. I also tried to download the PDF document through the DocumentPackage as you suggested and was successful, but I am not sure it is the most efficient way. This is what I did: DocumentPackage docPackage = client.getPackage(packageId); List edocs = new ArrayList(); edocs = docPackage.getDocuments(); Iterator iterEdocs = edocs.iterator(); Document edoc = null, edocument = null; while (iterEdocs.hasNext()) { edoc = iterEdocs.next(); edocument = docPackage.getDocument(edoc.getName()); } byte[] documentContent = client.downloadDocument(packageId, edocument.getId().toString()); Files.saveTo(documentContent, "C:/SampleEsignDocumentContent.pdf");

harishaidary | Posts: 1812

Reply to: Can't find the documentid

0 votes
Hey Paul, Good to hear you were able to figure it out. That is one way to go about retrieving the documents. Alternatively, you can simply download all documents as a zip file like so:
byte[] zipContent = eslClient.DownloadZippedDocuments(packageId);
File.WriteAllBytes(Directory.GetCurrentDirectory() + "/package-documents.zip", zipContent);

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