1
0

align.ps 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. % Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: align.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  16. % Print a page that indicates the proper settings of Margins and HWMargins
  17. % for a given device. Requires a Level 2 system.
  18. % Reset the offset and margins.
  19. <<
  20. /PageOffset [0 0]
  21. /Margins [0 0]
  22. /.HWMargins [0 0 0 0]
  23. >>
  24. setpagedevice
  25. <<
  26. /ImagingBBox null
  27. >>
  28. setpagedevice
  29. % Determine the actual page size.
  30. clippath pathbbox newpath
  31. /y1 exch def /x1 exch def pop pop
  32. % Draw lines that should be exactly 1" in from each edge,
  33. % and should extend precisely to the edge of the paper.
  34. 1 setlinewidth
  35. 0 setgray
  36. 72 0 moveto 0 y1 rlineto stroke
  37. 0 72 moveto x1 0 rlineto stroke
  38. % Print the text in the middle of the page.
  39. /S 80 string def
  40. 108 480 moveto
  41. /Helvetica 12 selectfont
  42. { currentfile S readline pop dup (%END) eq { pop exit } if
  43. gsave show grestore 0 -15 rmoveto
  44. } loop
  45. Let the distance in inches from the left edge of the page to
  46. the vertical line be H, and from the bottom edge to the
  47. horizontal line be V; let the lengths of the gaps at the top
  48. and bottom of the vertical line be T and B respectively, and
  49. the gaps at the left and right of the horizontal line be L
  50. and R. For correct alignment of pages, put the following line
  51. in a file named (for example) margins.ps, and then mention
  52. margins.ps on the gs command line when printing any of your
  53. own files:
  54. << /.HWMargins [ml mb mr mt] /Margins [x y] >> setpagedevice
  55. where
  56. ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72,
  57. %END
  58. /res currentpagedevice /.MarginsHWResolution get def
  59. ( x = (1 - H) * ) show res 0 get =string cvs show
  60. (, y = (V - 1) * ) show res 1 get =string cvs show
  61. showpage