Error processing SSI file
LEADTOOLS Leadtools.Documents (Leadtools.Documents assembly)

Show in webframe

LoadFromStream Method






Stream containing the original document data. This value cannot be null and the stream must be seekable.
Options to use when loading the document. This value cannot be null.
Loads a document from existing data stored in a stream.
Syntax
public static Document LoadFromStream( 
   Stream stream,
   LoadDocumentOptions options
)
'Declaration
 
Public Shared Function LoadFromStream( _
   ByVal stream As Stream, _
   ByVal options As LoadDocumentOptions _
) As Document
'Usage
 
Dim stream As Stream
Dim options As LoadDocumentOptions
Dim value As Document
 
value = DocumentFactory.LoadFromStream(stream, options)
public static Document loadFromStream(InputStream stream, LoadDocumentOptions options)
            
public:
static Document^ LoadFromStream( 
   Stream^ stream,
   LoadDocumentOptions^ options
) 

Parameters

stream
Stream containing the original document data. This value cannot be null and the stream must be seekable.
options
Options to use when loading the document. This value cannot be null.

Return Value

The newly created document object.
Remarks

This method might use the cache and will throw an exception if neither LoadDocumentOptions.Cache nor Cache was setup with a valid cache object if certain options are used.

LoadFromFile, LoadFromUri, LoadFromUriAsync and LoadFromStream creates a Document class from any supported image or document file format stored in a disk file, remote URL or a stream. The returned object can then be used to retrieve any page as image or SVG, to obtain the text using SVG or OCR, use the annotations or the document structure such as links and bookmarks.

The Document class will use the stream members to read the various parts such as the images and metadata on demand as needed. It is the user 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.

The value of stream will be stored in Document.Stream property when this method successfully returns.

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 LoadFromCache, then it is treated as it was downloaded from an external resource and the stream functionality is not used (the value of Stream will be null).

After the document is obtained, InternalObject will be to the internal LEADTOOLS object used with the document.

Refer to Loading Using LEADTOOLS Documents Library for detailed information on how to use this method and the various options used.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools.Svg
Imports Leadtools.Documents
Imports Leadtools.Caching
Imports Leadtools.Annotations.Core
Imports Leadtools.Barcode
Imports Leadtools.Forms.Ocr

<TestMethod()> _
Public Sub DocumentFactoryLoadFromStreamExample()
   ' Get a stream to anything, in this case a file
   ' Note that the stream must be seekable
   Dim fileName As String = Path.Combine(ImagesPath.Path, "Leadtools.pdf")
   Using stream As Stream = File.OpenRead(fileName)
      ' We must keep the stream alive as long as the document is alive
      Dim options As New LoadDocumentOptions()
      options.UseCache = False
      Using document As Document = DocumentFactory.LoadFromStream(stream, options)
         PrintOutDocumentInfo(document)
      End Using
   End Using
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.DocumentWriters;
using Leadtools.Svg;
using Leadtools.Documents;
using Leadtools.Caching;
using Leadtools.Annotations.Core;
using Leadtools.Forms.Ocr;
using Leadtools.Barcode;

[TestMethod]
public void DocumentFactoryLoadFromStreamExample()
{
   // Get a stream to anything, in this case a file
   // Note that the stream must be seekable
   var fileName = Path.Combine(ImagesPath.Path, "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();
      options.UseCache = false;
      using (var document = DocumentFactory.LoadFromStream(stream, options))
      {
         PrintOutDocumentInfo(document);
      }
   }
}
Requirements

Target Platforms

See Also

Reference

DocumentFactory Class
DocumentFactory Members

Error processing SSI file
   Leadtools.Documents requires a Document or Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features