*/ // must be run within Dokuwiki if (!defined('DOKU_INC')) die(); if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); require_once (DOKU_PLUGIN . 'action.php'); class action_plugin_html2pdf extends DokuWiki_Action_Plugin { /** * Constructor. */ function action_plugin_html2pdf(){} /** * return some info */ function getInfo(){ return confToHash(dirname(__FILE__).'/info.txt'); } /** * Register the events */ function register(&$controller) { $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert',array()); } function convert(&$event, $param) { global $ACT; global $REV; global $ID; global $conf; //$ID = $param[0]; if ( $ACT == 'export_pdf' ) { $event->preventDefault(); $html = header('Content-Type: text/html; charset=utf-8'); $html .= ''.DOKU_LF; $html .= ''.DOKU_LF; $html .= ''.DOKU_LF; $html .= ' '.DOKU_LF; $html .= ' '.$ID.''.DOKU_LF; // load stylesheets but skip the rest of the usual junk generated by tpl_metaheaders $html .= ' '.DOKU_LF; $html .= ' '.DOKU_LF; $html .= ''.DOKU_LF; $html .= ''.DOKU_LF; $html .= '
'.DOKU_LF; $html .= p_wiki_xhtml($ID,$REV,false); $html .= '
'.DOKU_LF; $html .= ''.DOKU_LF; $html .= ''.DOKU_LF; // Replace images with dereferenced, gettable pictures $pattern = '//'; while ( preg_match($pattern,$html,$matches ) ) { $link = preg_replace('/:/','/',$matches[1]); // $matches[0] is the whole matching line $width = $matches[2]; $height = $matches[3]; //$replace = 'dokuwiki image'; $replace = 'dokuwiki image'; $html = preg_replace($pattern,$replace,$html); } // Dereference wiki links $html = str_replace('href="/','href="http://'.$_SERVER['HTTP_HOST'].'/',$html); $fout = fopen("lib/plugins/html2pdf/tmp/export_pdf.html",'w'); fwrite($fout,$html); fclose($fout); // Ghostscript method is method=fastps, FPDF method is method=fpdf // pdflib method is method=pdflib header("Location: " .DOKU_URL.'/lib/plugins/html2pdf/html2ps/demo/html2ps.php?URL='.DOKU_URL.'lib/plugins/html2pdf/tmp/export_pdf.html&pixels=1024&media=A4&method=fpdf&output=0&pdfversion=1.3&cssmedia=screen&renderlinks=1&renderimages=1&scalepoints=1&leftmargin=10&rightmargin=10&topmargin=10&bottommargin=10'); //header("Location: " .'../../html2ps/demo/html2ps.php?URL=http://'.$_SERVER['HTTP_HOST'].getBaseURL().'lib/plugins/html2pdf/tmp/export_pdf.html&pixels=1024&media=A4&method=fpdf&output=0&pdfversion=1.3&cssmedia=screen&renderlinks=1&renderimages=1&scalepoints=1&leftmargin=10&rightmargin=10&topmargin=10&bottommargin=10'); die(); } } } ?>