←选择平台

DownloadDocument (DownloadDocumentOptions)方法

总结

下载的数据指定的文档ID。

语法
c#
VB
c++
公共静态DownloadDocument (DownloadDocumentOptions选项)
公共共享函数DownloadDocument (按值传递选项作为DownloadDocumentOptions)作为
公共:静态Int64 DownloadDocument (DownloadDocumentOptions^选项)

参数

选项

包含文档属性的选择和下载选项来使用。这个值不能

返回值

读入的字节总数DownloadDocumentOptions.DataDownloadDocumentOptions.Stream。这可以小于请求的字节数DownloadDocumentOptions.Length如果目前许多字节不,或者零(0)如果数据的结束。

讲话

类似于UploadDocument,数据可以在块或下载。指使用文档库上传详细的信息关于如何使用这些方法和所使用的各种选项。

GetDocumentCacheInfo可以用来确定一个文档是否在缓存中并得到它的信息。

DownloadAnnotations可以用来下载文档的注释(如果有的话)。

例子

这个示例将展示如何下载文档的数据存储在缓存到一个流一次,然后使用块缓冲区数组。

c#
VB
使用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 kdownloadDocumentOptions =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 = DocumentIddownloadDocumentOptions。抵消= 0downloadDocumentOptions。长度= 1使用作为MemoryStream ()downloadDocumentOptions。流=流昏暗的字节作为= DocumentFactory.DownloadDocument (downloadDocumentOptions)Console.WriteLine (“{0}个字节到下载流”字节)“流保存到文件并显示它使用输出作为流= File.Create (documentFile1)stream.WriteTo(输出)结束使用Process.Start (documentFile1)结束使用再下载一次,这一次我们将缓冲区32 kdownloadDocumentOptions =DownloadDocumentOptions ()downloadDocumentOptions。缓存=缓存downloadDocumentOptions。DocumentId = DocumentId昏暗的缓冲((1024 * 32)- 1)作为字节使用输出作为流= File.Create (documentFile2)我们的抵消昏暗的抵消作为= 0昏暗的字节作为整数downloadDocumentOptions。抵消=抵消downloadDocumentOptions。长度= buffer.LengthdownloadDocumentOptions。Data =缓冲downloadDocumentOptions。DataOffset = 0字节数=CType(DocumentFactory.DownloadDocument (downloadDocumentOptions),整数)如果字节> 0然后Console.WriteLine (“{0}下载字节缓冲区”字节)“下一个块+ =字节抵消输出。写(缓冲0字节)结束如果循环字节> 0结束使用Process.Start (documentFile2)我们正在做,清理昏暗的deleteFromCacheOptions作为LoadFromCacheOptionsdeleteFromCacheOptions。缓存=缓存deleteFromCacheOptions。DocumentId = DocumentIdDocumentFactory.DeleteFromCache (deleteFromCacheOptions)结束
需求
目标平台
Leadtools.Document作为sembly
188金宝搏的网址客服|支持|联系我们|知识产权的通知
©1991 - 2021领先的技术公司。保留所有权利。