Docusign - 打开通过 Rest 下载的 PDF 时出错 API

Docusign - Error opening PDF downloaded through the Rest API

使用 REST api,我试图从完整的信封中取出文档。我的 header 正在使用 X-DocuSign-Authentication.

EnvelopesApi ap = new EnvelopesApi();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

EnvelopeDocumentsResult edr = ap.ListDocuments((AccountId, "xxx-xx-xxx");

List<EnvelopeDocument> docs = edr.EnvelopeDocuments;

foreach(EnvelopeDocument doc in docs)
{  
   Stream stream1 = ap.GetDocument(AccountId, "xxx-xx-xxx", doc.DocumentId);
   StreamReader reader = new System.IO.StreamReader(stream1, encode);
   var data = reader.ReadToEnd();
   StreamWriter writer = new StreamWriter(@"C:\mysigneddoc.pdf");
   writer.Write(data);
   writer.Close();
}

当我尝试打开已完成的 pdf 时,出现错误

the signers identity has not been verified.

我有什么地方可能出错的想法吗?

请查看 API 方法 here 以从信封中下载文档。

var ap = new EnvelopesApi();
var edr = ap.ListDocuments((AccountId, "xxx-xx-xxx");
List<EnvelopeDocument> docs = edr.EnvelopeDocuments;

foreach(EnvelopeDocument doc in docs)
{
  // GetDocument() API call returns a MemoryStream
  var docStream = (MemoryStream)envelopesApi.GetDocument(accountId, envelopeId, doc.DocumentId);
  // let's save the document to local file system
  filePath = @"C:\temp\" + Path.GetRandomFileName() + ".pdf";
  fs = new FileStream(filePath, FileMode.Create);
  docStream.Seek(0, SeekOrigin.Begin);
  docStream.CopyTo(fs);
  fs.Close();
}

您还可以使用 GetEnvelopeDocuments api 下载信封中的组合文档。您不需要查询每个单独的文档。


  • 合并 PDF

将字符串 combined 作为 documentId 传递。

Retrieve a PDF that contains the combined content of all documents and the certificate.

string envelopeId = "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
string accountId = "XXXXXX";
var envApi = new EnvelopesApi();

// GetDocument() API call returns a MemoryStream
var docStream = (MemoryStream)envApi.GetDocument(accountId, envelopeId, "combined");
// let's save the document to local file system
string filePath = @"C:\temp\" + Path.GetRandomFileName() + ".pdf";
var fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();

  • ZIP 文件

将字符串 archive 作为 documentId

传递

Retrieve a ZIP archive that contains all of the PDF documents, the certificate, and any .WAV files used for voice authentication.

var envApi = new EnvelopesApi();

// GetDocument() API call returns a MemoryStream
var docStream = (FileStream)envApi.GetDocument(accountId, envelopeId, "archive");
// let's save the document to local file system
string filePath = @"C:\temp\" + Path.GetRandomFileName() + ".zip";
var fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();