PDFの結合や圧縮処理はGhostscriptが便利
Contents
スキャンの都合、複数ファイルになってしまったPDFを1つのファイルにまとめたい。膨れ上がったデータを小さくしたい等、PDFの処理にこまることがあります。 そんな、PDFの結合や圧縮処理はGhostscriptが便利です。
install
windowsであれば、WSL2のubuntuから簡単にインストールできます
$ sudo aptitude install ghostscript
$ gs -v
GPL Ghostscript 10.02.1 (2023-11-01)
Copyright (C) 2023 Artifex Software, Inc. All rights reserved.バージョン表示がなされるようであれば、インストール完了です。
結合
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdfinput1.pdfとinput2.pdfを結合してoutput.pdfを作成します。
圧縮
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=output.pdf input.pdfinput.pdfを圧縮してoutput.pdfを作成します。
文字抽出
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.txt input.pdfinput.pdfの文字を抽出してoutput.txtを作成します。