Gets or sets the printer specifications.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As Printer
Dim value As PrinterSpecifications
instance.Specifications = value
value = instance.Specifications
|
Return Value
The printer specifications.
Example
Visual Basic | Copy 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()
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