[comp.lang.postscript] How do I determine a printer's imaging area?

fsset@bach.lerc.nasa.gov (Scott E. Townsend) (02/09/91)

I have a question, somewhat similar to one which I've seen recently in this
group.  I want to know the imaging area of whatever printer my code gets
executed on.  The reason is that I have a viewgraph package running on a
Silicon Graphics Iris in which I want the ability to save drawings in
Postscript format.  Through some trial and error I have code which takes
a full Iris screen and prints it on a 'full' 8.5"x11" page on Apple & Sparc
printers.  Attempting this on a QMS color printer caused problems due to
the QMS printer's smaller imaging area.

So, given an Iris imaging space of (say) 1280x1024, how can I portably
determine the correct transform to fill an arbitrary printer's page.
(or at least a large class of printers) ?

Any suggestions (including pointers to the correct manual) would be
appreciated.  I'm just beginning to learn Postscript, so please be patient
and basic with your explanations.  Thanks.

Scott

--
------------------------------------------------------------------------
Scott Townsend               |   Phone: 216-433-8101
NASA Lewis Research Center   |   Mail Stop: 5-11
Cleveland, Ohio  44135       |   Email: fsset@bach.lerc.nasa.gov
------------------------------------------------------------------------

sun@me.utoronto.ca (Andy Sun Anu-guest) (02/09/91)

fsset@bach.lerc.nasa.gov (Scott E. Townsend) writes:


>I have a question, somewhat similar to one which I've seen recently in this
>group.  I want to know the imaging area of whatever printer my code gets
>executed on.  The reason is that I have a viewgraph package running on a
>Silicon Graphics Iris in which I want the ability to save drawings in
>Postscript format.  Through some trial and error I have code which takes
>a full Iris screen and prints it on a 'full' 8.5"x11" page on Apple & Sparc
>printers.  Attempting this on a QMS color printer caused problems due to
>the QMS printer's smaller imaging area.

How about a brute-force method: blasting a 8.5"x11" black/grey rectangle by
sending the following code:

%!
0 setgray
newpath 0 0 moveto 0 792 lineto 612 792 lineto 612 0 lineto closepath fill
showpage

to the laser printer and then measure off the white margins using a ruler?

BTW, I think most printer manuals provide specifications on imageable areas.
Check your printer manual on this.

Andy

_______________________________________________________________________________
Andy Sun                            | Internet: sun@me.utoronto.ca
University of Toronto, Canada       | UUCP    : ...!utai!me!sun
Dept. of Mechanical Engineering     | BITNET  : sun@me.utoronto.BITNET

rberlin@birdland@Eng.Sun.COM (Rich Berlin) (02/09/91)

In article <1991Feb8.174934.5816@eagle.lerc.nasa.gov>, fsset@bach.lerc.nasa.gov (Scott E. Townsend) writes:
|> 
|> I have a question, somewhat similar to one which I've seen recently in this
|> group.  I want to know the imaging area of whatever printer my code gets
|> executed on.  The reason is that I have a viewgraph package running on a
|> Silicon Graphics Iris in which I want the ability to save drawings in
|> Postscript format.  Through some trial and error I have code which takes
|> a full Iris screen and prints it on a 'full' 8.5"x11" page on Apple & Sparc
|> printers.  Attempting this on a QMS color printer caused problems due to
|> the QMS printer's smaller imaging area.
|> 
|> So, given an Iris imaging space of (say) 1280x1024, how can I portably
|> determine the correct transform to fill an arbitrary printer's page.
|> (or at least a large class of printers) ?
|> 
|> Any suggestions (including pointers to the correct manual) would be
|> appreciated.  I'm just beginning to learn Postscript, so please be patient
|> and basic with your explanations.  Thanks.
|> 
|> Scott
|> 
|> --
|> ------------------------------------------------------------------------
|> Scott Townsend               |   Phone: 216-433-8101
|> NASA Lewis Research Center   |   Mail Stop: 5-11
|> Cleveland, Ohio  44135       |   Email: fsset@bach.lerc.nasa.gov
|> ------------------------------------------------------------------------

Getting the printer's imageable area is fairly simple.

    gsave initclip clippath pathbbox grestore

should leave four numbers (llx lly urx ury) on the stack which
describe the imageable area in current user units.  If you know the
bounding box of your image, you can use these numbers to determine the
largest scale that will work on your printer.

Hope that helps.

-- Rich

choma@scotty.dccs.upenn.edu (Peter Choma) (02/11/91)

    One area of PostScript incompatibility is the imageable region. For example,
the Apple LaserWriter has top and bottom margins of 0.04 while the NEC LC890
PostScript printer has top and bottom margins arround 0.22 inches.

    If you assume a value of 0.25 inches for each margin (top, bottom, left, 
and right) and a letter paper size of 8.5 by 11.0 inches, you should be able
to print on most PostScript printers without having to ask the printer for
its imaging area - ie. Scale your image to be 8.0 by 10.50 inches centered 
within a 8.5 by 11.0 inch region.

    This way you will not have to worry about having a bi-directional
communications channel to your PostScript printer and you will make life
much easier for anyone who gets your PostScript output and tries to print
it on some other manufacturer's PostScript printer.

toms@fcs260c2.ncifcrf.gov (Tom Schneider) (02/12/91)

In article <7723@exodus.Eng.Sun.COM> rberlin@Eng.Sun.COM writes:

>Getting the printer's imageable area is fairly simple.
>
>    gsave initclip clippath pathbbox grestore
>
>should leave four numbers (llx lly urx ury) on the stack which
>describe the imageable area in current user units.  If you know the
>bounding box of your image, you can use these numbers to determine the
>largest scale that will work on your printer.

Since I just made it and it works, here is a complete PostScript program
to print out these numbers:

%! this is a PostScript program
erasepage
/Times-Roman findfont 30 scalefont setfont
/down {0 -100 rmoveto} def
/print {gsave show 10 string cvs show grestore down} def
gsave initclip clippath pathbbox grestore
144 432 moveto
(printer imageable area:) gsave show grestore down
(llx: ) print
(lly: ) print
(urx: ) print
(ury: ) print
showpage

>-- Rich

  Tom Schneider
  National Cancer Institute
  Laboratory of Mathematical Biology
  Frederick, Maryland  21702-1201
  toms@ncifcrf.gov

woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (02/12/91)

In article <1991Feb8.174934.5816@eagle.lerc.nasa.gov>, fsset@bach.lerc.nasa.gov (Scott E. Townsend) writes:
> 
> I have a question, somewhat similar to one which I've seen recently in this
> group.  I want to know the imaging area of whatever printer my code gets
> Any suggestions (including pointers to the correct manual) would be
> appreciated.  I'm just beginning to learn Postscript, so please be patient
> and basic with your explanations.  Thanks.

The Red Book states about the  clippath  operator
"sets the current path to one that describes the current clipping path.  This
operator is useful for determinig the exact extent of the imaging area on the
current output device...

Cheers
Woody


> 

toms@fcs260c2.ncifcrf.gov (Tom Schneider) (02/13/91)

In my previous posting I gave an incorrect program!!  Oops.  Here is
a corrected version (at least I HOPE so) with some more bells and
whistles that help figure things out:

%! this is a PostScript program
% printerarea.ps
% 1991 February 12
% This program determines the printable area of a printer
% and prints the coordinates out in readable form.
% In addition, it draws a rectangle around the area,
% then it makes a series of shrinking rectangles to help
% visualize where the boundary is.  Finally, the corners
% of all these rectangles are connected to a single
% point on the image, to make it clear what is going on.
%   Tom Schneider
%   National Cancer Institute
%   Laboratory of Mathematical Biology
%   Frederick, Maryland  21702-1201
%   toms@ncifcrf.gov
erasepage
/Times-Roman findfont 30 scalefont setfont
/down {0 -50 rmoveto} def
/print {gsave show 10 string cvs show grestore down} def

% obtain the imagable area of the printer using initclip
gsave initclip clippath pathbbox grestore
%pstack % use this if you want to see the stack
        % while running the program

% capture the corners of the imagable area
% (see pathbbox in the red book)
/ury exch def
/urx exch def
/lly exch def
/llx exch def

% use the following if you want to see the values
% llx lly urx ury
% pstack  % this stack should match the first one
% clear

150 450 moveto
(printer imageable area:) gsave show grestore down

% print the values
llx ( lower left x [llx]: ) print
lly ( lower left y [lly]: ) print
urx (upper right x [urx]: ) print
ury (upper right y [ury]: ) print

/tospot { % draw a line to a special spot
% to help keep track of what's happening
gsave currentpoint moveto 100 400 lineto stroke grestore
} def

/roundstroke{
% draw a box around the area
llx lly moveto
tospot
urx lly lineto
tospot
urx ury lineto
tospot
llx ury lineto
tospot
llx lly lineto
tospot
stroke
} def

/shift 20 def % amount to decrease the area each time

/shiftinward {
% reduction of the area by the amount shift
/ury ury shift sub def
/urx urx shift sub def
/lly lly shift add def
/llx llx shift add def
} def

% draw a series of decreasing boxes to help figure
% things out
roundstroke
shiftinward

roundstroke
shiftinward

roundstroke
shiftinward

roundstroke
shiftinward

roundstroke

showpage

clewis@ferret.ocunix.on.ca (Chris Lewis) (02/13/91)

In article <37288@netnews.upenn.edu> choma@scotty.dccs.upenn.edu (Peter Choma) writes:

>    One area of PostScript incompatibility is the imageable region. For example,
>the Apple LaserWriter has top and bottom margins of 0.04 while the NEC LC890
>PostScript printer has top and bottom margins arround 0.22 inches.

>    If you assume a value of 0.25 inches for each margin (top, bottom, left, 
>and right) and a letter paper size of 8.5 by 11.0 inches, you should be able
>to print on most PostScript printers without having to ask the printer for
>its imaging area - ie. Scale your image to be 8.0 by 10.50 inches centered 
>within a 8.5 by 11.0 inch region.

I took a different approach with psroff (CAT Troff to postscript/lj converter).
I don't force a .25 inch margin OR scale 11 inches into 10.5.  After a great
deal of thought (and some reports from elsewhere) I came to the conclusion that:
	a) it's rude to scale the output of troff because oft-times the
	   troff actually has absolute measurements, and one would want
	   them to come out accurately.  So that people could use
	   a ruler to determine the commands to issue (I'm taking "Scale
	   your image" literally)  (This was very important to me because
	   I was doing some "real" publishing)
	b) an explicit .25" horizontal shift doesn't always do the trick.
Psroff has several options to shift the image vertically or horizontally to
fit in with specific printers, but none of these are hardwired into the
converter itself.  Fortunately, none of the troff macro sets I've seen plant
anything too high or too low.  Most CAT troff macro sets have a ~.5i right
shift to begin with, and I add another offset (default .5i) to permit
proper page centering.  It all works pretty good.

When you're drawing an image manually, on the other hand, it's more
useful to assume a (0,0) origin and possibly even a (1.0,1.0) upper right
corner, then scaling/translating to fit is a lot easier.
-- 
Chris Lewis, Phone: (613) 832-0541, Internet: clewis@ferret.ocunix.on.ca
UUCP: uunet!mitel!cunews!latour!ecicrl!clewis; Ferret Mailing List:
(ferret-request@eci386); Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386, current patchlevel is *7*.

lpw@lance.esd.sgi.com (Lance Welsh) (02/13/91)

In article rberlin@birdland@Eng.Sun.COM (Rich Berlin) writes:

>     gsave initclip clippath pathbbox grestore

Just a note for Display PostScript users - use view clips:

      gsave initviewclip viewclippath pathbbox grestore

-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
Lance P. Welsh		Silicon Graphics, Inc.
lpw@sgi.com		PO Box 7311
wk: (415) 335-1860	2011 North Shoreline Blvd.
hm: (415) 326-3870	Mountain View, CA  94039-7311
-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-