Help:PDF/ja
- (en) PDF
Wikidata contains data entry Q42332 related to these Wikipedia articles.
PDF is a file format of documents. This page shares some tips on using PDF.
Searching for PDFs in Wikimedia Commons
Try the search button above to limit search results to PDF. This is achieved by including filemime:pdf
in search keywords.
Using PDF within Wikimedia projects
Page
Normally page 1 from a PDF or DjVu file is used to generate the thumbnail. A different page can be used with the parameter |page=
: [[File:IMSLP01578-Ravel - Bolero Full Score Durand 1929.pdf|thumb|page=2|''Boléro'': page 2 from the score]]
:
PDF software
See the list of PDF software. For example, you could use the free software Okular to read PDFs, LibreOffice Draw to edit PDFs, and ImageMagick to manipulate PDFs.
PDFを作成
Processing images obtained from scanners
Images obtained from scanners usually require some processing before making a PDF or DJVU out of them: cropping, turning, splitting, reducing the size, converting to TIFF etc. The open-source application ScanTailor-Universal is designed for this purpose. It can be downloaded from the project's releases page.
画像から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.
Creating PDF from bitonal images
Bitonal images (i.e. images that only contain a single shade of black and white) are a very efficient way of storing scanned documents that only contain text or other simple elements that only need two colors to be clearly represented. A high-quality bitonal text page is commonly only tens of kilobytes in size.
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.
The following ImageMagick command converts all .jpg files in a folder into bitonal TIF files using Group 4 compression and places them into a folder named "bitonal":
mogrify -format tif -compress Group4 -path bitonal/ -threshold 50% *.jpg
Play around with the value of -threshold
to find one that produces good results with your content.
JBIG2 conversion
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.
See OCRmyPDF's documentation for further usage examples.