Extension:PdfBook

(Redirected from Extension:Pdf Book)
MediaWiki extensions manual
PdfBook
Release status: stable
Implementation Data extraction
Description Composes a book from articles in a category and exports as a PDF file
Author(s)
Latest version 3.1.0 (2023-08-10)
Compatibility policy For every MediaWiki release that is a Long Term Support release there is a corresponding branch in the extension.
MediaWiki 1.39+
PHP 7.4.x
Database changes No
License GNU General Public License 2.0 or later
Download

  • $wgPdfBookTab
  • $wgPdfBookDownload

The PdfBook extension composes a book from pages in a category and exports them as a PDF file.

Overview

edit

Categories are a good way of organizing many articles comprising a book. One can use the sort keys in the "pages" categorization statements to ensure they are correctly ordered. This extension allows such categories to be compiled into downloadable PDF files with a table of contents, each page forming the start of a new chapter.

Usage

edit

The PDF creation is initialized by the "pdfbook" action, so a category can be downloaded as a PDF book directly from a link such as:

https://www.example.org/wiki/index.php?title=Category:foo&action=pdfbook

A more generic way of creating the link is to use the "fullurl" parser function and {{FULLPAGENAME}} variable as in the following example:

[{{fullurl:{{FULLPAGENAME}}|action=pdfbook}} download this selection of pages as a PDF book]

This link can then be added to a template which can be transcluded into any category or page suitable for downloading as a book. For an example of such a template, see OrganicDesign:Category:I am that, which uses OrganicDesign:Template:Book to display the message and download link.

In order to include this parser function link automatically to every category page, add it to the Mediawiki:Category-article-count page.

This extension also allows books to be generated from non-category pages as well. If the page to be downloaded as a book is not a category, then the extension will extract the titles from page links in a bullet list. The list may be explicitly defined, or may be the result of a query. For an example of this functionality, see Creating a PDF book from a DPL query

Raw HTML output

edit

You can download the file as a single HTML document by setting format=html in the query-string. Example:

https://www.example.org/wiki/index.php?title=Main_Page&action=pdfbook&format=html

Single page exports

edit

You can export a single page as a one-page PDF by setting format=single in the query-string. Example:

https://www.example.org/wiki/index.php?title=Main_Page&action=pdfbook&format=single

Page Breaks

edit

You can add page breaks into your book by adding <!-- PAGE BREAK --> into the relevant places in the content pages.

Installation

edit

Configuration

edit

This extension provides the following configuration parameters, which should be added below invoking the extension in your "LocalSettings.php" file:

Variable Default value Meaning
$wgPdfBookTab false Defines whether or not an action tab is wanted for printing to PDF
$wgPdfBookDownload true Defines whether or not the files should be downloaded or viewed in-browser

Limitations

edit
  • UTF-8 support of HTMLDOC is limited to the first 128 Unicode characters found in the input.

See also

edit