Exporting Wiki content to PDF


 

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 export format). There are several GPL-licensed Java and php solution for generating PDFs on the fly.

Some references


FPDF


Hi James. Any progress on generating a PDF file output from wikka? -- Mike Bowen (GmBowen)
http://www.jamesmcl.co.uk/fpdf/try_pdf.php
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

Concept

  1. make a concept for ExportToPdf
      • FYI: wikini conversation re wiki2pdf...already a wikini handler developed....see here...might be easier to just adapt since GPL. I tested it in wikini and it worked okay. --GmBowen
    • I sure hope somebody grabbed this code as it's not there any more. If you have it, please let me know. I have a php coder working for me the next 2 months who may be able to adapt it for wikka. --GmBowen
      • Looks like there is no code yet - as far as I can deduce from the wiki2pdf page the project is still in the conceptual stage? http://www.thierrybazzanella.com/ only redirects to another (Flash-only) site. --JavaWoman
      • I've looked at the page but forgot to grab the code (I darkly remember the beeing of code on the page) --NilsLindenberg

R & OS pdf class


Html2pdf

I think that a better way to investigate would be to look at the html2pdf package. This package seems to do pretty well with css and images. It is backended by gostscript to convert the page to postscript then to pdf. The downfall for this package is that it seems to be quite cpu intensive while generating the pdf. You can see a demo of it at http://pdf.shroom.net.

I invision this as a action that can be added to a float box and the pdf is returned when a user click on a pdf icon or something along these lines.

I also think that some code should be added to cache a generated pdf, and serve the cached pdf if the page has not changed since the pdf was generated.

-AdamCrews


CategoryDevelopmentHandlers CategoryDevelopmentArchitecture
Comments [Hide comments]
Comment by NilsLindenberg
2005-06-24 11:01:56
If some wants to work on another solution (like the mentioned html2pdf), we better move the fpdf-code from here to an extra-page and keep this as a discussion-page
Comment by JavaWoman
2005-06-24 23:09:45
Nils: I agree (refactor endlessly ;-))
Comment by DanDavis
2008-07-11 15:34:09
I'm using wikkawiki as the engineering wiki for my company. But for the wiki to really take off, there are some people who need to see a print out, be able to scribble on it, and hand it back. Doing a PDF of a single page would be useful, especially if the headings become bookmarks.

What would be even nicer is to have some action that would build a PDF if the Wikinames, or link text as bookmarks to that content. Then, you can have a hypertextual wiki that is converted to a hypertextual PDF, that can also be printed.

It supports even the dinosaurs...
Comment by NilsLindenberg
2008-07-23 13:36:56
Hi Dan,
unfortunately I don't understand:

>What would be even nicer is to have some action that would build a PDF if the Wikinames, or link text as bookmarks to that content

could you please explain what you need?
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki