2 rcs_id('$Id: pdf.php,v 1.4 2004-06-14 11:31:37 rurban Exp $');
4 // PDF functions taken from FPDF http://www.fpdf.org
5 // Edited for PHPWebthings by Don SebĂ
6 // Feel free to edit , enhance the module, and please share it at http://www.phpdbform.com
7 // Keep PHPWT COOL submit your modules/themes/mods, it will help to improve ! :)
8 // Changes for PhpWiki by Reini Urban
10 require_once('lib/fpdf.php');
12 class PDF extends FPDF {
18 function PDF ($orientation='P', $unit='mm', $format='A4') {
19 $this->FPDF($orientation,$unit,$format);
20 //$this->SetCompression(false);
23 // Simple HTML to PDF converter
24 function ConvertFromHTML($html) {
25 $html = str_replace("\n",' ',$html);
26 $a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
27 foreach($a as $i=>$e) {
31 $this->PutLink($this->HREF,$e);
37 $this->CloseTag(strtoupper(substr($e,1)));
40 $a2 = explode(' ',$e);
41 $tag = strtoupper(array_shift($a2));
44 if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
45 $attr[strtoupper($a3[1])]=$a3[2];
46 $this->OpenTag($tag,$attr);
54 $this->SetFont('Arial','',9);
55 //URL - space from side - space from top - width
57 $imgurl = $GLOBALS['WikiTheme']->_findFile("images/logo.png"); // header and wikilogo
59 $this->Image($imgurl,3,3);
66 //global $cfg, $config, $lang;
70 $this->SetFont('arial','I',8);
73 function OpenTag($tag,$attr) {
74 if($tag=='B' or $tag=='I' or $tag=='U')
75 $this->SetStyle($tag,true);
77 $this->HREF=$attr['HREF'];
82 function CloseTag($tag) {
83 if($tag=='B' or $tag=='I' or $tag=='U')
84 $this->SetStyle($tag,false);
89 //Wijzig stijl en selecteer lettertype
90 function SetStyle($tag,$enable) {
91 $this->$tag+=($enable ? 1 : -1);
93 foreach(array('B','I','U') as $s)
96 $this->SetFont('',$style);
99 function PutLink($URL,$txt) {
100 // hyperlink as simple underlined text
101 $this->SetTextColor(0,0,255);
102 $this->SetStyle('U',true);
103 $this->Write(5,$txt,$URL);
104 $this->SetStyle('U',false);
105 $this->SetTextColor(0);
109 function ConvertAndDisplayPdf (&$request) {
110 if (empty($request->_is_buffering_output))
111 $request->buffer_output(false/*'nocompress'*/);
112 if ($GLOBALS['LANG'] == 'ja') {
113 include_once("lib/fpdf/japanese.php");
114 $pdf = new PDF_Japanese;
115 } elseif ($GLOBALS['LANG'] == 'zh') {
116 include_once("lib/fpdf/chinese.php");
117 $pdf = new PDF_Chinese;
121 include_once("lib/display.php");
122 displayPage($request);
123 $html = ob_get_contents();
126 $pdf->ConvertFromHTML($html);
127 $request->discardOutput();
129 $request->buffer_output(false/*'nocompress'*/);
130 $pagename = $request->getArg('pagename');
131 $dest = $request->getArg('dest');
132 $pdf->Output($pagename.".pdf", $dest ? $dest : 'F');
133 if (!empty($errormsg)) {
134 $request->discardOutput();
138 // $Log: not supported by cvs2svn $
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