function WriteHTML($html) { $html = strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote>"); //remove all unsupported tags $html = str_replace("\n", ' ', $html); //replace carriage returns by spaces $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //explodes the string foreach ($a as $i => $e) { if ($i % 2 == 0) { //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); } else { $this->Write(5, stripslashes(txtentities($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 (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) { $attr[strtoupper($a3[1])] = $a3[2]; } } $this->OpenTag($tag, $attr); } } } }
function WriteHTML($indent = 0, $indentY = 0, $html) { $oldmargin = $this->lMargin; $this->SetX($indent); $this->SetY($indentY); $this->SetLeftMargin($indent); $this->SetRightMargin(15); $html = str_replace("’", "'", str_replace("‘", "'", str_replace("”", "'", str_replace("“", "'", str_replace("–", "-", str_replace("&", "&", str_replace("<", "<", str_replace(">", "<", str_replace("'", "'", str_replace(""", "\"", str_replace("–", "-", str_replace(" ", " ", $html)))))))))))); // HTML parser $html = strip_tags($html, "<b><u><i><a><ul><li><img><p><br><h1><h2><h3><h4><h5><h6><h7><strong><em><font><tr><blockquote>"); // supprime tous les tags sauf ceux reconnus $html = str_replace("\n", ' ', $html); // remplace retour à la ligne par un espace $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); // éclate la chaîne avec les balises foreach ($a as $i => $e) { if ($i % 2 == 0) { // Text if ($this->HREF) { $this->PutLink($this->HREF, $e); } else { $this->Write(4, stripslashes(txtentities($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); } } } $this->SetLeftMargin($oldmargin); return $this->GetY() + 8; }
function WriteHTML($h, $html) { //HTML parser $html = strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote>"); //supprime tous les tags sauf ceux reconnus $html = str_replace("\n", ' ', $html); //remplace retour àa ligne par un espace $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //éate la chaî avec les balises $this->ln_height = $h; foreach ($a as $i => $e) { if ($i % 2 == 0) { //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); } else { $this->Write($this->ln_height, stripslashes(txtentities($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 WriteHTML($html, $bi) { //remove all unsupported tags $this->bi = $bi; if ($bi) { $html = strip_tags($html, "<a><img><p><br><font><tr><blockquote><h1><h2><h3><h4><pre><red><blue><ul><li><hr><b><i><u><strong><em>"); } else { $html = strip_tags($html, "<a><img><p><br><font><tr><blockquote><h1><h2><h3><h4><pre><red><blue><ul><li><hr>"); } $html = str_replace("\n", ' ', $html); //replace carriage returns by spaces // debug if (isset($this->debug) && $this->debug) { echo $html; exit; } $html = str_replace('™', '™', $html); $html = str_replace('©', '©', $html); $html = str_replace('€', '€', $html); $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); $skip = false; foreach ($a as $i => $e) { if (!$skip) { if ($this->HREF) { $e = str_replace("\n", "", str_replace("\r", "", $e)); } if ($i % 2 == 0) { // new line if (isset($this->ALIGN) && $this->ALIGN == 'left') { $this->Cell(100, 4, $e, 0, 1, 'L'); } if ($this->PRE) { $e = str_replace("\r", "\n", $e); } else { $e = str_replace("\r", "", $e); } //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); $skip = true; } else { $this->Write(5, stripslashes(txtentities($e))); } } else { //Tag if (substr(trim($e), 0, 1) == '/') { $this->CloseTag(strtoupper(substr($e, strpos($e, '/')))); } 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); } } } else { $this->HREF = ''; $skip = false; } } }
function WriteHTML($html) { //die("****$html"); //HTML parser $html = strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags $html = str_replace("\n", '', $html); //replace carriage returns by spaces $html = str_replace("\t", '', $html); //replace carriage returns by spaces $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //explodes the string foreach ($a as $i => $e) { if ($i % 2 == 0) { //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); } elseif ($this->tdbegin) { if (trim($e) != '' and $e != " ") { $this->Cell($this->tdwidth, $this->tdheight, $e, $this->tableborder, '', $this->tdalign, $this->tdbgcolor); } elseif ($e == " ") { $this->Cell($this->tdwidth, $this->tdheight, '', $this->tableborder, '', $this->tdalign, $this->tdbgcolor); } } else { $this->Write(5, stripslashes(txtentities($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 (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) { $attr[strtoupper($a3[1])] = $a3[2]; } } $this->OpenTag($tag, $attr); } } } }
function WriteHTML($html) { //! @desc HTML parser //! @return void /* $e == content */ if (!$this->usetitle) { $regexp = '/<title>.*?<\\/title>/si'; // eliminate <TITLE> content </TITLE> $html = preg_replace($regexp, '', $html); } AdjustHTML($html, $this->usepre); $html = $this->CreateInternalLinks($html); if ($this->usecss) { $html = $this->ReadCSS($html); } //Add new supported tags in the DisableTags function $html = strip_tags($html, $this->enabledtags); //remove all unsupported tags, but the ones inside the 'enabledtags' string $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //explodes the string foreach ($a as $i => $e) { //echo "i=[" . $i . "] e[" . $e ."] pbegin[".$this->pbegin."]<br/>\n"; if ($i % 2 == 0) { //TEXT //Prepare text, if needed if (strlen($e) == 0) { continue; } if ($this->divrevert) { $e = strrev($e); } if ($this->toupper) { $e = strtoupper($e); } if ($this->tolower) { $e = strtolower($e); } if ($this->cssbegin and !$this->tablestart) { if ($this->divwidth == 0) { $this->divwidth = $this->GetStringWidth($e); } if ($this->divheight == 0) { $this->divheight = 5; } $bak_x = $this->x; // if (!$this->divbegin) $this->x = $this->oldx + $this->GetStringWidth($e) - $this->cMargin; if (!$this->divbegin and $this->oldx > 0) { $this->x = $this->oldx; } if ($this->divbgcolor) { $this->Cell($this->divwidth, $this->divheight, '', $this->divborder, '', $this->divalign, $this->divbgcolor); } if ($this->dash_on) { $this->Rect($this->x - $this->divwidth, $this->y, $this->divwidth, $this->divheight); } if ($this->dotted_on) { $this->DottedRect($this->x - $this->divwidth, $this->y, $this->divwidth, $this->divheight); } $this->x = $bak_x; } //Start of 'if/elseif's if ($this->titulo) { $this->titulo = $e; $this->Header(); } elseif ($this->issetlist) { if ($this->li) { if ($this->orderedlist) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); if ($this->oldx < 0) { $this->oldx = $this->x + $this->GetStringWidth($this->orderedlist . '. ') + 3; } $this->oldx += $this->GetStringWidth($e); } else { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); if ($this->oldx < 0) { $this->oldx = $this->x + $this->GetStringWidth(chr(149)) + 3; } $this->oldx += $this->GetStringWidth($e); } } } elseif ($this->tablestart) { if ($this->tdbegin) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); $this->cell[$this->row][$this->col]['text'][] = $e; if ($this->cell[$this->row][$this->col]['s'] < $this->GetStringWidth($e) + 3) { $this->cell[$this->row][$this->col]['s'] = $this->GetStringWidth($e) + 3; } } } elseif ($this->divbegin) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); } elseif ($this->pbegin) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); if ($this->oldx < 0) { $this->oldx = $this->x + $this->GetStringWidth(' '); } $this->oldx += $this->GetStringWidth($e); if ($this->oldx < $this->pgwidth + $this->lMargin) { $this->oldy = $this->y; } else { $this->oldy = $this->y + 5 * (int) ($this->oldx / ($this->pgwidth + $this->lMargin)); } } elseif ($this->SUP) { $this->textbuffer[] = array($e); } elseif ($this->SUB) { $this->textbuffer[] = array($e); } elseif ($this->strike) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); } elseif ($this->centertag) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); } elseif ($this->addresstag) { $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', 0, $this->strike); } elseif ($this->HREF) { $this->PutLink($this->HREF, $e); } elseif ($this->frm_textarea) { $this->textbuffer[] = array($e); } elseif ($this->frm_select) { $this->textbuffer[] = array($e); } else { $lineheight = 5; //para compensar os H1 H2 H3 H4 usados... if ($this->FontSizePt == 20) { $lineheight = 7; } if ($this->FontSizePt == 16) { $lineheight = 6; } if ($this->FontSizePt == 11) { $lineheight = 5; } if ($this->FontSizePt == 8) { $lineheight = 4; } $this->Write($lineheight, stripslashes(txtentities($e))); } } else { //Tag if ($e[0] == '/') { $this->CloseTag(strtoupper(substr($e, 1))); } else { $regexp = '/ (\\w+?)=([^\\s>"]+)/si'; // change algo=algo to algo="algo" (only do this when this happens inside tags) $e = preg_replace($regexp, " \$1=\"\$2\"", $e); //Extract attributes $contents = array(); preg_match_all('/\\S*=["\'][^"\']*["\']/', $e, $contents); preg_match('/\\S+/', $e, $a2); $tag = strtoupper($a2[0]); $attr = array(); if (!empty($contents)) { foreach ($contents[0] as $v) { if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) { $attr[strtoupper($a3[1])] = $a3[2]; } } } $this->OpenTag($tag, $attr); } } } }
function WriteHTML($html) { $this->B = 0; $this->I = 0; $this->U = 0; $this->HREF = ''; $this->tableborder = 0; $this->tdbegin = false; $this->tdwidth = 0; $this->tdheight = 0; $this->tdalign = "L"; $this->tdbgcolor = false; $this->oldx = 0; $this->oldy = 0; $this->fontlist = array("arial", "times", "courier", "helvetica", "symbol"); $this->issetfont = false; $this->issetcolor = false; $html = strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags $html = str_replace("\n", '', $html); //replace carriage returns by spaces $html = str_replace("\t", '', $html); //replace carriage returns by spaces $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //explodes the string foreach ($a as $i => $e) { if ($i % 2 == 0) { //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); } elseif ($this->tdbegin) { if (trim($e) != '' && $e != " ") { $this->Cell($this->tdwidth, $this->tdheight, $e, $this->tableborder, '', $this->tdalign, $this->tdbgcolor); } elseif ($e == " ") { $this->Cell($this->tdwidth, $this->tdheight, '', $this->tableborder, '', $this->tdalign, $this->tdbgcolor); } } else { $this->Write(5, stripslashes(txtentities($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 WriteHTML($html, $bi) { //remove all unsupported tags $this->bi = $bi; if ($bi) { $html = strip_tags($html, "<a><img><p><br><font><tr><blockquote><h1><h2><h3><h4><pre><red><blue><ul><li><hr><b><i><u><strong><em>"); } else { $html = strip_tags($html, "<a><img><p><br><font><tr><blockquote><h1><h2><h3><h4><pre><red><blue><ul><li><hr>"); } $html = str_replace("\n", ' ', $html); //replace carriage returns by spaces $str = array('<br />' => '<br>', '<hr />' => '<hr>', '[r]' => '<red>', '[/r]' => '</red>', '[l]' => '<blue>', '[/l]' => '</blue>', '“' => '"', '”' => '"', '„' => '"', '…' => '...', '’' => '\'', '’' => '\'', '^' => 'ˆ'); foreach ($str as $_from => $_to) { $html = str_replace($_from, $_to, $html); } // debug if ($this->debug) { echo $html; exit; } $html = str_replace('™', '™', $html); $html = str_replace('©', '©', $html); $html = str_replace('€', 'ˆ', $html); $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); $skip = false; foreach ($a as $i => $e) { if (!$skip) { if ($this->HREF) { $e = str_replace("\n", "", str_replace("\r", "", $e)); } if ($i % 2 == 0) { // new line if ($this->PRE) { $e = str_replace("\r", "\n", $e); } else { $e = str_replace("\r", "", $e); } //Text if ($this->HREF) { $this->PutLink($this->HREF, $e); $skip = true; } else { $this->Write(5, stripslashes(txtentities($e))); } } else { //Tag if (substr(trim($e), 0, 1) == '/') { $this->CloseTag(strtoupper(substr($e, strpos($e, '/')))); } else { //Extract attributes $a2 = explode(' ', $e); $tag = strtoupper(array_shift($a2)); $attr = array(); foreach ($a2 as $v) { if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) { $attr[strtoupper($a3[1])] = $a3[2]; } } $this->OpenTag($tag, $attr); } } } else { $this->HREF = ''; $skip = false; } } }
/** * WriteHeader() * Gibt den formatieten Header fest aus. * @param string $html */ function WriteHTMLHeader($html) { $a = $this->splitTag($html); $iz = 0; // Standard Zähler $txtZ = 0; // Textzähler $vtxZ = 0; // Textzähler nur wenn Text vorhanden $tagZ = 0; // Tagzähler (wird hier nur gemehrt, wenn ein IMG Tag vorhanden ist) $width = 197; // PAgeWidth in mm foreach ($a as $i => $e) { $iz++; /** * Jede zweite Zeile ist Text oder leer */ // TEXT if ($i % 2 == 0) { $txtZ++; if (trim($e) != '' && $e != " ") { $vtxZ++; switch ($vtxZ) { case 1: $this->SetY(10); $this->SetFontSize(15); break; case 2: $this->ln(4); $this->SetFontSize(9); break; case 3: $this->ln(7); $this->SetFontSize(8); break; case 4: $this->ln(7); $this->SetFontSize(10); break; case 5: $this->ln(3); $this->SetFontSize(8); break; case 6: $this->ln(3); $this->SetFontSize(8); break; } $this->SetX($width - $this->GetStringWidth($e)); $this->Write(5, stripslashes(txtentities($e))); $this->SetFontSize(7); } } else { $aTag = $this->extractTag($e); $tag = $aTag['tag']; $attr = $aTag['attr']; if ($tag == "IMG") { $tagZ++; switch ($tagZ) { case 1: if (!strstr($attr['SRC'], "blank.gif")) { $this->Image($attr['SRC'], 10, 25, px2mm(300), px2mm(65)); } break; case 2: $this->Image($attr['SRC'], $width - px2mm(70), $vtxZ * 7, px2mm(70), px2mm(70)); break; } } } } }
function WriteHTML($html) { //Parseur HTML $html = str_replace("\n", ' ', $html); //remplace retour à la ligne par un espace $html = strip_tags($html, '<h1><h2><h3><h4><h5><h6><b><u><i><a><img><p><br><strong><em><font><tr><blockquote>'); //supprime tous les tags sauf ceux reconnus //$html=strip_tags($html,'<a><img><p><br><strong><em><font><tr><blockquote>'); //supprime tous les tags sauf ceux reconnus $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //éclate la chaîne avec les balises foreach ($a as $i => $e) { if ($i % 2 == 0) { //Texte if ($this->HREF) { $this->PutLink($this->HREF, $e); } else { $this->Write(5, stripslashes(txtentities($e))); } } else { //Balise if ($e[0] == '/') { $this->CloseTag(strtoupper(substr($e, 1))); } else { //Extraction des attributs $a2 = explode(' ', $e); $tag = strtoupper(array_shift($a2)); $attr = array(); foreach ($a2 as $v) { if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) { $attr[strtoupper($a3[1])] = $a3[2]; } } $this->OpenTag($tag, $attr); } } } }