2017-04-03 62 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

哇。我不知道有語音驗證功能。我不認爲我們會使用它,但如果我們確實需要它,它確實有它。 –

相關問題