GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / FlattenAnnotation Method
The 0-based index of the required annotation within the current page. It must be a value from 0 to GetAnnotationCount-1.
Example





In This Topic
FlattenAnnotation Method (GdPicturePDF)
In This Topic
Flattens the required annotation specified by its index related to the currently selected page of the loaded PDF document.

Flattening an annotation means removing the annotation object from the document's internal structure and placing its data within the PDF document as regular item, so the previously defined annotation is no longer available for user's interaction.

Syntax
'Declaration
 
Public Function FlattenAnnotation( _
   ByVal AnnotationIdx As Integer _
) As GdPictureStatus
public GdPictureStatus FlattenAnnotation( 
   int AnnotationIdx
)
public function FlattenAnnotation( 
    AnnotationIdx: Integer
): GdPictureStatus; 
public function FlattenAnnotation( 
   AnnotationIdx : int
) : GdPictureStatus;
public: GdPictureStatus FlattenAnnotation( 
   int AnnotationIdx
) 
public:
GdPictureStatus FlattenAnnotation( 
   int AnnotationIdx
) 

Parameters

AnnotationIdx
The 0-based index of the required annotation within the current page. It must be a value from 0 to GetAnnotationCount-1.

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
This method is only allowed for use with non-encrypted documents.

Please always ensure that you have selected the correct page using the SelectPage method before applying an annotation index. To flatten all annotations included in the current document please follow the attached example.

Example
Flattening all annotations in the loaded PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("input.pdf", False)
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    For page As Integer = 1 To pageCount
        gdpicturePDF.SelectPage(page)
        Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
        For i As Integer = 0 To annotCount - 1
            gdpicturePDF.FlattenAnnotation(0)
        Next
    Next
    gdpicturePDF.SaveToFile("output.pdf", True)
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("input.pdf", false);
    int pageCount = gdpicturePDF.GetPageCount();
    for (int page = 1; page <= pageCount; page++)
    {
        gdpicturePDF.SelectPage(page);
        int annotCount = gdpicturePDF.GetAnnotationCount();
        for (int i = 0; i < annotCount; i++)
        {
            gdpicturePDF.FlattenAnnotation(0);
        }
    }
    gdpicturePDF.SaveToFile("output.pdf", true);
}
See Also