Benutzer:Dirk Hünniger/wb2pdf/install

Aus Wikibooks
Zur Navigation springen Zur Suche springen

Installation on Ubuntu[Bearbeiten]

sudo apt-get install mediawiki2latex
mediawiki2latex

Currently version 7.39 is available from the Ubuntu package repositories.

Installation on Debian[Bearbeiten]

mediawiki2latex 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 install mediawiki2latex version 7.33 in Stretch. Please install mediawiki2latex version 7.25 first by typing (as root).

apt-get install mediawiki2latex

Then install the build time dependencies (as root).

apt-get install ghc libghc-x509-dev libghc-pem-dev
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 

Download mediawiki2latex version 7.44 from sourceforge Download Link. Extract the archive and run (as root in the directory in which you extracted the archive from sourceforge)

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.

To install (if needed):

apt-get install imagemagick

Edit permissions (as root) /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.

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 avoid standard CentOS repository packages. Specifically the standard CentOS standard "epel" (Extra Packages for Enterprise Linux) repository contains ghc, cabal-install, and texlive, howwever, 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 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
  • Download and install the latest LaTex from: http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz. This installer is a "live" install (it downloads install content as the install runs).
  • 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 rechead using docker

Dockerfile:

FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y tzdata keyboard-configuration make
RUN apt-get install -y ghc libghc-x509-dev libghc-pem-dev
RUN apt-get install -y libghc-regex-compat-dev libghc-http-dev cabal-install libghc-hxt-dev
RUN apt-get install -y libghc-split-dev libghc-blaze-html-dev libghc-file-embed-dev
RUN apt-get install -y libghc-highlighting-kate-dev  libghc-hxt-http-dev libghc-regex-pcre-dev
RUN apt-get install -y libghc-temporary-dev libghc-url-dev libghc-utf8-string-dev
RUN apt-get install -y libghc-utility-ht-dev libghc-http-conduit-dev libghc-happstack-server-dev
RUN apt-get install -y libghc-directory-tree-dev libghc-zip-archive-dev libghc-strict-dev
RUN apt-get install -y libghc-network-uri-dev libghc-tagsoup-dev libghc-word8-dev
RUN apt-get install -y ghostscript calibre latex2rtf libreoffice git 
RUN apt-get install -y librsvg2-bin imagemagick
RUN apt-get install -y  fonts-freefont-ttf texlive-xetex texlive-latex-recommended
RUN apt-get install -y  texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra
RUN apt-get install -y  cm-super-minimal texlive-lang-all poppler-utils
RUN apt-get install -y  lmodern texlive-plain-generic latex-cjk-common
RUN apt-get install -y  fonts-cmu fonts-wqy-zenhei
RUN apt-get install -y  djvulibre-bin
RUN apt-get install -y mediawiki2latex tzdata
RUN apt-get install -y make
RUN git clone https://git.code.sf.net/p/wb2pdf/git wb2pdf-git 
RUN make -C wb2pdf-git
RUN make -C wb2pdf-git install
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/