C#
VB
C++
Initializes a new instance of the class with the specified printer information and then installs the LEADTOOLS Virtual Printer to the system.
public Printer(PrinterInfo printerInfo)
Public Function New( _ByVal printerInfo As Leadtools.Printer.PrinterInfo _)
public:Printer(Leadtools.Printer.PrinterInfo^ printerInfo)
printerInfo
Printer information that is used to initialize the printer object.
This overloaded constructor will automatically install a LEADTOOLS printer to the system.
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;tmpPrinterInfo.DriverName = printerName;Printer.UnInstall(tmpPrinterInfo);}string documentPrinterRegPath = "SOFTWARE\\LEAD Technologies, Inc.\\19\\Printer\\";PrinterInfo printerInfo = new PrinterInfo();printerInfo.MonitorName = printerName;printerInfo.PortName = printerName;printerInfo.DriverName = printerName;printerInfo.ProductName = printerName;printerInfo.PrinterName = printerName;printerInfo.Password = printerPassword;printerInfo.RegistryKey = documentPrinterRegPath + printerName;printerInfo.RootDir = @"C:\LEADTOOLS 19\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("Installion {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:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.Support.ExamplesImports Leadtools.PrinterImports Leadtools''' <!--Leadtools.Printer.Printer.GetPrinterInfo-->If Printer.IsLeadtoolsPrinter(printerName) Then''' <!--Leadtools.Printer.Printer.GetPrinterInfo-->''' <!--Leadtools.Printer.Printer.Install-->If (Printer.IsLeadtoolsPrinter(printerName)) ThenprinterInfo.Url = "http://www.LeadtoolsPrinterDriver.com"''' <!--Leadtools.Printer.Printer.Install-->''' <!--Leadtools.Printer.Printer.Specifications-->If (Printer.IsLeadtoolsPrinter(printerName)) ThenprinterInfo.Url = "http://www.LeadtoolsPrinterDriver.com"''' <!--Leadtools.Printer.Printer.Specifications-->''' <!--Leadtools.Printer.Printer.RemoteData-->''' <!--Leadtools.Printer.Printer.RemoteData-->''' <!--Leadtools.Printer.Printer.EnableInternetPrinting-->''' <!--Leadtools.Printer.Printer.EnableInternetPrinting-->Public Sub InstallPrinter()TryDim printerName As String = "Test LEADTOOLS Printer"Dim printerPassword As String = "Test Password"If (Printer.IsLeadtoolsPrinter(printerName)) ThenDim tmpPrinterInfo As New PrinterInfo()tmpPrinterInfo.PrinterName = printerNametmpPrinterInfo.DriverName = printerNamePrinter.UnInstall(tmpPrinterInfo)End IfDim documentPrinterRegPath As String = "SOFTWARE\\LEAD Technologies, Inc.\\19\\Printer\\"Dim printerInfo As New PrinterInfo()printerInfo.MonitorName = printerNameprinterInfo.PortName = printerNameprinterInfo.DriverName = printerNameprinterInfo.ProductName = printerNameprinterInfo.PrinterName = printerNameprinterInfo.Password = printerPasswordprinterInfo.RegistryKey = documentPrinterRegPath + printerNameprinterInfo.RootDir = "C:\\LEADTOOLS 19\\Bin\\Common\\PrinterDriver"printerInfo.Url = "http://www.LeadtoolsPrinterDriver.com"printerInfo.PrinterExe = Application.ExecutablePathprinterInfo.AboutString = "LEADTOOLS Printer"printerInfo.AboutIcon = Path.Combine(LEAD_VARS.ImagesDir, "\\RasterPro.ico")Printer.Install(printerInfo)Dim strMsg As String = String.Format("Installion {0} Completed Successfully", printerName)MessageBox.Show(strMsg, "LEADTOOLS Printer Demo", MessageBoxButtons.OK, MessageBoxIcon.Information)Catch ex As PrinterDriverExceptionMessageBox.Show(String.Format("Other error: Message:{0}", ex.Message))End TryEnd SubPrivate Sub printerTest_EmfEvent(ByVal sender As Object, ByVal e As EmfEventArgs) Handles printerTest.EmfEventSystem.IO.File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir, "LEADTOOLS_IMAGE2.emf"))End SubPrivate Sub printerTest_JobEvent(ByVal sender As Object, ByVal e As JobEventArgs) Handles printerTest.JobEventDim printerName As String = e.PrinterNameDim jobID As Integer = e.JobIDIf (e.JobEventState = EventState.JobStart) ThenMessageBox.Show(String.Format("Job {0} was started with printer {1}", jobID, printerName))ElseIf (e.JobEventState = EventState.JobEnd) ThenMessageBox.Show(String.Format("Job {0} was ended with printer {1}", jobID, printerName))ElseprinterTest.CancelPrintedJob(jobID)End IfEnd SubDim WithEvents printerTest As PrinterPublic Sub PrinterDriverExamples()printerTest = New Printer("Test LEADTOOLS Printer")InstallPrinter()If (printerTest.IsPrinterLocked()) ThenprinterTest.UnLock("Test Password")ElseprinterTest.Lock("Test Password")End IfDim iPAPER_USER As Integer = 256Dim myPrinterSpecifications As New PrinterSpecifications()myPrinterSpecifications.PaperID = iPAPER_USER + 200myPrinterSpecifications.PaperSizeName = "Custom Paper Name"myPrinterSpecifications.PaperHeight = 11myPrinterSpecifications.PaperWidth = 8myPrinterSpecifications.DimensionsInInches = TruemyPrinterSpecifications.PortraitOrient = TruemyPrinterSpecifications.MarginsPrinter = "Margins Printer Name"myPrinterSpecifications.PrintQuality = 300myPrinterSpecifications.YResolution = 300printerTest.Specifications = myPrinterSpecificationsprinterTest.UserDefaultSpecifications = myPrinterSpecificationsEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
