and Janusz Dobrowolski */ define("K_RE_PATTERN_RTL", "/( \xD6\xBE # R | \xD7[\x80\x83\x86\x90-\xAA\xB0-\xB4] # R | \xDF[\x80-\xAA\xB4\xB5\xBA] # R | \xE2\x80\x8F # R | \xEF\xAC[\x9D\x9F\xA0-\xA8\xAA-\xB6\xB8-\xBC\xBE] # R | \xEF\xAD[\x80\x81\x83\x84\x86-\x8F] # R | \xF0\x90\xA0[\x80-\x85\x88\x8A-\xB5\xB7\xB8\xBC\xBF] # R | \xF0\x90\xA4[\x80-\x99] # R | \xF0\x90\xA8[\x80\x90-\x93\x95-\x97\x99-\xB3] # R | \xF0\x90\xA9[\x80-\x87\x90-\x98] # R | \xE2\x80[\xAB\xAE] # RLE & RLO )/x"); /* * Pattern to test Arabic strings using regular expressions. * source: http://www.w3.org/International/questions/qa-forms-utf-8 */ define("K_RE_PATTERN_ARABIC", "/( \xD8[\x80-\x83\x8B\x8D\x9B\x9E\x9F\xA1-\xBA] # AL | \xD9[\x80-\x8A\xAD-\xAF\xB1-\xBF] # AL | \xDA[\x80-\xBF] # AL | \xDB[\x80-\x95\x9D\xA5\xA6\xAE\xAF\xBA-\xBF] # AL | \xDC[\x80-\x8D\x90\x92-\xAF] # AL | \xDD[\x8D-\xAD] # AL | \xDE[\x80-\xA5\xB1] # AL | \xEF\xAD[\x90-\xBF] # AL | \xEF\xAE[\x80-\xB1] # AL | \xEF\xAF[\x93-\xBF] # AL | \xEF[\xB0-\xB3][\x80-\xBF] # AL | \xEF\xB4[\x80-\xBD] # AL | \xEF\xB5[\x90-\xBF] # AL | \xEF\xB6[\x80-\x8F\x92-\xBF] # AL | \xEF\xB7[\x80-\x87\xB0-\xBC] # AL | \xEF\xB9[\xB0-\xB4\xB6-\xBF] # AL | \xEF\xBA[\x80-\xBF] # AL | \xEF\xBB[\x80-\xBC] # AL | \xD9[\xA0-\xA9\xAB\xAC] # AN )/x"); include_once (dirname(__FILE__).'/tcpdf.php'); class Cpdf extends TCPDF { function Cpdf($pageSize='A4', $l=array()) { if (!isset($l['a_meta_charset'])) $l = array('a_meta_charset' => 'ISO-8859-1', 'a_meta_dir' => 'ltr', 'a_meta_language' => 'en_GB', 'w_page' => 'page'); $enc = $l['a_meta_charset']; $uni = ($enc == 'UTF-8' || $enc == 'GB2312' ? true : false); if ($uni) ini_set("memory_limit", "48M"); $this->TCPDF('P', 'pt', $pageSize, $uni, $enc); $this->setLanguageArray($l); $this->setPrintHeader(false); $this->setPrintFooter(false); $this->setPDFVersion("1.3"); $this->setAutoPageBreak(0); $this->AddPage(); $this->SetLineWidth(1); $this->cMargin = 0; } function selectFont($fontname, $style='') { if ($fontname != '') $fontname = basename($fontname); if ($style == 'italic') $type = 'i'; elseif ($style == 'bold') $type = 'b'; else $type = ''; if ($fontname == '') { if ($this->isunicode) { switch ($this->l['a_meta_language']) { case "ar_EG" : $fontname = "ae_tholoth"; break; case "zh_CN" : $fontname = "gbsn00lp"; break; default : $fontname = "dejavu"; break; } } elseif ($this->encoding === "ISO-8859-2") { switch ($this->l['a_meta_language']) { default : $fontname = "freesans"; break; } } elseif ($this->encoding === "ISO-8859-5") { switch ($this->l['a_meta_language']) { default : $fontname = "freesans5"; break; } } // else use built-in adobe fonts helvetica. } $this->SetFont($fontname, $type); } function Header1() { } function Footer() { } function newPage() { TCPDF::AddPage(); } function line($x1,$y1,$x2,$y2) { TCPDF::line($x1, $this->h-$y1, $x2, $this->h-$y2); } function rectangle($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array()) { TCPDF::Rect($x, $this->h-$y, $w, $h, $style, $border_style, $fill_color); } function addText($xb,$yb,$size,$txt)//,$angle=0,$wordSpaceAdjust=0) { if ($this->isunicode && $this->encoding != "UTF-8") $txt = iconv($this->encoding, "UTF-8", $txt); $this->SetFontSize($size); $this->Text($xb, $this->h-$yb, $txt); } function addInfo($label,$value) { if($label=='Title') { $this->SetTitle($value); } if ($label=='Subject') { $this->SetSubject($value); } if($label=='Creator') { // The Creator info in source is not exactly it should be ;) $value = str_replace( "ros.co.nz", "tcpdf.org", $value ); $value = str_replace( "R&OS", "", $value ); $this->SetCreator( $value ); } if($label=='Author') { $this->SetAuthor($value); } } function addJpegFromFile($img,$x,$y,$w=0,$h=0) { $this->Image($img, $x, $this->h-$y-$h, $w, $h); } function addPngFromFile($img,$x,$y,$w=0,$h=0) { $this->Image($img, $x, $this->h-$y-$h, $w, $h); } /* * Next Two functions are adopted from R&OS pdf class */ /** * draw a part of an ellipse */ function partEllipse($x0,$y0,$astart,$afinish,$r1,$r2=0,$angle=0,$nSeg=8) { $this->ellipse($x0,$y0,$r1,$r2,$angle,$nSeg,$astart,$afinish,0); } /** * draw an ellipse * note that the part and filled ellipse are just special cases of this function * * draws an ellipse in the current line style * centered at $x0,$y0, radii $r1,$r2 * if $r2 is not set, then a circle is drawn * nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a * pretty crappy shape at 2, as we are approximating with bezier curves. */ function ellipse($x0,$y0,$r1,$r2=0,$angle=0,$nSeg=8,$astart=0,$afinish=360,$close=1,$fill=0) { TCPDF::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg); } function Stream() { TCPDF::Output('', 'I'); } function calcTextWrap($txt, $width, $spacebreak=false) { $ret = ""; $txt2 = $txt; $w = $this->GetStringWidth($txt); if ($w > $width && $w > 0 && $width != 0) { $n = strlen($txt); $k = intval($n * $width / $w); if ($k > 0 && $k < $n) { $txt2 = substr($txt, 0, $k); if ($spacebreak && (($pos = strrpos($txt2, " ")) !== false)) { $txt2 = substr($txt2, 0, $pos); $ret = substr($txt, $pos+1); } else $ret = substr($txt, $k); } } return array($txt2, $ret); } function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $spacebreak=false) { $ret = ""; if (!$this->rtl) { if ($align == 'right') $align = 'R'; elseif ($align == 'left') $align = 'L'; } else $align = 'R'; $txt = $this->calcTextWrap($txt, $w, $spacebreak); $ret = $txt[1]; $txt = $txt[0]; $this->SetXY($xb, $this->h - $yb - $h); $txt = TCPDF::unhtmlentities($txt); if ($this->isunicode && $this->encoding != "UTF-8") $txt = iconv($this->encoding, "UTF-8", $txt); $this->Cell($w, $h, $txt, $border, 0, $align, $fill); return $ret; } /** * sets the colour for stroke operations */ function setStrokeColor($r,$g,$b,$force=0) { TCPDF::SetDrawColor($r,$g,$b); } /** * this sets the line drawing style. * width, is the thickness of the line in user units * cap is the type of cap to put on the line, values can be 'butt','round','square' * where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the * end of the line. * join can be 'miter', 'round', 'bevel' * dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the * on and off dashes. * (2) represents 2 on, 2 off, 2 on , 2 off ... * (2,1) is 2 on, 1 off, 2 on, 1 off.. etc * phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts. */ function setLineStyle($width=1,$cap='',$join='',$dash='',$phase=0) { $this->SetLineWidth($width); } function Text($x, $y, $txt, $stroke=0, $clip=false) { TCPDF::Text($x,$y, TCPDF::unhtmlentities($txt), $stroke, $clip); } } // end of class ?>