4 Copyright (C) 2003 Olivier PLATHEY
5 Copyright (C) 200? Don SebĂ
6 Copyright (C) 2004,2006,2007 Reini Urban
8 This file is part of PhpWiki.
10 PhpWiki is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 PhpWiki is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with PhpWiki; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 //define("USE_EXTERNAL_HTML2PDF", "htmldoc --quiet --format pdf14 --jpeg --webpage --no-toc --no-title %s");
27 * handler for format=pdf
28 * http://phpwiki.sourceforge.net/phpwiki/PhpWikiToDocBookAndPDF
29 * htmldoc or ghostscript + html2ps or docbook (dbdoclet, xsltproc, fop)
30 * http://www.easysw.com/htmldoc
32 function ConvertAndDisplayPdfPageList (&$request, $pagelist, $args = array()) {
34 if (empty($request->_is_buffering_output))
35 $request->buffer_output(false/*'nocompress'*/);
36 $pagename = $request->getArg('pagename');
37 $dest = $request->getArg('dest');
38 $request->setArg('dest',false);
39 $request->setArg('format',false);
40 include_once("lib/display.php");
41 include_once("lib/loadsave.php");
43 array_unshift($pagelist->_pages, $request->_dbi->getPage($pagename));
44 require_once("lib/WikiPluginCached.php");
45 $cache = new WikiPluginCached;
47 $tmpfile = $cache->tempnam();
48 $tmpdir = dirname($tmpfile);
51 $WikiTheme->DUMP_MODE = 'PDFHTML';
52 _DumpHtmlToDir($tmpdir,
53 new WikiDB_Array_generic_iter($pagelist->_pages),
54 $request->getArg('exclude'));
55 $WikiTheme->DUMP_MODE = false;
60 * Main action handler: action=pdf
61 * TODO: inline cached content: /getimg.php? => image.png
62 * Just use an external exe.
64 function ConvertAndDisplayPdf (&$request) {
66 if (empty($request->_is_buffering_output))
67 $request->buffer_output(false/*'nocompress'*/);
68 $pagename = $request->getArg('pagename');
69 $dest = $request->getArg('dest');
72 $WikiTheme->DUMP_MODE = true;
73 include_once("lib/display.php");
74 // TODO: urldecode pagename to get rid of %20 in filename.pdf
75 displayPage($request, new Template('htmldump', $request));
76 $html = ob_get_contents();
77 $WikiTheme->DUMP_MODE = false;
79 // check hook for external converters
80 if (defined('USE_EXTERNAL_HTML2PDF')
81 and USE_EXTERNAL_HTML2PDF)
82 { // See http://phpwiki.sourceforge.net/phpwiki/PhpWikiToDocBookAndPDF
83 // htmldoc or ghostscript + html2ps or docbook (dbdoclet, xsltproc, fop)
84 Header('Content-Type: application/pdf');
85 $request->discardOutput();
86 $request->buffer_output(false/*'nocompress'*/);
87 require_once("lib/WikiPluginCached.php");
88 $cache = new WikiPluginCached;
90 $tmpfile = $cache->tempnam('pdf.html');
91 $fp = fopen($tmpfile, "wb");
94 passthru(sprintf(USE_EXTERNAL_HTML2PDF, $tmpfile));
97 // clean the hints errors
99 $ErrorManager->destroyPostponedErrors();
101 if (!empty($errormsg)) {
102 $request->discardOutput();
110 // c-hanging-comment-ender-p: nil
111 // indent-tabs-mode: nil