DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:dw2pdf

This is an old revision of the document!


DW2PDF Plugin

Compatible with DokuWiki

2016-06-26, Weatherwax, Binky, Ponder Stibbons, Hrun,Detritus, Frusterick Manners

plugin Export DokuWiki content to PDF

Last updated on
2017-11-15
Provides
Action, Render
Repository
Source
Conflicts with
inlineeditor, subjectindex

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to bookcreator, ebookexport, html2pdf, pdfex, xslfo

Tagged with export, pdf

Needed for bookcreator, pdftools

Previous developer: Luigi Micco

Download and Installation

Download and install the plugin using the bundled Extension Manager using the URL given above. Refer to Plugins on how to install plugins manually.

:!: The plugin can't be installed through the plugin manager on pre-Angua releases, because it's too big and the plugin manager will fail while downloading. Please install it manually and make sure the installed directory is named dw2pdf.

Only PHP 5.6 and newer are supported by dw2pdf plugin.

To export images with an alpha channel (used for transparency), you need to install the GD library for PHP. For example on Debian systems:

sudo apt-get install php5-gd

Also see the PHP with gd tips page.

Recent Changes

Overview

The goal of this plugin was to provide a simple, ready-to-go PDF converter that almost faithfully replicates the screen view of your wiki pages (i.e. doesn't convert them to a print-document format like the latex plugin). It also bundles the necessary fonts and libraries (hence the 48MB size) so that you should not need to do any configuration to get it up and running as quickly as possible.

Features

  • Uses the mPDF PHP library.
  • Handles different languages (it bundles the large, but relatively complete Unicode font).
  • Easy customizing through headers, footers and CSS
  • Automatic index of bookmarks
  • Use with the BookCreator plugin to create a PDF from only the pages selected.

Since July 2017 version 7.0-beta of mPDF library is included, which supports PHP7, but not PHP 5.4 and older.

As (temporary) fallback the following old releases could be found:

  • Since 11 June 2015 version 6.0 of the mPDF library was included. This should significantly improve the styling possibilities. However there could also be regressions.
    Release based at previous mPDF 6.0 version – dw2pdf Plugin with mPDF 6.0.0.zip (50 MB)
  • Release based at previous mPDF 5.7.4 version – dw2pdf Plugin with mPDF 5.7.4.zip (12 MB)

Usage

There are three ways to export:

  • Export one page
    You simply need to call the page with an additional do=export_pdf URL parameter. This starts the PDF export of the page. Some templates let the plugin extend the pagetools automatically. For other templates you need to implement this yourself to add a button or similar somewhere in your template design.
  • Export an entire namespace
    There is the URL parameter do=export_pdfns which let you export a chosen entire namespace as one PDF. Create a link with the syntax.
  • Export selection of pages
    If you need to select just some pages to export to one PDF, you can use Bookcreator plugin, which offers an interface for the dw2pdf plugin.

HowTo's

Please refer to the following pages to learn how to use or support the plugin:

Syntax

To create a link in any wiki page to export any namespace, you can use the following syntax: ~~PDFNS>namespace|pdftitle~~

  • namespace is the namespace you want to export
  • pdftitle is the title of the generated output PDF
  • You can add further options (like &book_order=pagename) by simply appending them to the pdftitle.

Handling of startpages: If the page <namespace>:start doesn't exist, it checks if the page with the name <namespace> exists and will add to the pdf as well.

Issues and Requests

Please report issues and requests in the issue tracker: https://github.com/splitbrain/dokuwiki-plugin-dw2pdf/issues/

How to collect more debug info?

If you are using the dw2pdf plugin and you don't get the wanted output, than you might investigate the data during its workflow. The dw2pdf plugin uses the HTML code of the print version of an wiki article (which has a leaner styling than the screen version) and converts this code with the mPDF-library to a pdf-file.

Some options to investigate with the intermediate results are:

  1. Look at the print preview of an article via the print preview function of your browser
  2. Output the plain html for manually testing or reading.

How-to output the plain html (just before it is fed into the mPDF library):

  1. Enable the debugging mode of the wiki with the allowdebug setting (see also debugging)
  2. Add url-parameter to the url used to initiate your pdf-export (copy and modify the link of the button or url you use):
    • Adding &debughtml=text displays html as plain text in the browser
    • Adding &debughtml=html displays html rendered by the browser

See for the debugging options of the mPDF library related to images: images documentation of mPDF.

Sites using this plugin

Other info

Linked Images

Not all image format variations are successfully embedded in the PDF, even if they are properly displayed in DokuWiki. If you get missing images in your output, try stripping the Alpha channel of your (e.g. PNG) images.

  • The mPDF library used by this plugin for building the pdf requires the GD library for processing .png images with alpha channels.

If using full http links, make sure the permissions are set up for retrieving the image directly (test in a browser). DokuWiki may prevent outside access to images in the data/media directory.

Password protection of generated documents

To set fixed password for generated documents, edit:

dokuwiki/lib/plugins/dw2pdf/mpdf/config.php

and add following lines:

$this->setUserRights();
$this->SetProtection(array('print','copy', 'modify'),'password','password');

where password is your password :) (filips)

iPhone/iPad

When using with an iPhone/iPad disable the setting: Seiten mit gzip komprimiert ausliefern otherwise this plugin will not generate PDF-Files on iPhone/iPad.

Discussion

Linked Images

Is it possible to somehow add a tutorial for how to get external embedded images into the pdf? i'd really appreciate that.

Date format example

An example for the footer HTML placeholder / variable to show just the Year so that you can add a dated copyright notice : &copy; Your Company Name @DATE(@DATE@,%Y)@?

Is there a way to disable all hyperlinks in the pdf export? The pdf contains internal wiki links that the client can't access (as the wiki is for internal use only).

The only way I have found is to modify the file mpdf.php:

lib/plugins/dw2pdf/mpdf/mpdf.php
    /**
     * add this after line 8816
     */
                                $annot='';

Styling and sizing the box that appears when hovering over the TOC in the pdf

I see a huge yellow box with a number in it when hovering over the TOC in the PDF. I'd like to make it smaller, and less yellow and put some useful information in it or turn it off but I've not found how to do this.

plugin/dw2pdf.1511133824.txt.gz · Last modified: 2017-11-20 00:23 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki