PrintGetDocumentName Method (GdPicturePDF)
Returns the printer document name setting of the active printer. You can use it to display during the next print process (for example, in a print
status dialog box or printer queue) while printing the document.
public string PrintGetDocumentName()
public function PrintGetDocumentName(): String;
public function PrintGetDocumentName() : String;
public: string* PrintGetDocumentName();
public:
String^ PrintGetDocumentName();
'Declaration
Public Function PrintGetDocumentName() As String
Return Value
The value of the active printer document name setting. The
GdPicturePDF.GetStat method can be subsequently used or the
GdPicturePDF.PrintGetStat method to determine if this method has been successful.
How to find out the document name property of the active printer and how to use it further.
Dim caption As String = "Example: PrintGetDocumentName"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim docName As String = gdpicturePDF.PrintGetDocumentName()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim curName As String = gdpicturePDF.GetTitle()
If String.IsNullOrEmpty(curName) = False Then
'We only change the document name if the document title is not empty.
gdpicturePDF.PrintSetDocumentName(curName)
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file " + curName + " has been printed successfully.", caption)
Else
Dim message As String = "The file " + curName + " can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption)
End If
Else
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintGetDocumentName";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string docName = gdpicturePDF.PrintGetDocumentName();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string curName = gdpicturePDF.GetTitle();
if (String.IsNullOrEmpty(curName) == false)
{
//We only change the document name if the document title is not empty.
status = gdpicturePDF.PrintSetDocumentName(curName);
if (status == GdPictureStatus.OK)
docName = curName;
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file " + docName + " has been printed successfully.", caption);
}
else
{
string message = "The file " + docName + " can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption);
}
}
else
{
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}