Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
'Let's say that metadata.xmp are your required metadata you want to add/replace.
Dim metadataFile As System.IO.StreamReader = New System.IO.StreamReader("metadata.xmp")
Dim xmp As String = metadataFile.ReadToEnd()
metadataFile.Close()
'Now you can change the metadata here.
If gdpicturePDF.SetMetadata(xmp) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
xmp = gdpicturePDF.GetMetadata()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The changed metadata are:" + vbCrLf + xmp, "Example: SetMetadata")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetMetadata")
End If
Else
MessageBox.Show("The SetMetadata() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), "Example: SetMetadata")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetMetadata")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
//Let's say that metadata.xmp are your required metadata you want to add/replace.
System.IO.StreamReader metadataFile = new System.IO.StreamReader("metadata.xmp");
string xmp = metadataFile.ReadToEnd();
metadataFile.Close();
//Now you can change the metadata here.
if (gdpicturePDF.SetMetadata(xmp) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
xmp = gdpicturePDF.GetMetadata();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The changed metadata are:\n" + xmp, "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The SetMetadata() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetMetadata");
}
}