[gs-devel] Printer alignment in CUPS?

Ken Sharp ken.sharp at artifex.com
Sat Feb 7 02:19:50 PST 2009


At 21:04 06/02/2009 -0500, Tom Horsley wrote:


>Can anyone point me to some information on exactly what
>those mysterious settings actually do? If not, I guess
>I'll start poking them with a stick and measuring what
>happens to the printed results :-).

You can find information on the Margins page device parameter in the 
PostScript Language Reference Manual which is available (somewhere) on the 
Adobe web site. The relevant section (p420 of the 3rd edition) says:

Margins     array       An array of two numbers, [x y], that reposition the 
page image on the physical medium by x units horizontally and y units 
vertically, in the direction of increasing coordinate values in the device 
coordinate system. x and y are ex-pressed in device-specific units usually 
units of device space at one of the supported resolutions. The purpose of 
this parameter is to compensate for mechanical misalignments in the device, 
not to perform purposeful positioning of the page image itself. It differs 
from PageOffset (above) in that the re-positioning is typically 
accomplished by device-dependent means that are independent of the graphics 
state (in particular, of the current transformation matrix). The range and 
precision of the parameter values may be restricted by the physical 
implementation.

HWMargins is defined in the Adobe Tech Note 5003 of which I only seem to 
have version 4.3 from 1996 (there may be a more recent version). Again this 
ought to be available from the Adobe web site. The section on p113 says:

*HWMargins:     left bottom right top

This keyword describes how much space around the outer edge of the page 
cannot be imaged because of hardware restrictions. A print manager can use 
this information to calculate the imageable area and tell a user when the 
entire requested custom page size cannot be printed upon, or to show the 
user which part of the page can be imaged. For non-custom page sizes, the 
key-word *ImageableArea provides the same information (in the form of 
imageable area, rather than non-imageable area) for each supported page 
size. See Responsibilities of a Print Manager Regarding Custom Page Sizes 
at the end of this section for a description of how the print manager can 
use *HWMargins. The StringValue of this keyword is composed of multiple 
components, separated by white space. The components are real numbers of 
PostScript default units, and are defined in default user space as 
follows:top = distance, in PostScript default units, from the top edge of 
the page to the nearest beginning of imageable area. The top edge is the 
edge of the page that enters the printer first (the leading edge in the 
direction of media feed).right, left, and bottom are similarly defined, as 
shown in Figure 4. This is a top view; you are looking down at the paper 
going into the device.



Now, a PPD file describes the capabilities of a device to a 
PostScript-producing application, so the interpreter will ignore HWMargins 
(its not part of PostScript). The HWMargins parameter in the PPD file is 
used by the PostScript producer to set a Margins entry in the dictionary 
argument to setpagedevice. The interpreter should honour the Margins values 
when rendering.

Ordinarily the application would select a page size, then set up the 
margins, and would adjust the PostScript it produces so that it fits into 
the area defined by (media size - margins).

CUPS should use the PPD file /HWMargins value to set the /Margins values 
being sent to Ghostscript, assuming that Ghostscript is consuming 
PostScript and producing an image, which is then sent to the printer.

You may also find this document useful :

http://www.cups.org/documentation.php/ref-ppdcfile.html


Hope that helps,


                                 Ken



More information about the gs-devel mailing list