[svn r21969] improve export to pdf

skala
Juan Carlos Raña 16 years ago
parent e09cf1433c
commit 2ab4049f13
  1. 22
      main/inc/lib/html2pdf/html2pdf.class.php
  2. 53
      main/wiki/export_html2pdf.php

@ -19,6 +19,8 @@ $configurationPearPath = $configuration['root_sys'].'/main/inc/lib/html2pdf';
ini_set('include_path', $configurationPearPath);
/////
include('../../inc/global.inc.php');
if (!defined('__CLASS_HTML2PDF__'))
{
@ -4609,7 +4611,7 @@ if (!defined('__CLASS_HTML2PDF__'))
{
case 1:
$msg = (HTML2PDF::textGET('err01'));
$msg = str_replace('[[OTHER]]', $other, $msg);
$msg = str_replace('[[OTHER]]', $other, $msg);
break;
case 2:
@ -4643,12 +4645,18 @@ if (!defined('__CLASS_HTML2PDF__'))
$msg = (HTML2PDF::textGET('err07'));
break;
}
echo '<span style="color: #AA0000; font-weight: bold;">'.(HTML2PDF::textGET('txt01')).$err.'</span><br>';
echo (HTML2PDF::textGET('txt02')).' '.$file.'<br>';
echo (HTML2PDF::textGET('txt03')).' '.$line.'<br>';
echo '<br>';
echo $msg;
exit;
$Dokeosmsg = '<div style="position: relative; margin-top: 10px; margin-bottom: 10px; border-width: 1px; border-style: solid; padding: 5px; border: 1px solid #FF0000; color: #000; background-color: #FFD1D1; min-height: 30px;"><b>'.get_lang("ConvesionFailled").'</b></br>'.get_lang("CommentErrorExportDocument").'</div>';
echo $Dokeosmsg;
/*
////uncomment for debug
echo '<span style="color: #AA0000; font-weight: bold;">'.(HTML2PDF::textGET('txt01')).$err.'</span><br>';
echo (HTML2PDF::textGET('txt02')).' '.$file.'<br>';
echo (HTML2PDF::textGET('txt03')).' '.$line.'<br>';
echo '<br>';
echo $msg;
*/
exit;
}
}
}

@ -35,32 +35,59 @@ require('../inc/lib/html2pdf/html2pdf.class.php');
$contentPDF=stripslashes(api_html_entity_decode($_POST['contentPDF'], ENT_QUOTES, $charset));
$titlePDF=stripslashes(api_html_entity_decode($_POST['titlePDF'], ENT_QUOTES, $charset));
//activate Output -Buffer:
ob_start();
////START-OF-PHP code
echo $contentPDF; //original
//END -OF- PHP code
//Output-Buffer in variable:
$htmlbuffer=ob_get_contents();
//// delete Output-Buffer:
ob_end_clean();
ob_start();//activate Output -Buffer
echo $contentPDF;
$htmlbuffer=ob_get_contents();// Store Output-Buffer in one variable
ob_end_clean();// delete Output-Buffer
/////bridge to dokeos lang
@ $langhtml2pdf = Database :: get_language_isocode($language_interface);
// Some code translations are needed.
$langhtml2pdf = strtolower(str_replace('_', '-', $langhtml2pdf));
if (empty ($langhtml2pdf))
{
$langhtml2pdf = 'en';
}
switch ($langhtml2pdf)
{
case 'uk':
$langhtml2pdf = 'ukr';
break;
case 'pt':
$langhtml2pdf = 'pt_pt';
break;
case 'pt-br':
$langhtml2pdf = 'pt_br';
break;
// Code here other noticed exceptions.
}
// Checking for availability of a corresponding language file.
if (!file_exists(api_get_path(SYS_PATH).'main/inc/lib/html2pdf/langues/'.$langhtml2pdf.'.txt'))
{
// If there was no language file, use the english one.
$langhtml2pdf = 'en';
}
////
//$script = "
//var rep = app.response('Your name');
//app.alert('Hello '+rep);
//";
//$html2pdf = new HTML2PDF('P','A4','es', array(0,0,0,0)); //margin left, margin top, margin right, margin bottom
$html2pdf = new HTML2PDF('P','A4','en');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf = new HTML2PDF('P','A4',$langhtml2pdf, array(30,25,30,25));//array (margin left, margin top, margin right, margin bottom)
$html2pdf->pdf->SetMyFooter( 'page','','','' );//page, date, time, form
$html2pdf->pdf->SetDisplayMode('real');
//$html2pdf->pdf->IncludeJS($script);
//$html2pdf->pdf->IncludeJS("print(true);");
//$html2pdf->pdf->IncludeJS("app.alert('Generated by Dokeos to PDF');");
//$html2pdf->pdf->SetProtection(array('print'), 'guest');//add a password sample: guest
$html2pdf->pdf->SetAuthor('Wiki Dokeos');
$html2pdf->pdf->SetTitle($titlePDF);
$html2pdf->pdf->SetSubject('Exported from Dokeos Wiki');
$html2pdf->pdf->SetKeywords('Dokeos Wiki');
$html2pdf->WriteHTML($htmlbuffer);
$html2pdf->WriteHTML(utf8_decode($htmlbuffer));
$html2pdf->Output($titlePDF.'.pdf', 'D');
?>
Loading…
Cancel
Save