1. Home
  2. Docs
  3. Scense Embedded Scripting...
  4. Scense Native Scriptable ...
  5. Printing

Printing

The printing object can be used to work with printers. Typically, a user needs administrative privileges to control printers. The object includes several collections and methods.
 

Printing Object

Collections Description
PrintingServers Collection of servers in the network that share printers.
Each server holds a collection of printer objects.
DirectoryPrinters Collection of printer objects that are published in the active directory.
LocalPrinters

 

 

Collection of locally installed printer objects. These printers can be connected directly to the computer (LPT or USB) as well as connected over the network. This collection will also include any software printers (like PDF printers etc.)

 

Methods Description
ConnectPrinter

 

 

Connect specified printer.
The function accepts a ‘printer name’ and returns a Boolean value (True if successful).

Function ConnectPrinter(ByRef PrinterName As String) As Boolean
DisconnectPrinter

 

 

 

Disconnect specified printer.
The function accepts a ‘printer name’ and returns a Boolean value (True if successful). Printer’s drivers can be uninstalled optionally.

Function DisconnectPrinter(ByVal PrinterName As String, Optional UninstallDrivers As Boolean) As Boolean
SetDefaultPrinter

 

 

Set up default printer.
The function accepts a ‘printer name’ and returns a Boolean value (True if successful).

Function SetDefaultPrinter(ByVal PrinterName As String) As Boolean
DeleteLocalPrinter

 

Delete locally installed printer.

Function DeleteLocalPrinter(ByRef PrinterName As String) As Boolean

 

Printer Object

Main object for controlling a printer.

Properties Description
Location Location of the printer

Location() As String
DriverName Driver name of the printer

DriverName() As String
Port Port of the printer

Port() As String
UNCName UNC name of the printer

UNCName() As String
ShareName Share name of the printer. For locally installed printers will be empty.

ShareName() As String
Server Printer server name. For locally installed printers will be empty.

Server() As String
Flags Flags of the printers

flags() As Long
Comment Comment

Comment() As String
Description Description of the printer

Description() As String
Model Printer model

Model() As String
Manufacturer Printer manufacturer

Manufacturer() As String
Name

 

Name of the printer

Name() As String

 

Methods Description
Disconnect Disconnect printer

Sub Disconnect()
Connect Connect printer

Sub Connect()
SetAsDefault Set as default printer

Sub SetAsDefault()
CancelAllJobs Cancel all printers jobs

Sub CancelAllJobs()
Activate Activate all jobs

Sub Activate()
Pause Pause all jobs

Sub Pause()
IsHardware

 

 

Check if printer is a ‘real’ (hardware) printer.
If this property returns ‘False’ the printer is a software printer.

Function IsHardware() As Boolean

 

Collections Description
Jobs Collection of job objects currently in the printer queue.

 

Collection DirectoryPrinters

Collection of active directory printers.

Properties Description
Count Count of printer objects in the collection

Count() As Long
Item Get the item from the collection

Item(IndexOrKey) As Printer
Methods Description
Find Clear and refresh the collection with active directory printers

Sub Find()

 

Collection LocalPrinters

Collection of locally installed and connected printers.

Properties Description
Count Count of printer objects in the collection

Count() As Long
Item

 

Get the item from the collection

Item(IndexOrKey) As Printer

 

Methods Description
Refresh Refresh the collection

Sub Refresh()

 

PrintServer Object

The object represents printing server. It holds the collection of printers installed on the server.

Properties Description
Count Count of printer objects in the collection

Count() As Long
Item Get the item from the collection

Item(IndexOrKey) As Printer
Name

 

Name of the printing server

Name() As String

 

Methods Description
Refresh Refresh the collection

Sub Refresh()

 

Collection PrintingServers

Collection of printing servers.

Properties Description
Count Count of printers in the collection

Count() As Long
Item

 

Get the item from the collection

Item(vntIndexKey As Variant) As clsPrintServer

 

Methods Description
Refresh Refresh the collection

Sub Refresh()

 

Job Object

Main object for controlling printer job.

Properties Description
PrinterName Name of the printer

PrinterName() As String
JobId Id of the job

JobId() As Integer
Status Status of the job

Status() As String
IP IP address of the printer

IP() As Integer
Size Size of the job

Size() As Integer
Name

 

Name of the job

Name() As String

 

Methods Description
Cancel Cancel the job

Sub Cancel()
Restart Restart the job

Sub Restart()
Pause Pause the job

Sub Pause()
Activate Activate the job

Sub Activate()

 

Collection Jobs

Holds collection of jobs, used in clsPrinter.

Properties Description
Count Count of jobs in collection

Count() As Long
Item

 

Job item

Item(IndexOrKey) As Job

 

Methods Description
Refresh Refresh the collection

Sub Refresh(ByRef PrinterName As String)
Clear Clear the collection

Sub Clear()
Add Add item to the collection

Function Add(Name As String, Optional sKey As String) As clsJob
Remove Remove item from the collection

Sub Remove(Index)

Usage:

Sub Scense_Main()
    With Printing
        'Connect directory printer
        If Not .ConnectPrinter(.DirectoryPrinters(1).Name) Then
            WriteScenseLog .ReturnCode
	Else
            WriteScenseLog “Count of printer jobs ” & .DirectoryPrinters(1).Jobs.Count
	    'Disconnnect network printer
            If Not .DisconnectPrinter(.DirectoryPrinters(1).Name) Then
                WriteScenseLog .ReturnCode
            End If
       End If
    End With
End Sub

Sub Scense_Main()
    'Count printers
    With Printing
        WriteScenseLog “Count of directory printers: ” & .DirectoryPrinters.Count 	
	WriteScenseLog “Count of local printers: ” & .LocalPrinters.Count 	
	WriteScenseLog “Count of print servers in network: ” & .PrintingServers.Count 
    End With
End Sub
 
Sub Scense_Main()
    With Printing
        'Set default printer
        If Not .SetDefaultPrinter(.LocalPrinters(1).Name) Then
            WriteScenseLog .ReturnCode
        End If
    End With
End Sub