Offset into the source data at which to begin reading the data during this download operation.
public long Offset {get; set;} public:property Int64 Offset{Int64 get()void set(Int64 value)}
Offset # get and set (DownloadDocumentOptions)
0-based byte offset into the source data at which to begin reading the data. The default value is 0.
Use DocumentFactory.DownloadDocument to download the document data in chunks by using the values of Offset and Length to determine the start and maximum number of bytes to download from each chunk.
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public void DownloadDocumentExample(){var documentUri = new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf");string documentFile1 = Path.Combine(LEAD_VARS.ImagesDir, "downloaded1.pdf");string documentFile2 = Path.Combine(LEAD_VARS.ImagesDir, "downloaded2.pdf");// Setup a cacheFileCache cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";string documentId;// Load a document into the cachevar loadDocumentOptions = new LoadDocumentOptions();loadDocumentOptions.Cache = cache;using (var document = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)){// Get its document ID and save itdocumentId = document.DocumentId;document.AutoDeleteFromCache = false;document.AutoSaveToCache = false;document.SaveToCache();}// Now download it all at once into a memory streamvar downloadDocumentOptions = new DownloadDocumentOptions();downloadDocumentOptions.Cache = cache;downloadDocumentOptions.DocumentId = documentId;downloadDocumentOptions.Offset = 0;downloadDocumentOptions.Length = -1;using (var stream = new MemoryStream()){downloadDocumentOptions.Stream = stream;long bytes = DocumentFactory.DownloadDocument(downloadDocumentOptions);Console.WriteLine("Downloaded {0} bytes into the stream", bytes);long annotations = DocumentFactory.DownloadAnnotations(downloadDocumentOptions);Console.WriteLine(annotations + " annotations downloaded");// The following method is obsolete. Use DownloadAnnotations(DownloadDocumentOptions) insteadint annotations2 = DocumentFactory.DownloadAnnotations(downloadDocumentOptions.Cache, downloadDocumentOptions.DocumentId, downloadDocumentOptions.Offset, (int)bytes, stream);Console.WriteLine(annotations2 + " annotations downloaded");// Save the stream to a file and show itusing (var output = File.Create(documentFile1))stream.WriteTo(output);Process.Start(documentFile1);}// Download it again, this time we will buffer it 32K at a timedownloadDocumentOptions = new DownloadDocumentOptions();downloadDocumentOptions.Cache = cache;downloadDocumentOptions.DocumentId = documentId;byte[] buffer = new byte[1024 * 32];using (var output = File.Create(documentFile2)){// Offset to where we are:long offset = 0;int bytes;do{downloadDocumentOptions.Offset = offset;downloadDocumentOptions.Length = buffer.Length;downloadDocumentOptions.Data = buffer;downloadDocumentOptions.DataOffset = 0;bytes = (int)DocumentFactory.DownloadDocument(downloadDocumentOptions);if (bytes > 0){Console.WriteLine("Downloaded {0} bytes into the buffer", bytes);// Next chunkoffset += bytes;output.Write(buffer, 0, bytes);// The following method is obsolete. Use DownloadAnnotations(DownloadDocumentOptions) insteadint annotations = DocumentFactory.DownloadAnnotations(downloadDocumentOptions.Cache, downloadDocumentOptions.DocumentId, downloadDocumentOptions.Offset, buffer, downloadDocumentOptions.DataOffset, buffer.Length);Console.WriteLine(annotations + " annotations downloaded");}}while (bytes > 0);}Process.Start(documentFile2);// We are done, clean upvar deleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
