Application.OnNewPrintJob Event

ClosedDescription

Occurs when a new print job is created.

ClosedVB.NET Syntax

Private Sub EventHandler(ByVal printerName As String, ByVal jobID As Integer) Handles Application.OnNewPrintJob

Where:

ClosedC# Event Connection Syntax

Application.OnNewPrintJob+=new BarTender.IApplicationEvents_OnNewPrintJobEventHandler(EventHandler)

Where EventHandler is the name of the method that is called when the event occurs.

ClosedC# Event Callback Signature

void EventHandler(string printerName, int jobID){}

Where:

ClosedRequirements

Version

BarTender 9.01 or higher

Edition

Automation, Enterprise Automation

ClosedRemarks

When the Application.OnNewPrintJob event is used with the Application.XMLScript and the Format.Print methods, all print jobs will call the event handler.

ClosedVB.NET Example

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

ClosedC# Example

Event Handler:


public void OnNewPrintJobEventHandler(string

{

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