Revision [7476]
This is an old revision of WikkaToPDF made by DarTar on 2005-04-22 14:33:19.
Exporting Wiki content to PDF
See also: WikkaFilters
I'm opening this page for a prelilminary discussion on how to generate PDFs from Wiki content.
An appropriate implementation of this feature would probably be a /pdf handler allowing a user to generate a PDF from a given page.
(More generally, an /export handler could give the user the choice about the preferred WikkaFilters export format). There are several GPL-licensed Java and php solution for generating PDFs on the fly.
Some useful references
- FPDF
a PHP class, which allows to generate PDF files without using the PDFlib library.
- FOP (Formatting Objects Processor)
(GPL) is the world's first print formatter driven by XSL formatting objects (XSL-FO) and the world's first output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PCL, PS, SVG, XML (area tree representation), Print, AWT, MIF and TXT. The primary output target is PDF.
- XWiki PDF Export
An implementation of FOP for XWiki.
Discussion
Hi James. Any progress on generating a PDF file output from wikka? -- Mike Bowen (GmBowen)- Sorry Mike, no progress as yet as I've got other things to do at the moment. My lack of programming skills doesn't help although I have had success using the class without wikka. It shouldn't be too difficult though. Basically you have a file which includes the FPDF Class and queries the database. The problem is restricting the results to the latest page and presumably reversing the wikka markup to show bold etc. I could e-mail you an example file if you would like, need your e-mail address though.
- Have a look at this example Mike.
As you can see it picks the Page Name and Content fromm the database alright. The script needs a little refinement to format the page layout correctly and as I said earlier to restrict the results set from the sl query. The code is below.
<?php define('FPDF_FONTPATH','font/'); require('mysql_table.php'); class PDF extends PDF_MySQL_Table { function Header() { //Title $this->SetFont('Arial','',18); $this->Cell(0,6,'Wikka Output To PDF',0,1,'C'); $this->Ln(10); //Ensure table header is output parent::Header(); } } //Connect to database mysql_connect('localhost','user','password'); mysql_select_db('dbname'); $pdf=new PDF(); $pdf->Open(); $pdf->AddPage(); //First table: put all columns automatically $pdf->Table('select tag,body from main_wikka_pages'); $pdf->AddPage(); //Second table: specify 2 columns, $pdf->AddCol('tag',50,'tag','C'); $pdf->AddCol('body',50,'body','C'); $prop=array('HeaderColor'=>array(255,150,100), 'color1'=>array(210,245,255), 'color2'=>array(255,255,210), 'padding'=>2); //$pdf->Table('select tag,body from main_wikka_pages order by tag limit 0,10',$prop); $pdf->Output(wikka,I); ?>
Thanks James. I've got an undergrad programmer hired for a few weeks in May....and I found the pdf generating code for wikini as well (which is now only in a google cache).....so I'm probably going to have him try and get pdf output working (using a handler). I found a "footnoting/endnoting" action for wikini too, so I'll get him working on that also. When either are working I'll post them up (um, I hope this is okay and you don't feel like your efforts are being hi-jacked.....some people are really touchy about such things, but I really do need PDF output from wikka.). Cheers. --GmBowen
- Mike, have a look at FPDF at http://www.fpdf.org. Download the class and one of the database examples from the examples page. I'm sure your undergrad will have it working in no time. For what it's worth, I would like to place a link on each page or footer that allowed for the content to be saved as a pdf file. A further option to e-mail the page to another wikka user would also be good. I hope to hear about your success with this, soon. Cheers Jim.
CategoryDevelopment