Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Mar 1999 09:55:33 +1030
From:      Greg Lehey <grog@lemis.com>
To:        Tony Jones <tony@rtd.com>
Cc:        FreeBSD Questions <questions@FreeBSD.org>
Subject:   Re: Postscript/lpr question
Message-ID:  <19990320095533.I429@lemis.com>
In-Reply-To: <199903191634.JAA14664@seagull.rtd.com>; from Tony Jones on Fri, Mar 19, 1999 at 09:34:31AM -0700
References:  <199903191634.JAA14664@seagull.rtd.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--VywGB/WGlW4DM4P8
Content-Type: text/plain; charset=us-ascii

On Friday, 19 March 1999 at  9:34:31 -0700, Tony Jones wrote:
>>> 1) If the following lines are in the PS file (Windows driver adds them):
>>> 	<esc>%-12345X@PJL JOB
>>> 	@PJL ENTER LANGUAGE = POSTSCRIPT
>>>> !PS-Adobe-3.0
>>> 	...
>>>>> EOF
>>> 	<esc>%-12345X@PJL EOJ
>>> 	<esc>%-12345X
>>>
>>>    Then the printing works perfectly if I 'cat file.ps > /dev/lpt0'
>>>    If I use lpr, I get a blank trailing page each time.
>>
>> OK.  If necessary, you can get printcap to do that for you.
>
> Realise this. Would have to be somewhat smart, to detect if they were
> already there (Windows via Samba), or it would probably be easier
> to create two queues, one that added and the other that didn't.

Not really.  See below for an easier solution.

>> What happens for two page documents?  Do they both come out, or just
>> the first one?
>
> Multipage documents come out fine, no trailing blank page, no flashing LED.
>
> Whether you get the flashing LED or not, depends on if you cat or lpr and/or
> the Postscript itself.

This is what you need to investigate in more detail.

>> I'm attaching a PostScript document that prints just fine on my HP
>> LaserJet 6MP.  Try it and see whether you can print it.  If so, you
>
> Great, the 6MP is basically the same as the 2100M.

I think you'll find interface differences.  I have had no such trouble
with the 6MP.

> However, you didn't attach any PS file :-)

Ugh.  It's there this time.

> I did read the handbook entries, I have the stairstepping on pure
> text problem (LF/CR issue) and the parts about the formfeeds/LED
> staying lit, but none seemed to exactly fit what i was seeing, plus
> I tried all the suggested solutions and they didn't help.

There's a section in the handbook entitled "Simulating PostScript on
Non-PostScript printers".  It includes a script for recognizing
PostScript; you can modify this to add the PCL commands if they're not
there already.

Greg
--
When replying to this message, please copy the original recipients.
For more information, see http://www.lemis.com/questions.html
See complete headers for address, home page and phone numbers
finger grog@lemis.com for PGP public key

--VywGB/WGlW4DM4P8
Content-Type: application/postscript
Content-Disposition: attachment; filename="bar.ps"

%!PS-Adobe-3.0
%%Title: foo
%%For: Greg Lehey,Echunga SA,+61-8-8388-8286,+61-8-8388-8250
%%Creator: a2ps version 4.9.7
%%CreationDate: Fri Mar 19 16:57:01 1999
%%BoundingBox: 24 24 571 818
%%DocumentData: Clean7Bit
%%Orientation: Landscape
%%Pages: 1
%%PageOrder: Ascend
%%DocumentMedia: A4 595 842 0 () ()
%%DocumentNeededResources: font Symbol
%%+ font Courier
%%+ font Courier-Oblique
%%+ font Courier-Bold
%%+ font Courier-BoldOblique
%%+ font Times-Roman
%%DocumentProcessColors: Black 
%%DocumentSuppliedResources: procset a2ps-black+white-Prolog 2.0 1
%%EndComments
/a2psdict 200 dict def
a2psdict begin
%%BeginProlog
%%BeginResource: procset a2ps-black+white-Prolog 2.0 1
%%Copyright (c) 1988, 89, 90, 91, 92, 93 Miguel Santana
%%Copyright (c) 1995, 96, 97 Akim Demaille, Miguel Santana
% Check PostScript language level.
/languagelevel where {
  pop /gs_languagelevel languagelevel def
} {
  /gs_languagelevel 1 def
} ifelse

% Page prefeed
/page_prefeed {         % bool -> -
  statusdict /prefeed known {
    statusdict exch /prefeed exch put
  } {
    pop
  } ifelse
} bind def

/deffont {
  findfont exch scalefont def
} bind def

/reencode_font {
  findfont exch scalefont reencode 2 copy definefont pop def
} bind def

% Function c-show (str => -)
% centers text only according to x axis.
/c-show { 
  dup stringwidth pop
  2 div neg 0 rmoveto
  show
} bind def

% Function l-show (str => -)
% prints texts so that it ends at currentpoint
/l-show {
  dup stringwidth pop neg 
  0 
  rmoveto show
} bind def

% center-fit show (str w => -)
% show centered, and scale currentfont so that the width is less than w
/cfshow {
  exch dup stringwidth pop
  % If the title is too big, try to make it smaller
  3 2 roll 2 copy
  gt
  { % if, i.e. too big
    exch div
    currentfont exch scalefont setfont
  } { % ifelse
    pop pop 
  }
  ifelse
  c-show			% center title
} bind def


% reencode the font
% <encoding-vector> <fontdict> -> <newfontdict>
/reencode { %def
  dup length 5 add dict begin
    { %forall
      1 index /FID ne 
      { def }{ pop pop } ifelse
    } forall
    /Encoding exch def

    % Use the font's bounding box to determine the ascent, descent,
    % and overall height; don't forget that these values have to be
    % transformed using the font's matrix.
    FontBBox
    FontMatrix transform /Ascent exch def pop
    FontMatrix transform /Descent exch def pop
    /FontHeight Ascent Descent sub def

    % Define these in case they're not in the FontInfo (also, here
    % they're easier to get to.
    /UnderlinePosition 1 def
    /UnderlineThickness 1 def
    
    % Get the underline position and thickness if they're defined.
    currentdict /FontInfo known {
      FontInfo
      
      dup /UnderlinePosition known {
	dup /UnderlinePosition get
	0 exch FontMatrix transform exch pop
	/UnderlinePosition exch def
      } if
      
      dup /UnderlineThickness known {
	/UnderlineThickness get
	0 exch FontMatrix transform exch pop
	/UnderlineThickness exch def
      } if
      
    } if
    currentdict 
  end 
} bind def

% Function title: prints page header.
% <ct> <rt> <lt> are passed as argument
/title { 
  % 1. Draw the background
  x v get y v get moveto
  gsave
    0 th 2 div neg rmoveto 
    th setlinewidth
    0.95 setgray
    pw 0 rlineto stroke
  grestore
  % 2. Border it
  gsave
    0.7 setlinewidth
    pw 0 rlineto
    0 th neg rlineto
    pw neg 0 rlineto
    closepath stroke
  grestore
  % stk: ct rt lt
  x v get y v get th sub 1 add moveto
  df setfont
  % 3. The left title
  gsave
    dup stringwidth pop dfs add exch % leave space took on stack
    dfs hm rmoveto
    show			% left title
  grestore
  exch
  % stk: ct ltw rt
  % 4. the right title
  gsave
    dup stringwidth pop dfs add exch % leave space took on stack
    dup
    pw exch stringwidth pop dfs add sub
    hm
    rmoveto
    show			% right title
  grestore
  % stk: ct ltw rtw
  % 5. the center title
  gsave
    pw 3 1 roll
    % stk: ct pw ltw rtw
    3 copy 
    % Move to the center of the left room
    sub add 2 div hm rmoveto
    % What is the available space in here?
    add sub dfs sub dfs sub
    % stk: ct space_left
    fnf setfont
    cfshow
  grestore
} bind def

% Function border: prints virtual page border
/border { %def
  gsave				% print four sides
    0 setgray
    x v get y v get moveto
    0.7 setlinewidth		% of the square
    pw 0 rlineto
    0 ph neg rlineto
    pw neg 0 rlineto
    closepath stroke
  grestore
} bind def

% Function water: prints a water mark in background
/water { %def
  gsave
    scx scy moveto rotate
    wf setfont
    .97 setgray
    dup stringwidth pop 2 div neg -50 rmoveto
    show
  grestore
} bind def

% Function rhead: prints the right header
/rhead {  %def
  lx ly moveto
  df setfont
  l-show
} bind def

% Function footer (cf rf lf -> -)
/footer {
  df setfont
  dx dy moveto
  show

  snx sny moveto
  l-show
  
  fnx fny moveto
  c-show
} bind def

% Function print line number (<string> # -)
/# {
  gsave
    sx cw mul neg 2 div 0 rmoveto
    f# setfont
    c-show
  grestore
} bind def

% -------- Some routines to enlight plain b/w printings ---------

% Underline
% width --
/dounderline {
  currentpoint
  gsave
    moveto
    0 currentfont /Descent get rmoveto
    0 rlineto
    stroke
  grestore
} bind def

% Underline a string
% string --
/dounderlinestring {
  stringwidth pop
  dounderline
} bind def

/UL {
  /ul exch store
} bind def

% Draw a box of WIDTH wrt current font
% width --
/dobox {
  currentpoint
  gsave
    newpath
    moveto
    0 currentfont /Descent get rmoveto
    dup 0 rlineto
    0 currentfont /FontHeight get rlineto
    neg 0 rlineto
    closepath
    stroke
  grestore
} bind def

/BX {
  /bx exch store
} bind def

% Box a string
% string --
/doboxstring {
  stringwidth pop
  dobox
} bind def

%
% ------------- Color routines ---------------
%
/FG /setrgbcolor load def

% Draw the background
% width --
/dobackground {
  currentpoint
  gsave
    newpath
    moveto
    0 currentfont /Descent get rmoveto
    dup 0 rlineto
    0 currentfont /FontHeight get rlineto
    neg 0 rlineto
    closepath
    bgcolor aload pop setrgbcolor
    fill
  grestore
} bind def

% Draw bg for a string
% string --
/dobackgroundstring {
  stringwidth pop
  dobackground
} bind def


/BG {
  dup /bg exch store
  { mark 4 1 roll ] /bgcolor exch store } if
} bind def


/Show {
  bg { dup dobackgroundstring } if
  ul { dup dounderlinestring } if
  bx { dup doboxstring } if
  show
} bind def

% Function T(ab), jumps to the n-th tabulation in the current line
/T {
  cw mul x0 add
  bg { dup currentpoint pop sub dobackground } if
  ul { dup currentpoint pop sub dounderline } if
  bx { dup currentpoint pop sub dobox } if
  y0 moveto
} bind def

% Function n: move to the next line
/n {
  /y0 y0 bfs sub store
  x0 y0 moveto
} bind def

% Function N: show and move to the next line
/N {
  Show
  /y0 y0 bfs sub store
  x0 y0 moveto
} bind def

/S {
  Show
} bind def

% Function T(ab), jumps to the n-th tabulation in the current line
/T { 
  cw mul x0 add y0 moveto
} bind def

% Function n: move to the next line
/n { %def
  /y0 y0 bfs sub store
  x0 y0 moveto
} bind def

% Function N: show and move to the next line
/N {
  Show
  /y0 y0 bfs sub store
  x0 y0 moveto
}  bind def

/S {
  Show
} bind def

/p {
  false UL
  false BX
   fc setfont
  Show
} bind def

/sy {
  false UL
  false BX
   fs setfont
  Show
} bind def

/k {
  false UL
  false BX
   fci setfont
  Show
} bind def

/K {
  false UL
  false BX
   fcb setfont
  Show
} bind def

/c {
  false UL
  false BX
   fci setfont
  Show
} bind def

/C {
  false UL
  false BX
   fce setfont
  Show 
} bind def

/l {
  false UL
  false BX
   fci setfont
  Show
} bind def

/L {
  false UL
  false BX
   fce setfont
  Show 
} bind def

/str{
  false UL
  false BX
   ft setfont
  Show
} bind def

%%EndResource
% ISOLatin1Encoding is already defined in the interpreter
%%IncludeResource: font Courier
%%IncludeResource: font Courier-Oblique
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Courier-BoldOblique
%%IncludeResource: font Times-Roman
%%EndProlog
%%BeginSetup
% Initialize page description variables.
/sh 595 def
/sw 842 def
/llx 24 def
/urx 818 def
/ury 571 def
/lly 24 def
/#copies 1 def
/th 15.000000 def
/fnfs 11 def
/dfs 8.800000 def
/bfs 8.005733 def
/cw 4.803440 def

/bgcolor [ 0 0 0 ] def
/bg false def
/ul false def
/bx false def
% The font for line numbering
/f# /Helvetica findfont bfs .6 mul scalefont def
% Dictionary for ISOLatin1Encoding support
/latin1dict 15 dict begin
  /fc  ISOLatin1Encoding bfs /Courier reencode_font
  /fcb ISOLatin1Encoding bfs /Courier-Bold reencode_font
  /fci ISOLatin1Encoding bfs /Courier-Oblique reencode_font
  /fce ISOLatin1Encoding bfs /Courier-BoldOblique reencode_font
  /ft  ISOLatin1Encoding bfs /Times-Roman reencode_font
  /df ISOLatin1Encoding dfs /Helvetica reencode_font
  /fnf ISOLatin1Encoding fnfs /Helvetica-Bold reencode_font
  /wf ISOLatin1Encoding 100 /Times-Bold reencode_font
currentdict end def
/fs bfs /Symbol		deffont
/hm fnfs 0.25 mul def
/pw
   cw 81.400000 mul
def
/ph
   501.959430 th add
def
/pmw urx llx sub pw 2 mul sub 1 div def
/pmh 0 def
/v 0 def
/x [
  0
  dup pmw add pw add
] def
/y [
  pmh ph add 0 mul ph add
  dup
] def
/scx sw 2 div def
/scy sh 2 div def
/snx urx def
/sny lly 2 add def
/dx llx def
/dy sny def
/fnx scx def
/fny dy def
/lx snx def
/ly ury dfs sub def
/sx 0 def
/tab 8 def
/x0 0 def
/y0 0 def
%%EndSetup

%%Page: (1) 1
%%BeginPageSetup
/pagesave save def
%%EndPageSetup
sh 0 translate
90 rotate
% Encoding is ISO8859-1
latin1dict begin
gsave
llx lly 12 add translate
/v 0 store
/x0 x v get 3.362408 add sx cw mul add store
/y0 y v get bfs th add sub store
x0 y0 moveto
(From owner-freebsd-questions@FreeBSD.ORG Fri Mar 19 15:56:35 1999) p n
(Received: from sarip.sol.net \(mail@sarip.sol.net [169.207.30.120]\)) N
() S 8 T (by allegro.lemis.com \(8.9.1/8.9.0\) with ESMTP id PAA00357) N
() S 8 T (for <grog@lemis.com>; Fri, 19 Mar 1999 15:56:32 +1030 \(CST\)) N
(Received: from hub.freebsd.org \(hub.FreeBSD.ORG [204.216.27.18]\)) N
() S 8 T (by sarip.sol.net \(8.8.8/8.8.8/SNNS-1.02\) with ESMTP id XAA22480;) N
() S 8 T (Thu, 18 Mar 1999 23:18:49 -0600 \(CST\)) N
(Received: by hub.freebsd.org \(Postfix, from userid 538\)) N
() S 8 T (id E1A7C15239; Thu, 18 Mar 1999 20:39:49 -0800 \(PST\)) N
(Received: from localhost \(localhost [127.0.0.1]\)) N
() S 8 T (by hub.freebsd.org \(Postfix\) with SMTP) N
() S 8 T (id C11921CD5E9; Thu, 18 Mar 1999 20:39:49 -0800 \(PST\)) N
() S 8 T (\(envelope-from owner-freebsd-questions\)) N
(Received: by hub.freebsd.org \(bulk_mailer v1.12\); Thu, 18 Mar 1999 20:39:49 -080) N
(0) N
(Delivered-To: freebsd-questions@freebsd.org) N
(Received: from zebedee.local \(fdsl228.ptld.uswest.net [216.161.80.228]\)) N
() S 8 T (by hub.freebsd.org \(Postfix\) with ESMTP id 2FECA153EC) N
() S 8 T (for <questions@freebsd.org>; Thu, 18 Mar 1999 20:39:29 -0800 \(PST\)) N
() S 8 T (\(envelope-from tony@rtd.com\)) N
(Received: from zebedee.local \(localhost.local [127.0.0.1]\)) N
() S 8 T (by zebedee.local \(8.8.8/8.8.6\) with ESMTP id UAA06359;) N
() S 8 T (Thu, 18 Mar 1999 20:38:13 -0800 \(PST\)) N
(Message-Id: <199903190438.UAA06359@zebedee.local>) N
(X-Mailer: exmh version 2.0zeta 7/24/97) N
(To: questions@FreeBSD.ORG) N
(Cc: tony@rtd.com) N
(X-Face: ZQe?G+$UQG8,i~KL=gy`<?o:\(AZ:6dZbMH]/`C`lsbcBIGcmQmyeWhF\\q&E%Hh6PK8oqhi5) N
( [t#-kli@aa1Pgm^I?qc??t?kjf_&GZz2UXh\\Yy8NtB\(k!w\(usJ"|.N.!C>T:c1bxG<{7ta&{,'$LiA) N
( !`"u>-"@wkx>yf.z_5<N=AaH{P&FrCwwm94G,Ym'NTF"H"{weMX4~wh) N
(Subject: Postscript/lpr question) N
(Mime-Version: 1.0) N
(Content-Type: text/plain; charset=us-ascii) N
(Date: Thu, 18 Mar 1999 20:38:08 -0800) N
(From: Tony Jones <tony@rtd.com>) N
(Sender: owner-freebsd-questions@FreeBSD.ORG) N
(X-Loop: FreeBSD.ORG) N
(Precedence: bulk) N
(Status: RO) N
(Content-Length: 2048) N
(Lines: 64) N
() N
() N
(I recently purchased a HP2100M Postscript laser printer and am having) N
(some printing problems.) N
() N
(Have it connected to my FreeBSD parallel port using the) N
(following printcap entry:) N
() N
(lp|local line printer:\\) N
(        :sh:\\) N
(        :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:) N
() N
(I also access the printer from Windows \(NT and 98\) using Samba.) N
() N
(>>> When printing documents from NT, I get a blank page emitted after) N
(    the last real page.) N
() N
(>>> Usually from Unix the activity light will remain flashing after the ) N
(    job has printed, indicating data in the buffer. Eventually it times out, ) N
(    no trailing blank page is printed.) N
() N
(foo) (Page 1/2) (Mar 19, 99 16:56) title
border
/v 1 store
/x0 x v get 3.362408 add sx cw mul add store
/y0 y v get bfs th add sub store
x0 y0 moveto
() p n
(I moved the PS files over to Unix, to isolate NT from the picture) N
(and noticed the following results.) N
() N
(1\) If the following lines are in the PS file \(Windows driver adds them\):) N
() S 8 T (<esc>%-12345X@PJL JOB) N
() S 8 T (@PJL ENTER LANGUAGE = POSTSCRIPT) N
() S 8 T (%!PS-Adobe-3.0) N
() S 8 T (...) N
() S 8 T (%%EOF) N
() S 8 T (<esc>%-12345X@PJL EOJ) N
() S 8 T (<esc>%-12345X) N
() N
(   Then the printing works perfectly if I 'cat file.ps > /dev/lpt0') N
(   If I use lpr, I get a blank trailing page each time.) N
() N
(   Adding a 'sf' \(supress formfeeds\) to the printcap cures the problem) N
(   \(for lpr\) except that for single page documents, nothing is printed, ) N
(   just the same flashing activity LED until timeout.) N
() N
(2\) If I remove the PJL/escape lines before the %!PS and after the %%EOF, ) N
(   then I get the flashing activity light until timeout using either) N
(   the direct 'cat > /dev/lpt0' or lpr. No blank page.) N
() N
(   I read the Handbook entry about formfeeds, tried ) N
() S 8 T ('\(cat file.ps ; printf "\\f"\) > /dev/lpt0) N
(   but it made no difference, still the activity light stays lit) N
(   until the timeout.) N
() N
(The printer's physical controls are limited to one 'cancel' button,) N
(and the documentation is limited to NT/Mac, no mention of Unix.) N
() N
(Does anyone have any ideas ? Please CC: me directly. I must have) N
(wasted 100 sheets of paper trying to figure out what exactly is) N
(going on.) N
() N
(Thanks) N
() N
(Tony) N
() N
() N
() N
(To Unsubscribe: send mail to majordomo@FreeBSD.org) N
(with "unsubscribe freebsd-questions" in the body of the message) N
() N
(foo) (Page 2/2) (Mar 19, 99 16:56) title
border
% End of virtual page
grestore
(Printed by Greg Lehey) rhead
(/tmp/foo) (1/1) (Friday March 19, 99) footer
end % of latin1dict
pagesave restore
showpage

%%Trailer
end
%%EOF

--VywGB/WGlW4DM4P8--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990320095533.I429>