Revision 260 action.php
| action.php (revision 260) | ||
|---|---|---|
| 17 | 17 |
/** |
| 18 | 18 |
* Constructor. |
| 19 | 19 |
*/ |
| 20 |
function action_plugin_html2pdf(){
|
|
| 21 |
} |
|
| 20 |
function action_plugin_html2pdf(){}
|
|
| 22 | 21 |
|
| 23 | 22 |
/** |
| 24 | 23 |
* return some info |
| ... | ... | |
| 30 | 29 |
/** |
| 31 | 30 |
* Register the events |
| 32 | 31 |
*/ |
| 33 |
function register(&$controller) |
|
| 34 |
{
|
|
| 32 |
function register(&$controller) {
|
|
| 35 | 33 |
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert',array());
|
| 36 | 34 |
} |
| 37 | 35 |
|
| 38 | 36 |
|
| 39 |
function convert(&$event, $param) |
|
| 40 |
{
|
|
| 37 |
function convert(&$event, $param) {
|
|
| 41 | 38 |
global $ACT; |
| 42 |
global $REV; |
|
| 43 |
global $ID; |
|
| 44 |
global $conf; |
|
| 45 |
|
|
| 46 |
//$ID = $param[0]; |
|
| 47 |
if ( $ACT == 'export_pdf' ) {
|
|
| 48 |
$event->preventDefault(); |
|
| 49 |
$html = header('Content-Type: text/html; charset=utf-8');
|
|
| 50 |
$html .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.DOKU_LF; |
|
| 51 |
$html .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.DOKU_LF; |
|
| 52 |
$html .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'"'.DOKU_LF; |
|
| 53 |
$html .= ' lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">'.DOKU_LF; |
|
| 54 |
$html .= '<head>'.DOKU_LF; |
|
| 55 |
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.DOKU_LF; |
|
| 56 |
$html .= ' <title>'.$ID.'</title>'.DOKU_LF; |
|
| 57 |
// load stylesheets but skip the rest of the usual junk generated by tpl_metaheaders |
|
| 58 |
$html .= ' <link rel="stylesheet" media="all" type="text/css" href="/doku/lib/exe/css.php?s=all"/>'.DOKU_LF; |
|
| 59 |
$html .= ' <link rel="stylesheet" media="screen" type="text/css" href="/doku/lib/exe/css.php"/>'.DOKU_LF; |
|
| 60 |
$html .= '</head>'.DOKU_LF; |
|
| 61 |
$html .= '<body style="background:none;">'.DOKU_LF; |
|
| 62 |
$html .= '<div class="dokuwiki">'.DOKU_LF; |
|
| 63 |
$html .= p_wiki_xhtml($ID,$REV,false); |
|
| 64 |
$html .= '</div>'.DOKU_LF; |
|
| 65 |
$html .= '</body>'.DOKU_LF; |
|
| 66 |
$html .= '</html>'.DOKU_LF; |
|
| 67 |
// Replace images with dereferenced, gettable pictures |
|
| 68 |
$pattern = '/<a.*?detail.php\/(.*?)\?.*?width="(.*?)" height="(.*?)".*?<\/a>/'; |
|
| 69 |
while ( preg_match($pattern,$html,$matches ) ) |
|
| 70 |
{
|
|
| 71 |
$link = preg_replace('/:/','/',$matches[1]);
|
|
| 72 |
// $matches[0] is the whole matching line |
|
| 73 |
$width = $matches[2]; |
|
| 74 |
$height = $matches[3]; |
|
| 75 |
//$replace = '<img src="http://snorriheim.dnsdojo.com/doku/data/media/'.$link.'" class="media" alt="dokuwiki image" width="'.$width.'" height="'.$height.'" />'; |
|
| 76 |
$replace = '<img src="'.DOKU_URL.'data/media/'.$link.'" class="media" alt="dokuwiki image" width="'.$width.'" height="'.$height.'" />'; |
|
| 77 |
$html = preg_replace($pattern,$replace,$html); |
|
| 78 |
} |
|
| 79 |
// Dereference wiki links |
|
| 80 |
$html = str_replace('href="/','href="http://'.$_SERVER['HTTP_HOST'].'/',$html);
|
|
| 81 |
$fout = fopen("lib/plugins/html2pdf/tmp/export_pdf.html",'w');
|
|
| 82 |
fwrite($fout,$html); |
|
| 83 |
fclose($fout); |
|
| 84 |
// Ghostscript method is method=fastps, FPDF method is method=fpdf |
|
| 85 |
// pdflib method is method=pdflib |
|
| 86 |
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');
|
|
| 87 |
//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');
|
|
| 88 |
die(); |
|
| 89 |
} |
|
| 39 |
global $REV; |
|
| 40 |
global $ID; |
|
| 41 |
global $conf; |
|
| 42 |
|
|
| 43 |
//$ID = $param[0]; |
|
| 44 |
if ( $ACT == 'export_pdf' ) {
|
|
| 45 |
$event->preventDefault(); |
|
| 46 |
$html = header('Content-Type: text/html; charset=utf-8');
|
|
| 47 |
$html .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.DOKU_LF; |
|
| 48 |
$html .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.DOKU_LF; |
|
| 49 |
$html .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'"'.DOKU_LF; |
|
| 50 |
$html .= ' lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">'.DOKU_LF; |
|
| 51 |
$html .= '<head>'.DOKU_LF; |
|
| 52 |
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.DOKU_LF; |
|
| 53 |
$html .= ' <title>'.$ID.'</title>'.DOKU_LF; |
|
| 54 |
// load stylesheets but skip the rest of the usual junk generated by tpl_metaheaders |
|
| 55 |
$html .= ' <link rel="stylesheet" media="all" type="text/css" href="/doku/lib/exe/css.php?s=all"/>'.DOKU_LF; |
|
| 56 |
$html .= ' <link rel="stylesheet" media="screen" type="text/css" href="/doku/lib/exe/css.php"/>'.DOKU_LF; |
|
| 57 |
$html .= '</head>'.DOKU_LF; |
|
| 58 |
$html .= '<body style="background:none;">'.DOKU_LF; |
|
| 59 |
$html .= '<div class="dokuwiki">'.DOKU_LF; |
|
| 60 |
$html .= p_wiki_xhtml($ID,$REV,false); |
|
| 61 |
$html .= '</div>'.DOKU_LF; |
|
| 62 |
$html .= '</body>'.DOKU_LF; |
|
| 63 |
$html .= '</html>'.DOKU_LF; |
|
| 64 |
// Replace images with dereferenced, gettable pictures |
|
| 65 |
$pattern = '/<a.*?detail.php\/(.*?)\?.*?width="(.*?)" height="(.*?)".*?<\/a>/'; |
|
| 66 |
while ( preg_match($pattern,$html,$matches ) ) |
|
| 67 |
{
|
|
| 68 |
$link = preg_replace('/:/','/',$matches[1]);
|
|
| 69 |
// $matches[0] is the whole matching line |
|
| 70 |
$width = $matches[2]; |
|
| 71 |
$height = $matches[3]; |
|
| 72 |
//$replace = '<img src="http://snorriheim.dnsdojo.com/doku/data/media/'.$link.'" class="media" alt="dokuwiki image" width="'.$width.'" height="'.$height.'" />'; |
|
| 73 |
$replace = '<img src="'.DOKU_URL.'data/media/'.$link.'" class="media" alt="dokuwiki image" width="'.$width.'" height="'.$height.'" />'; |
|
| 74 |
$html = preg_replace($pattern,$replace,$html); |
|
| 75 |
} |
|
| 76 |
// Dereference wiki links |
|
| 77 |
$html = str_replace('href="/','href="http://'.$_SERVER['HTTP_HOST'].'/',$html);
|
|
| 78 |
$fout = fopen("lib/plugins/html2pdf/tmp/export_pdf.html",'w');
|
|
| 79 |
fwrite($fout,$html); |
|
| 80 |
fclose($fout); |
|
| 81 |
// Ghostscript method is method=fastps, FPDF method is method=fpdf |
|
| 82 |
// pdflib method is method=pdflib |
|
| 83 |
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');
|
|
| 84 |
//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');
|
|
| 85 |
die(); |
|
| 86 |
} |
|
| 90 | 87 |
} |
| 91 | 88 |
} |
| 92 | 89 |
?> |
Also available in: Unified diff