@echo off rem Time-stamp: <2007/11/14, 10:21:46 (EST), maverick, pdf-rescale.bat> setlocal rem settings set _pdf_defscale=0.8 set _pdf_tmpfile=_pdf-rescale_.pdf rem ensure the input exists if [%1]==[] goto usage if not exist %1 goto notfound rem set default scale if needed set _pdf_scale=%2 if "%_pdf_scale%"=="" set _pdf_scale=%_pdf_defscale% rem make a temp file to deal with spaces if exist %_pdf_tmpfile% goto tempexists copy %1 %_pdf_tmpfile% > nul rem set job name with no double quotes, assumes input ending with .pdf set _pdf_jobname=%1 set _pdf_jobname=%_pdf_jobname:"=% set _pdf_jobname=%_pdf_jobname:~0,-4%-%_pdf_scale% rem Go! echo Generating [%_pdf_jobname%.pdf]... pdflatex -quiet -job-name="%_pdf_jobname%" "\documentclass[twoside]{article}\usepackage{pdfpages}\begin{document}\includepdf[pages=-,scale=%_pdf_scale%]{%_pdf_tmpfile%}\end{document}\batchmode" > nul if exist "%_pdf_jobname%.pdf" goto cleanup echo Trouble generating [%_pdf_jobname%.pdf]. See [%_pdf_jobname%.log]. goto end :cleanup echo Done. del "%_pdf_tmpfile%" del "%_pdf_jobname%.log" del "%_pdf_jobname%.aux" goto end :tempexists echo Temp file [%_pdf_tmpfile%] exists. Please delete it first. goto end :notfound echo File [%1] not found. rem fall through :usage echo Usage: %0 foo.pdf [scale] (scale defaults to %_pdf_defscale%) goto end :end