PrintGetDocumentName Method (GdViewer)
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
GetStat method can be subsequently used or the
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.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim docName As String = GdViewer1.PrintGetDocumentName()
If GdViewer1.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim curName As String = GdViewer1.GetLastPath()
If String.IsNullOrEmpty(curName) = False Then
'We only change the document name if the current file path (the last path) is not empty.
status = GdViewer1.PrintSetDocumentName(curName)
If status = GdPictureStatus.OK Then docName = curName
End If
If status = GdPictureStatus.OK Then
If GdViewer1.Print(PrintSizeOption.PrintSizeOptionActual) = GdPictureStatus.OK Then
MessageBox.Show("The file " + docName + " has been printed successfully.", "GdViewer.PrintGetDocumentName")
Else
Dim message As String = "The file " + docName + " can't be printed." + vbCrLf + "Status: " + GdViewer1.PrintGetStat().ToString()
If GdViewer1.PrintGetStat() = GdPictureStatus.PrintingException Then message = message + " Error: " + GdViewer1.PrintGetLastError()
MessageBox.Show(message, "GdViewer.PrintGetDocumentName")
End If
Else
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintGetDocumentName")
End If
Else
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintGetDocumentName")
End If
GdViewer1.CloseDocument()
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetDocumentName")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string docName = GdViewer1.PrintGetDocumentName();
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string curName = GdViewer1.GetLastPath();
if (String.IsNullOrEmpty(curName) == false)
{
//We only change the document name if the current file path (the last path) is not empty.
status = GdViewer1.PrintSetDocumentName(curName);
if (status == GdPictureStatus.OK)
docName = curName;
}
if (status == GdPictureStatus.OK)
{
if (GdViewer1.Print(PrintSizeOption.PrintSizeOptionActual) == GdPictureStatus.OK)
{
MessageBox.Show("The file " + docName + " has been printed successfully.", "GdViewer.PrintGetDocumentName");
}
else
{
string message = "The file " + docName + " can't be printed.\nStatus: " + GdViewer1.PrintGetStat().ToString();
if (GdViewer1.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + GdViewer1.PrintGetLastError();
MessageBox.Show(message, "GdViewer.PrintGetDocumentName");
}
}
else
{
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintGetDocumentName");
}
}
else
{
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintGetDocumentName");
}
GdViewer1.CloseDocument();
}
else
{
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetDocumentName");
}