summaryrefslogtreecommitdiff
blob: f5e7b3e5dc83ac5edbf1e0cc09d4c9856095e55f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@echo off 

if %1/==/ goto usage
if %2/==/ goto usage

call "%~dp0gssetgs.bat"
set infile=%~1
set outfile=%~2

rem First we need to determine the bounding box. ps2epsi.ps below will pick
rem the result up from %outfile%
%GSC% -q -dNOPAUSE -dBATCH -P- -sDEVICE=bbox -sOutputFile=NUL %1 2> %2

rem Ghostscript uses %outfile% to define the output file
%GSC% -q -dNOPAUSE -P- -sDEVICE=bit -sOutputFile=NUL ps2epsi.ps < %1

rem We bracket the actual file with a few commands to help encapsulation
echo %%%%Page: 1 1 >> %2
echo %%%%BeginDocument: %2 >> %2
echo /InitDictCount countdictstack def gsave save mark newpath >> %2
echo userdict /setpagedevice /pop load put >> %2

rem Append the original onto the preview header
rem cat.ps uses the %infile% and %outfile% environment variables for the filenames
%GSC% -q -dNOPAUSE -dBATCH -P- -sDEVICE=bit -sOutputFile=NUL cat.ps


echo %%%%EndDocument >> %2
echo countdictstack InitDictCount sub { end } repeat >> %2
echo cleartomark restore grestore >> %2

goto end

:usage
echo "Usage: ps2epsi <infile.ps> <outfile.epi>"

:end