/share/examples/printing/make-ps-header

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 79 lines · 53 code · 8 blank · 18 comment · 1 complexity · 85aded538d08916addb2c6f44b3530e9 MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # make-ps-header - make a PostScript header page on stdout
  4. # Installed in /usr/local/libexec/make-ps-header
  5. #
  6. #
  7. # These are PostScript units (72 to the inch). Modify for A4 or
  8. # whatever size paper you are using:
  9. #
  10. page_width=612
  11. page_height=792
  12. border=72
  13. #
  14. # Check arguments
  15. #
  16. if [ $# -ne 3 ]; then
  17. echo "Usage: `basename $0` <user> <host> <job>" 1>&2
  18. exit 1
  19. fi
  20. #
  21. # Save these, mostly for readability in the PostScript, below.
  22. #
  23. user=$1
  24. host=$2
  25. job=$3
  26. date=`date`
  27. #
  28. # Send the PostScript code to stdout.
  29. #
  30. exec cat <<EOF
  31. %!PS
  32. %
  33. % Make sure we do not interfere with user's job that will follow
  34. %
  35. save
  36. %
  37. % Make a thick, unpleasant border around the edge of the paper.
  38. %
  39. $border $border moveto
  40. $page_width $border 2 mul sub 0 rlineto
  41. 0 $page_height $border 2 mul sub rlineto
  42. currentscreen 3 -1 roll pop 100 3 1 roll setscreen
  43. $border 2 mul $page_width sub 0 rlineto closepath
  44. 0.8 setgray 10 setlinewidth stroke 0 setgray
  45. %
  46. % Display user's login name, nice and large and prominent
  47. %
  48. /Helvetica-Bold findfont 64 scalefont setfont
  49. $page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto
  50. ($user) show
  51. %
  52. % Now show the boring particulars
  53. %
  54. /Helvetica findfont 14 scalefont setfont
  55. /y 200 def
  56. [ (Job:) (Host:) (Date:) ] {
  57. 200 y moveto show /y y 18 sub def
  58. } forall
  59. /Helvetica-Bold findfont 14 scalefont setfont
  60. /y 200 def
  61. [ ($job) ($host) ($date) ] {
  62. 270 y moveto show /y y 18 sub def
  63. } forall
  64. %
  65. % That is it
  66. %
  67. restore
  68. showpage
  69. EOF