Extension:DownloadBook

Category:Extensions without an imageCategory:GPL licensed extensions
MediaWiki extensions manual
DownloadBook
Release status: betaCategory:Beta status extensions
Implementation Special page Category:Special page extensions
Description Allows extension Collection to convert books/pages into PDF, etc. locally
Author(s) Edward Chernenkotalk
Latest version 0.1.0
Compatibility policy Master maintains backward compatibility.Category:Extensions with master compatibility policy
MediaWiki 1.39+Category:Extensions with manual MediaWiki version
Database changes Yes
Tables bookrenderingtask
License GNU General Public License 2.0 or later
Download Category:Extensions in GitHub version control
  • $wgDownloadBookConvertCommand
  • $wgDownloadBookFileExtension
  • $wgDownloadBookMetadataFromRegex
  • $wgDownloadBookDefaultMetadata
Category:All extensions

The DownloadBook extension allows extension Collection to generate PDF files without a local or external MWServe server.

It can use third-party utilities such as pandoc (for ePub, ODT, etc.) or WeasyPrint (for PDF). They exist as packages in many Linux distributions.

Installation

The Collection extension needs to be installed for this extension to work. Moreover, depending on which output formats are chosen also pandoc (for ePub, ODT, etc.) and/or WeasyPrint (for PDF).

Advanced configuration

You can modify the conversion commands in "LocalSettings.php", for example:

$wgDownloadBookConvertCommand['epub'] = "pandoc --from=html --to=epub {INPUT} -o {OUTPUT}";

Please see the file "extension.json" for other configuration options. Also note that keys in $wgDownloadBookConvertCommand array are the same formats as in Collection (i.e. $wgDownloadBookConvertCommand['rl'] is the command for PDF).

Installing third-party conversion tool is your own risk and responsibility. This extension simply calls that tool, and then provides the result to extension Collection.

Using custom CSS when generating PDF

When using weasyprint to generate PDF, custom CSS can be specified with the --stylesheet parameter.

$wgDownloadBookConvertCommand['rl'] = "weasyprint --stylesheet \"https://example.com/wiki/MediaWiki:Print.css?action=raw&ctype=text/css\"  --stylesheet \"https://example.com/load.php?lang=fr&modules=site.styles&only=styles&printable=1\" --encoding utf8 {INPUT} {OUTPUT}";

Troubleshooting

Add the following to your "LocalSettings.php":

$wgDebugLogGroups['DownloadBook'] = '/path/to/writable/logfile.txt';
IMPORTANT: 99,9% of issues are caused by incorrect installation of pandoc, permission errors, etc. You will see the cause in the log. Developer of this extension is NOT going to troubleshoot your server configuration for you.
Category:PDF extensions
Category:All extensions Category:Beta status extensions Category:Extensions in GitHub version control Category:Extensions with manual MediaWiki version Category:Extensions with master compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:LoadExtensionSchemaUpdates extensions Category:PDF extensions Category:Special page extensions Category:UserGetReservedNames extensions