'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim filename As String = GdViewer1.GetLastPath()
Dim message As String = "The current file is: " + filename
If GdViewer1.GetDocumentType() = DocumentType.DocumentTypePDF Then
message += vbCrLf + "PDF Version: " + GdViewer1.PdfGetVersion() +
vbCrLf + "Keywords: " + GdViewer1.PdfGetKeywords()
'Retrieving the PDF metadata.
Dim metadata As String = GdViewer1.PdfGetMetadata()
If GdViewer1.GetStat() = GdPictureStatus.OK Then
Dim metadataFile As String = filename.Replace(".pdf", "_metadata.xmp")
System.IO.File.WriteAllText(metadataFile, metadata)
message += vbCrLf + "Metadata has been successfully saved. File: " + metadataFile
Else
message += vbCrLf + "Metadata has not been retrieved. Status: " + GdViewer1.GetStat().ToString()
End If
Else
message += vbCrLf + "This file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString()
End If
MessageBox.Show(message, "GdViewer.PdfGetMetadata")
Else
MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetMetadata")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string filename = GdViewer1.GetLastPath();
string message = "The current file is: " + filename;
if (GdViewer1.GetDocumentType() == DocumentType.DocumentTypePDF)
{
message += "\nPDF Version: " + GdViewer1.PdfGetVersion() +
"\nKeywords: " + GdViewer1.PdfGetKeywords();
//Retrieving the PDF metadata.
string metadata = GdViewer1.PdfGetMetadata();
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
string metadataFile = filename.Replace(".pdf", "_metadata.xmp");
System.IO.File.WriteAllText(metadataFile, metadata);
message += "\nMetadata has been successfully saved. File: " + metadataFile;
}
else
message += "\nMetadata has not been retrieved. Status: " + GdViewer1.GetStat().ToString();
}
else
{
message += "\nThis file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString();
}
MessageBox.Show(message, "GdViewer.PdfGetMetadata");
}
else
MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetMetadata");