Format.Print Method |
Prints a BarTender document and optionally waits for printing to complete.
Format.Print(PrintJobName, WaitForJobToComplete, TimeoutMs, Messages)
Where the following parameters are optional:
PrintJobName is the name of the print job. If PrintJobName is an empty string, the function will use the file name of the BarTender document. There is no limit on the size of the name, but only the first 31 characters will display in the printer queue.
WaitForJobToComplete sets whether the Print method will wait until the print job has been sent to the spooler.
TimeoutMs is the length of time (in milliseconds) that the Print method will wait for a job to complete printing. If set to -1 the wait is infinite. The default value is -1 if not specified.
Messages returns one or more Message objects from the print job. An uninitialized Messages object is passed in to the function.
Version |
BarTender 8.01 or higher |
Edition |
Automation, Enterprise Automation |
The Format.Print method returns a Messages collection of Message objects giving print job status.
The Format.Print method returns one of the following enumerated values:
Constant |
Value |
Description |
---|---|---|
BtPrintResult.btSuccess |
0 |
The job printed successfully |
BtPrintResult.btTimeout |
1 |
The job exceeded the timeout period before completing |
BtPrintResult.btFailure |
2 |
The job failed to print successfully |
'Declare BarTender variables
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Dim btPrintRtn As BarTender.BtPrintResult
Dim btMsgs As BarTender.Messages = Nothing
'Create a new instance of BarTender
btApp = New BarTender.Application
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender document
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Print the document
btPrintRtn = btFormat.Print("Job1", True, -1, btMsgs)
'Check to see if there are any error messages
Dim msg As BarTender.Message
If (btPrintRtn <> BarTender.btPrintResult.btSuccess) Then
For Each msg In btMsgs
MessageBox.Show(msg.Message)
Next msg
End If
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
// Declare BarTender variables
BarTender.Application btApp;
BarTender.Format btFormat;
BarTender.BtPrintResult btPrintRtn;
BarTender.Messages btMsgs;
// Create a new instance of BarTender
btApp = new BarTender.Application();
// Set the BarTender application visible
btApp.Visible = true;
// Open a BarTender document
btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");
// Print the document
btPrintRtn = btFormat.Print("Job1", true, -1, out btMsgs);
// Check to see if there are any error messages
if (btPrintRtn != BarTender.BtPrintResult.btSuccess)
{
foreach(BarTender.Message msg in btMsgs)
{
MessageBox.Show(msg.Message);
}
}
// End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
Related Topics