Creating an application

  1. Create an instance.

  2. Create a context.

  3. If applicable, set the port range.

  4. Specify scan settings.

  5. If applicable, set the Observer.

  6. Call one of the scan functions.

  7. Get previously created scan context.

Note: All examples in the following sections are shown using Java.

Creating an instance

In order to use LexImgTk-x.x.jar, you must:

  1. Create an instance variable:

    LITScan litScan;
  2. Create an instance where config_pro_file_path is the absolute path of the config.properties file:

    litScan=new LITScan(config_pro_file_path);

    You can also create the instance using the default configuration:

    litScan=new LITScan();
    Note: A default configuration cannot be used in a Linux environment, because the location of the config.properties file must be passed.

Creating a context

litScan.createContext().

This function returns a long integer value that is used as a handle to refer to a particular scan.

In order to create the handle, you must provide a valid printer address, a profile name, and a TCP port number for the Toolkit to listen on for printer connections. The function will use the default scan values for each created scan context.

Setting

Default value

brightness

4

colorDepth

8

compression

JPEG

contrast

TEXT

duplex

SINGLE

edgeToEdge

FALSE

jobBuild

FALSE

jpegQuality

80

linearXfer

FALSE

orientation

PORTRAIT

paperSize

LETTER

resolution

150

scanPreview

FALSE

shortcut

0

type

JPEG


Sample code for creating a context

String profile = profileText.getText();
String ipAddress = mfpIPText.getText();        
 ……………………   
index = litScan.createContext(ipAddress, profile,9750);

Setting the port range

The Set Port Range function is called to designate which ports the Toolkit will use for receiving images. Lower and upper port range values are passed as a parameter, and must be set between 1024 and 65535. If both the lower and upper port numbers are set to -1, the port range function will be disabled, and any previously set port range values will be deleted.

if(isEmptyLowerPort && isEmptyUpperPort){
         try{
              litScan.setPortRange(-1,-1);

	………..
else if(!isEmptyLowerPort &&  !isEmptyUpperPort && 
                    !isNotIntegerLowerPort && !isNotIntegerUpperPort){
        try{
              litScan.setPortRange(lowPort,upperPort);
	
	………………………………

Specifying scan settings

The Imaging Toolkit allows scan parameters to be set individually for each context. Call litScan.setSettings() to adjust settings, or litScan.getSettings() to view the current set of parameters for a given context.

Note: Scan parameters are case-sensitive. For more information about legal values for scan settings, see Scan settings.

Sample code for specifying scan settings using litScan.getSettings() and litScan.setSettings()

Map temp=new HashMap();

Map sm=litScan.getSettings(idScanBack);

temp.putAll(sm);
..........
temp.put("resolution","200");
..........

litScan.setSettings(idScanBack,temp);

Calling the scan functions

litScan.scanBlock()
litScan.ScanNoBlock()

The two scan function options enable you to scan with or without a blocking function. The non-blocking version allows the application to respond to your input. When you call the function, the profile is sent to the printer and the Toolkit waits for the printer to connect back to it.

Sample code to call the API for non-blocking scanning

String str=(String)model.getElementAt(selectedIndex);
int idScanBack=Integer.parseInt(str);

litScan.scanNoBLock(idScanBack);

Getting a previously created scan context

You can use the following sample code to display a previously created context in the context list when the application is launched:

ScanInfo[] scList=lit.getInitScanContext();
......
while(index< scList[index].getContextID();
listModel.addElement(String.valueOf(contextID));
String profile=scList[index].getProfileName();
String ipAddress=scList[index].getMfpIPAdress();
String fileName=scList[index].getOutputLocation();
.........
}

Using the sample application

Using the Java Swing sample

The sample application is a Java Swing application that uses LexImgTk-x.x.jar to send scan profiles to a printer and receive the scanned images back from the printer. The LITScan APIs exposed by LexImgTk-x.x.jar consist of public functions of the class LITScan that facilitate the imaging process. The sample application can be run from the command line, as long as LexImgTk-x.x.jar has been included in the CLASSPATH.

Executing the application

  1. Create a context by specifying the following:

    • The IP address or host name of the destination printer

    • A profile name

    Once this information has been typed into the appropriate fields, click Create Context. An integer should appear in the Contexts list. Create Context calls the LITScan.createContext function to create the context and the LITScan.setObserver function to enable your application to receive status information from the JAR file.

  2. Set the port range.

    Lower and upper port range values can be set by typing a value (between 1024 and 65535) in the corresponding field and clicking Set Port Range.

    If port range settings are left blank, then the server will attempt to open a socket on the first available port. In this case, the port range function will be disabled, and any previously set port ranges will be deleted.

    After a context has been created, default values will be shown for all scan settings.

  3. Adjust scan settings, if necessary, by typing new values in the appropriate fields, and then click Set Scan Values to call the LITScan.setSettings function. Invalid settings will not be saved. For more information about legal values for scan settings, see Scan settings.

    Note: To test whether your new settings have been accepted, click Get Scan Values to call LITScan.getSettings and display the saved values.
  4. Type the full path of the icon file.

    If the printer has a control panel with a welcome screen, then an icon will be sent to the printer and placed on the welcome screen.

    Note: Icon images can be GIF, JPEG, or PNG, with dimensions of 120 x 75 pixels that is 11KB or smaller.
  5. Click Start Scan to send a profile to the printer by calling the LITScan.scanNoBlock() function. This is a non-blocking call. Updates on status come through the observer, which outputs text into the output window.

  6. Initiate a scan at the printer by choosing the appropriate profile name, shortcut number, or icon on the printer control panel.

Additional options and functionality

Click

To

Cancel Scan

Cancel the scan job.

Release Context

Release any resources used by the scan context.

Remove Profile

Delete the profile currently selected in the profile name field.

Exit

Terminate the application.


Possible API-related error messages

The following is a list of possible error messages that you can receive while using the Imaging Toolkit. Information contained in brackets is a variable, and is filled in by the code when the error occurs.

Note: Only Toolkit-specific error messages are provided. Messages resulting from unexpected behavior within Java are not listed.

Possible OptraImage error messages

The following error messages are specific to OptraImageTM printers only: