Last active
November 1, 2019 11:21
-
-
Save ManzDev/2072346fd65edce190d4 to your computer and use it in GitHub Desktop.
Reduce size PDF file (needs GhostScript)
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 | |
chcp 1252 >nul | |
set argc=0 | |
for %%x in (%*) do set /a argc+=1 | |
if [%argc%] == [0] goto syntax | |
if [%argc%] == [1] goto default | |
if [%argc%] == [2] goto param | |
:syntax | |
echo Sintaxis: %0 [options] [nombre.pdf] | |
echo. | |
echo Donde [options] puede ser: | |
echo. | |
echo /screen Tamaño optimizado para pantalla | |
echo /ebook Tamaño optimizado para ebooks | |
echo /printer Tamaño optimizado para impresión | |
echo /prepress Tamaño optimizado para imprenta de alta calidad | |
goto end | |
:default | |
echo Generando %~n1.min.pdf (puede tardar, dependiendo del tamaño del archivo)... | |
gswin32c.exe -q -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dBATCH -sOutputFile="%~n1.min.pdf" "%1" | |
goto end | |
:param | |
echo Generando %~n2.min.pdf (puede tardar, dependiendo del tamaño del archivo)... | |
gswin32c.exe -q -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=%1 -dNOPAUSE -dBATCH -sOutputFile="%~n2.min.pdf" "%2" | |
goto end | |
:end |
set GS_BIN=C:\Program Files\gs\gs9.21\bin\gswin64c.exe
set GS_OUTPUT_DIR=compressed
mkdir %GS_OUTPUT_DIR%
for %%i in (*.pdf) do "%GS_BIN%" -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile="%GS_OUTPUT_DIR%%%i" "%%i"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do I send a pdf's folder as a parameter ?