GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetEmbeddedFileTitle Method
The 0-based index of the embedded file. It must be a value from 0 to GetEmbeddedFileCount-1.
Example





In This Topic
GetEmbeddedFileTitle Method (GdPicturePDF)
In This Topic
Gets the title of an embedded file (the title of an attached file) within the currently loaded PDF document. You need to specify this attachment by its 0-based index.
Syntax
'Declaration
 
Public Function GetEmbeddedFileTitle( _
   ByVal FileIdx As Integer _
) As String
public string GetEmbeddedFileTitle( 
   int FileIdx
)
public function GetEmbeddedFileTitle( 
    FileIdx: Integer
): String; 
public function GetEmbeddedFileTitle( 
   FileIdx : int
) : String;
public: string* GetEmbeddedFileTitle( 
   int FileIdx
) 
public:
String^ GetEmbeddedFileTitle( 
   int FileIdx
) 

Parameters

FileIdx
The 0-based index of the embedded file. It must be a value from 0 to GetEmbeddedFileCount-1.

Return Value

The title of the embedded file. The GetStat method can be subsequently used to determine if this method has been successful.

Mostly it is the whole file name of the embedded file with the file extension. If your files have been embedded using the EmbedFile(String,String) method, the return value is only the file name of the embedded file without the file extension.

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.

Example
How to find out the title of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileTitle"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
    Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If embeddedFileCount = 0 Then
            MessageBox.Show("This PDF file does not contain embedded files.", caption)
        Else
            Dim title As String = gdpicturePDF.GetEmbeddedFileTitle(0)
            Dim status As GdPictureStatus = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The file title of the first embedded file is: " + title, caption)
            Else
                MessageBox.Show("The GetEmbeddedFileTitle() method has failed with the status: " + status.ToString(), caption)
            End If
        End If
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
    int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if (embeddedFileCount == 0)
        {
            MessageBox.Show("This PDF file does not contain embedded files.", caption);
        }
        else
        {
            string title = gdpicturePDF.GetEmbeddedFileTitle(0);
            GdPictureStatus status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
            {
                MessageBox.Show("The title of the first embedded file is: " + title, caption);
            }
            else
            {
                MessageBox.Show("The GetEmbeddedFileTitle() method has failed with the status: " + status.ToString(), caption);
            }
        }
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also