In This Topic
Gets the metadata of the currently selected page in the loaded PDF document.
Syntax
'Declaration
Public Function GetPageMetadata() As String
public string GetPageMetadata()
public function GetPageMetadata(): String;
public function GetPageMetadata() : String;
public: string* GetPageMetadata();
public:
String^ GetPageMetadata();
Return Value
The metadata of the current page as a string, if any are defined. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to obtain the metadata linked with all pages of the PDF document. Metadata linked to each page are subsequently saved into a separate file.
Dim caption As String = "Example: GetPageMetadata"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
data = gdpicturePDF.GetPageMetadata()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + vbCrLf
//Metadata of each page are saved into a separate file.
Dim filename As String = "metadata_page" + i.ToString() + ".xmp"
System.IO.File.WriteAllText(filename, data)
Else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() 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: GetPageMetadata";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
data = gdpicturePDF.GetPageMetadata();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + "\n";
//Metadata of each page are saved into a separate file.
string filename = "metadata_page" + i.ToString() + ".xmp";
System.IO.File.WriteAllText(filename, data);
}
else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Example
How to obtain the metadata linked with all pages of the PDF document. Metadata linked to each page are subsequently saved into a separate file.
Dim caption As String = "Example: GetPageMetadata"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
data = gdpicturePDF.GetPageMetadata()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + vbCrLf
//Metadata of each page are saved into a separate file.
Dim filename As String = "metadata_page" + i.ToString() + ".xmp"
System.IO.File.WriteAllText(filename, data)
Else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() 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: GetPageMetadata";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
data = gdpicturePDF.GetPageMetadata();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + "\n";
//Metadata of each page are saved into a separate file.
string filename = "metadata_page" + i.ToString() + ".xmp";
System.IO.File.WriteAllText(filename, data);
}
else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also