2 rcs_id('$Id: pdf.php,v 1.13 2007-09-15 12:28:46 rurban Exp $');
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 if (!empty($errormsg)) {
98 $request->discardOutput();
102 // $Log: not supported by cvs2svn $
103 // Revision 1.12 2007/09/12 19:41:38 rurban
104 // Enable format=pdf for pagelists (not yet finished)
106 // Revision 1.11 2007/02/17 14:14:55 rurban
107 // fix pagename for lists
109 // Revision 1.10 2007/01/07 18:44:39 rurban
110 // Add ConvertAndDisplayPdfPageList
112 // Revision 1.9 2006/09/06 06:02:05 rurban
113 // omit actionbar from pdf
115 // Revision 1.8 2006/08/25 22:09:00 rurban
116 // print pdf header earlier
118 // Revision 1.7 2004/09/22 13:46:26 rurban
119 // centralize upload paths.
120 // major WikiPluginCached feature enhancement:
121 // support _STATIC pages in uploads/ instead of dynamic getimg.php? subrequests.
122 // mainly for debugging, cache problems and action=pdf
124 // Revision 1.6 2004/09/20 13:40:19 rurban
125 // define all config.ini settings, only the supported will be taken from -default.
126 // support USE_EXTERNAL_HTML2PDF renderer (htmldoc tested)
128 // Revision 1.5 2004/09/17 14:19:02 rurban
129 // default pdf dest: browser
131 // Revision 1.4 2004/06/14 11:31:37 rurban
132 // renamed global $Theme to $WikiTheme (gforge nameclash)
133 // inherit PageList default options from PageList
134 // default sortby=pagename
135 // use options in PageList_Selectable (limit, sortby, ...)
136 // added action revert, with button at action=diff
137 // added option regex to WikiAdminSearchReplace
139 // Revision 1.3 2004/05/15 19:49:09 rurban
140 // moved action_pdf to lib/pdf.php
147 // c-hanging-comment-ender-p: nil
148 // indent-tabs-mode: nil