Sorry, forgot the file.

#!/bin/bash

  file="$1"
  tempfile="$file.edited.$$"

  sed -e '
  /^%%DocumentMedia:/d
  /^%%HiResBoundingBox:/d
  /^%%PageBoundingBox:/d
  /^%%BoundingBox:/d
  /^%%DocumentSuppliedResources: 
font/s/DocumentSuppliedResources/DocumentNeededResources/
  /^%%BeginFont:/,/^%%EndFont/{
  s/%%BeginFont: /%%IncludeResource: font /p
  d
  }
  /^\/init-paper {/,/} bind def/c\
/init-paper {\
  pop\
  /paper-height 842 def\
} bind def
  s/gsave set-ps-scale-to-lily-scale/gsave 0 paper-height translate 
set-ps-scale-to-lily-scale/
  / \/space$/{
  N
  /\n1 print_glyphs/d
  }
  ' <"$file" >"$tempfile"

  BBOX=`gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox "$tempfile" 2>&1 | grep 
'%%BoundingBox:'`
  echo "  --> $BBOX"

  sed -e "
  /^%%EndComments/{
  i\
$BBOX
  :n
  n
  b n
  }
  " <"$tempfile" >"$file"

  rm "$tempfile"

Reply via email to