首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >DocuSign API视图文档在浏览器中发送供签名

DocuSign API视图文档在浏览器中发送供签名
EN

Stack Overflow用户
提问于 2014-05-06 13:47:52
回答 1查看 359关注 0票数 0

我指的是这里的C#示例:http://iodocs.docusign.com/APIWalkthrough/getEnvelopeDocuments

这个API实际上根据服务器上的信封ID下载文档。

然而,对于我的用例,我想知道是否有一种方法通过API通过URL来检索文档,而不是下载到服务器。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-07 14:28:05

虽然不可能通过URL直接链接到DocuSign文档,但当用户单击站点上的链接时,可以在浏览器中显示文档(而不必下载到服务器)。这样做只需要链接的onClick,您的代码通过API从DocuSign请求文档(如示例所示),然后立即将响应流(字节数组)写入浏览器(而不是将其写入文件)。

通过将"// read the response and store into a local file:“部分替换为如下内容(在链接到的代码示例中),您应该能够做到这一点:

代码语言:javascript
复制
// Write the response stream to the browser (render PDF in browser).
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
byte[] b = null;
using (Stream stream = webResponse.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
    int count = 0;
    do
    {
        byte[] buf = new byte[1024];
        count = stream.Read(buf, 0, 1024);
        ms.Write(buf, 0, count);
    } while (stream.CanRead && count > 0);
    b = ms.ToArray();
}
Response.BufferOutput = true;
Response.ClearHeaders();
Response.AddHeader("content-disposition", "inline;filename=DSfile.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(b);
Response.Flush();
Response.End();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23496544

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档