Сжатие pdf файла Linux
Ситуация: бухгалтерия отсканировала кипу документов в 300dpi, чтобы отослать письмом. Файлы получились 20-30мб. Задача: сжать.
Способ 1:
Устанавливаем Ghostscript и pdftk
sudo apt-get install ghostscript pdftk
Далее кидаем файлы pdf в какую-то папку,далее создаем и запускаем следующий скрипт:
for file in *.pdf; do ps=".ps"; pdf2ps $file "$file+$ps"; done for file in *.ps; do pdf=".pdf"; pdf2ps $file "$file+$pdf"; done
В итоге получаем сжатые в несколько раз файлы.
Способ 2:
Воспользуемся ghostscript. Убедимся, что он установлен:
sudo apt-get install ghostscript
А затем сожмем PDF:
for file in *.pdf; do pdf=".pdf"; gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$file$pdf" $file done
-dPDFSETTINGS=configuration
Presets the «distiller parameters» to one of four predefined settings:
/screen selects low-resolution output similar to the Acrobat Distiller «Screen Optimized» setting.
/printer selects output similar to the Acrobat Distiller «Print Optimized» setting.
/prepress selects output similar to Acrobat Distiller «Prepress Optimized» setting.
/default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.



. Конечно у некоторых может быть проблема с хостингом, в смысле размера диска, но у меня такой проблемы нет