Web便利ノート
cman.jp cman.jp > Web便利ノート > PDF > 解析・変換
広告
広告
広告

popplerコマンドの共通オプション

フリーソフトPopplerの各種コマンドには共通のオプションがあります。

コマンド オプション
f l enc opw upw q v h
pdfattach × × × × × × ○ ○
pdfdetach × × ○ ○ ○ × ○ ○
pdffonts ○ ○ × ○ ○ × ○ ○
pdfimages ○ ○ × ○ ○ ○ ○ ○
pdfinfo ○ ○ ○ ○ ○ × ○ ○
pdfseparate ○ ○ × × × × ○ ○
pdftocairo ○ ○ × ○ ○ ○ ○ ○
pdftohtml ○ ○ ○ ○ ○ ○ ○ ○
pdftoppm ○ ○ × ○ ○ ○ ○ ○
pdftops ○ ○ × ○ ○ ○ ○ ○
pdftotext ○ ○ ○ ○ ○ ○ ○ ○
pdfunite × × × × × × ○ ○
広告

共通オプションの詳細

各オプションの意味は以下となります。

オプション
-f <int> 解析・変換を行うPDFの開始ページを指定
-l <int> 解析・変換を行うPDFの終了ページを指定
-enc <string> 解析・変換結果の文字コードを指定
-opw <string> オーナーパスワード設定されている場合にパスワードを指定
-upw <string> ユーザーパスワード設定されている場合にパスワードを指定
-q 解析・変換時のエラーを表示しない
-v バージョンとコピーライトを表示
-h コマンドの使用方法を表示
「-help」「--help」「-?」でも同じ表示となる
ページTOP
広告

共通オプションの実行例

「-f」, 「-l」 対象ページを指定

解析・変換対象のページを指定する。

>rem /* 3ページ目以降を対象とする */
>pdftotext -f 3 Sample_text.pdf text.txt

>rem /* 5ページ目までを対象とする */
>pdftotext -l 5 Sample_text.pdf text.txt

>rem /* 3ページ目~5ページ目を対象とする */
>pdftotext -f 3 -l 5 Sample_text.pdf text.txt

ページTOP

「-enc <string>」 出力する文字コードを指定

解析・変換の結果に出力する文字コードを指定する。
使用できる文字コードは「-listenc」で確認できます。

>rem /* シフトJISで出力する */
>pdftotext -enc Shift-JIS Sample_text.pdf text.txt

>rem /* 変換できる文字コードを確認する */
>pdftotext -listenc
Available encodings are:
.
..
ASCII7
Big5
Big5ascii
EUC-CN
EUC-JP
GBK
ISO-2022-CN
ISO-2022-JP
ISO-2022-KR
ISO-8859-6
ISO-8859-7
ISO-8859-8
ISO-8859-9
KOI8-R
Latin1
Latin2
Shift-JIS
Symbol
TIS-620
UTF-16
UTF-8
Windows-1255
ZapfDingbats

ページTOP

「-opw <string>」, 「-upw <string>」 PDFのパスワードを指定

パスワード保護されているPDFの場合は、パスワードを指定する。

オーナーパスワード
(権限設定等のパスワード)
ユーザーパスワード
(PDFを開くパスワード)
指定オプション
あり なし 基本的に指定不要
なし あり -upw
あり あり -upw or -opw

PDF内のテキスト内容を画面に表示するサンプルとなります。

>rem /* opwのみ設定されているPDF */
>pdftotext Sample_opw.pdf -
この PDF にはオーナーパスワードが設定されています。

>rem /* upwのみ設定されているPDF → パスワード指定なしNG */
>pdftotext Sample_upw.pdf -
Command Line Error: Incorrect password

>rem /* upwのみ設定されているPDF → パスワード指定ありOK */
>pdftotext -upw pass1 Sample_upw.pdf -
この PDF にはユーザーパスワードが設定されています。

>rem /* opw,upwの両方が設定されているPDF → パスワード指定なしNG */
>pdftotext Sample_opw_upw.pdf -
Command Line Error: Incorrect password

>rem /* opw,upwの両方が設定されているPDF → upw指定:OK */
>pdftotext -upw pass1 Sample_opw_upw.pdf -
この PDF にはオーナーとユーザーのパスワードが設定されています。

>rem /* opw,upwの両方が設定されているPDF → opw指定:OK */
>pdftotext -opw pass2 Sample_opw_upw.pdf -
この PDF にはオーナーとユーザーのパスワードが設定されています。

ページTOP

「-q」 エラーを表示しない

>rem /* 対象PDFファイルなしエラー */
>pdftotext Sample_opw_upw.XXX -
I/O Error: Couldn't open file 'Sample_opw_upw.XXX': No error.

>rem /* 「-p」を付けるとエラーが表示されなくなる */
>pdftotext -q Sample_opw_upw.XXX -
>
ページTOP

「-v」 バージョンとコピーライトを表示

>pdftotext -v
pdftotext version 24.08.0
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC

ページTOP

「-h」 バージョンとコピーライトを表示
「-help, --help, -?」も同様となる

>pdftotext -h
pdftotext version 24.08.0
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
Usage: pdftotext [options] <PDF-file> [<text-file>]
  -f <int>             : first page to convert
  -l <int>             : last page to convert
  -r <fp>              : resolution, in DPI (default is 72)
  -x <int>             : x-coordinate of the crop area top left corner
  -y <int>             : y-coordinate of the crop area top left corner
  -W <int>             : width of crop area in pixels (default is 0)
  -H <int>             : height of crop area in pixels (default is 0)
  -layout              : maintain original physical layout
  -fixed <fp>          : assume fixed-pitch (or tabular) text
  -raw                 : keep strings in content stream order
  -nodiag              : discard diagonal text
  -htmlmeta            : generate a simple HTML file, including the meta information
  -tsv                 : generate a simple TSV file, including the meta information for bounding boxes
  -enc <string>        : output text encoding name
  -listenc             : list available encodings
  -eol <string>        : output end-of-line convention (unix, dos, or mac)
  -nopgbrk             : don't insert page breaks between pages
  -bbox                : output bounding box for each word and page size to html. Sets -htmlmeta
  -bbox-layout         : like -bbox but with extra layout bounding box data.  Sets -htmlmeta
  -cropbox             : use the crop box rather than media box
  -colspacing <fp>     : how much spacing we allow after a word before considering adjacent text to be a new column, as a fraction of the font size (default is 0.7, old releases had a 0.3 default)
  -opw <string>        : owner password (for encrypted files)
  -upw <string>        : user password (for encrypted files)
  -q                   : don't print any messages or errors
  -v                   : print copyright and version info
  -h                   : print usage information
  -help                : print usage information
  --help               : print usage information
  -?                   : print usage information

ページTOP
広告

その他のPopplerツール機能

主な機能 概要
pdfattach PDFファイルに添付ファイルを埋め込みします
pdfdetach PDF内に添付(埋め込み)されているファイルの一覧表示や抽出を行います
pdffonts PDFファイルで使用されているフォントやフォントの埋め込み有無を調べる
pdfimages PDFファイルで使用(埋め込み)されている画像を抽出する
pdfinfo PDFファイルの情報(作成者、作成日時、ページ数など)を表示する
pdfseparate PDFファイルを1ページごとに分割する
pdftocairo PDFファイルを画像に変換する(Cairoベクターグラフィックスを使用)
pdftohtml PDFをHTML形式に変換する
pdftoppm PDFファイルを画像に変換する
pdftops PDFファイルをPostScriptファイルに変換する
pdftotext PDFファイルからテキストを抽出する
pdfunite 複数のPDFファイルをページ結合する
ページTOP
広告
QrCode
このページのURL
スマートフォン・タブレット運営:株式会社シーマン