Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

GeneratePDF

Summary: Generate PDF versions of pages (?action=pdf)
Version: 2006-09-07
Prerequisites: PmWiki >=2.1.0, htmldoc >=1.8.27
Status: Stable
Maintainer: Pm
Categories: PDF

Questions answered by this recipe

  • Can I generate a PDF file on the fly from a wiki page?

Description

The htmldoc package combined with the generatepdf.phpΔ script adds an ?action=pdf option that will generate PDF copies of a wiki page.

Notes

First, download and install htmldoc onto your system, and download and install the generatepdf.phpΔ script into your cookbook directory.

Next, tell the GeneratePDF script where to find the htmldoc command on your system:

    $HtmlToPdfCmd = '/path/to/htmldoc -t pdf --quiet --webpage';
    include_once('cookbook/generatepdf.php');

That's it! Using ?action=pdf on your pages should result in PDF versions of the file. For example, you can try it on this page with Cookbook.GeneratePDF?action=pdf.

By default, GeneratePDF uses PmWiki's 'print' skin to format the page; this can be changed by setting

    $ActionSkin['pdf'] = 'myskin';

Comments

  • Watch the "--quiet" option with older versions of HTMLDOC. I use 1.8.7, where this option is implicit; requiring you to call "--verbose" instead. The wrong option leads to the system sending its help message, which does not create a PDF. BenWilson May 02, 2007, at 09:44 AM
  • I obtain the PDF file, but with php extension! This way users have to rename manually files after saving. I obtatin always pmwiki.php .
    MassimilianoVessi 24 Sept 2007
You could add this after line 46 in generatepdf.php :
header("Content-Disposition: attachment; filename=$pagename.pdf");

Nicolas Poulain 26 April 2008

I have downloaded the software (htmldoc) in 2 different versions (both complete and exe files). Unfortunately, neither one is recognized (the install wasn't because I had to purchase a license and the complete package didn't respond to any queries). Is there something in the works that will convert our PMWiki files into pdf? -Chris (August 25, 2008)

Test with an image

See Also

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on August 29, 2008, at 06:43 AM