Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
$promenliva = 'blaa bla blaaa ';
$promenliva = mb_convert_encoding($promenliva, "UTF-8");
<?php
header('Content-Type: text/html; charset=utf-8');
//nqkakav kod
?>
Дай малко код за да не гадаемr_a_s каза:dakata__92, пробвах твоя вариант и не ставаFakeheal, това което си ми написала е за съвсем друго нещо! Разбрах какво си имала предвид
но не ми върши работа в този случай
![]()
<?php
require('fpdf17/fpdf.php');
class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;
function PDF($orientation='P', $unit='mm', $size='A4')
{
// Call parent constructor
$this->FPDF($orientation,$unit,$size);
// Initialization
$this->B = 0;
$this->I = 0;
$this->U = 0;
$this->HREF = '';
}
function WriteHTML($html)
{
// HTML parser
$html = str_replace("\n",' ',$html);
$a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
foreach($a as $i=>$e)
{
if($i%2==0)
{
// Text
if($this->HREF)
$this->PutLink($this->HREF,$e);
else
$this->Write(5,$e);
}
else
{
// Tag
if($e[0]=='/')
$this->CloseTag(strtoupper(substr($e,1)));
else
{
// Extract attributes
$a2 = explode(' ',$e);
$tag = strtoupper(array_shift($a2));
$attr = array();
foreach($a2 as $v)
{
if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
$attr[strtoupper($a3[1])] = $a3[2];
}
$this->OpenTag($tag,$attr);
}
}
}
}
function OpenTag($tag, $attr)
{
// Opening tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,true);
if($tag=='A')
$this->HREF = $attr['HREF'];
if($tag=='BR')
$this->Ln(5);
}
function CloseTag($tag)
{
// Closing tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,false);
if($tag=='A')
$this->HREF = '';
}
function SetStyle($tag, $enable)
{
// Modify style and select corresponding font
$this->$tag += ($enable ? 1 : -1);
$style = '';
foreach(array('B', 'I', 'U') as $s)
{
if($this->$s>0)
$style .= $s;
}
$this->SetFont('',$style);
}
function PutLink($URL, $txt)
{
// Put a hyperlink
$this->SetTextColor(0,0,255);
$this->SetStyle('U',true);
$this->Write(5,$txt,$URL);
$this->SetStyle('U',false);
$this->SetTextColor(0);
}
}
$html = 'сада <b>сдадад</b>';
$html2 = 'дсададасдса';
$pdf = new PDF();
// First page
$pdf->AddPage();
$pdf->SetFont('Arial','',20);
$pdf->SetRightMargin(50);
$pdf->Write(5,"To find out what's new in this tutorial, click ");
$pdf->SetFont('','U');
$link = $pdf->AddLink();
$pdf->Write(5,'here',$link);
$pdf->SetFont('');
// Second page
$pdf->AddPage();
$pdf->SetLink($link);
$pdf->Image('logo.gif',10,12,30,0,'','http://www.fpdf.org');
$pdf->SetLeftMargin(50);
$pdf->SetFontSize(14);
$pdf->WriteHTML($html);
$pdf->SetLeftMargin(10);
$pdf->WriteHTML($html2);
$pdf->Output();
?>
$str = iconv('UTF-8', 'windows-1252', $str);
$str = utf8_decode($str);
Не мога да разбера какъв е проблема..r_a_s каза:Благодаря ти, но не ми върши работа, защото работи само от файлове .txt!
А мен ми трябва да се въвежда в дадена променлива, а не да ми чете от текстов документ!
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
$txt = 'HelloWorld';
$pdf->Write(8,$txt);
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/");
require('tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',14);
// Load a UTF-8 string from a file and print it
$txt = "Български текст!";
$pdf->Write(8,$txt);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 12 KB.');
$pdf->Output();
?>