GetEmbeddedFileSize Method (GdPicturePDF)
In This Topic
Gets the file size of an embedded file (the size of an attached file) within the currently loaded PDF document, in bytes. You need to specify this attachment by its 0-based index.
Syntax
'Declaration
Public Function GetEmbeddedFileSize( _
ByVal As Integer _
) As Integer
public int GetEmbeddedFileSize(
int
)
public function GetEmbeddedFileSize(
: Integer
): Integer;
public function GetEmbeddedFileSize(
: int
) : int;
public: int GetEmbeddedFileSize(
int
)
public:
int GetEmbeddedFileSize(
int
)
Parameters
- FileIdx
- The 0-based index of the embedded file. It must be a value from 0 to GdPicturePDF.GetEmbeddedFileCount-1.
Return Value
The size of the embedded file, in bytes. It is the current size in bytes of the attached file.
The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to find out the file size of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileSize"
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 fsize As Integer = gdpicturePDF.GetEmbeddedFileSize(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption)
Else
MessageBox.Show("The GetEmbeddedFileSize() 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: GetEmbeddedFileSize";
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
{
int fsize = gdpicturePDF.GetEmbeddedFileSize(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileSize() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Example
How to find out the file size of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileSize"
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 fsize As Integer = gdpicturePDF.GetEmbeddedFileSize(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption)
Else
MessageBox.Show("The GetEmbeddedFileSize() 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: GetEmbeddedFileSize";
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
{
int fsize = gdpicturePDF.GetEmbeddedFileSize(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileSize() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also