html=$_html; // html text to convert to PDF $this->title=$_title; // article title $this->articleurl=$_articleurl; // article URL $this->author=$_author; // article author $this->date=$_date; // date being published // other options $this->from='iso-8859-2'; // input encoding $this->to='cp1250'; // output encoding $this->useiconv=false; // use iconv $this->bi=true; // support bold and italic tags } function _convert($s) { if ($this->useiconv) return iconv($this->from,$this->to,$s); else return $s; } function run() { // change some win codes, and xhtml into html $str=array( '
' => '
', '
' => '
', '[r]' => '', '[/r]' => '', '[l]' => '', '[/l]' => '', '“' => '"', '”' => '"', '„' => '"', '…' => '...', '’' => '\'' ); foreach ($str as $_from => $_to) $this->html = str_replace($_from,$_to,$this->html); $pdf=new PDF('P','mm','A4',$this->title,$this->articleurl,false); $pdf->SetCreator("Script by Radek HULAN, http://hulan.info/blog/"); $pdf->SetDisplayMode('real'); $pdf->SetTitle($this->_convert($this->title)); $pdf->SetAuthor($this->author); $pdf->AddPage(); // header $pdf->PutMainTitle($this->_convert($this->title)); $pdf->PutMinorHeading('Article URL'); $pdf->PutMinorTitle($this->articleurl,$this->articleurl); $pdf->PutMinorHeading('Author'); $pdf->PutMinorTitle($this->_convert($this->author)); $pdf->PutMinorHeading("Published: ".@date("F j, Y, g:i a",$this->date)); $pdf->PutLine(); $pdf->Ln(10); // html $pdf->WriteHTML($this->_convert($this->html),$this->bi); // output $pdf->Output(); // stop processing exit; } } /************************************/ /* class PDF */ /************************************/ class PDF extends FPDF { protected $B; protected $I; protected $U; protected $HREF; protected $PRE; protected $fontlist; protected $issetfont; protected $issetcolor; protected $articletitle; protected $articleurl; protected $debug; protected $bi; function __construct($orientation='P',$unit='mm',$size='A4',$_title='',$_url='',$_debug=false) { parent::__construct($orientation,$unit,$size); $this->B=0; $this->I=0; $this->U=0; $this->HREF=''; $this->PRE=false; $this->SetFont('Times','',12); $this->fontlist=array('Times','Courier'); $this->issetfont=false; $this->issetcolor=false; $this->articletitle=$_title; $this->articleurl=$_url; $this->debug=$_debug; $this->AliasNbPages(); } function WriteHTML($html,$bi) { //remove all unsupported tags $this->bi=$bi; if ($bi) $html=strip_tags($html,"