←Select platform

Stream Property

Summary

Gets the original document stream.

Syntax
C#
C++/CLI
Java
Python
public Stream Stream {get;} 
public:  
   property System::IO::Stream^ Stream 
   { 
      System::IO::Stream^ get() 
   } 
public InputStream getStream() 
Stream # get  (LEADDocument) 

Property Value

Original document stream.

Remarks

Stream contains the original value passed to DocumentFactory.LoadFromStream; otherwise, the value will be null.

The LEADDocument class will use the stream members to read the various parts of the stream, such as the images and metadata, on demand as needed. It is the user's responsibility to keep the stream alive while the document is not disposed. When the document is disposed, the stream is no longer used and can be closed or disposed by the user.

If the document is saved into the cache using SaveToCache, then the entire content of the stream is saved into the cache and the stream is no longer used and can be safely disposed by the user. When the document is later re-loaded from the cache using DocumentFactory.LoadFromCache, then it is treated as if it was downloaded from an external resource and the stream functionality is not used (the value of Stream will be null).

Example
C#
using Leadtools; 
using Leadtools.Caching; 
using Leadtools.Document; 
 
 
public void DocumentFactoryLoadFromStreamExample() 
{ 
   // Get a stream to anything, in this case a file 
   // Note that the stream must be seekable 
   var fileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"); 
   using (var stream = File.OpenRead(fileName)) 
   { 
      // We must keep the stream alive as long as the document is alive 
      var options = new LoadDocumentOptions(); 
      using (var document = DocumentFactory.LoadFromStream(stream, options)) 
      { 
         Console.WriteLine(document.Stream); 
         PrintOutDocumentInfo(document); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.4.21
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.