This is an old revision of the document!
Table of Contents
⇐ dw2pdf plugin
PDF Templates
PDF Templates define the design of the created PDF files and are a good way to easily customize them to your Corporate Identity.
The default PDF template which is shipped with the dw2pdf plugin is shown below. It has simple headers, footers and citation box.
To create a new template, just create a new folder within the plugin's
lib/plugins/dw2pdf/tpl/
folder and put your header, footers, cover page, and style definitions in it. See lib/plugins/dw2pdf/tpl/default
for an example. Do not modify the template default
, this template will be overwritten on updates, so you will lose your changes.
After creation, you set in the Configuration Manager that your template should be used for exports. Eventually, if you like to change template incidentally, you can use the URL parameter &tpl=<foldername>
.
Default the css is included for the print view (which replaces parts of the screen view to make it leaner - see also Print preview of your browser) of the wiki-template and the active plugins. The PDF-templates can override these styles.
Headers and Footers
The following files can be created and will be used to set headers and footers on odd or even pages. Special headers/footers can be used on the first page of a document. If a file does not exist the next more generic one will be tried. E.g. if you don't differ between even and odd pages, just the header.html
is used.
header.html
– Header for all pagesheader_odd.html
– Header for odd pagesheader_even.html
– Header for even pagesheader_first.html
– Header for the first page
footer.html
– Footer for all pagesfooter_odd.html
– Footer for odd pagesfooter_even.html
– Footer for even pagesfooter_first.html
– Footer for the first page
citation.html
– Citationbox to be printed after each article
cover.html
– If exists, added once before first pageback.html
– If exists, added once after last page
You can use all HTML that is understood by mPDF (See mpdf.github.io)
If you reference image files from your pdf-template file, be sure to prefix them with the @TPLBASE@
(or for some cases @TPLINC@
) parameter (See Replacements below).
Replacements
The following replacement patterns can be used within the header and footer files.
@PAGE@
– current page number in the PDF@PAGES@
– number of all pages in the PDF (excluded a ToC)@TITLE@
– the article's title@WIKI@
– the wiki's title@WIKIURL@
– URL to the wiki@DATE@
– time when the PDF was created (might be in the past if cached)@BASE@
– the wiki base directory@TPLBASE@
– the URL base of PDF-template directory (use to reference images) (e.g./[wikiURLbase]/lib/plugins/dw2pdf/tpl/<yourtplfolder>/
)@TPLINC@
– the absolute path to the PDF template directory on the filesystem (e.g./var/www/dokuwiki/lib/plugins/dw2pdf/tpl/<yourtplfolder>/
)@INC@
– the absolute wiki install directory on the filesystem@DATE(<date>[, <format>])@
– formats the given date with dformat or with the given format such as%Y-%m-%e
, e.g. this would give just the current year@DATE(@DATE@,%Y)@
Remark about Bookcreator:
The next page dependent replacements are only for citation.html
updated for every page.
In the headers and footers the ID of the bookmanager page of the Bookcreator is applied.
@ID@
– The article's pageID@PAGEURL@
– URL to the article@UPDATE@
– Time of the last update of the article@QRCODE@
– QR code image pointing to the original page url (requires an online generator on https://quickchart.io, see qr_code config setting). On a closed LAN-network, this could result in timeouts, Error 504)
Styles
Custom stylings can be provided in the following file of your pdf-template folder:
[wikibase]/lib/plugins/dw2pdf/tpl/<yourpdftplfolder>/style.css
You can use all the CSS that is understood by mPDF
(See https://mpdf.github.io/css-stylesheets/supported-css.html)
Style sheets loaded by dw2pdf
Some background about css file loading. The dw2pdf loads the print style sheets of the wiki including these of plugins to get a leaner appearance of the article. A first impression can be gotten by looking in the print preview of your browser. Note that due to limitations of the mPDF-library, the final pdf can look different.
During the generation of the pdf the following files are tried to load in the given order:
lib/styles/screen.css
lib/styles/print.css
- per plugin:
- only if requested in config setting
plugin»dw2pdf»usestyles
:lib/plugins/<plugin>/screen.css
andscreen.less
lib/plugins/<plugin>/style.css
andstyle.less
lib/plugins/<plugin>/all.css
andall.less
- if exists:
lib/plugins/<plugin>/pdf.css
andpdf.less
- if pdf.css/pdf.less not exists:
lib/plugins/<plugin>/print.css
andprint.less
- for the active template:
lib/tpl/<template>/pdf.css
andpdf.less
lib/tpl/<template>/css/pdf.css
andpdf.less
lib/tpl/<template>/styles/pdf.css
andpdf.less
lib/plugins/dw2pdf/conf/style.css
(overwritten on each plugin update)lib/plugins/dw2pdf/tpl/<pdf-template>/style.css
(note that the supplied example pdf-template “default” is overwritten on each plugin update, so rename/copy that pdf-template folder before making changes)lib/plugins/dw2pdf/conf/style.local.css