Application.OnNewPrintJob Event |
Occurs when a new print job is created.
Private Sub EventHandler(ByVal printerName As String, ByVal jobID As Integer) Handles Application.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.
Application.OnNewPrintJob+=new BarTender.IApplicationEvents_OnNewPrintJobEventHandler(EventHandler)
Where EventHandler is the name of the method that is called when the event occurs.
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.
Version |
BarTender 9.01 or higher |
Edition |
Automation, Enterprise |
When the Application.OnNewPrintJob event is used with the Application.XMLScript and the Format.Print methods, all print jobs will call the event handler.
Module App_OnNewPrintJob
'Declare a BarTender application variable with support for events
Public WithEvents btApp As BarTender.Application
'Define the event handler
Private Sub OnNewPrintJobEventHandler(ByVal printerName As String, ByVal jobID As Integer) Handles btApp.OnNewPrintJob
MsgBox("New print event on printer: " + printerName + "with Job ID: " + jobID.ToString())
End Sub
Public Sub DoOnNewPrintJob()
'Create a new instance of BarTender
btApp = CreateObject("BarTender.Application")
'Open a BarTender document and print it
Dim btFormat As BarTender.Format
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
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
btApp.OnNewPrintJob += new BarTender.IApplicationEvents_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