PDF、PS および DjVu

提供: ArchWiki
2022年11月28日 (月) 10:27時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎Advanced editors: 飜訳)
ナビゲーションに移動 検索に移動

この記事は、PDF, PostScript (PS), DjVu ('déjà vu'), XPS ファイルを閲覧、編集、変換するソフトウェアを扱います。

エンジン

  • Poppler — Xpdf をベースにした PDF 描画ライブラリ。Poppler で CJK(中国語、日本語、韓国語)に対応するには、poppler-dataインストールします。
https://poppler.freedesktop.org/ || poppler
  • Mupdf — MuPDF は、ソフトウェアライブラリ、コマンドラインツール、ビューアから構成される、軽量のPDF、XPS、EPUBビューアです。
https://mupdf.com/ || libmupdf
  • libspectre — PostScript 文書を描画するための小さなライブラリ。
https://www.freedesktop.org/wiki/Software/libspectre || libspectre
  • Ghostscript — PostScript と PDF のためのインタープリタです。gs(1) コマンドラインインターフェイスを提供します。(online) を参照してください。また、ps2pdfpdf2ps などの多くのラッパースクリプトも含まれています。
ghostscript || パッケージが存在しないか AUR で検索
  • DjVuLibre — DjVu ドキュメントの作成、操作、表示を行うスイートです。
http://djvu.sourceforge.net/ || djvulibre
  • libgxps — XPS ドキュメントを処理し、レンダリングするための GObject ベースのライブラリです。
https://wiki.gnome.org/Projects/libgxps || libgxps

ビューア

フレームバッファ

  • fbgs — linux フレームバッファ・コンソール用のプアマンズ PostScript/pdf ビューアです。
https://www.kraxel.org/blog/linux/fbida/ || fbida
  • fbpdf — MuPDF ベースの小さなフレームバッファ PDF および DjVu ビューア,Vim キーバインド付きで C で書かれています。
https://repo.or.cz/w/fbpdf.git || fbpdf-gitAUR
  • jfbview — フレームバッファ型 PDF・画像ビューア。Vim ライクなコントロール、zoom-to-fit、TOC(アウトライン)ビュー、高速なマルチスレッドレンダリングなどの機能があります。
https://github.com/jichu4n/jfbview || jfbviewAUR

グラフィカル

ノート: ウェブブラウザの中には、PDF.jsなどでPDFファイルを表示できるものがあります。
  • Adobe Reader — Adobeが提供するプロプライエタリの PDF ファイルビューア。Linuxでは廃止されました。
https://www.adobe.com/products/reader.html || acroreadAUR
  • apvlv — Lightweight document viewer with Vim keybindings. Supports PDF, DjVu, EPUB, HTML and TXT.
https://naihe2010.github.io/apvlv/ || apvlvAUR
  • Atril — Simple multi-page document viewer for MATE. Supports DjVu, DVI, EPS, EPUB, PDF, PostScript, TIFF, XPS and Comicbook.
https://github.com/mate-desktop/atril || atril
  • CorePDF — Simple lightweight PDF viewer based on Qt and poppler. Part of C-Suite.
https://cubocore.org/ || corepdfAUR
  • Deepin Document Viewer — A simple PDF and DjVu reader, supporting bookmarks, highlights and annotations.
https://github.com/linuxdeepin/deepin-reader || deepin-reader
  • DjView — Viewer for DjVu documents.
http://djvu.sourceforge.net/djview4.html || djview
  • ePDFView — Lightweight PDF document viewer using the Poppler and GTK libraries. Development stopped.
http://freecode.com/projects/epdfview || epdfview
https://www.gnu.org/software/emacs/ || emacs
  • Evince — GNOME 用ドキュメントビューア。DjVu、DVI、EPS、PDF、PostScript、TIFF、XPS、Comicbook をサポートします。
https://wiki.gnome.org/Apps/Evince || evince
https://www.foxitsoftware.com/pdf-reader/ || foxitreaderAUR
  • gv — Graphical user interface for the Ghostscript interpreter that allows to view and navigate through PostScript and PDF documents.
https://www.gnu.org/software/gv/ || gv
  • llpp — Very fast PDF reader based off of MuPDF, that supports continuous page scrolling, bookmarking, and text search through the whole document.
https://repo.or.cz/w/llpp.git || llpp
  • MuPDF — Very fast EPUB, FictionBook, PDF, XPS and Comicbook viewer written in portable C. Features CJK font support.
https://mupdf.com/ || mupdf
  • Okular — Universal document viewer for KDE. Supports CHM, Comicbook, DjVu, DVI, EPUB, FictionBook, Mobipocket, ODT, PDF, Plucker, PostScript, TIFF and XPS.
https://okular.kde.org/ || okular
  • pdfpc — Presenter console with multi-monitor support for PDF files.
https://pdfpc.github.io/ || pdfpc
  • qpdfview — タブ式ドキュメントビューアです。PDF サポートに Poppler、PS サポートに libspectre、DjVu サポートに DjVuLibre、印刷サポートに CUPS、インターフェースに Qt toolkit を使用しています。
https://launchpad.net/qpdfview || qpdfview
  • Xpdf — Viewer that can decode LZW and read encrypted PDFs.
https://www.xpdfreader.com/ || xpdf
  • Xreader — Document viewer part of the X-Apps Project. Supports DjVu, DVI, EPUB, PDF, PostScript, TIFF, XPS, Comicbook.
https://github.com/linuxmint/xreader/ || xreader
  • Zathura — カスタマイズ性の高い高機能ドキュメントビューア(プラグインベース)。PDF、DjVu、PostScript、Comicbookをサポート。
https://pwmt.org/projects/zathura/ || zathura

比較

この記事またはセクションの正確性には問題があります。
理由: Filling out PDF forms seem to be broken in MuPDF and llpp. (議論: トーク:PDF、PS および DjVu#)

ライブラリの横にあるアスタリスクは、指定された機能に対してオプションの依存関係をインストールする必要があることを示しています。

Name PDF PostScript DjVu XPS PDF フォーム PDF Annotation License
Adobe Reader Custom Yes proprietary
apvlv Poppler DjVuLibre No GPLv2
Atril Poppler libspectre DjVuLibre libgxps Yes GPLv2
DjView DjVuLibre GPLv2
Emacs Ghostscript* DjVuLibre* No Yes GPLv3
ePDFView Poppler No GPLv2
Evince Poppler libspectre DjVuLibre libgxps Yes Yes GPLv2
Foxit Reader Custom Yes Yes proprietary
gv Ghostscript No GPLv3
llpp libmupdf libmupdf Yes GPLv3
MuPDF Custom Custom Yes Yes AGPLv3
Okular Poppler libspectre DjVuLibre Custom Yes Yes GPL, LGPL
pdfpc Poppler No GPLv2
qpdfview Poppler libspectre* DjVuLibre* Yes Yes GPLv2
Xpdf Custom No GPLv3
Xreader Poppler libspectre* DjVuLibre* libgxps* Yes Yes GPLv2
Zathura Poppler* / libmupdf* libspectre* DjVuLibre* libmupdf* No zlib

PDF フォーム

上の表のPDF フォーム欄はAcroFormsのサポートを指しています。入力内容を PDF から直接取り出す必要がない場合は、#注釈#グラフィカル PDF 編集のアプリケーションを使って、PDF の上にテキストを配置することもできます。PDF フォームは、LibreOffice Writer (View > Toolbars > Form Controls) とadvanced PDF editors で作成することが可能です。

プロプライエタリで非推奨の XFA 形式のフォームは、Poppler[1][2]では完全にサポートしておらず、Adobe ReaderMaster PDF Editor でのみサポートされています。

また、FirefoxChromiumなどのWebブラウザは、フォームに入力できるPDFビューアを内蔵しています。

注釈

  • flpsed — PostScript と PDF のアノテーターで、テキストボックスのみサポートします。
https://flpsed.org/flpsed.html || flpsedAUR

アプリケーション一覧/ドキュメント#手書きメモ を参照してください。

グラフィカル PDF エディター

  • Scribus は PDF のインポートとエクスポートが可能で、テキストはポリゴンとしてインポートされます。[3]
  • LibreOffice Draw では、PDF の取り込みと書き出しが可能です。テキストはテキストとして取り込み、埋め込みフォントは置換されます。[4][5]
  • Inkscape は PDF から 1 ページを取り込み、PDF にエクスポートすることができます。テキストはクローングリフまたはテキストとして取り込まれ、後者では埋め込みフォントが代用されます。
  • GIMPkrita などのグラフィックエディタも、ラスタ化を犠牲にして PDF をインポート/エクスポートすることが可能です。

ベーシックエディタ

  • jPDF Tweak — Java Swing アプリケーションで、PDF ファイルの結合、分割、回転、並べ替え、透かし、暗号化、署名、その他微調整ができます。
http://jpdftweak.sourceforge.net/ || jpdftweakAUR
  • PDF Arranger — PDF 文書の結合や分割、ページの回転、切り取り、並べ替えを支援します。PDF-Shuffler のフォークとしてメンテナンスされています。
https://github.com/jeromerobert/pdfarranger || pdfarranger
  • PDF Chain — C++ で書かれた PDFtk 用の GTK フロントエンドで、連結、バースト、透かし、ファイルの添付などをサポートしています。
http://pdfchain.sourceforge.net/ || pdfchainAUR
  • PdfJumbler — PDF ファイルのページを並べ替え、結合、削除、回転させるシンプルなツールです。
https://github.com/mgropp/pdfjumbler || pdfjumblerAUR
  • PDF Mix Tool — C++ で書かれた PoDoFo 用の Qt フロントエンドで、PDF ファイルの分割、結合、回転、混合をサポートします。
https://scarpetta.eu/pdfmixtool/ || pdfmixtool
  • PDF Mod — ページの並べ替え、回転、削除、文書からの画像のエクスポート、タイトル、件名、著者、キーワードの編集、ドラッグ&ドロップによる文書の結合が可能です。
https://wiki.gnome.org/Attic/PdfMod || pdfmod
  • PDFsam — Java で書かれたオープンソースのアプリケーションで、結合、分割、回転をサポートしています。
https://pdfsam.org/ || pdfsamAUR
  • PDF Slicer — PDF 文書の抽出、結合、回転、ページの並べ替えを行うシンプルなアプリケーションです。
https://junrrein.github.io/pdfslicer/ || pdfslicer
  • PDF Tricks — Ghostscript を使って PDF ファイルにちょっとした操作をするためのシンプルで効率的なアプリケーションです。
https://github.com/muriloventuroso/pdftricks || pdftricks

切り取りツール

  • briss — 選択した 1 つ以上の領域に PDF ドキュメントのページを切り取るための Java GUI。
https://sourceforge.net/projects/briss/ || brissAUR
  • krop — PDF ファイルのページを切り取るためのシンプルなグラフィカル ツール。
https://arminstraub.com/software/krop || kropAUR
  • pdfCropMargins — PDF ファイルの余白を自動的に切り取ります。
https://github.com/abarker/pdfCropMargins || pdfcropmarginsAUR
  • PdfHandoutCrop — 1 シートに複数のページがある PDF 配布資料を切り取りするツール。
https://cges30901.github.io/pdfhandoutcrop/ || pdfhandoutcropAUR

アドバンスドエディタ

  • Master PDF Editor — 機能的なプロプライエタリな PDF エディタ。最新版は非商用利用で無料。'-free' パッケージは古いものですが、透かしがないのが特徴です。
https://code-industry.net/free-pdf-editor/ || masterpdfeditorAUR, masterpdfeditor-freeAUR
  • PDF Studio — Adobe Acrobat に似たオールインワンのプロプライエタリな PDF エディタ。
https://www.qoppa.com/pdfstudio/ || pdfstudio-binAUR

PDF ツール

See also Ghostscript.

  • Coherent PDF — Command line tools to manipulate PDF files including merge, encrypt, decrypt, scale, crop, rotate, bookmarks, stamp, logos, page numbers.
https://community.coherentpdf.com/ || cpdfAUR
  • DiffPDF — Compare the text or the visual appearance of each page in two PDF files.
https://gitlab.com/eang/diffpdf || diffpdf
  • mupdf-tools — Tools developed as part of MuPDF, contains mutool(1) and muraster.
https://mupdf.com || mupdf-tools
  • pdfgrep — Commandline utility to search text in PDF files.
https://pdfgrep.org/ || pdfgrep
  • pdfjam — Can be used to n-up, join, rotate and flip PDFs and arrange them into a format suitable for book binding.
https://github.com/DavidFirth/pdfjam || texlive-core
  • pdf2svg — Convert PDF files to SVG files.
http://www.cityinthesky.co.uk/opensource/pdf2svg/ || pdf2svg
  • PDFtk — Simple tool for doing everyday things with PDF documents.
http://www.pdfhacks.com/pdftk || pdftk
  • QPDF — Content-preserving PDF transformation system.
https://github.com/qpdf/qpdf || qpdf
  • Stapler — Light alternative to PDFtk using the PyPDF2 library.
https://github.com/hellerbarde/stapler || staplerAUR, stapler-gitAUR

画像から PDF を作成

GraphicsMagick を使用:

$ gm convert 1.jpg 2.jpg 3.jpg out.pdf

PDF の連結

Ghostscript の場合:

$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=out.pdf -dBATCH 1.pdf 2.pdf 3.pdf

PDFtk を使用:

$ pdftk 1.pdf 2.pdf 3.pdf cat 出力 out.pdf

Poppler を使用:

$ pdfunite 1.pdf 2.pdf 3.pdf out.pdf

QPDF の場合:

$ qpdf --empty --pages 1.pdf 2.pdf 3.pdf -- out.pdf

PDFをテキストに変換

Poppler を使用してレイアウトを維持する:

$ pdftotext -レイアウト in.pdf out.txt

pdftotext(1) も参照してください。

PDF の復号化

このセクションでは、PDF を暗号化されていないファイルに復号化するコマンドを示します。ほとんどの PDF ビューア は、暗号化された PDF もサポートしていることに注意してください。

PDFtk を使用:

$ pdftk in.pdf input_pw パスワード output out.pdf

Poppler から PostScript へ:

$ pdftops -upw パスワード in.pdf out.ps

QPDF の場合:

$ qpdf --decrypt --password=password in.pdf out.pdf
ヒント: パスワードを忘れた場合は、pdfcrack で回復できる場合があります。pdfcrack(1) を参照してください。

PDF を暗号化

「ユーザーパスワード」は暗号化に使用され、「所有者パスワード」はドキュメントが復号化された後の操作を制限するために使用されます。詳細については、Wikipedia:PDF#Security and signatures を参照してください。

PDFtk を使用:

$ pdftk in.pdf output out.pdf user_pw password

PoDoFo を使用:

$ podofoencrypt -u user_password -o owner_password in.pdf out.pdf

QPDF を使用:

$ qpdf --encrypt user_password owner_password key_length -- in.pdf out.pdf

ここで、key_length は 40、128、または 256 です。

PDF から画像を抽出

Poppler から JPEG へ:

$ pdfimages infile.pdf -j outfileroot

Extract page range from PDF, split multipage PDF document

With Ghostscript as a single file[6]

$ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=first -dLastPage=last -sOutputFile=outfile.pdf infile.pdf

With PDFtk as a single file:

$ pdftk infile.pdf cat first-last output outfile.pdf

With Poppler as separate files:

$ pdfseparate -f first -l last infile.pdf outfileroot-%d.pdf

With QPDF as a single file:

$ qpdf --empty --pages infile.pdf first-last -- outfile.pdf

With mutool as a single file:

$ mutool clean -g infile.pdf outfile.pdf first-last

Imposing a PDF

PDF Imposition can be done with pdfjam, for example paper waste can be reduced with pdfnup and pdfbook can be used to arrange PDFs into a format suitable for book binding.

Inspecting metadata

With ExifTool:

$ exiftool file.pdf

With Poppler:

$ pdfinfo file.pdf

Optimize, reduce size of a PDF

With Ghostscript one of:

$ ps2pdf -dPDFSETTINGS=/screen in.pdf out.pdf
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf

For different settings see the documentation.

There is also shrinkpdfAUR, a script wrapping gs.

Rasterize a PDF

With GraphicsMagick to convert a specific page:

$ gm convert -density dpi infile.pdf[page] outfile.jpg

With Poppler to convert all pages:

$ pdftoppm -jpeg -r dpi infile.pdf outfileroot

With Poppler to convert a specific page:

$ pdftoppm -jpeg -r dpi -f page -singlefile infile.pdf outfileroot

Splitting PDF pages

With mupdf-tools to split every page vertically into two pages:

$ mutool poster -y 2 in.pdf out.pdf

Can be used to undo simple imposition.

Add signature.png or image to one of the pages in the PDF

To add an image to any location in PDF can be done with ImageMagick (convert), xv and pdftk. A wrapper script is here and other hints are here.

DjVu ツール

  • DjVuLibre provides many command-line tools, like ddjvu(1) for example.
  • img2djvu — Single-pass DjVu encoder based on DjVu Libre and ImageMagick.
https://github.com/ashipunov/img2djvu || img2djvu-gitAUR
  • pdf2djvu — Creates DjVu files from PDF files.
https://jwilk.net/software/pdf2djvu || pdf2djvuAUR

Convert DjVu to images

Break Djvu into separate pages:

$ djvmcvt -i input.djvu /path/to/out/dir output-index.djvu

Convert Djvu pages into images:

$ ddjvu --format=tiff page.djvu page.tiff

Convert Djvu pages into PDF:

$ ddjvu --format=pdf inputfile.djvu ouputfile.pdf

You can also use --page to export specific pages:

$ ddjvu --format=tiff --page=1-10 input.djvu output.tiff

this will convert pages from 1 to 10 into one tiff file.

Processing images

You can use scantailor-advanced to:

  • fix orientation
  • split pages
  • deskew
  • crop
  • adjust margins

Make DjVu from images

There is a useful script img2djvu-gitAUR.

$ img2djvu -c1 -d600 -v1 ./out

it will create 600 DPI out.djvu from all files in ./out directory.

Alternatively, you can try didjvuAUR, which seems to create smaller files especially on images with well defined background.

PostScript ツール

  • pstotext — PostScript ファイルをテキストに変換します。
https://www.cs.wisc.edu/~ghost/doc/pstotext.htm || pstotext

ps2pdf

ps2pdf は、PostScript を PDF に変換するための ghostscript のラッパーです。

$ ps2pdf -sPAPERSIZE=a4 -dOptimize=true -dEmbedAllFonts=true YourPSFile.ps

説明:

  • -sPAPERSIZE=something で、用紙サイズを定義します。有効な PAPERSIZE の値については、[7] を参照してください。
  • -dOptimize=true で、作成した PDF を読み込みに最適化させます。
  • -dEmbedAllFonts=true は、フォントを常に美しく見せるようにします。
ノート: ps2pdf で用紙の向きを選択することはできません。入力された PS ファイルが健全なものであれば、すでに向きの情報が含まれています。Encapsulated PS ファイルを使おうとしている場合、指定した -sPAPERSIZE に収まらない場合は問題が発生します。回避策として、ghostscript の設定で新しい用紙を作成し(例:slide)、それを-sPAPERSIZE=slide として使用することができます。

ライブラリ

  • libharu — C library for generating PDF documents.
https://github.com/libharu/libharu || libharu, Lua binding: lua-hpdfAUR
  • PoDoFo — A C++ library to work with the PDF file format.
http://podofo.sourceforge.net || podofo

Python

  • PDFMiner — Utils to extract, analyze text data of PDF files. Includes pdf2txt, dumppdf, and latin2ascii
https://www.unixuser.org/~euske/python/pdfminer/ || python-pdfminer, pdfminerAUR
  • pdfrw — A pure Python library that reads and writes PDFs.
https://github.com/pmaupin/pdfrw || python-pdfrw, python2-pdfrwAUR
  • PyPDF2 — A pure-Python library built as a PDF toolkit.
https://mstamy2.github.io/PyPDF2/ || python-pypdf2AUR, python2-pypdf2AUR
  • PyX — Python library for the creation of PostScript and PDF files.
http://pyx.sourceforge.net || python-pyx
  • ReportLab — A proven industry-strength PDF generating solution
https://www.reportlab.com/ || python-reportlab, python2-reportlabAUR

参照