Dim caption As String = "Example: PrintSetDocumentName"
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.
status = gdpicturePDF.PrintSetDocumentName(curName)
If status = GdPictureStatus.OK Then
docName = curName
End If
End If
If status = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file " + docName + " has been printed successfully.", caption)
Else
Dim message As String = "The file " + docName + " 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: PrintSetDocumentName";
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.
gdpicturePDF.PrintSetDocumentName(curName);
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file " + curName + " has been printed successfully.", caption);
}
else
{
string message = "The file " + curName + " 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);
}
}