Leadtools.Printer Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Printer Constructor(PrinterInfo)
See Also  Example
Leadtools.Printer Namespace > Printer Class > Printer Constructor : Printer Constructor(PrinterInfo)



printerInfo
Printer information that is used to initialize the printer object.
Initializes a new instance of the class with the specified printer information.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal printerInfo As PrinterInfo _
)
Visual Basic (Usage)Copy Code
Dim printerInfo As PrinterInfo
 
Dim instance As Printer(printerInfo)
C# 
public Printer( 
   PrinterInfo printerInfo
)
C++/CLI 
public:
Printer( 
   PrinterInfo^ printerInfo
)

Parameters

printerInfo
Printer information that is used to initialize the printer object.

Example

Visual BasicCopy Code
Private Sub printerTest_EmfEvent(ByVal sender As Object, ByVal e As EmfEventArgs) Handles printerTest.EmfEvent
   System.IO.File.WriteAllBytes("c:\LEADTOOLS_IMAGE1.emf", e.Stream.ToArray())
   Dim metaFile As New Metafile(e.Stream)
   Dim emfImage As Image = metaFile.GetThumbnailImage(metaFile.Width, metaFile.Height, Nothing, IntPtr.Zero)
   emfImage.Save("c:\LEADTOOLS_IMAGE2.emf")
End Sub

Private Sub printerTest_JobEvent(ByVal sender As Object, ByVal e As JobEventArgs) Handles printerTest.JobEvent
   Dim printerName As String = e.PrinterName
   Dim jobID As Integer = e.JobID

   If (e.JobEventState = EventState.JobStart) Then
      MessageBox.Show(String.Format("Job {0} was started with printer {1}", jobID, printerName))
   ElseIf (e.JobEventState = EventState.JobEnd) Then
      MessageBox.Show(String.Format("Job {0} was ended with printer {1}", jobID, printerName))
   Else
      printerTest.CancelPrintedJob(jobID)
   End If
End Sub

Dim WithEvents printerTest As Printer

Public Sub PrinterDriverExamples()
   '' Unlock Printer Driver support
   '' Note that this is a sample key, which will not work in your toolkit
   RasterSupport.Unlock(RasterSupportType.PrintDriver, "TestKey")

   printerTest = New Printer("Test LEADTOOLS Printer")
   InstallNewPrinter()

   If (printerTest.IsPrinterLocked()) Then
      printerTest.UnLock("Test Password")
   Else
      printerTest.Lock("Test Password")
   End If

   Dim iPAPER_USER As Integer = 256
   Dim myPrinterSpecifications As 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

   printerTest.Specifications = myPrinterSpecifications
End Sub
C#Copy Code
void printer_EmfEvent(object sender, EmfEventArgs e) 

   System.IO.File.WriteAllBytes(@"c:\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(@"c:\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); 
   } 

 
Printer printer; 
 
public void PrinterDriverExamples() 

   /* Unlock Printer Driver support. 
      Note that this is a sample key, which will not work in your toolkit. */ 
   RasterSupport.Unlock(RasterSupportType.PrintDriver, "TestKey"); 
 
   InstallNewPrinter(); 
 
   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.EmfEvent += new EventHandler<EmfEventArgs>(printer_EmfEvent); 
   printer.JobEvent += new EventHandler<JobEventArgs>(printer_JobEvent); 
}

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Printer requires a Printer module license and unlock key. It is included as part of LEADTOOLS Document Imaging Enterprise. For more information, refer to: Imaging Pro/Document/Medical Features