GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetFileAttachmentAnnotModificationDate 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
GetFileAttachmentAnnotModificationDate Method (GdPicturePDF)
In This Topic
Gets the modification date of the embedded file (the attachment's modification date) associated with the specified annotation related to the currently selected page of the loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
Syntax
'Declaration
 
Public Function GetFileAttachmentAnnotModificationDate( _
   ByVal AnnotationIdx As Integer _
) As String
public string GetFileAttachmentAnnotModificationDate( 
   int AnnotationIdx
)
public function GetFileAttachmentAnnotModificationDate( 
    AnnotationIdx: Integer
): String; 
public function GetFileAttachmentAnnotModificationDate( 
   AnnotationIdx : int
) : String;
public: string* GetFileAttachmentAnnotModificationDate( 
   int AnnotationIdx
) 
public:
String^ GetFileAttachmentAnnotModificationDate( 
   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

The modification date of the embedded file associated with the specified annotation. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

Please always ensure that you have selected the correct page using the SelectPage method before applying an annotation index.

Example
How to retrieve all files and their properties associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotModificationDate"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim message As String = ""
        Dim status As GdPictureStatus = GdPictureStatus.OK
        For page As Integer = 1 To pageCount
            message = message + "Page nr." + page.ToString()
            status = gdpicturePDF.SelectPage(page)
            If status = GdPictureStatus.OK Then
                Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim subtype As String = ""
                    For annotID As Integer = 0 To annotCount - 1
                        subtype = gdpicturePDF.GetAnnotationSubType(annotID)
                        status = gdpicturePDF.GetStat()
                        If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
                            message = message + vbCrLf + "AnnotID: " + annotID.ToString()
                            Dim filedata As Byte() = Nothing
                            Dim filesize As Integer = 0
                            Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
                            Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
                            status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then
                                Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
                                    file.Write(filedata, 0, filesize)
                                End Using
                                message = message + "  file: " + filename + "  desc: " + fileDesc + "  size: " + filesize.ToString() +
                                          "  creation: " + crDate + "  modif: " + modDate
                            End If
                        End If
                        message = message + "  status: " + status.ToString()
                    Next
                Else
                    message = message + "GetAnnotationCount - status: " + status.ToString()
                End If
            Else
                message = message + "SelectPage - status: " + status.ToString()
            End If
            message += vbCrLf
        Next
        MessageBox.Show(message, caption)
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotModificationDate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int pageCount = gdpicturePDF.GetPageCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string message = "";
        GdPictureStatus status = GdPictureStatus.OK;
        for (int page = 1; page <= pageCount; page++)
        {
            message = message + "Page nr." + page.ToString();
            status = gdpicturePDF.SelectPage(page);
            if (status == GdPictureStatus.OK)
            {
                int annotCount = gdpicturePDF.GetAnnotationCount();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    string subtype = "";
                    for (int annotID = 0; annotID < annotCount; annotID++)
                    {
                        subtype = gdpicturePDF.GetAnnotationSubType(annotID);
                        status = gdpicturePDF.GetStat();
                        if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
                        {
                            message = message + "\nAnnotID: " + annotID.ToString();
                            byte[] filedata = null;
                            int filesize = 0;
                            string fileDesc = "", crDate = "", modDate = "";
                            string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
                            status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
                            else status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
                            else status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
                            else status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
                            else status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
                            else status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK)
                            {
                                using (System.IO.Stream file = File.OpenWrite(filename))
                                {
                                    file.Write(filedata, 0, filesize);
                                }
                                message = message + "  file: " + filename + "  desc: " + fileDesc + "  size: " + filesize.ToString() +
                                          "  creation: " + crDate + "  modif: " + modDate;
                            }
                        }
                        message = message + "  status: " + status.ToString();
                    }
                }
                else
                    message = message + "GetAnnotationCount - status: " + status.ToString();
            }
            else
                message = message + "SelectPage - status: " + status.ToString();
            message += "\n";
        }
        MessageBox.Show(message, caption);
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also