| Format.OnNewPrintJob Event | 
 Description
Description
        Occurs when a new print job is created.
 VB.NET Syntax
VB.NET SyntaxPrivate Sub EventHandler(ByVal printerName As String, ByVal jobID As Integer) Handles Format.OnNewPrintJob
Where:
EventHandler is the name of the subroutine that get called when the event occurs.
printerName is the name of the printer that is processing the new print job.
jobID is the print job's identification number.
 C# Event Connection Syntax
C# Event Connection Syntax
        Format.OnNewPrintJob+=new BarTender.IFormatEvents_OnNewPrintJobEventHandler(EventHandler)
Where EventHandler is the name of the method that is called when the event occurs.
 C# Event Callback Signature
C# Event Callback Signature void EventHandler(string printerName, int jobID){}
Where:
EventHandler is the name of the method that is called when the event occurs.
printerName is the name of the printer that is processing the new print job.
jobID is the print job's identification number.
 Requirements
Requirements | Version | BarTender 9.01 or higher | 
| Edition | Automation, Enterprise | 
 Remarks
RemarksWhen the Format.OnNewPrintJob event is used with the Format object, only the document's print jobs will call the event handler.
 VB.NET Example
VB.NET Example
        Module Format_OnNewPrintJob
'Declare a BarTender document variable with support for events
Public WithEvents btFormat As BarTender.Format
'Define the event handler
Private Sub OnNewPrintJobEventHandler(ByVal printerName As String, ByVal jobID As Integer) Handles btFormat.OnNewPrintJob
MsgBox("New print event on printer: " + printerName + "with Job ID: " + jobID.ToString())
End Sub
Public Sub DoOnNewPrintJob()
'Declare a BarTender application variable
Dim btApp As BarTender.Application
'Create a new instance of BarTender
btApp = CreateObject("BarTender.Application")
'Open a BarTender document and print it
BtFormat = btApp.Formats.Open("C:\Temp\Format1.btw")
btFormat.Print("My PrintJob", True)
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
End Sub
End Module
 C# Example
C# Example
        Event Handler:
public void OnNewPrintJobEventHandler(string printerName, int jobID)
{
MessageBox.Show("OnNewPrintJob Event: Printer: " + printerName +" - Job ID: " + jobID.ToString());
}
Code that causes the Event:
public void DoOnNewPrintJob()
{
BarTender.Application btApp = null;
BarTender.Format btFormat = null;
BarTender.Messages btMsgs = null;
// Create a new instance of BarTender
btApp = new BarTender.Application();
// Register the event handler
btFormat.OnNewPrintJob += new BarTender.IFormatEvents_OnNewPrintJobEventHandler(OnNewPrintJobEventHandler);
// Open a BarTender document and print it
btFormat = btApp.Formats.Open(@"C:\Temp\Format1.btw", true, "");
btFormat.Print("My PrintJob", true, -1, out btMsgs);
// End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
}
Related Topics