User:Manetta/Booklet.sh

From XPUB & Lens-Based wiki
< User:Manetta
Revision as of 16:22, 21 November 2023 by Manetta (talk | contribs)

The script below uses curl, pandoc, weasyprint, pdfbook2 and Booklet-stylesheet.css as a stylesheet to render a PDF from a wiki page.

# insert your wiki page below, between the quotes
WIKIPAGE=""

# first download the wiki page in wikitext to a local file
curl https://pzwiki.wdka.nl/mediadesign/$WIKIPAGE?action=raw > $WIKIPAGE.mediawiki

# then convert this file into a HTML page, using the stylesheet at https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css
pandoc --from mediawiki --to html $WIKIPAGE.mediawiki --css https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw --output $WIKIPAGE.html

# then turn the HTML page into a PDF with weasyprint
weasyprint $WIKIPAGE.html --stylesheet https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw $WIKIPAGE.pdf

# and finally, turn the PDF into an A5 booklet PDF for printing
# pdfbook2 is part of the texlive-extra-utils package in Debian
pdfbook2 --paper=a4paper --short-edge --no-crop $WIKIPAGE.pdf