eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PrinterStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: PrinterStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PrinterStream
         |
         +--EpsonFX1PrinterStream
         |
         +--HPLjetIIPrinterStream
         |
         +--HTMLPrinterStream
         |
         +--PostscriptPrinterStream

Package:
stx:libbasic2
Category:
Interface-Printing
Version:
rev: 1.90 date: 2023/07/27 15:50:29
user: cg
file: PrinterStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


a stream for printing; this (concrete or abstract) class can handle only
very dumb printers. 
No attributes (italic, bold etc) and no multiple fonts are supported 
- just plain single font text printing.

More intelligence is added by subclasses (see PostscriptPrinterStream among others.)

These classes do not support graphics printing - they are only for text; 
although some limited font functionality (such as bold or italic printing)
may be supported by some subclasses.


[usage:]

The concrete printer class is bound to the global variable Printer,
which is either set to PrinterStream (for dumb printers) or to one of
the subclasses (PostscriptPrinterStream etc.).

To print:

    |p|

    p := Printer new.
    p notNil ifTrue:[
        p nextPutAll:'hello world'; cr.
        p nextPutAll:' ...'; cr.
        p close
    ].

See users of the Printer global variable for more examples.

[class variables:]
    PrintCommand    <String>        UNIX only: the operatingSystem command for printing.
                                    Usually something like 'lp' or 'lpr'

    PrintDevice     <String>        VMS only: the printers device.
                                    Usually something like 'sys$print:'

copyright

COPYRIGHT (c) 1990 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

accessing-defaults
o  bottomMargin
return the bottomMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes

o  defaultCommands
UNIX only:
return a list presented as possible commands for printing
(in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultCommands:#( ... )

o  defaultCommands: collectionOfCommandStrings
UNIX only:
set the list which will be presented as possible commands for printing.
(shown in in the launchers printer configuration).
This can be done from the startup script with:
PrinterStream defaultCommands:#( ... )

o  defaultDevices
VMS only:
return a list presented as possible devices for printers.
(in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultDevices:#( ... )

o  defaultDevices: collectionOfDeviceNameStrings
VMS only:
set the list which will be presented as possible devices for printing.
(shown in in the launchers printer configuration).
This can be done from the startup script with:
PrinterStream defaultDevices:#( ... )

o  defaultPageFormats
return a list of supported page formats.
This list can be set from the startup script with:
PrinterStream defaultPageFormats:#( ... )

o  defaultPageFormats: aList
set the list of supported page formats.
(shown in in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultPageFormats:#( ... ).
All symbols must be known by UnitConverter

Usage example(s):

     PrinterStream
        defaultPageFormats:#(
                                'letter'
                                'a4'
                                'a5'
                                'a6'
                            )

o  defaultPrinter
self defaultPrinter

o  landscape
return the landscape setting

o  landscape: aBoolean
set/clear landscape printing

o  leftMargin
return the leftMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes

o  pageFormat
return a symbol describing the default page format.
This can be set from the startup script with:
PrinterStream pageFormat:#...
or via the launchers settings menu.

o  pageFormat: aSymbol
set the default page format to be aSymbol.
Valid symbols are #letter, #a4, #a5 etc.
The UnitConverter must contain width/height information on
that symbol, in order for printing to be correct.

o  printCommand
UNIX only:
return the command used for printing (usually 'lp' or 'lpr').
This is either set from the startup file, or via the launchers
settings menu.

o  printCommand: aString
UNIX only:
set the command for printing (usually 'lp' or 'lpr').
This is either set from the startup file, or via the launchers
settings menu.

Usage example(s):

     PrinterStream printCommand:'lpr'
     PrinterStream printCommand:'lpr -h'
     PrinterStream printCommand:'rsh ibm lpr -h'
     PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h'

o  printDevice
VMS only: return the device for printing (usually 'sys$print:')
This is either set from the startup file, or via the launchers
settings menu.

o  printDevice: aString
VMS only:
set the device for printing (usually 'sys$print:').
This is either set from the startup file, or via the launchers
settings menu.

Usage example(s):

     PrinterStream printDevice:'lta1739:'

o  printFilename
UNIX only:
return the file into which the print-document should be generated.
If nil (the default), printOut is piped through printCommand,
which is usually a variant of the lpr-command.

Usage example(s):

     PrinterStream printFilename
     Printer printFilename 

o  printFilename: aString
UNIX only:
set the output file for printing. If non nil, printout goes into that file.
If nil, it is piped through printCommand.
This is either set from the startup file, or via the launcher's settings menu.

Usage example(s):

     PrinterStream printFilename:'/tmp/out.ps'

o  rightMargin
return the rightMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes

o  topMargin
return the topMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes

initialization
o  initialize
this is usually redefined by the startup-file

Usage example(s):

self initializePrintParameters  -- now done lazily

o  initializePrintParameters
this is usually redefined by the startup-file

o  reInitPage
nothing done here

instance creation
o  new
return a new stream for printing.
If printFilename is nonNil, printOut goes into that file.
otherwise, it is piped through the printCommand OS-command.

o  newForFile: aFileNameOrNil
return a new stream for printing into aFileName

Usage example(s):

     |p|

     p := PostscriptPrinterStream newForFile:'/tmp/out.ps'.
     True printOutOn:p.
     p close.

o  newForFile: aFileNameOrNil native: nativePrinting
return a new stream for printing into aFileName

Usage example(s):

     |p|

     p := PostscriptPrinterStream newForFile:'/tmp/out.ps'.
     True printOutOn:p.
     p close.

o  newForStream: aStream
return a new stream for printing into aStream

Usage example(s):

     |s p|

     s := WriteStream on:String new.
     p := HTMLPrinterStream newForStream:s.
     True printOutOn:p.
     p close.
     s contents

o  newForStream: aStream native: nativePrinting
return a new stream for printing into aStream

Usage example(s):

     |s p|

     s := WriteStream on:String new.
     p := PostscriptPrinterStream newForStream:s native:false.
     True printOutOn:p.
     p close.
     s contents

Usage example(s):

     |s p|

     s := WriteStream on:String new.
     p := HTMLPrinterStream newForStream:s native:false.
     True printOutOn:p.
     p close.
     s contents

o  newNative
return a new stream for untranslated printing
(i.e. text should be sent via nextPutUntranslated in the printer's native format).
For example, this is used with PostScriptPrinterStream,
if the application generates postscript.

o  newWarnOnError

queries
o  isDrivenByCommand
return true if this printer is driven via an OS-command
(as opposed to writing a file or using a native printing API)

o  printerTypeName
return a descriptive name

o  supportsColor
return true if this is a color printer

o  supportsContext
return true if this printer supports a graphicContext (fonts, colors etc.)

o  supportsGrayscale
assume false by default

o  supportsGreyscale
marked as obsolete by exept MBP at 20-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  supportsMargins
return true if this printer supports margin settings (in inches)
if not, it supports at least a leftMargin to be specified in columns.

o  supportsPageSizes
return true if this printer supports different page sizes

o  supportsPostscript
return true if this is a postscript printer

o  supportsPrintingToCommand

o  supportsPrintingToFile


Instance protocol:

emphasis
o  bold
set emphasis to bold
- ignore here, since this class does not know anything about the printer

o  boldItalic
set emphasis to boldItalic
- ignore here, since this class does not know anything about the printer

o  emphasis: anEmphasis
change the emphasis

o  italic
set emphasis to italic
- ignore here, since this class does not know anything about the printer

o  normal
set emphasis to normal (non-bold, non-italic)
- ignore here, since this class does not know anything about the printer

o  strikeout
set emphasis to strikeout
- ignore here, since this class does not know anything about the printer

o  underline
set emphasis to underline
- ignore here, since this class does not know anything about the printer

emphasis change
o  noStrikeout
set emphasis to no strikeout
- ignore here, since this class does not know anything about the printer

o  noUnderline
set emphasis to no underline
- ignore here, since this class does not know anything about the printer

font change
o  courier
set font to courier
- ignore here, since this class does not know anything about the printer

o  helvetica
set font to helvetic
- ignore here, since this class does not know anything about the printer

o  times
set font to times
- ignore here, since this class does not know anything about the printer

helpers writing
o  escape: aCharacter
since its so common, this method sends escape followed by aCharacter

o  escapeAll: aString
since its so common, this method sends escape followed by aString

initialization
o  initialize
(comment from inherited method)
just to ignore initialize to objects which do not need it

o  printCommand

o  printJobName: aString
ignored here - some subclass might implement this

o  stream: aStream

open & close
o  basicClose

o  close
(comment from inherited method)
close the stream - nothing done here.
Added for compatibility with external streams.

o  endPrint

o  setNative

o  setNative: aBoolean

o  startPrint

queries
o  bottomMargin

o  landscape

o  leftMargin

o  lineLength
the printer pages width (in characters)

o  pageFormat
(comment from inherited method)
return the pageFormat - nil here.
This has NO meaning whatsoever to regular streams;
however, it has been added for protocol compatibility with printerStreams

o  printerContext

o  rightMargin

o  supportsColor
return true if this is a color printer

o  supportsContext

o  supportsGrayscale
ask my class (by default)

o  supportsGreyscale
marked as obsolete by exept MBP at 20-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  supportsMargins
return true if this printer supports margin settings (in inches)
if not, it supports at least a leftMargin to be specified in columns.

o  supportsPostscript
return true if this is a postscript printer

o  supportsPrintingToCommand

o  supportsPrintingToFile

o  topMargin

testing
o  isPrinterStream
return true, if this is a printerStream.
Always true here.

writing
o  flush
(comment from inherited method)
write out all buffered data - ignored here, but added
to make internalStreams protocol compatible with externalStreams

o  next: count put: aCharacter
send some character multiple times to the printer - translate as needed.
Redefined to allow individual character translation in subclasses

o  nextPut: aCharacter
send a character to the printer.
Answer aCharacter

o  nextPutAll: aCollection
send some characters to the printer - translate as needed.
The argument, aCollection can be a Text (i.e. include emphasis)

o  nextPutAllText: aText
send some characters to the printer - translate as needed.
The argument is a String or Text (i.e. includes emphasis)

o  nextPutAllUntranslated: aCollection
send some raw characters to the printer - even if not in native mode

o  nextPutUntranslated: aCharacter
send a raw character to the printer - even if not in native mode



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:54:45 GMT