Docusign结合了pdf - 我们可以提取单个文档吗?

时间:2017-04-03 17:57:25

标签: docusignapi

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

2 个答案:

答案 0 :(得分: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);        

修改 By Kathy-Lori

出于某种原因,我在将Stream转换为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); 
} 

答案 1 :(得分:2)

创建DocuSign信封后,您可以从信封中读取文档信息,并记住每个文档的页数。如果您使用模板,这也应该有用。

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

以下是列表文档调用的示例API响应:

geoJsonLayer = L.geoJson(null, {
  pointToLayer: function(feature, latlng) {
    var smallIcon = L.DivIcon.extend({
      options: {
        iconSize: [27, 27],
        html: "<div>" + feature.properties.FEATURE_STYLE.SVG_ELEMENT + "</div>"
      }
    });
    return L.marker(latlng, {icon: new smallIcon()});
  },      
  style: getLayerStyle,
  onEachFeature: setFeatureProperties,
});
geoJsonLayer.addTo(baseMap);
相关问题