Extension:PdfHandler
PdfHandler リリースの状態: 安定 |
|
---|---|
実装 | メディア |
説明 | Allows to handle PDF files like multipage DJVU |
作者 | Martin Seidel (xarax) |
互換性の方針 | MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。 |
MediaWiki | >= 1.43 |
データベースの変更 | いいえ |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | |
例 | |
|
|
四半期ごとのダウンロード数 | 228 (Ranked 26th) |
使用中の公開ウィキ | 3,575 (Ranked 185th) |
translatewiki.net で翻訳を利用できる場合は、PdfHandler 拡張機能の翻訳にご協力ください | |
Vagrant role | pdfhandler |
問題点 | 未解決のタスク · バグを報告 |
The PdfHandler extension shows uploaded PDF files in a multipage preview layout.[1]
Together with the Proofread Page extension, PDF files can be displayed side-by-side with text. This allows users to transcribe books and other documents.[2]
使用法
- A user can display PDF files as an image, showing a single page at a time, like so:
[[File:myPdfFile.pdf|page=1|600px]]
. The page and size parameters are optional; the default page is page #1. Instead of a size-parameter, you can also use the thumb-parameter, with or without captions:[[File:myPdfFile.pdf|page=1|thumb|My PDF]]
.[3] - Because PdfHandler extends ImageHandler, you can use all the arguments that you would for an Image -- for example: thumb, right/left, caption, border, link, etc.
- If you would like to present a 2-page pdf, for example, do the following:
[[File:myPdfFile.pdf|page=1]] [[File:myPdfFile.pdf|page=2]]
- The main usage of the PdfHandler extension is without user interaction. If you upload a new pdf file, the metadata will be stored in the database, and then this file can be shown in a multipage preview layout like the djvu handler does. Without this extension, pdfs will not display properly when uploaded.
- Additionally, this extension allows Extension:ProofreadPage to handle pdfs in side-by-side view for transcribing/proofreading, as is done on Wikisource
前提条件
This extension requires the following packages to be installed first:
Package | Description | Link |
---|---|---|
ghostscript
|
Renders the page images.
It provides the command |
www.ghostscript.com |
imagemagick
|
Does dynamic resizing and thumbnailing of images.
It provides the command |
www.imagemagick.org |
xpdf-utils or poppler-utils
|
Extracts metadata from PDF files. If you see "0 × 0 pixel" on the file description of a PDF, you lack this package.
It provides the command |
www.xpdfreader.com
On Ubuntu and Debian, the "poppler-utils" package can be used instead of "xpdf-utils". |
Type the following in your shell to see if you have the above installed first (it should list 4 rows):
which gs convert pdfinfo pdftotext
If something is missing, install the related packages. Example in Debian and Ubuntu:
sudo apt install ghostscript imagemagick xpdf-utils
If you are unable to install these packages, kindly contact your server administrator for assistance in your environment.
インストール
- Make sure that the required software is installed before you continue!
- ダウンロードして、ファイルを
extensions/
フォルダー内のPdfHandler
という名前のディレクトリ内に配置します。
開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfHandler - 以下のコードを LocalSettings.php ファイルの末尾に追加します:
wfLoadExtension( 'PdfHandler' );
- 必要に応じて設定します。 (see also the examples provided)
- 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
設定
You can (or, depending on the operating system of the server, will have to) set some variables in the "LocalSettings.php" file:
$wgPdfProcessor
(default = "gs")- path to your ghostscript implementation
$wgPdfPostProcessor
(default = "convert")- path to your imagemagick convert
$wgPdfInfo
(default = "pdfinfo")- path to your pdfinfo
$wgPdftoText
(default = "pdftotext")- path to your pdftotext
$wgPdfOutputExtension
(default = "jpg")- preferred output format[4]
$wgPdfHandlerDpi
(default = "150" )- resolution in dpi
- The extension extracts a bitmap image for each page of the PDF, using this resolution (dpi = dots per inch). For example, a PDF page with the European size A4 is 210 mm wide, corresponding to 595 points (at 72 dpi). This yields an image 1240 pixels wide (at 150 dpi). If instead this parameter is set to 300 dpi, the width will be 2480 pixels.
$wgPdfHandlerJpegQuality
(default = "95" / since MW 1.24+ )- Quality level, which the post processor should use.
- Variables below are not specific to this extension
- Enable PDF uploads, if you haven't already:
$wgFileExtensions [] = 'pdf';
- Enable ImageMagick, if you haven't already:
$wgUseImageMagick = true;
$wgMaxShellMemory
- memory limit for gs, convert and pdfinfo. The default value might be too low.
Ubuntu
注: This is identical to the default settings for this extension.
$wgPdfProcessor = 'gs';
$wgPdfPostProcessor = $wgImageMagickConvertCommand; // if defined via ImageMagick
// $wgPdfPostProcessor = 'convert'; // if not defined via ImageMagick
$wgPdfInfo = 'pdfinfo';
$wgPdftoText = 'pdftotext';
Debian
$wgPdfProcessor = '/usr/bin/gs';
$wgPdfPostProcessor = $wgImageMagickConvertCommand; // if defined via ImageMagick
// $wgPdfPostProcessor = '/usr/bin/convert'; // if not defined via ImageMagick
$wgPdfInfo = '/usr/bin/pdfinfo';
$wgPdftoText = '/usr/bin/pdftotext';
Windows
$wgPdfProcessor = 'C:\Program Files\gs\gs8.60\bin\gswin32.exe';
$wgPdfPostProcessor = $wgImageMagickConvertCommand; // if defined via ImageMagick
// $wgPdfPostProcessor = 'C:\Program Files\ImageMagick-6.6.2-Q16\convert.exe'; // if not defined via ImageMagick
$wgPdfInfo = 'C:\Program Files\xpdf-3.02pl1-win32\pdfinfo.exe';
$wgPdftoText = 'C:\Program Files\xpdf-3.02pl1-win32\pdftotext.exe';
macOS
$wgPdfProcessor = '/usr/local/bin/gs';
$wgPdfPostProcessor = $wgImageMagickConvertCommand; // if defined via ImageMagick
// $wgPdfPostProcessor = '/usr/local/bin/convert'; // if not defined via ImageMagick
$wgPdfInfo = '/usr/local/bin/pdfinfo';
$wgPdftoText = '/usr/local/bin/pdftotext';
トラブルシューティング
- General issues
- If PDF files do not display after upload, make sure that MediaWiki can execute the pdfinfo command and that configuration parameter
$wgPdfInfo
is set properly. Also check your error log, and make sure that your host hasn't disabled running external commands. - If PDF files do not show properly after installation (for example saying 0 height and width) you may need to use the maintenance scripts "refreshImageMetadata.php -f" and "rebuildImages.php"
- Example:
php refreshImageMetadata.php --mime application/pdf --force
- Also try to purge the page of the file. See Manual:Purge.
- If PDF files are rendered randomly check if the "C.UTF-8" locale is available on your server by running
locale -a
and make sure that configuration parameter $wgShellLocale is set to this locale. - If the main preview image of PDF files is broken (image not found by browser), but all other images are working, also check your configuration parameter $wgShellLocale . If it is set to a locale that does not use the point
.
as a decimal separator (e.g. "de-de", which use a comma), thesrcset
for theimg
tags will be broken. MediaWiki strongly recommends to use the "C.UTF-8" locale.
- Special solutions for Windows Server running MW 1.31.x
If you are running this extension on a windows machine with PHP 7, please see Tommeyheyser's workaround description.
If you are having pdfoinfo and/or pdftotext hanging issue that prevents a big PDF upload, please check the modified extension by SeongMoon
注記
- ↑ PROBABLY not required any more: with WebStore enabled, the extension automatically generates images from the specified page
- ↑ This allows users to transcribe books and other documents as is commonly done with DjVu files (particularly in Wikisource).
- ↑ This single page option was introduced quite long ago (r25575)
- ↑ This does not preclude rendering to other formats, as the picture is served in a format determined by the extension (suffix) in its
src=
path, not by$wgPdfOutputExtension
. The server-side choice can be overridden with a user script – see example.
関連項目
- http://wiki.4intra.net/PdfHandler — a fork with much faster thumbnail generation by using pdftocairo instead of ghostscript+imagemagick
- Extension:Proofread Page — may be used in conjunction with PdfHandler
- How to use DjVu with MediaWiki
- Extension PDFEmbed
この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |
この拡張機能は以下のウィキ ファーム/ウィキ ホスト/パッケージに含まれています: これは正式な一覧ではありません。 一部のウィキ ファーム/ウィキ ホスト/パッケージは、ここに記載されていなくてもこの拡張機能を含んでいる場合があります。 必ずご利用のウィキ ファーム、ウィキ ホスト、バンドルで確認してください。 |
- Extensions bundled with MediaWiki 1.21/ja
- Stable extensions/ja
- Media handling extensions/ja
- GPL licensed extensions/ja
- Extensions in Wikimedia version control/ja
- All extensions/ja
- Extensions used on Wikimedia/ja
- Extensions included in BlueSpice/ja
- Extensions included in Canasta/ja
- Extensions available as Debian packages/ja
- Extensions included in Fandom/ja
- Extensions included in Miraheze/ja
- Extensions included in MyWikis/ja
- Extensions included in ProWiki/ja
- Extensions included in semantic::core/ja
- Extensions included in ShoutWiki/ja
- Extensions included in Telepedia/ja
- Extensions included in wiki.gg/ja
- Extensions included in WikiForge/ja
- Transcription extensions/ja
- PDF extensions/ja