🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18357

Re: Printing Postscriptfiles Or Textfiles !

#18357
From: Davide De Benedictis
Date: Thu, 02 Jul 1998 00:00
105 lines
3699 bytes
Last year I writed a class for printig data in tabular form with lines printed
with PCL codes. The files created can be printed in DOS mode just with
"copy >". Anyway I printed this on Macs without problems.
This is an excerpt:
/**
*  Set the printer
*
*  @param String st    Name of printer; LPT1 or also a filename
*           or whatever your system recognize like printing device.
*/
public boolean setprinter(String st)
{
    boolean prtopen = true;
      try
      {
           prt = new FileOutputStream(prtname);
       }
      catch (IOException e)
      {
           System.err.println("errore opening " + st + e.getMessage());
            prtopen = false;
      }
      return prtopen;
 }


 /**
 * write a line followed by a CR+LF
 * @param  StringBuffer st    string to write
 */
 public void printLine(StringBuffer st)
{
      boolean status=false;
      String appo =new String(st.toString()+"\r\n");
      int len = appo.length();
      try
      {
           for (int i = 0 ; i < len ; i++)
           {
                prt.write((byte)appo.charAt(i));
           }
           status=true;
           prt_row++ ;    // global... how many line I printed
      }
      catch (IOException e)
      {
           System.err.println("error printing "+ prtname + e.getMessage());
      }
      return status;
 }

You can substitute the FileOutputStream class with something better...

Actually for a new application I delegated this task at the OS:
In the .INI  file of my application I have a line like :
....
PRT_CMD,cmd.exe /c  copy   .\
....
This is for an OS2 system or WIN32 system but you can change this command
for different OS.
Inside my application, I launch this command like Richard wrote:

   String command = memo.getPrtCmd() + memo.getFileName() + " " + memo.getPrt();

   this.print(command);
    // memo is a cass to store the application data.
    // getPrtCmd()        give me the command from INI file
    // getFileName()     give me the file to print.
    // getPrt();              give me the Printer port.
    // so, for example I have: cmd.exe /c copy davide.txt LPT1

  private void print(String command)
  {
      try
      {
           Process p = Runtime.getRuntime().exec(command);
       }
      catch (java.io.IOException e)
      {
        alert = new AlertBox(frame, e.getMessage());
        alert.show();
      }
  }



Ingo, Kopido wrote:

> Do someone know if there is a possibility to print out a
> postscriptfile as it is.
> Or is it possible to print a textfile as it is ? That means if it is
> posible to send characters to a printer without interpreting them.
> They should appear at the page whitout any styles or something else.
> Or do someone know a book or something else where i can find a
> solution for my problem ?

 -----------------------------------------------------------
Davide De Benedictis

Pegaso Srl
Via Asiago 9,  00195 Roma,  Italy
tel +39 6 32.20.437   fax +39 6 37.00.454
email :  pegaso@mclink.it
-----------------------------------------------------------
Technical Details
Message-ID: <359AB5AC.70C8B25A@mclink.it>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35923baf.3803651@123.0.0.50>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,14a281d8a8f7464e
X-Google-Attributes: gidf74b3,public
From: Davide De Benedictis <pegaso@mclink.it>
Subject: Re: Printing Postscriptfiles Or Textfiles !
Date: 1998/07/02
Message-ID: <359AB5AC.70C8B25A@mclink.it>
X-Deja-AN: 367892690
Content-Transfer-Encoding: 7bit
References: <35923baf.3803651@123.0.0.50>
To: Ingo@mclink.it, Kopido@mclink.it
Content-Type: text/plain; charset=us-ascii
Organization: Pegaso Srl
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language