Created
October 16, 2014 17:38
-
-
Save zr-tex8r/138b07c6d71e31aa5334 to your computer and use it in GitHub Desktop.
バッチで作る、劣化版pdfcrop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
set FROM=%~n1 | |
set TO=%~n2 | |
set TPX=_tcpc | |
if not exist %FROM%.pdf exit /B | |
if "%TO%"=="" exit /B | |
if exist %TO%.pdf del %TO%.pdf | |
if exist %TO%.pdf del exit /B | |
gswin32c -dBATCH -dNOPAUSE -q -sDEVICE=bbox %FROM%.pdf 2>%TPX%1.tex | |
echo {\catcode37=13 \catcode13=12 \def^^^^25^^^^25#1: #2^^^^M{\gdef\do{\proc[#2]}}\input _tcpc1.tex\relax}{}^ | |
\def\proc[#1 #2 #3 #4]{\pdfhorigin-#1bp \pdfvorigin#2bp \pdfpagewidth=\dimexpr#3bp-#1bp\relax\pdfpageheight\dimexpr#4bp-#2bp\relax}\do^ | |
\setbox0=\hbox{\pdfximage mediabox{%FROM%.pdf}\pdfrefximage\pdflastximage}^ | |
\ht0=\pdfpageheight \shipout\box0\relax \end >%TPX%2.tex | |
pdftex -no-shell-escape -batchmode %TPX%2.tex | |
if not exist %TPX%2.pdf exit /B | |
ren %TPX%2.pdf %TO%.pdf | |
del %TPX%1.tex %TPX%2.tex %TPX%2.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
“Perl無しで”pdfcrop(のオプション無し)と同じことをする。
Ghostscript(
gswin32c
に固定)とpdfTeXは相変わらず必要。ディレクトリ指定不可でカレントディレクトリを仮定する。