ValidateAnnotations Method (AnnotationManager)
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.
'Declaration
Public Shared Function ValidateAnnotations( _
ByVal As Stream _
) As GdPictureStatus
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.
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();
}