Format.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 Format.OnNewPrintJob

Where:

ClosedC# 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.

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 Format.OnNewPrintJob event is used with the Format object, only the document's print jobs will call the event handler.

ClosedVB.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

ClosedC# 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