JobEvent Event

Summary
Provides the listening application with print job information for each print job received by the Virtual Printer.
Syntax
C#
C++/CLI
public event EventHandler<JobEventArgs> JobEvent 
public: 
event EventHandler<JobEventArgs^>^ JobEvent 
Event Data

The event handler receives an argument of type JobEventArgs containing data related to this event. The following JobEventArgs properties provide information specific to this event.

PropertyDescription
JobEventState Gets the current job state.
JobID Gets the current job id.
PrinterName Gets the name of the printer that generated the event.
Remarks

The event handler receives an argument indicating if the specified job was started or ended as well as other print job information.

Example
C#
using Leadtools.Printer; 
using Leadtools; 
 
 
public void PrinterDriverExamples() 
{ 
   InstallPrinter(); 
 
   printer = new Printer("Test LEADTOOLS Printer "); 
 
   if (printer.IsPrinterLocked()) 
   { 
      printer.UnLock("Test Password"); 
   } 
   else 
   { 
      printer.Lock("Test Password"); 
   } 
 
   int iPAPER_USER = 256; 
   PrinterSpecifications myPrinterSpecifications = new PrinterSpecifications(); 
   myPrinterSpecifications.PaperID = iPAPER_USER + 200; 
   myPrinterSpecifications.PaperSizeName = "Custom Paper Name"; 
   myPrinterSpecifications.PaperHeight = 11; 
   myPrinterSpecifications.PaperWidth = 8; 
   myPrinterSpecifications.DimensionsInInches = true; 
   myPrinterSpecifications.PortraitOrient = true; 
   myPrinterSpecifications.MarginsPrinter = "Margins Printer Name"; 
   myPrinterSpecifications.PrintQuality = 300; 
   myPrinterSpecifications.YResolution = 300; 
 
   printer.Specifications = myPrinterSpecifications; 
   printer.UserDefaultSpecifications = myPrinterSpecifications; 
 
   printer.EmfEvent += new EventHandler<EmfEventArgs>(printer_EmfEvent); 
   printer.JobEvent += new EventHandler<JobEventArgs>(printer_JobEvent); 
} 
 
Printer printer; 
 
public void InstallPrinter() 
{ 
   try 
   { 
      string printerName = "Test LEADTOOLS Printer"; 
      string printerPassword = "Test Password"; 
      if (Printer.IsLeadtoolsPrinter(printerName)) 
      { 
         PrinterInfo tmpPrinterInfo = new PrinterInfo(); 
         tmpPrinterInfo.PrinterName = printerName; 
         Printer.UnInstall(tmpPrinterInfo); 
      } 
 
      string documentPrinterRegPath = "SOFTWARE\\LEAD Technologies, Inc.\\22\\Printer\\"; 
      PrinterInfo printerInfo = new PrinterInfo(); 
      printerInfo.MonitorName = printerName; 
      printerInfo.PortName = printerName; 
      printerInfo.ProductName = printerName; 
      printerInfo.PrinterName = printerName; 
      printerInfo.Password = printerPassword; 
      printerInfo.RegistryKey = documentPrinterRegPath + printerName; 
      printerInfo.RootDir = @"C:\LEADTOOLS22\Bin\Common\PrinterDriver"; 
      printerInfo.Url = "https://www.leadtools.com"; 
      printerInfo.PrinterExe = Application.ExecutablePath; 
      printerInfo.AboutString = "LEADTOOLS Printer"; 
      printerInfo.AboutIcon = Path.Combine(LEAD_VARS.ImagesDir, "RasterPro.ico"); 
 
      Printer.Install(printerInfo); 
 
      string strMsg = string.Format("Installation {0} Completed Successfully", printerName); 
      MessageBox.Show(strMsg, "LEADTOOLS Printer Demo", MessageBoxButtons.OK, MessageBoxIcon.Information); 
   } 
   catch (PrinterDriverException ex) 
   { 
      MessageBox.Show(string.Format("Other error: Message:{0}", ex.Message)); 
   } 
} 
 
void printer_EmfEvent(object sender, EmfEventArgs e) 
{ 
   System.IO.File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, @"LEADTOOLS_IMAGE1.emf"), e.Stream.ToArray()); 
   Metafile metaFile = new Metafile(e.Stream); 
 
   Image emfImage = metaFile.GetThumbnailImage(metaFile.Width, metaFile.Height, null, IntPtr.Zero); 
   emfImage.Save(Path.Combine(LEAD_VARS.ImagesDir, @"LEADTOOLS_IMAGE2.emf")); 
} 
 
void printer_JobEvent(object sender, JobEventArgs e) 
{ 
   string printerName = e.PrinterName; 
   int jobID = e.JobID; 
 
   if (e.JobEventState == EventState.JobStart) 
   { 
      MessageBox.Show(string.Format("Job {0} was started with printer {1}", jobID, printerName)); 
   } 
   else if (e.JobEventState == EventState.JobEnd) 
   { 
      MessageBox.Show(string.Format("Job {0} was ended with printer {1}", jobID, printerName)); 
   } 
   else 
   { 
      printer.CancelPrintedJob(jobID); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

See Also

Reference

Printer Class

Printer Members

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Printer Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.