Saves the annotation objects to a stream.
public void Save(Stream stream,Leadtools.Annotations.AnnContainer container,Leadtools.Annotations.AnnCodecsFormat format,int page,Leadtools.Annotations.AnnCodecsSavePageMode pageMode)
Public Overloads Sub Save( _ByVal stream As Stream, _ByVal container As Leadtools.Annotations.AnnContainer, _ByVal format As Leadtools.Annotations.AnnCodecsFormat, _ByVal page As Integer, _ByVal pageMode As Leadtools.Annotations.AnnCodecsSavePageMode _)
public:void Save(Stream^ stream,Leadtools.Annotations.AnnContainer^ container,Leadtools.Annotations.AnnCodecsFormat format,int page,Leadtools.Annotations.AnnCodecsSavePageMode pageMode)
stream
The stream to which to save the objects.
container
An AnnContainer containing the objects to be saved.
format
An AnnCodecsFormat value that specifies the annotation format to use when saving.
page
1-based index of the page to be saved.
pageMode
A value that indicates how to handle the page when saving to a multi-page stream.
pageMode
A value that indicates how to handle the page when saving to a multi-page stream.
| Mode | Description |
|---|---|
| AnnCodecsSavePageMode.Overwrite | The stream will be overwritten and all previous information will be lost. The value of page must be 1 or -1 (if appending the objects as the last page). |
| AnnCodecsSavePageMode.Insert | The stream must have valid annotation objects saved to it. The value of page must be between 1 and the total number of pages in the stream. A value of -1 will append the objects as the last page. |
| AnnCodecsSavePageMode.Replace | The stream must have valid annotation objects saved to it. The value of page must be between 1 and total number of pages in the stream. |
This method will not position the stream back to its original position before it returns. It is your responsibility to position the stream back before you can load objects from this stream.
To save multiple containers to a multi-page stream using one method, use Save(Stream, AnnContainer[], AnnCodecsFormat).
For more information, refer to Annotation Files (Deprecated).
using Leadtools;using Leadtools.Annotations;using Leadtools.Codecs;using Leadtools.WinForms;public void AnnCodecs_Save(){// create a new annotation containerAnnContainer container = new AnnContainer();// add a few objects into the containerAnnRectangleObject rectObj = new AnnRectangleObject();rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));rectObj.Brush = null;container.Objects.Add(rectObj);AnnLineObject lineObj = new AnnLineObject();lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel);lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel);lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));container.Objects.Add(lineObj);MessageBox.Show(string.Format("Before Save: Container has {0} objects", container.Objects.Count));// create a memory stream to save the objects intousing (MemoryStream ms = new MemoryStream()){// create a new AnnCodecs classAnnCodecs codecs = new AnnCodecs();// save the objects in this containercodecs.Save(ms, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite);// clear the containercontainer.Objects.Clear();MessageBox.Show(string.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Objects.Count, ms.Length));// get information about the stream// note, the Save method does not seek the stream back to its original position, so do that nowms.Position = 0;AnnCodecsInformation information = new AnnCodecsInformation();codecs.GetInformation(ms, information);MessageBox.Show(string.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));// load the objects back from the streamcodecs.Load(ms, container, 1);MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Objects.Count));}}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.CodecsImports Leadtools.WinFormsPublic Sub AnnCodecs_Save()' create a new annotation containerDim container As AnnContainer = New AnnContainer()' add a few objects into the containerDim rectObj As AnnRectangleObject = New AnnRectangleObject()rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))rectObj.Brush = Nothingcontainer.Objects.Add(rectObj)Dim lineObj As AnnLineObject = New AnnLineObject()lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))container.Objects.Add(lineObj)MessageBox.Show(String.Format("Before Save: Container has {0} objects", container.Objects.Count))' create a memory stream to save the objects intoDim ms As MemoryStream = New MemoryStream()Try' create a new AnnCodecs classDim codecs As AnnCodecs = New AnnCodecs()' save the objects in this containercodecs.Save(ms, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite)' clear the containercontainer.Objects.Clear()MessageBox.Show(String.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Objects.Count, ms.Length))' get information about the stream' note, the Save method does not seek the stream back to its original position, so do that nowms.Position = 0Dim information As AnnCodecsInformation = New AnnCodecsInformation()codecs.GetInformation(ms, information)MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))' load the objects back from the streamcodecs.Load(ms, container, 1)MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Objects.Count))FinallyCType(ms, IDisposable).Dispose()End TryEnd Sub
|
Products |
Support |
Feedback: Save(Stream,AnnContainer,AnnCodecsFormat,Int32,AnnCodecsSavePageMode) Method - Leadtools.Annotations |
Introduction |
Help Version 19.0.2017.6.20
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.