This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/load-a-file/annotation-stream.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Load a stream for annotation manager in C# .NET | Nutrient .NET SDK
Stream

To load a Stream into the AnnotationManager class, use the InitFromStream method.

InitFromStream overloads:

  • InitFromStream(Stream)
  • InitFromStream(Stream, string FileName)

Parameters:

  • Stream — The input stream containing document data.
  • FileName (optional) — A file name/path hint used for format detection when needed (for example, for formats that may require extension-based identification).

InitFromStream returns a GdPictureStatus, which should be checked before applying annotations.

The list of supported file formats is available on the supported file types page.

The AnnotationManager handles only the GdPicture annotations and XMP annotations contained in the source document.

To load a stream into AnnotationManager, add an annotation, and save the result, use the following code:

using GdPicture14;
using GdPicture14.Annotations;
using System;
using System.Drawing;
using System.IO;
using AnnotationManager annotationManager = new AnnotationManager();
using Stream file = new FileStream(@"C:\temp\source.txt", FileMode.Open, FileAccess.Read);
GdPictureStatus status = annotationManager.InitFromStream(file, @"C:\temp\source.txt");
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"InitFromStream failed: {status}");
return;
}
AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(
Color.Red,
0.5f,
0.5f,
2,
1,
"APPROVED");
if (stamp == null)
{
Console.WriteLine("AddRubberStampAnnot failed.");
return;
}
stamp.Rotation = 20;
status = annotationManager.SaveAnnotationsToPage();
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveAnnotationsToPage failed: {status}");
return;
}
status = annotationManager.BurnAnnotationsToPage(false);
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"BurnAnnotationsToPage failed: {status}");
return;
}
status = annotationManager.SaveDocumentToJPEG(@"C:\temp\output.jpg", 100);
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveDocumentToJPEG failed: {status}");
}