1
0

align.ps 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. % Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: align.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % Print a page that indicates the proper settings of Margins and HWMargins
  19. % for a given device. Requires a Level 2 system.
  20. % Reset the offset and margins.
  21. <<
  22. /PageOffset [0 0]
  23. /Margins [0 0]
  24. /.HWMargins [0 0 0 0]
  25. >>
  26. setpagedevice
  27. <<
  28. /ImagingBBox null
  29. >>
  30. setpagedevice
  31. % Determine the actual page size.
  32. clippath pathbbox newpath
  33. /y1 exch def /x1 exch def pop pop
  34. % Draw lines that should be exactly 1" in from each edge,
  35. % and should extend precisely to the edge of the paper.
  36. 1 setlinewidth
  37. 0 setgray
  38. 72 0 moveto 0 y1 rlineto stroke
  39. 0 72 moveto x1 0 rlineto stroke
  40. % Print the text in the middle of the page.
  41. /S 80 string def
  42. 108 480 moveto
  43. /Helvetica 12 selectfont
  44. { currentfile S readline pop dup (%END) eq { pop exit } if
  45. gsave show grestore 0 -15 rmoveto
  46. } loop
  47. Let the distance in inches from the left edge of the page to
  48. the vertical line be H, and from the bottom edge to the
  49. horizontal line be V; let the lengths of the gaps at the top
  50. and bottom of the vertical line be T and B respectively, and
  51. the gaps at the left and right of the horizontal line be L
  52. and R. For correct alignment of pages, put the following line
  53. in a file named (for example) margins.ps, and then mention
  54. margins.ps on the gs command line when printing any of your
  55. own files:
  56. << /.HWMargins [ml mb mr mt] /Margins [x y] >> setpagedevice
  57. where
  58. ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72,
  59. %END
  60. /res currentpagedevice /.MarginsHWResolution get def
  61. ( x = (1 - H) * ) show res 0 get =string cvs show
  62. (, y = (V - 1) * ) show res 1 get =string cvs show
  63. showpage