0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CLIでpdfファイルを分割する方法(macOS)

0
Posted at

はじめに

pdfseparateは、PDFファイルを個別のページに分割するコマンドラインツールです。Poppler(PDFレンダリングライブラリ)に含まれており、大容量のPDFファイルや複数ページの文書を効率的に管理するための便利なツールです。

インストール方法

macOSの場合はHomebrewを使用していインストール可能です。

brew install poppler

基本コマンド

pdfseparate sample.pdf output-%d.pdf

sample.pdf: 分割したい元のPDFファイル
output-%d.pdf: 出力ファイル名のパターン
%d: ページ番号のプレースホルダー(1, 2, 3...と順番に置換される)

実行結果例

10ページのPDFファイルを分割した場合:

output-1.pdf  # 1ページ目
output-2.pdf  # 2ページ目
output-3.pdf  # 3ページ目
...
output-10.pdf # 10ページ目

応用的な使用方法

特定のページ範囲を指定

# 3ページ目から7ページ目まで分割
pdfseparate -f 3 -l 7 sample.pdf page-%02d.pdf

オプション説明

  • -f N: 開始ページ番号を指定
  • -l N: 終了ページ番号を指定
  • %02d: ゼロパディング付きの番号(01, 02, 03...)

出力ディレクトリを指定

# 分割したファイルを特定のディレクトリに保存
mkdir split_pages
pdfseparate sample.pdf split_pages/page-%d.pdf

より柔軟なファイル名

# 日付やタイムスタンプを含む
pdfseparate document.pdf "$(date +%Y%m%d)_page-%d.pdf"

# プロジェクト名を含む
pdfseparate report.pdf "project_alpha_page-%03d.pdf"

他のツールとの比較

ツール メリット デメリット
pdfseparate 軽量、高速、コマンドライン GUIなし
Adobe Acrobat GUI、多機能 有料、重い
PDFtk 多機能 インストールが複雑
QPDF セキュリティ機能豊富 学習コストが高い

関連コマンド

  • pdfunite: PDFファイルを結合
  • pdfinfo: PDFファイルの情報を表示
  • pdftocairo: PDFを画像形式に変換
  • pdffonts: PDFで使用されているフォント情報を表示
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?