$lang = 'pl'; if (isset($_GET['lang']) && $_GET['lang'] == 'en') { $lang = 'en'; } if ($lang != 'pl') { require_once(dirname(__FILE__).'/../lib/tcpdf/config/lang/eng.php'); } else { require_once(dirname(__FILE__).'/../lib/tcpdf/config/lang/pol.php'); } require_once(dirname(__FILE__).'/../lib/tcpdf/tcpdf.php'); function toUpper($str) { $str = strtoupper($str); $str = str_replace("ą", "Ą", $str); $str = str_replace("ć", "Ć", $str); $str = str_replace("ę", "Ę", $str); $str = str_replace("ł", "Ł", $str); $str = str_replace("ń", "Ń", $str); $str = str_replace("ó", "Ó", $str); $str = str_replace("ś", "Ś", $str); $str = str_replace("ź", "Ź", $str); $str = str_replace("ż", "Ż", $str); return $str; } class MyPdf extends TCPDF { public $thinLine = 0.25; public $normalLine = 0.35; public $thickLine = 0.75; public $blackColor = array(0x00, 0x00, 0x00); public $vsmallFontSize = 8; public $smallFontSize = 9.4; public $normalFontSize = 12; public $big1FontSize = 14; public $bigFontSize = 16; public function Header() { $this->setJPEGQuality(90); } public function Footer() { $this->SetY(-15); $this->SetFont(PDF_FONT_NAME_MAIN, 'I', 8); $this->Cell(0, 10, '', 0, false, 'C'); } public function drawText($str, $x = 0, $y = 0, $width = 0, $height = 10, $fontsize = 10, $fontstyle = '', $color = array(0, 0, 0), $bgColor = '', $align = 'L') { if (is_array($bgColor)) { $this->SetXY($x, $y); $this->setFillColor($bgColor[0], $bgColor[1], $bgColor[2]); } $this->SetXY($x, $y); $this->SetTextColor($color[0], $color[1], $color[2]); $this->SetFont("freeserif", $fontstyle, $fontsize); $this->Cell($width, $height, $str, 0, false, $align); } public function drawVerticalText($str, $x = 0, $y = 0, $width = 0, $height = 10, $fontsize = 10, $fontstyle = '', $color = array(0, 0, 0), $bgColor = '', $align = 'L') { $this->StartTransform(); $this->Rotate(-90, $x, $y); $this->drawText($str, $x, $y, $width, $height, $fontsize, $fontstyle, $color, $bgColor, $align); $this->StopTransform(); } public function drawRect($x, $y, $width, $height, $style = array()) { if (isset($style['bg'])) { $this->SetXY($x, $y); $this->setFillColor($style['bg'][0], $style['bg'][1], $style['bg'][2]); $this->Cell($width, $height, "", 0, false, "", true); } if (isset($style['fg']) && $style['fg'] == '') { return; } $this->Line($x, $y, $x+$width, $y, $style); $this->Line($x+$width, $y, $x + $width, $y + $height, $style); $this->Line($x+$width, $y+$height, $x, $y + $height, $style); $this->Line($x, $y+$height, $x, $y, $style); } public function drawCircle($x, $y, $r, $style = array()) { $this->Circle($x, $y, $r, 0, 360, '', $style); } public function drawTextField($x, $y, $width, $height, $style = array()) { $this->Line($x, $y, $x, $y+$height, $style); $this->Line($x, $y+$height, $x + $width, $y + $height, $style); $this->Line($x+$width, $y+$height, $x+$width, $y, $style); } } // create a PDF object $pdf = new MyPdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setLanguageArray($l); // set document (meta) information $pdf->SetCreator(PDF_CREATOR); $pdf->SetTitle('Advertisement'); $pdf->SetSubject('Advertisement'); $pdf->SetKeywords('Advertisement'); $pdf->AddPage(); $margin = 10; $pdf->SetTopMargin($margin); $pdf->SetAutoPageBreak(true, $margin); $content = array( '* Systemy informatyczne', '* Programy oparte o serwer www', '* Skrypty i strony www', ' PHP (framework kohana)', ' Javascript (framework Mootools)' ); $contact = array( 'name' => 'mgr inż. Marcin Załęczny', 'email' => 'mzaleczny@gmail.com', 'www' => 'http://progmar.net.pl', 'tel' => '794 598 713 (8:00 – 10:00)' ); function drawAdv($x, $y) { global $content, $contact, $pdf; $contentLineHeight = 5; $contactLineHeight = 4.5; for ($i = 0; $i < count($content); $i++) { $bold = ''; $line = $content[$i]; if (strpos($content[$i], '') !== false) { $bold = 'B'; $line = str_replace('', '', $line); $line = str_replace('', '', $line); } $pdf->drawText($line, $x, $y, 10, 10, $pdf->bigFontSize, $bold); $y += 1.5*$contentLineHeight; } $y += 2*$contentLineHeight; foreach ($contact as $key => $value) { if ($key != 'name') { $pdf->drawText($key . ': ', $x, $y, 10, 10, $pdf->bigFontSize, 'B'); } $pdf->drawText($value, $x + 20, $y, 10, 10, $pdf->bigFontSize, ''); $y += 1.5*$contactLineHeight; } } drawAdv(10, 10); drawAdv(110, 10); $pdf->Line(10, 95, 195, 95); drawAdv(10, 100); drawAdv(110, 100); $pdf->Line(10, 190, 195, 190); drawAdv(10, 200); drawAdv(110, 200); $pdf->Line(100, 10, 100, 285); $pdf->Output();