1@echo off
2rem Internal batch file for calling pdfwrite driver.
3
4rem The files that call this one (ps2pdf*.bat) write the command-line
5rem options into _.at, and then pass the last 2 (or fewer) arguments
6rem to this file.
7
8call "%~dp0gssetgs.bat"
9echo -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite >"%TEMP%\_.at"2
10
11if "%OS%"=="Windows_NT" goto nt
12
13rem	Run ps2pdf on any Microsoft OS.
14
15if %1/==/ goto usage
16if %2/==/ goto usage
17
18rem Watcom C deletes = signs, so use # instead.
19rem We have to include the options twice because -I only takes effect if it
20rem appears before other options.
21
22:run
23echo -sOutputFile#%2 >>"%TEMP%\_.at"2
24copy /b /y "%TEMP%\_.at"2+"%TEMP%\_.at" "%TEMP%\_.at"2 >NUL
25echo %1 >>"%TEMP%\_.at"2
26%GSC% @"%TEMP%\_.at" @"%TEMP%\_.at"2
27goto end
28
29:usage
30echo Usage: ps2pdf [options...] input.[e]ps output.pdf
31goto end
32
33rem	Run ps2pdf on Windows NT.
34
35:nt
36if not CMDEXTVERSION 1 goto run
37if %1/==/ goto ntusage
38if %2/==/ goto nooutfile
39goto run
40
41:ntusage
42echo Usage: ps2pdf input.ps [output.pdf]
43echo    or: ps2pdf [options...] input.[e]ps output.pdf
44goto end
45
46:nooutfile
47rem We don't know why the circumlocution with _1 is needed....
48set _1=%1
49set _outf=%_1:.PS=.pdf%
50if %_1%==%_outf% goto addsuff
51call "%~dp0ps2pdfxx" %1 %_outf%
52goto postsuff
53
54:addsuff
55call "%~dp0ps2pdfxx" %1 %1%.pdf
56
57:postsuff
58set _1=
59set _outf=
60
61:end
62rem	Clean up.
63if exist "%TEMP%\_.at" erase "%TEMP%\_.at"
64if exist "%TEMP%\_.at"2 erase "%TEMP%\_.at"2
65