com.lowagie.tools
Class LPR

java.lang.Object
  extended by com.lowagie.tools.LPR

public class LPR
extends java.lang.Object

Modified! This class provides methods for the Line Printer Daemon Protocol
more info about LPD/LPR

Version:
1.0 (12/98)
Author:
Mario Müller

Nested Class Summary
private  class LPR.PrintJob
          Job ************************
 
Field Summary
private  java.lang.String cfA
           
private  boolean cfA_banner
           
private  boolean cfA_formatted
           
private  boolean cfA_postscript
           
private  boolean cfA_pr
           
private  java.lang.String cfAlen
           
private  int copies
           
private  java.lang.String host
           
private  java.lang.String hostname
           
private  java.lang.String jobname
           
private  java.util.Vector jobs
           
private  int port
           
private  int timeout
           
static int UNKNOWN
           
private  java.lang.String user
           
 
Constructor Summary
LPR()
          default constructor without parameters, standard port is 515
LPR(java.lang.String host, int port, java.lang.String user)
          constuctor with host, port and username
LPR(java.lang.String host, java.lang.String user)
          constuctor with host and username standard port is 515
 
Method Summary
private  void close(java.net.Socket socket, java.io.BufferedReader in, java.io.DataOutputStream out)
          closed connection to the LPD
private  java.net.Socket connect()
          connect to the LPD Server
private  java.lang.String fillLeft(java.lang.String data, int size, java.lang.String filler)
           
 boolean getCfA_banner()
          get if job printed with banner page
 java.lang.String getCfA_jobname()
          get the job name
 boolean getCfA_postscript()
          get if file printed as postscript file
 boolean getCfA_pr()
          get if print file with 'pr' format
 int getCopies()
          get Copies
 java.lang.String getHost()
          get LPD host
 java.lang.String getHostname()
          get the host name for this computer
private  java.lang.String getNewJobId()
           
 int getPort()
          get LPD port
 java.lang.String getQueueState(java.lang.String queue, boolean shortstate)
          gets the state and description of the printer queue in short or long format
 int getTimeout()
          get the timeout for any commands
 java.lang.String getUser()
          get username
private  void makecfA(java.lang.String document, java.lang.String jobid)
          internal methode to create the control file
 java.lang.String print(java.lang.String queue, byte[] dfA, java.lang.String document)
          print a byte array with the document name as parameter
 java.lang.String print(java.lang.String queue, char[] dfA, java.lang.String document)
          print a char array with the document name as parameter
 java.lang.String print(java.lang.String queue, java.io.File file, java.lang.String document)
          print a file with the document name as parameter
private  boolean print(java.lang.String queue, java.lang.String document, byte[] dfA1, char[] dfA2, int mode, java.lang.String jobid)
          internal funktion for printing
 java.lang.String print(java.lang.String queue, java.lang.String dfA, java.lang.String document)
          print a String with the document name as parameter
 boolean printWaitingJobs(java.lang.String queue)
          Print any waiting jobs
 boolean removeJob(java.lang.String queue, java.lang.String user, java.lang.String jobid)
          Remove job
 void setCfA_banner(boolean value)
          set if job printed with banner page
 void setCfA_jobname(java.lang.String value)
          set the job name
 void setCfA_postscript(boolean value)
          set if file printed as postscript file
 void setCfA_pr(boolean value)
           p - Print file with 'pr' format
 void setCopies(int value)
          set Copies
 void setHost(java.lang.String value)
          set LPD host
 void setHostname(java.lang.String value)
          set the host name for this computer
 void setPort(int value)
          set LPD port
 void setTimeout(int timeout)
          set the timeout for any commands
 void setUser(java.lang.String value)
          set username
 void waitFor(java.lang.String jobid)
          wait until job is printed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

host

private java.lang.String host

port

private int port

user

private java.lang.String user

jobs

private java.util.Vector jobs

hostname

private java.lang.String hostname

jobname

private java.lang.String jobname

cfAlen

private java.lang.String cfAlen

cfA

private java.lang.String cfA

copies

private int copies

timeout

private int timeout

cfA_formatted

private boolean cfA_formatted

cfA_postscript

private boolean cfA_postscript

cfA_banner

private boolean cfA_banner

cfA_pr

private boolean cfA_pr
Constructor Detail

LPR

public LPR()
default constructor without parameters, standard port is 515


LPR

public LPR(java.lang.String host,
           java.lang.String user)
constuctor with host and username standard port is 515


LPR

public LPR(java.lang.String host,
           int port,
           java.lang.String user)
constuctor with host, port and username

Method Detail

setHost

public void setHost(java.lang.String value)
set LPD host


getHost

public java.lang.String getHost()
get LPD host


setPort

public void setPort(int value)
set LPD port


getPort

public int getPort()
get LPD port


setUser

public void setUser(java.lang.String value)
set username


getUser

public java.lang.String getUser()
get username


setTimeout

public void setTimeout(int timeout)
set the timeout for any commands


getTimeout

public int getTimeout()
get the timeout for any commands


getCfA_postscript

public boolean getCfA_postscript()
get if file printed as postscript file


setCfA_postscript

public void setCfA_postscript(boolean value)
set if file printed as postscript file

o option in control file

This command prints the data file to be printed, treating the data as standard Postscript input.


getCfA_jobname

public java.lang.String getCfA_jobname()
get the job name


setCfA_jobname

public void setCfA_jobname(java.lang.String value)
set the job name

J option in control file

This command sets the job name to be printed on the banner page. The name of the job must be 99 or fewer octets. It can be omitted. The job name is conventionally used to display the name of the file or files which were "printed". It will be ignored unless the print banner command ('L') is also used.


getCfA_pr

public boolean getCfA_pr()
get if print file with 'pr' format


setCfA_pr

public void setCfA_pr(boolean value)

p - Print file with 'pr' format

This command causes the data file to be printed with a heading, page numbers, and pagination. The heading should include the date and time that printing was started, the title, and a page number identifier followed by the page number. The title is the name of file as specified by the 'N' command, unless the 'T' command (title) has been given. After a page of text has been printed, a new page is started with a new page number. (There is no way to specify the length of the page.)


getCfA_banner

public boolean getCfA_banner()
get if job printed with banner page


setCfA_banner

public void setCfA_banner(boolean value)
set if job printed with banner page

L option in control file

This command causes the banner page to be printed. The user name can be omitted. The class name for banner page and job name for banner page commands must precede this command in the control file to be effective.


getHostname

public java.lang.String getHostname()
get the host name for this computer


setHostname

public void setHostname(java.lang.String value)
set the host name for this computer


setCopies

public void setCopies(int value)
set Copies


getCopies

public int getCopies()
get Copies


printWaitingJobs

public boolean printWaitingJobs(java.lang.String queue)
Print any waiting jobs

This command starts the printing process if it not already running.


removeJob

public boolean removeJob(java.lang.String queue,
                         java.lang.String user,
                         java.lang.String jobid)
Remove job

This command deletes the print jobs from the specified queue which are listed as the other operands. If only the agent is given, the command is to delete the currently active job. Unless the agent is "root", it is not possible to delete a job which is not owned by the user. This is also the case for specifying user names instead of numbers. That is, agent "root" can delete jobs by user name but no other agents can.


getQueueState

public java.lang.String getQueueState(java.lang.String queue,
                                      boolean shortstate)
gets the state and description of the printer queue in short or long format


print

public java.lang.String print(java.lang.String queue,
                              byte[] dfA,
                              java.lang.String document)
print a byte array with the document name as parameter

See Also:
{

print

public java.lang.String print(java.lang.String queue,
                              java.lang.String dfA,
                              java.lang.String document)
print a String with the document name as parameter

See Also:
{

print

public java.lang.String print(java.lang.String queue,
                              char[] dfA,
                              java.lang.String document)
print a char array with the document name as parameter

See Also:
{

print

public java.lang.String print(java.lang.String queue,
                              java.io.File file,
                              java.lang.String document)
print a file with the document name as parameter

See Also:
{

waitFor

public void waitFor(java.lang.String jobid)
wait until job is printed


print

private boolean print(java.lang.String queue,
                      java.lang.String document,
                      byte[] dfA1,
                      char[] dfA2,
                      int mode,
                      java.lang.String jobid)
internal funktion for printing


connect

private java.net.Socket connect()
connect to the LPD Server


close

private void close(java.net.Socket socket,
                   java.io.BufferedReader in,
                   java.io.DataOutputStream out)
closed connection to the LPD


makecfA

private void makecfA(java.lang.String document,
                     java.lang.String jobid)
internal methode to create the control file


getNewJobId

private java.lang.String getNewJobId()

fillLeft

private java.lang.String fillLeft(java.lang.String data,
                                  int size,
                                  java.lang.String filler)