SetAuthor Method (GdPicturePDF)
In This Topic
Sets up a new author of the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Author property is synchronized with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
Syntax
'Declaration
Public Sub SetAuthor( _
ByVal As String _
)
public void SetAuthor(
string
)
public procedure SetAuthor(
: String
);
public function SetAuthor(
: String
);
public: void SetAuthor(
string*
)
public:
void SetAuthor(
String^
)
Parameters
- Author
- A new value of the Author property as a string.
Example
How to set up who is the author of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim author As String = gdpicturePDF.GetAuthor()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor")
gdpicturePDF.SetAuthor(author + " Victor Hugo")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
author = gdpicturePDF.GetAuthor()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF was set properly." + vbCrLf + "The new author is: " + author, "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetAuthor")
End If
Else
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string author = gdpicturePDF.GetAuthor();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor");
gdpicturePDF.SetAuthor(author + " Victor Hugo");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
author = gdpicturePDF.GetAuthor();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF was set properly.\nThe new author is: " + author, "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor");
}
}
Example
How to set up who is the author of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim author As String = gdpicturePDF.GetAuthor()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor")
gdpicturePDF.SetAuthor(author + " Victor Hugo")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
author = gdpicturePDF.GetAuthor()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF was set properly." + vbCrLf + "The new author is: " + author, "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetAuthor")
End If
Else
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string author = gdpicturePDF.GetAuthor();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor");
gdpicturePDF.SetAuthor(author + " Victor Hugo");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
author = gdpicturePDF.GetAuthor();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF was set properly.\nThe new author is: " + author, "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor");
}
}
See Also