Benutzer:Dirk Hünniger/wb2pdf/install

General Remarks for all Operating Systems Bearbeiten

Use the Latest Version Bearbeiten

MediaWiki changes quickly, requiring frequent updates to mediawiki2latex. But the version in the operating systems repositories usually is not the latest version as found on the sourceforge website. So we generally recommend that you update to the latest version as described below in the installation instructions for Debian.

Install Enough Memory Bearbeiten

Mediawiki2latex makes quite heavy use of memory. We recommend a host system with at least 8 GByte. This should be OK for documents of up to 100 pages of its output format. If LaTeX or PDF output is requested in combination with --bookmode, it should suffice for documents of almost arbitrary size. In all other cases the rule of thumb is 32 GByte of memory for 1000 pages of output. If a "killed" message appears in the terminal which you are running mediawiki2latex on, this usually means the available memory has been used up.

Installation on Ubuntu Bearbeiten

sudo apt-get install mediawiki2latex
mediawiki2latex

Currently version 7.47 is available from the Ubuntu package repositories.

Configure Image Magicks access rights as described in the section on Debian below.

Installation on Debian Bearbeiten

mediawiki2latex 7.25 is included in the Debian Stretch distribution and works out of the box, but the output is limited to a few pages. To work around this problem you should upgrade mediawiki2latex to version 7.44, once you have installed it from the Stretch repository. You will also need to ensure that ImageMagick is installed and configured.

To install version 7.25 from the Stretch repository, enter (as root).

 apt-get install mediawiki2latex

Install the gnu unifont package at least version trixie:

 https://packages.debian.org/trixie/all/fonts-unifont/download

Then install the build-time and run-time dependencies (as root):

 apt-get install ghc libghc-x509-dev libghc-pem-dev chromium chromium-sandbox
 apt-get install libghc-regex-compat-dev libghc-http-dev cabal-install libghc-hxt-dev
 apt-get install libghc-split-dev libghc-blaze-html-dev libghc-file-embed-dev
 apt-get install libghc-highlighting-kate-dev  libghc-hxt-http-dev libghc-regex-pcre-dev
 apt-get install libghc-temporary-dev libghc-url-dev libghc-utf8-string-dev
 apt-get install libghc-utility-ht-dev libghc-http-conduit-dev libghc-happstack-server-dev
 apt-get install libghc-directory-tree-dev libghc-zip-archive-dev libghc-strict-dev
 apt-get install libghc-network-uri-dev libghc-tagsoup-dev libghc-word8-dev
 apt-get install ghostscript calibre latex2rtf libreoffice curl texlive-extra-utils
 apt-get install pdftk

To upgrade to version 7.44:

  1. Download mediawiki2latex version 7.44 from sourceforge: Download Link.
  2. Extract the archive into your directory of choice.
  3. From this directory, run (as root):
   make install

Finally, to enable image conversions, make sure that ImageMagick is installed and that it has permission to transform PS and PDF files to PNG.

Check whether ImageMagick is installed, and if not then run:

 apt-get install imagemagick

Edit permissions (as root) in /etc/ImageMagick-6/policy.xml

 <policy domain="coder" rights="read|write" pattern="PS" />
 <policy domain="coder" rights="none|write" pattern="PS2" />
 <policy domain="coder" rights="none|write" pattern="PS3" />
 <policy domain="coder" rights="none|write" pattern="EPS" />
 <policy domain="coder" rights="read|write" pattern="PDF" />
 <policy domain="coder" rights="read|write" pattern="XPS" /> 

Note that this may entail some risks on a server machine, as explained in this piece on Solution to ImageMagick "not authorized" PDF Error by Bob Cromwell.

When processing large images it might be needed to update the maximum processable image sizes in the same file like this (/etc/ImageMagick-6/policy.xml):

 <policy domain="resource" name="memory" value="8GiB"/>
 <policy domain="resource" name="map" value="8GiB"/>
 <policy domain="resource" name="width" value="100KP"/>
 <policy domain="resource" name="height" value="100KP"/>
 <policy domain="resource" name="area" value="10GP"/>
 <policy domain="resource" name="disk" value="20GiB"/>

Installation on CentOS 7 Bearbeiten

The instructions below apply to CentOS 7 (and likely CentOS 6). The primary concern with a CentOS 7 installation is to avoid the standard CentOS repository packages. Specifically the standard CentOS standard "epel" (Extra Packages for Enterprise Linux) repository contains ghc, cabal-install, and texlive, however, the versions in epel either provide incompatible versions (ghc and cabal) or are missing many components (texlive). Finally there are font dependancies that must be installed in order for MediaWike2LaTex to generate PDFs.

Prepare and Compile MediaWiki2LaTex Bearbeiten

The following versions of GHC, Cabal and Texlive are compatible with MediaWiki2PDF 7.33.

    name=Copr repo for ghc-8.0.2 owned by petersen
    baseurl=https://copr-be.cloud.fedoraproject.org/results/petersen/ghc-8.0.2/epel-7-$basearch/
    type=rpm-md
    skip_if_unavailable=True
    gpgcheck=1
    gpgkey=https://copr-be.cloud.fedoraproject.org/results/petersen/ghc-8.0.2/pubkey.gpg
    repo_gpgcheck=0
    enabled=1
    enabled_metadata=1
    yum disablerepo=epel install ghc cabal-install
    cabal update
    wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
    tar xvzf install-tl-unx.tar.gz
    cd install-tl-[build-date]
      ./install-tl
Note the install-tl texlive is a lengthly install (5+ hours), optionally run the process in the background and disassociate it from the current login session:
nohup sh -c "echo I | ./install-tl" > texlive-install.log 2>&1 &
note the command avoid includes "echo I" for Install which is a required keyboard input to install-tl
nohup will allow the install to run without being logged in.
  • Download and install the latest mediawiki2latex source.
    git clone https://git.code.sf.net/p/wb2pdf/git wb2pdf-git
    cd wb2pdf-git
    cabal install
  • All going well, this will result in a binary wb2pdf-git/dist/build/mediawiki2latex.

Install Fonts Bearbeiten

There are a fonts needed by mediawiki2latex that will not be available through the prior installation steps (e.g. GNU Freefont).

GNU Freefont Bearbeiten

  • wget http://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip
  • unzip freefont-ttf-20120503.zip
  • cd freefont-20120503
  • mkdir /usr/share/fonts/truetype/freefont
  • cp *.ttf /usr/share/fonts/truetype/freefont
  • fc-cache -f /usr/share/fonts
    Note: initiating fc-cache is not explicitly needed, however, this is generally good practice in order to fully register fonts in CentOS

Test Installion Bearbeiten

See validation steps below.

Installation on Windows Bearbeiten

1) Activate Linux Subsystem

  • Go to Control Panel -> Programs -> Turn Windows Features On / Off
  • The Windows Features Dialog will open
  • Scroll to the bottom
  • Enable Windows Subsystem for Linux
  • Press OK

2) Use Docker

  • Follow instructions here

Native Windows Command Line Version Bearbeiten

We also provide an experimental command line version that runs on Windows without needing to install anything. The zip archive containing it, as well as all tools especially miktex, is called MediaWikiToLaTeX.zip . It may be downloaded from:

https://sourceforge.net/projects/wb2pdf/files/mediawiki2latex/7.32/

We do not recommend to use this native command line version but rather propose to follow the above installation instruction. We furthermore were not able to produce any results in recently patched version of the os on 25th of May 2019.

Installation on other OS Bearbeiten

Use Docker

  • Follow instructions here

Using Docker Bearbeiten

Some sucess was reached using docker

Dockerfile:

FROM ubuntu:noble
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y mediawiki2latex
ENTRYPOINT ["mediawiki2latex"]

Which is used like this:

sudo docker image build . -t m2lubuntu 
sudo docker container run --mount src=/home/dirk/2docker,target=/transfer,type=bind -i m2lubuntu -u https://de.wikibooks.org/wiki/Physikalische_Grundlagen_der_Nuklearmedizin/_Atom-und_Kernstruktur -o /transfer/dirk.pdf

Where you have to replace /home/dirk/2docker with you local directory where you want to output file dirk.pdf to be written to.

Installation Diagnostics and Validation Bearbeiten

Diagnostic Steps Bearbeiten

A recommended step to test a mediawiki2latex install is to run the following test:

   mkdir rmtest
   mediawiki2latex -u https://en.wikipedia.org/wiki/Book:River_martin -o rivermartin.pdf -k -c rmtest

If mediawiki2latex appears to finish and generate rivermartin.pdf, then examine rivermartin.pdf, it should be some 84 pages. If a pdf is not generated then:

  • cd rmtest/document/main
  • xelatex main.tex

alternately run

  • xelatex -interaction=nonstopmode main.tex

Review the detailed output of xelatex

Validation Bearbeiten

Given a version of rivermartin.pdf, compare this with the open server generated version of the River_martin test case via http://mediawiki2latex-large.wmflabs.org/