SetTitle Method (GdPicturePDF)
In This Topic
Sets up a new title of the currently loaded PDF document into the document information dictionary and into 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 Title 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 SetTitle( _
ByVal As String _
)
public void SetTitle(
string
)
public procedure SetTitle(
: String
);
public function SetTitle(
: String
);
public: void SetTitle(
string*
)
public:
void SetTitle(
String^
)
Parameters
- Title
- A new value of the Title property as a string.
Example
How to set up a new title of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim title As String = gdpicturePDF.GetTitle()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle")
gdpicturePDF.SetTitle("This is a new title.")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
title = gdpicturePDF.GetTitle()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetTitle")
End If
Else
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetTitle")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string title = gdpicturePDF.GetTitle();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle");
gdpicturePDF.SetTitle("This is a new title.");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
title = gdpicturePDF.GetTitle();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetTitle");
}
}
else
{
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetTitle");
}
}
Example
How to set up a new title of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim title As String = gdpicturePDF.GetTitle()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle")
gdpicturePDF.SetTitle("This is a new title.")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
title = gdpicturePDF.GetTitle()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetTitle")
End If
Else
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetTitle")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string title = gdpicturePDF.GetTitle();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle");
gdpicturePDF.SetTitle("This is a new title.");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
title = gdpicturePDF.GetTitle();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetTitle");
}
}
else
{
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetTitle");
}
}
See Also