Dim caption As String = "Example: GetFileAttachmentAnnotFileSize"
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: GetFileAttachmentAnnotFileSize";
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();