REBOL PostScript Dialect

Version 0.4.7
Updated: 2-Jun-2009
Author: John Niclasen

Contents:

1. Producing PostScript Output
1.1 The postscript Command
2. Producing PDF Output
2.1 The rebps2pdf Command
3. Printing
3.1 Net-printers
3.2 PRN-port
3.3 USB-port
4. Reference Manual
4.1 Rules
4.2 device
4.3 media
4.4 pagesize
4.5 font
4.6 comment
4.7 page
4.8 linewidth
4.9 path
4.10 content
4.11 at
4.12 setcolor
4.13 setgray
4.14 transform
4.15 box
4.16 boxfill
4.17 image
4.18 line
4.19 text
4.20 setcm
4.21 switchy

1. Producing PostScript Output

Try this test:

do http://www.fys.ku.dk/~niclasen/postscript/postscript.r
write %test.ps postscript load
http://www.fys.ku.dk/~niclasen/postscript/test.txt

Now the diskfile %test.ps holds the PostScript output.

1.1 The postscript Command

The postscript command takes a block! as input and gives a string! as output. The output is ISOLatin1 encoded.

2. Producing PDF Output

Try this test:

do http://www.fys.ku.dk/~niclasen/postscript/rebps2pdf.r
write %test.pdf rebps2pdf load
http://www.fys.ku.dk/~niclasen/postscript/test.txt

Now the diskfile %test.pdf holds the PDF output.

2.1 The rebps2pdf Command

The rebps2pdf command works as the postscript command.

3. Printing

To send a PostScript file to a printer, there are several situations:

3.1 Net-printers

Many printers can receive data on port 9100. In REBOL do something like:

write tcp://<ip-number>:9100 <PS-file>

3.2 PRN-port

If the printer is connected to LPT1, it's possible in REBOL to do it this way:

write %//prn <PS-file>

3.3 USB-port

Try this little trick: http://synapsedirect.com/forums/thread/396.aspx

4. Reference Manual

4.1 Rules

The dialect parses a block containing:

any [<device> | <media> | <pagesize> | <font> | <comment>]
some <page>

4.2 device

DeviceRGB

Specifying this word activate colour output.

4.3 media

MediaType <name> | ManualFeed <value> | MediaPosition <value>

4.3.1 MediaType

<name> is Plain, Preprinted or Letterhead specified as a word! or string!. Other values are possible, but those three are especial supported. According to PPD-Adobe 4.3 for HP LaserJet, MediaType can be: Plain, Preprinted, Letterhead, Transparency, Prepunched, Labels, Bond, Recycled, Color and Card Stock.

On the printer, you specify which tray holds which kind of paper.

MediaType is a preferred method over MediaPosition described below, but not all printers might support it.

4.3.2 ManualFeed

<value> is a logic! (true, false, on, off, yes or no). Set this to true to activate manual feeding of paper in the printer.

4.3.3 MediaPosition

<value> is an integer!. Use this to directly select a tray in the printer. According to PPD-Adobe 4.3 for HP LaserJet, MediaPosition is related to Tray in this way:

 Tray 1MediaPosition 3
 Tray 2MediaPosition 0
 Tray 3MediaPosition 1
 Tray 4MediaPosition 4
 Envelope FeederMediaPosition 2

NB! Only use this, if MediaType isn't supported on the printer!

4.4 pagesize

PageSize <name>

<name> can be:

 A4ISO A4, 595x842 dots with 72 dpi
 A5ISO A5, 420x595 dots with 72 dpi
 LetterUS Letter, 612x792 dots with 72 dpi

4.5 font

font into [<name> | <size> | italic | bold]

 nameword! or string! Holds the name of the font (e.g. Courier, Times, Helvetica or Symbol). If name is any of Courier, Times or Helvetica ISOLatin1 encoding is used, else Standard encoding is used.
 sizeinteger! The font-size.
 italicword! Makes text italic.
 boldword! Makes text bold.

It's required to specify a font before output of text.

4.6 comment

comment <any-type>

 any-typeany-type! Often a string, which is seen as a comment and therefore ignored.

4.7 page

opt page into [any [<transform> | <media> | <font> | <linewidth> | <path> | 
<setcm> | <switchy> | <comment>]]

Defines a page. It's optional to specify the word page, but a block is needed. So a page can be seen as a block of page content.

4.8 linewidth

linewidth <size>

 sizenumber! Specify linewidth when drawing.

4.9 path

opt path <content> | into [some <content>]

The word path is optional. A path can be a block of content, or just content without a block.

4.10 content

any [<at> | <linewidth> | <setcolor> | <setgray> | <transform>]
<box> | <boxfill> | <line> | <text>

Content can be any number of the elements on the first line followed by one of the elements on the second line. Often content start with a positioning using <at>.

4.11 at

at <pos>

Specify a position. <pos> can be a pair! or two number!, one for x and one for y coords.

4.12 setcolor

setcolor <col> | setcolour <col>

<col> is a tuple! specifying RGB values.

4.13 setgray

setgray <num> | setgrey <num>

Specify gray level. <num> goes from 0.0 meaning black to 1.0 meaning white.

4.14 transform

rotate <angle> | scale <size> | translate <pos>

Try it!
<angle> is a number!.
<size> and <pos> can be a pair! or two number!.

4.15 box

box <size>

<size> specify the size of the box and can be a pair! or two number!.

4.16 boxfill

boxfill <size>

<size> specify the size of a filled box and can be a pair! or two number!.

4.17 image

image <image>

<image> can be a file!, url! or word!. Use translate and scale together with images to specify position and scaling. To handle color images, also use DeviceRGB.

Example:

translate 100x500
scale 72x72
image logo.gif

4.18 line

line <pos> ...

<pos> can be a pair! or two number!.

4.19 text

string! opt [left [integer! | decimal!] | center [integer! | decimal!] |
right [integer! | decimal!]]

A text string may be followed by alignment (left, center or right followed by an integer! or decimal! to specify the size). Specifying left alignment has no effect (it's default), but it's there for completeness.

It's required to specify a font before output of text.

4.20 setcm

Experimental!

setcm

Change coordinate system from DPI (72 dots per inch) to cm.

4.21 switchy

Experimental!

switchy

Switch y-axis. In PostScript 0x0 is default in lower left. Using switchy puts it in upper left. (Text will be upside down.)


NicomDoc - 2-Jun-2009