InstallOEMPrinter Example for Visual Basic
Private Sub InstallOEMPrinter_Click()
Const DMPAPER_USER = 1
Const TEST_PRINTER_NAME = "Test Printer Name"
Dim PrinterSpecifications As New EpnPrinterSpecifications
Dim MultiSaveOptions As New EpnMultiSaveOptions
Dim MailMessageInfo As New EpnMailMessageInfo
Dim BatchPrinterInfo As New EpnBatchPrinterInfo
Dim PrintersList As New EpnPrinterList
Dim OemPrinterInfo As New EpnOemPrinterInfo
Dim ePrint As New ePrint
Dim nRet As Integer
If ePrint.IsSupportLocked (SUPPORT_OEM) Then
ePrint.UnlockSupport SUPPORT_OEM, OEM_KEY
End If
'Prepare Printer Specifications
'Custom Papers IDs starts from "DMPAPER_USER + 200"
PrinterSpecifications.PaperID = DMPAPER_USER + 200
PrinterSpecifications.PaperSizeName = "Custom Paper Name"
PrinterSpecifications.PaperHeight = 11
PrinterSpecifications.PaperWidth = 8
PrinterSpecifications.DimensionsInInches = True
PrinterSpecifications.PortraitOrient = True
PrinterSpecifications.MarginsPrinter = "Margins Printer Name"
PrinterSpecifications.PrintQuality = 300
PrinterSpecifications.YResolution = 300
'Prepare Save Options
MultiSaveOptions.UseSave = True
MultiSaveOptions.SaveElementsCount = 1
MultiSaveOptions.PrinterSaveOptions (0).SaveOptions.FileName = "c:\Untitled.cmp"
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.Format = FILE_CMP
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.DocumentType = FT_SAVE_TYPE_RASTER
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.BitsPerPixel = 24
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.QFactor = 100
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.StampBits = 24
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.StampWidth = 128
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.StampHeight = 128
MultiSaveOptions.PrinterSaveOptions(0).SaveOptions.RasterOptions.MultiPageFile = False
ePrint.GetDefaultNamingOptions MultiSaveOptions.PrinterSaveOptions(0).NamingOptions
'Prepare Mail Message
MailMessageInfo.UseMail = True
MailMessageInfo.To = "someone@somedomain.com"
MailMessageInfo.Cc = "another@anotherdomain.com"
MailMessageInfo.Bcc = "someonespecial@anotherdomain.com"
MailMessageInfo.Subject = "Attached Images"
MailMessageInfo.Body = "Hello, the images are attached."
'Index of the save options index to be used for the e-mailed files.
'Index of the PrinterSaveOptions property in the EpnMultiSaveOptions
'passed to the SetPrinterSaveOptions.
MailMessageInfo.EmailSaveOptionsIndex = 0
'Prepare Printers List
' This will add the Default Printer to the Printers List
BatchPrinterInfo.PrinterName = Printer.DeviceName
ePrint.GetDefaultEnhancedOptions BatchPrinterInfo.EnhancedOptions
BatchPrinterInfo.Flags = VALID_ENHANCED_OPTIONS
PrintersList.AddPrinter BatchPrinterInfo
'Prepare Printer Info
OemPrinterInfo.OEMDriverName = "Test Driver Name"
OemPrinterInfo.OEMPrinterName = TEST_PRINTER_NAME
OemPrinterInfo.OEMMonitorName = ""
OemPrinterInfo.OEMPortName = ""
OemPrinterInfo.OEMProductName = "OEM ePrint"
OemPrinterInfo.OEMSerialNumber = "xxxxx-xxxxx-xxxxx"
OemPrinterInfo.OEMRegistryKey = "Test Printer Inc."
OemPrinterInfo.OEMRootDir = "C:\Program Files\OEM"
OemPrinterInfo.OEMHelpFile = "C:\Program Files\OEM\OEM.hlp"
OemPrinterInfo.OEMPassword = "Test Password"
OemPrinterInfo.OEMUrl = "http://www.eprintdriver.com"
nRet = ePrint.InstallOEMPrinter (OemPrinterInfo, PRINTER_OEM_NORMAL)
If (nRet = 0) Then
' Set OEM Printer Specifications
ePrint.SetPrinterSpecifications TEST_PRINTER_NAME, PrinterSpecifications
'Set OEM Printer Save Options
ePrint.SetPrinterSaveOptions TEST_PRINTER_NAME, MultiSaveOptions
' Set OEM Printer Conflict Solve
Dim RenamingOptions As New EpnRenamingOptions
ePrint.GetDefaultRenamingOptions RenamingOptions
ePrint.SetPrinterConflictSolving TEST_PRINTER_NAME, SAVE_APPEND_FAVOR_RENAME, RenamingOptions
'Set OEM Printer Mail Message
ePrint.SetPrinterMailMessageInfo TEST_PRINTER_NAME, MailMessageInfo
'Set OEM Printer Batch Printers List
ePrint.SetPrinterBatchPrintersList TEST_PRINTER_NAME, PrintersList
'Set OEM E-Mail Configurations
Dim MailConfigurationSettings As New EpnMailConfigurationSettings
MailConfigurationSettings.IsMAPI = True
MailConfigurationSettings.UseDefaultMapiProfile = True
MailConfigurationSettings.Flags = 0
ePrint.SetPrinterEmailConfiguration TEST_PRINTER_NAME, MailConfigurationSettings
End If
End Sub