GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / ValidateAnnotations Method
A System.IO.Stream object containing the annotations data. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Example





In This Topic
ValidateAnnotations Method (AnnotationManager)
In This Topic
Validates GdPicture/XMP annotations from a stream containing annotations data previously generated by the AnnotationManager.SaveAnnotationsToXMP method or the AnnotationManager.SaveAnnotationsToXMPEx method.

Using this method you can very quickly check out if the specified stream is properly formatted and it can be used for further applying of annotations. Please note, that this method is static and therefore it does not depend on any document.

Be aware that this method only handles GdPicture/XMP annotations.

Syntax
'Declaration
 
Public Shared Function ValidateAnnotations( _
   ByVal Stream As Stream _
) As GdPictureStatus
public static GdPictureStatus ValidateAnnotations( 
   Stream Stream
)
public function ValidateAnnotations( 
    Stream: Stream
): GdPictureStatus; static; 
public static function ValidateAnnotations( 
   Stream : Stream
) : GdPictureStatus;
public: static GdPictureStatus ValidateAnnotations( 
   Stream* Stream
) 
public:
static GdPictureStatus ValidateAnnotations( 
   Stream^ Stream
) 

Parameters

Stream
A System.IO.Stream object containing the annotations data. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
The input stream should remain open and can only be closed/disposed of by the user as well.

This method requires the Annotations component to run.

Example
How to validate GdPicture/XMP annotations for their further use.
Dim annotStream As System.IO.Stream = New System.IO.FileStream("annots.xml", System.IO.FileMode.Open)
Dim status As GdPictureStatus = AnnotationManager.ValidateAnnotations(annotStream)
annotStream.Dispose()
'Annotations were validated successfully.
If status = GdPictureStatus.OK Then
    Dim annotationManager As AnnotationManager = New AnnotationManager()
    If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
       (annotationManager.LoadAnnotationsFromXMP("annots.xml") = GdPictureStatus.OK) AndAlso
       (annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK) Then
        MessageBox.Show("Done!", "AnnotationManager.ValidateAnnotations")
    Else
        MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.ValidateAnnotations")
    End If
    annotationManager.Dispose()
End If
System.IO.Stream annotStream = new System.IO.FileStream("annots.xml", System.IO.FileMode.Open);
GdPictureStatus status = AnnotationManager.ValidateAnnotations(annotStream);
annotStream.Dispose();
//Annotations were validated successfully.
if (status == GdPictureStatus.OK)
{
    AnnotationManager annotationManager = new AnnotationManager();
    if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
        (annotationManager.LoadAnnotationsFromXMP("annots.xml") == GdPictureStatus.OK) &&
        (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK))
        MessageBox.Show("Done!", "AnnotationManager.ValidateAnnotations");
    else
        MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.ValidateAnnotations");
    annotationManager.Dispose();
}
See Also