Java Reference
In-Depth Information
++ lineNum ;
return
return ;
}
moveTo ( leftMargin + ( tabPos * INCH ),
topMargin -( lineNum ++ * leading ));
System . out . println ( '(' + toPSString ( l )+ ") show" );
// If we just hit the bottom, start a new page
iif ( curY <= botMargin )
startPage ();
}
/** Overly simplistic conversion to PS, e.g., breaks on "foo\)bar" */
protected
protected String toPSString ( String o ) {
StringBuilder sb = new
new StringBuilder ();
for
for ( int
int i = 0 ; i < o . length (); i ++) {
char
char c = o . charAt ( i );
switch
switch ( c ) {
case
case '(' :
sb . append ( "\\(" ); break
break ;
case
case ')' :
sb . append ( "\\)" ); break
break ;
default
default :
sb . append ( c ); break
break ;
}
}
return
return sb . toString ();
}
protected
protected void
void moveTo ( int
int x , int
int y ) {
curX = x ;
curY = y ;
System . out . println ( x + " " + y + " " + "moveto" );
}
void
void prologue () {
System . out . println ( "%!PS-Adobe" );
System . out . println ( "/Courier findfont " + points + " scalefont setfont " );
}
}
The program could certainly be generalized more, and certain features (such as wrapping
long lines) could be handled. I could also wade into the debate among PostScript experts as
to how much of the formatting should be done on the main computer and how much should
be done by the PostScript program interpreter running in the printer. But perhaps I won't get
into that discussion. At least, not today.
Search WWH ::




Custom Search