# Add and Save Annotations

Learn to save a report containing annotations with section layout in ActiveReports. You can even add annotations in code at run time.

## Content



In a Section Report, you can save a report containing annotations along with the report data into an RDF file. You can also add annotations at run time. The following steps demonstrate how to accomplish these tasks in code.

These steps assume that you have already added a Section Report (code based) template in a Visual Studio project.

## Save annotations

The following example shows how to add a **Save Annotated Report** button to the viewer and save a report with annotations in RDF.

1.  From the Visual Studio toolbox, drag a **Button** control onto the viewer.
2.  Set the **Text** property of the button to **Save Annotated Report**.
3.  Double-click the button. This creates an event-handling method for the button **Click** event.
4.  Add code to the click handler to save the document to an **RDF** file. See [Save and Load RDF Files](/activereportsnet/docs/v20.1/developers/working-with-reports-devs/section-report-developers/save-load-rdf-files) for more information on loading the saved RDF file into the viewer.
    
    To write the code in Visual Basic.NET
    
    ```vbnet
    Me.Viewer1.Document.Save("C:\UserAnnotations.rdf")
    ```
    
    To write the code in C#
    
    ```csharp
    this.viewer1.Document.Save("C:\\UserAnnotations.rdf");
    ```
    

## Add annotations in code

The following example shows how to add annotations at run time and save the report data and annotations to an RDF file.

1.  Double-click the title bar of the Form in which you host the viewer. This creates an event-handling method for the Form\_Load event.
2.  Add code to the handler to run the report, add annotations, display the report in the viewer, and save it into an RDF file.
    
    To write the code in Visual Basic.NET
    
    ```vbnet
    Imports GrapeCity.ActiveReports.Document.Section.Annotations
    ```
    
    ```vbnet
    Dim rpt As New SectionReport1
       'Run the report first.
       rpt.Run()
    
       'Assign the viewer.
       Me.Viewer1.LoadDocument(rpt.Document)
    
       'Create an annotation and assign property values.
       Dim circle As New AnnotationCircle
       circle.Color = System.Drawing.Color.GreenYellow
       circle.Border.Color = System.Drawing.Color.Chartreuse
    
       'Add the annotation.
       circle.Attach(1,1) 'screen location
       Me.Viewer1.Document.Pages(0).Annotations.Add(circle)
    
       'Set the size properties. The annotation must be added to the page first.
       circle.Height = 0.25
       circle.Width = 0.50
    
       'Save annotations with the report in an RDF file.
       rpt.Document.Save("C:\AnnotatedReport.rdf")
    ```
    
    To write the code in C#
    
    ```csharp
    using GrapeCity.ActiveReports.Document.Section.Annotations;
    ```
    
    ```csharp
    SectionReport1 rpt = new SectionReport1();
       //Run the report first.
       rpt.Run();
       
       //Assign the viewer
       this.viewer1.LoadDocument(rpt.Document);
       
       //Create an annotation and assign property values.
       AnnotationCircle circle = new AnnotationCircle();
       circle.Color = System.Drawing.Color.GreenYellow;
       circle.Border.Color = System.Drawing.Color.Chartreuse;
      
       //Add the annotation.
       circle.Attach(1,1); //screen location
       this.viewer1.Document.Pages[0].Annotations.Add(circle);
    
       //Set the size properties. The annotation must be added to the page first.
       circle.Height = 0.25f;
       circle.Width = 0.50f;
    
       //Save annotations with the report in an RDF file.
       rpt.Document.Save("C:\\AnnotatedReport.rdf");
    ```
    

## See Also

#### Report Readers

[Annotations](/activereportsnet/docs/v20.1/report-readers/desktop-viewers/annotations)
