下载的数据指定的文档ID。
公共静态长DownloadDocument (
DownloadDocumentOptions选项
)
公共共享函数DownloadDocument (
按值传递选项作为DownloadDocumentOptions
)作为长
公共:
静态Int64 DownloadDocument (
DownloadDocumentOptions^选项
)
选项
包含文档属性的选择和下载选项来使用。这个值不能零。
读入的字节总数DownloadDocumentOptions.Data或DownloadDocumentOptions.Stream。这可以小于请求的字节数DownloadDocumentOptions.Length如果目前许多字节不,或者零(0)如果数据的结束。
类似于UploadDocument,数据可以在块或下载。指使用文档库上传详细的信息关于如何使用这些方法和所使用的各种选项。
GetDocumentCacheInfo可以用来确定一个文档是否在缓存中并得到它的信息。
DownloadAnnotations可以用来下载文档的注释(如果有的话)。
这个示例将展示如何下载文档的数据存储在缓存到一个流一次,然后使用块缓冲区数组。
使用Leadtools;
使用Leadtools.Codecs;
使用Leadtools.Document.Writer;
使用Leadtools.Document;
使用Leadtools.Caching;
使用Leadtools.Annotations.Engine;
使用Leadtools.Ocr;
使用Leadtools.Barcode;
使用Leadtools.Document.Converter;
公共无效DownloadDocumentExample ()
{
vardocumentUri =新Uri (“https://demo.leadtools.com/images/pdf/leadtools.pdf”);
字符串documentFile1 = Path.Combine (LEAD_VARS.ImagesDir,“downloaded1.pdf”);
字符串documentFile2 = Path.Combine (LEAD_VARS.ImagesDir,“downloaded2.pdf”);
/ /设置一个缓存
FileCache缓存=新FileCache ();
缓存。CacheDirectory =@“c: \ cache-dir”;
字符串documentId;
/ /文档加载到缓存中
varloadDocumentOptions =新LoadDocumentOptions ();
loadDocumentOptions。缓存=缓存;
使用(var文档= DocumentFactory。LoadFromUri (documentUri loadDocumentOptions))
{
/ /文档ID,并将其保存
documentId = document.DocumentId;
文档。AutoDeleteFromCache =假;
文档。AutoSaveToCache =假;
document.SaveToCache ();
}
/ /现在一次性下载到内存流
vardownloadDocumentOptions =新DownloadDocumentOptions ();
downloadDocumentOptions。缓存=缓存;
downloadDocumentOptions。DocumentId = DocumentId;
downloadDocumentOptions。抵消= 0;
downloadDocumentOptions。长度= 1;
使用(var流=新MemoryStream ())
{
downloadDocumentOptions。流=流;
长字节= DocumentFactory.DownloadDocument (downloadDocumentOptions);
Console.WriteLine (“{0}个字节到下载流”字节);
/ /保存流到一个文件中并表现出来
使用(var输出= File.Create (documentFile1))
stream.WriteTo(输出);
Process.Start (documentFile1);
}
/ /下载一遍,这一次我们将缓冲区32 k
downloadDocumentOptions =新DownloadDocumentOptions ();
downloadDocumentOptions。缓存=缓存;
downloadDocumentOptions。DocumentId = DocumentId;
字节[]缓冲=新字节(1024 * 32);
使用(var输出= File.Create (documentFile2))
{
/ /抵消,我们有:
长抵消= 0;
int字节;
做
{
downloadDocumentOptions。抵消=抵消;
downloadDocumentOptions。长度= buffer.Length;
downloadDocumentOptions。数据=缓冲区;
downloadDocumentOptions。DataOffset = 0;
字节数= (int)DocumentFactory.DownloadDocument (downloadDocumentOptions);
如果(字节> 0)
{
Console.WriteLine (“{0}下载字节缓冲区”字节);
/ /下一个块
+ =字节抵消;
输出。写(缓冲0字节);
}
}
而(字节> 0);
}
Process.Start (documentFile2);
/ /我们正在做,清理
vardeleteFromCacheOptions =新LoadFromCacheOptions ();
deleteFromCacheOptions。缓存=缓存;
deleteFromCacheOptions。DocumentId = DocumentId;
DocumentFactory.DeleteFromCache (deleteFromCacheOptions);
}
静态类LEAD_VARS
{
公共常量字符串ImagesDir =@“C: \ LEADTOOLS21 \ Resources \图片”;
}
进口Leadtools
进口Leadtools.Codecs
进口Leadtools.Document.Writer
进口Leadtools.Svg
进口Leadtools.Document
进口Leadtools.Caching
进口Leadtools.Annotations.Engine
进口Leadtools.Barcode
进口Leadtools.Ocr
进口LeadtoolsDocumentExamples.LeadtoolsExamples.Common
进口Leadtools.Document.Converter
公共共享子DownloadDocumentExample ()
昏暗的documentUri作为新Uri (“https://demo.leadtools.com/images/pdf/leadtools.pdf”)
昏暗的documentFile1作为字符串= Path.Combine (ImagesPath.Path“downloaded1.pdf”)
昏暗的documentFile2作为字符串= Path.Combine (ImagesPath.Path“downloaded2.pdf”)
“设置缓存
昏暗的缓存作为新FileCache ()
缓存。CacheDirectory =“c: \ cache-dir”
昏暗的documentId作为字符串
文档加载到缓存中
昏暗的loadDocumentOptions作为新LoadDocumentOptions ()
loadDocumentOptions。缓存=缓存
使用文档作为LEADDocument = DocumentFactory。LoadFromUri (documentUri loadDocumentOptions)
的文档ID,并将其保存
documentId = document.DocumentId
文档。AutoDeleteFromCache =假
文档。AutoSaveToCache =假
document.SaveToCache ()
结束使用
现在下载它一下子变成一个内存流
昏暗的downloadDocumentOptions作为新DownloadDocumentOptions ()
downloadDocumentOptions。缓存=缓存
downloadDocumentOptions。DocumentId = DocumentId
downloadDocumentOptions。抵消= 0
downloadDocumentOptions。长度= 1
使用流作为新MemoryStream ()
downloadDocumentOptions。流=流
昏暗的字节作为长= DocumentFactory.DownloadDocument (downloadDocumentOptions)
Console.WriteLine (“{0}个字节到下载流”字节)
“流保存到文件并显示它
使用输出作为流= File.Create (documentFile1)
stream.WriteTo(输出)
结束使用
Process.Start (documentFile1)
结束使用
再下载一次,这一次我们将缓冲区32 k
downloadDocumentOptions =新DownloadDocumentOptions ()
downloadDocumentOptions。缓存=缓存
downloadDocumentOptions。DocumentId = DocumentId
昏暗的缓冲((1024 * 32)- 1)作为字节
使用输出作为流= File.Create (documentFile2)
我们的抵消
昏暗的抵消作为长= 0
昏暗的字节作为整数
做
downloadDocumentOptions。抵消=抵消
downloadDocumentOptions。长度= buffer.Length
downloadDocumentOptions。Data =缓冲
downloadDocumentOptions。DataOffset = 0
字节数=CType(DocumentFactory.DownloadDocument (downloadDocumentOptions),整数)
如果字节> 0然后
Console.WriteLine (“{0}下载字节缓冲区”字节)
“下一个块
+ =字节抵消
输出。写(缓冲0字节)
结束如果
循环而字节> 0
结束使用
Process.Start (documentFile2)
我们正在做,清理
昏暗的deleteFromCacheOptions作为新LoadFromCacheOptions
deleteFromCacheOptions。缓存=缓存
deleteFromCacheOptions。DocumentId = DocumentId
DocumentFactory.DeleteFromCache (deleteFromCacheOptions)
结束子
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗Web查看器net
188宝金博怎么下载
支持的平台上
net, Java, Android和iOS / macOS组件
C / c++类库的API
HTML5 JavaScript库
你的邮件已经发送到支持!有人应该联系!如果你的问题是紧急请回到聊天。
聊天时间:
周一——周五,上午6点等
谢谢你的反馈!
请填写表单重新开始一个新的聊天。
所有代理目前离线。
聊天时间:
周一-周五
早上8:30 - 6点
联系我们请填写这张表格,我们将通过电子邮件联系你。