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





In This Topic
SaveAnnotationsToPage Method (AnnotationManager)
In This Topic
Forces the AnnotationManager object to save GdPicture/XMP annotations to the currently selected page of the handled document. Be aware that annotations are always treated relative to the current page.

This method only attaches rendered annotations to the currently selected page while keeping them in the GdPicture/XMP format. You need to use the BurnAnnotationsToPage(Boolean) method to permanently include them into the page content.

This method is applied internally automatically on each page change.

Syntax
'Declaration
 
Public Function SaveAnnotationsToPage() As GdPictureStatus
public GdPictureStatus SaveAnnotationsToPage()
public function SaveAnnotationsToPage(): GdPictureStatus; 
public function SaveAnnotationsToPage() : GdPictureStatus;
public: GdPictureStatus SaveAnnotationsToPage(); 
public:
GdPictureStatus SaveAnnotationsToPage(); 

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
Be aware that this method is applied internally always when you change the page using the SelectPage method.

Just to inform you that saving annotations keeps them in the GdPicture/XMP format alongside with the document. Please use the BurnAnnotationsToPage(Boolean) method if you want to permanently incorporate the annotations to be part of the document content.

This method requires the Annotations component to run.

Example
How to save the newly added annotation to the currently selected page of the handled document.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
    If stamp IsNot Nothing Then
        stamp.Rotation = 20
        If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
           (annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) Then
            If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) = GdPictureStatus.OK Then
                MessageBox.Show("Finished successfully!", "AnnotationManager.SaveAnnotationsToPage")
            Else
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
            End If
        Else
            MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
        End If
        stamp.Dispose()
    Else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
    End If
    annotationManager.Close()
Else
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
    if (stamp != null)
    {
        stamp.Rotation = 20;
        if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
            (annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK))
        {
            if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) == GdPictureStatus.OK)
                MessageBox.Show("Finished successfully!", "AnnotationManager.SaveAnnotationsToPage");
            else
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
        }
        else
            MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
        stamp.Dispose();
    }
    else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
    annotationManager.Close();
}
else
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
annotationManager.Dispose();
See Also