com.lowagie.tools
Class LPR

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

public class LPR
extends 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  String cfA
           
private  boolean cfA_banner
           
private  boolean cfA_formatted
           
private  boolean cfA_postscript
           
private  boolean cfA_pr
           
private  String cfAlen
           
private  int copies
           
private  String host
           
private  String hostname
           
private  String jobname
           
private  Vector jobs
           
private  int port
           
private  int timeout
           
static int UNKNOWN
           
private  String user
           
 
Constructor Summary
LPR()
          default constructor without parameters, standard port is 515
LPR(String host, int port, String user)
          constuctor with host, port and username
LPR(String host, String user)
          constuctor with host and username standard port is 515
 
Method Summary
private  void close(Socket socket, BufferedReader in, DataOutputStream out)
          closed connection to the LPD
private  Socket connect()
          connect to the LPD Server
private  String fillLeft(String data, int size, String filler)
           
 boolean getCfA_banner()
          get if job printed with banner page
 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
 String getHost()
          get LPD host
 String getHostname()
          get the host name for this computer
private  String getNewJobId()
           
 int getPort()
          get LPD port
 String getQueueState(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
 String getUser()
          get username
private  void makecfA(String document, String jobid)
          internal methode to create the control file
 String print(String queue, byte[] dfA, String document)
          print a byte array with the document name as parameter
 String print(String queue, char[] dfA, String document)
          print a char array with the document name as parameter
 String print(String queue, File file, String document)
          print a file with the document name as parameter
private  boolean print(String queue, String document, byte[] dfA1, char[] dfA2, int mode, String jobid)
          internal funktion for printing
 String print(String queue, String dfA, String document)
          print a String with the document name as parameter
 boolean printWaitingJobs(String queue)
          Print any waiting jobs
 boolean removeJob(String queue, String user, String jobid)
          Remove job
 void setCfA_banner(boolean value)
          set if job printed with banner page
 void setCfA_jobname(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(String value)
          set LPD host
 void setHostname(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(String value)
          set username
 void waitFor(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 String host

port

private int port

user

private String user

jobs

private Vector jobs

hostname

private String hostname

jobname

private String jobname

cfAlen

private String cfAlen

cfA

private 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(String host,
           String user)
constuctor with host and username standard port is 515


LPR

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

Method Detail

setHost

public void setHost(String value)
set LPD host


getHost

public 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(String value)
set username


getUser

public 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 String getCfA_jobname()
get the job name


setCfA_jobname

public void setCfA_jobname(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 String getHostname()
get the host name for this computer


setHostname

public void setHostname(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(String queue)
Print any waiting jobs

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


removeJob

public boolean removeJob(String queue,
                         String user,
                         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 String getQueueState(String queue,
                            boolean shortstate)
gets the state and description of the printer queue in short or long format


print

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

See Also:
{

print

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

See Also:
{

print

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

See Also:
{

print

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

See Also:
{

waitFor

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


print

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


connect

private Socket connect()
connect to the LPD Server


close

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


makecfA

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


getNewJobId

private String getNewJobId()

fillLeft

private String fillLeft(String data,
                        int size,
                        String filler)