GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetEmbeddedFileCount Method
Example





In This Topic
GetEmbeddedFileCount Method (GdPicturePDF)
In This Topic
Gets the number of all embedded (attached) files in your currently loaded PDF document.

Embedded files, so called File Attachments, can be included as a whole directly to a PDF document. Be aware that PDF documents can also contain attached files as part of the file attachment annotations. You can refer to our examples how to extract embedded files in both ways.

Syntax
'Declaration
 
Public Function GetEmbeddedFileCount() As Integer
public int GetEmbeddedFileCount()
public function GetEmbeddedFileCount(): Integer; 
public function GetEmbeddedFileCount() : int;
public: int GetEmbeddedFileCount(); 
public:
int GetEmbeddedFileCount(); 

Return Value

The number of all embedded files. The GdPicturePDF.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 GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

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