2017-04-03 93 views
1

我们正在寻找下载合并的pdf,然后提取单个文件(不是我的想法)。我尝试使用pdfsharp对付我的pdf,但没有在单个文档上看到任何标题信息。我只是想知道这是否可能。如果我使用pdfsharp,它可以取出所有页面,但我无法真正知道哪些页面属于文档。Docusign合并pdf - 我们可以提取单个文件吗?

回答

2

后创建的DocuSign信封您可以阅读信封中的文件信息,并记住每个文档的页数。如果您正在使用模板,这也应该可以工作。

您可以使用EnvelopeDocuments: list API来获取文档信息,其中包括每个文档的页面。然后,当您需要从组合PDF中提取单个文档时,您将知道将单个文档分开的位置。

这里有一个列表文件调用示例API响应:

{ 
    "envelopeDocuments": [ 
     { 
      "availableDocumentTypes": [ 
       { 
        "isDefault": "true", 
        "type": "electronic" 
       } 
      ], 
      "display": "inline", 
      "documentId": "1", 
      "includeInDownload": "true", 
      "name": "NDA.pdf", 
      "order": "1", 
      "pages": "3", 
      "signerMustAcknowledge": "no_interaction", 
      "type": "content", 
      "uri": "/envelopes/44efc9e6-915e-4b1d-9b54-801410d6922d/documents/1" 
     }, 
     { 
      "availableDocumentTypes": [ 
       { 
        "isDefault": "true", 
        "type": "electronic" 
       } 
      ], 
      "display": "inline", 
      "documentId": "2", 
      "includeInDownload": "true", 
      "name": "House.pdf", 
      "order": "2", 
      "pages": "1", 
      "signerMustAcknowledge": "no_interaction", 
      "type": "content", 
      "uri": "/envelopes/44efc9e6-915e-4b1d-9b54-801410d6922d/documents/2" 
     }, 
     { 
      "availableDocumentTypes": [ 
       { 
        "isDefault": "true", 
        "type": "electronic" 
       } 
      ], 
      "display": "inline", 
      "documentId": "3", 
      "includeInDownload": "true", 
      "name": "contractor_agreement.docx", 
      "order": "3", 
      "pages": "2", 
      "signerMustAcknowledge": "no_interaction", 
      "type": "content", 
      "uri": "/envelopes/44efc9e6-915e-4b1d-9b54-801410d6922d/documents/3" 
     }, 
     { 
      "availableDocumentTypes": [ 
       { 
        "isDefault": "true", 
        "type": "electronic" 
       } 
      ], 
      "display": "inline", 
      "documentId": "certificate", 
      "includeInDownload": "true", 
      "name": "Summary", 
      "order": "999", 
      "pages": "4", 
      "signerMustAcknowledge": "no_interaction", 
      "type": "summary", 
      "uri": "/envelopes/44efc9e6-915e-4b1d-9b54-801410d6922d/documents/certificate" 
     } 
    ], 
    "envelopeId": "44efc9e6-915e-4b1d-9b54-801410d6922d" 
} 
2

getEnvelopeDocuments api有一个选项,可以将信封中的所有文档作为zip文件下载。您可以解压缩文件并获取单个文档。

GET /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/archive 

检索包含所有用于语音认证的PDF文档,证书,以及任何.WAV文件的ZIP文件。


这里是一个示例代码下载的zip文件,并使用Docusign C# SDK将其解压缩。

完整示例here

var envApi = new EnvelopesApi(); 

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

string extractPath = @"c:\temp\" + zipName; 
System.IO.Compression.ZipFile.ExtractToDirectory(zipfilePath, extractPath);   

编辑凯西 - 洛瑞

出于某种原因,我不得不铸流到FileStream对象的问题。我所做的却是以下几点:

Stream docStream = envApi.GetDocument(AccountId, envelopeId, "archive"); 
MemoryStream ret = new MemoryStream(); 

byte[] buffer = new byte[8192]; 
int bytesRead; 
while ((bytesRead = docStream.Read(buffer, 0, buffer.Length)) > 0) 
{ 
    ret.Write(buffer, 0, bytesRead); 
} 
ret.Position = 0; 

using (var fs = new FileStream(@"C:\temp\envelopeDocuments.zip", FileMode.Create)) 
{ 
    ret.CopyTo(fs); 
} 
+0

我不知道该存档选项。很高兴知道。 –

+0

我会在这里向所有人介绍我的所有发现,他们可以做出决定。知道如何以不同的方式去皮肤,这是很好的。感谢所有的帮助。 –

+0

哇。我不知道有语音验证功能。我不认为我们会使用它,但如果我们确实需要它,它确实有它。 –

相关问题