[dokuwiki] pdf export
- From: Heikko Ellermaa <heikko.ellermaa@xxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 30 Aug 2006 12:18:07 +0300
Hi!
I created a simple (well, more or less) solution to get the wiki content
into a pdf file. Now I'm asking for comments, suggestions and a second
opinion.
Here's what worked for me:
1) I donwloaded the "html2ps and html2pdf" PHP library from
http://www.tufat.com/script19.htm. It worked amazingly vell for almost
every html page I tested it with (has image support, loads of options
and so on)
2) Based on the samples in html2pdf I created the attached url2pdf.php
script into 'samples' directory of html2pdf and configured the whole
thing work in my webserver.
3) Now we reach the connection to dokuwiki. In the main.php I added
manually a PDF button (I really could not find a way to create the
button automagically with dokuwiki scripts as these allowed only posting
to dokuwiki itself). So here's the listing of the PDF button code which
I placed right after the History button:
<form class="button" method="get"
action="http://localhost/html2pdf/samples/url2pdf.php"><div
class="no"><input type="hidden" name="url" value="<?=
"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] ?>" /><input
type="submit" value="Save as PDF" class="button" title="ALT+F"
accesskey="f" /></div></form>
4) The result - I have button which prompts me of saving the page as
PDF. Very useful. And quite clean.
So it's kind of a hack, and I am writing because if there's a better way
to create the button and to know the _real_ _absolute_ url for the
current wiki page then please let me know. If you find it any other way
useful or someone can import this to be a dokuwiki feature then this
would be even nicer.
best regards,
Heikko
'print',
'renderimages' => true,
'renderforms' => true,
'renderlinks' => true,
'mode' => 'html',
'debugbox' => false,
'draw_page_border' => false
);
$media = Media::predefined('A4');
$media->set_landscape(false);
$media->set_margins(array('left' => 10,
'right' => 10,
'top' => 10,
'bottom' => 10));
$media->set_pixels(1024);
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
$g_pt_scale = $g_px_scale * 1.43;
$pipeline = new Pipeline;
$pipeline->fetchers[] = new FetcherURL;
$pipeline->data_filters[] = new DataFilterDoctype();
$pipeline->data_filters[] = new DataFilterUTF8("");
$pipeline->data_filters[] = new DataFilterHTML2XHTML;
$pipeline->parser = new ParserXHTML;
$pipeline->pre_tree_filters = array();
$pipeline->layout_engine = new LayoutEngineDefault;
$pipeline->post_tree_filters = array();
$pipeline->output_driver = new OutputDriverFPDF();
$time = time();
$pipeline->destination = new DestinationDownload($url);
$pipeline->process($url, $media);
$message = sprintf("
Processing of '%s' completed in %u seconds", $url, time() - $time);
error_log($message);
flush();
$time = time();
?>
- Follow-Ups:
- [dokuwiki] Re: pdf export
- From: Werner Flamme
Other related posts:
- » [dokuwiki] pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
- » [dokuwiki] Re: pdf export
Hi!
best regards, Heikko
- [dokuwiki] Re: pdf export
- From: Werner Flamme