GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / SaveAnnotationsToXMPBase64 Method
Example





In This Topic
SaveAnnotationsToXMPBase64 Method (AnnotationManager)
In This Topic
Saves the GdPicture/XMP annotation part of the selected page of the document currently handled by this AnnotationManager object to a Base64 encoded string.

Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.

Syntax
'Declaration
 
Public Function SaveAnnotationsToXMPBase64() As String
public string SaveAnnotationsToXMPBase64()
public function SaveAnnotationsToXMPBase64(): String; 
public function SaveAnnotationsToXMPBase64() : String;
public: string* SaveAnnotationsToXMPBase64(); 
public:
String^ SaveAnnotationsToXMPBase64(); 

Return Value

A Base64 encoded string containing the annotations data of the selected page in the handled document.
Remarks

Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.

This method requires the Annotations component to run.

Example
How to transfer GdPicture/XMP annotations from one JPEG file to another using a Base64 encoded string.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpeg") = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim annotBase As String = annotationManager.SaveAnnotationsToXMPBase64()
    If annotationManager.GetStat() = GdPictureStatus.OK Then
        annotationManager.Close()
        If (annotationManager.InitFromFile("image2.jpeg") = GdPictureStatus.OK) AndAlso
           (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
           (annotationManager.LoadAnnotationsFromXMPBase64(annotBase) = GdPictureStatus.OK) Then
            If annotationManager.SaveDocumentToJPEG("image2_updated.jpeg", 75) = GdPictureStatus.OK Then
                MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64")
            End If
            annotationManager.Close()
        Else
            MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
        End If
    Else
        MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
    End If
Else
    MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpeg") == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    string annotBase = annotationManager.SaveAnnotationsToXMPBase64();
    if (annotationManager.GetStat() == GdPictureStatus.OK)
    {
        annotationManager.Close();
        if ((annotationManager.InitFromFile("image2.jpeg") == GdPictureStatus.OK) &&
            (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
            (annotationManager.LoadAnnotationsFromXMPBase64(annotBase) == GdPictureStatus.OK))
        {
            if (annotationManager.SaveDocumentToJPEG("image2_updated.jpeg", 75) == GdPictureStatus.OK)
                MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64");
            annotationManager.Close();
        }
        else MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
    }
    else MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
}
else MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
annotationManager.Dispose();
See Also