Help:PDF

- (en) PDF


PDFは文書のファイル形式です。このページではPDFの利用にあたり役に立つ情報を提供します。
ウィキメディア・コモンズでPDFを検索する
上記の検索ボタンは検索キーワードにfilemime:pdf
を含めることで、検索結果をPDFファイルに限定します。
ウィキメディアのプロジェクトでPDFを利用する
ページ
通常ではPDFやDjVuファイルの1ページ目がサムネイル画像の生成に使用されますが、|page=
引数を指定することで別のページが使用されます。例: [[File:IMSLP01578-Ravel - Bolero Full Score Durand 1929.pdf|thumb|page=2|『ボレロ』の楽譜の2ページ目]]
PDFソフトウェア
PDFソフトウェアの一覧を参照。たとえば、フリーソフトウェアのOkularでPDFを閲覧、LibreOffice DrawでPDFを編集、ImageMagickでPDFを操作できます。
PDFの作成方法
スキャナーで読み取った画像の処理
スキャナーで読み取った画像は通常、PDFやDJVUを作成する前に切り抜き、回転、分割、圧縮、TIFFへの変換といった処理を要します。オープンソースソフトウェアのScanTailor-Universalはこれらの処理を行うために設計され、リリースページからダウンロードできます。
画像からPDFを作成
- If you have ImageMagick installed you can run
convert ./page*.png ./output.pdf
to convert images named e.g. page_1.png (example) into a PDF according to its sorting.
- img2pdf, an open-source command line program, is designed to convert images losslessly to PDF. It can also set metadata (such as the title and author) and how the resulting PDF file should be presented by a PDF viewing program.
The following command will take all files in the current folder and convert them into a single PDF named test.pdf
with title and author metadata:
img2pdf --title "My First PDF" --author "Jack Example" --output test.pdf *
Note that this assumes the current directory does not contain non-image files or sub-folders. If all your source files are of a single type, such as JPEGs, you can specify *.jpg
as the input instead. You can also specify multiple input files individually.
See img2pdf --help
for everything img2pdf can do.
img2pdf is available from the Python Package Index and is also included in the repositories of many Linux distributions. A Windows executable is also available via the project's Appveyor.
- ImageMagick and GraphicsMagick can also be used to convert images to PDF files, if GhostScript is installed.
The following command will use ImageMagick's mogrify tool to convert all JPEG files to individual PDF files and place them in a subfolder named "pdf":
mogrify -format pdf -path pdf/ *.jpg
On some Linux distributions, the default ImageMagick security policy will block the program from handling PDF files. See this StackOverflow question for how to change the security policy.
白黒画像からPDFを作成
文字などのシンプルな要素しか含まれていない文書は内容を明確に表示するために2色しか必要とせず、白黒画像(白と黒の2色からなる画像)はスキャナーで読み取ったこれらの文書を保存するときに利用できる効率のいい形式です。白黒のテキストページはたとえ高品質な場合でもサイズが数十キロバイトしかならないことが多いです。
There are two bitonal compression methods used in PDF files, namely the CCITT Group 4 Fax compression and the JBIG2 compression. The latter is more efficient but has some perceived patent issues associated with it, resulting in JBIG2 encoding functionality often being missing or disabled in PDF creation software. However, it is sometimes possible to enable such functionality by installing the encoder yourself.
There are a number of tools for converting images to use bitonal compression. ScanTailor-Universal is an open-source tool for processing scanned pages that can output bitonal images. ImageMagick and GraphicsMagick are also able to do this with the -threshold
option.
下記のImageMagick用コマンドは特定のフォルダに含まれるすべての.jpgファイルをCCITTグループ4圧縮で白黒のTIFファイルに変換し、「bitonal」という名前のフォルダに保存します。
mogrify -format tif -compress Group4 -path bitonal/ -threshold 50% *.jpg
-threshold
の値を試行錯誤して、良い品質の画像が出力される値にしてください。
JBIG2への変換
OCRmyPDF is an open-source command line program mainly designed to add an OCR text layer to scanned PDF files. One of its additional features is its ability to optimize PDF files, which includes the conversion of other bitonal image formats to JBIG2. This requires the installation of the jbig2enc encoder. Compilation and installation instructions for Linux users are available here, and a third-party Windows executable is available here. The MacOS version packaged in Homebrew already includes jbig2enc.
See here for how to install OCRmyPDF on Windows. Many Linux distributions come with an OCRmyPDF package included in the repositories, though this may be outdated. OCRmyPDF is also available on pip.
The following command uses OCRmyPDF to add an OCR text layer to a PDF and arranges the PDF in a way that allows a web browser to start displaying it before it has been fully downloaded:
ocrmypdf --output-type pdf --fast-web-view 0 test.pdf test-OCR.pdf
OCRmyPDF by default losslessly optimizes the PDF, so bitonal images are automatically converted to JBIG2 if jbig2enc is installed.
If you want to skip the OCR process because you don't need to OCR the PDF, use --tesseract-timeout 0
to skip OCR altogether.
OCRmyPDFのドキュメントにも使用例があるので参照してください。