Source for file Xml2PdfTextTag.php
Documentation is available at Xml2PdfTextTag.php
* @author guillaume l. <guillaume@geelweb.org>
* @link http://www.geelweb.org
* @license http://opensource.org/licenses/bsd-license.php BSD License
* @copyright copyright © 2006, guillaume luchet
require_once('Xml2PdfTag.php');
* Xml2PdfTextTag define the properties and method used to for tags used to
* write content in the Pdf document. The content can be write using styles
* information define with {@link Xml2PdfTag_stylesheets styles sheet}.
* This class extends {@link Xml2PdfTag Xml2PdfTag}, the tag properties define
* by this parent class (like id) are available in Xml2PdfTextTag.
* - <b>font</b> - string - font (eg times)
* - <b>fontsize</b> - integer - font size (eg 10)
* - <b>fontcolor</b> - string - font color (eg #000000)
* - <b>fontstyle</b> - string - font style [B[U[I]]]
* - <b>lineheight</b> - integer - line height (eg 5)
* - <b>textalign</b> - string - text alignment [L|R|C|J]
* @author guillaume l. <guillaume@geelweb.org>
* @link http://www.geelweb.org
* @license http://opensource.org/licenses/bsd-license.php BSD License
* @copyright copyright © 2006, guillaume luchet
* true if use styles tag to write then content.
public $font =
PDF_DEFAULT_FONT;
// Xml2PdfTextTag::__construct() {{{
* Parse the tag properties.
* @param object Pdf $pdf object Pdf
* @param array $tagProperties tag properties
// parse the tag properties for text
if(isset
($tagProperties['FONT'])) {
$this->font =
$tagProperties['FONT'];
if(isset
($tagProperties['FONTSTYLE'])) {
$this->fontStyle =
$tagProperties['FONTSTYLE'];
if(isset
($tagProperties['FONTCOLOR'])) {
$this->fontColor =
$tagProperties['FONTCOLOR'];
if(isset
($tagProperties['FONTSIZE'])) {
$this->fontSize =
$tagProperties['FONTSIZE'];
if(isset
($tagProperties['TEXTALIGN'])) {
$this->textAlign =
$tagProperties['TEXTALIGN'];
if(isset
($tagProperties['LINEHEIGHT'])) {
// Xml2PdfTextTag::close() {{{
* Manage the trext writing.
public function close() {
$this->pdf->setTextColor($fontColor['r'], $fontColor['g'],
// Xml2PdfTextTag::render() {{{
* Write the text in the PDF if the tag use styles tags.
// first style is text style!
// Xml2PdfTextTag::_parseContent() {{{
* Return a part of the content.
* array(0 => 'string', // text witch have been extract or tag name
* 1 => 'string', // c if return closing tag, o if return opening tag, s if return space, t if return text
* 2 => 'string' // text witch don't be parsed.
* Return false if all the content have been parsed.
$result[2] =
trim($regs[2]);
} else if(ereg('^(<([^>]+)>).*', $this->content, $regs)) {
$regs[2] =
ereg_replace('^a', 'a ', $regs[2]); // Rustine : l'espace disparaît
$result[2] =
trim($regs[2]);
if(ereg('(.+) (.+)=\'(.+)\' *', $regs[2])) {
$params =
split(" +",$regs[2]);
$result[2] =
trim($params[0]);
while(list
($i, $couple) =
each($params)) {
$couple[0] =
trim($couple[0]);
$couple[1] =
trim($couple[1]);
$end =
strlen($couple[1]) -
2;
$result[$couple[0]] =
substr($couple[1], 1, $end);
} else if(ereg('^([^< ]+).*', $this->content, $regs)) {
$result[2] =
trim($regs[1]);
$begin = isset
($regs[1])?
strlen($regs[1]):
0;
// Xml2PdfTextTag::_makeLine() {{{
* Buil the next line to write.
while ($continue &&
$result) {
if(in_array($result[1], array('s', 't'))) {
//echo 'text or space : ';
} elseif (in_array($result[1], array('c', 'o'))) {
// on ajoute le tag de style
} elseif($result[1] ==
'c') {
if(isset
($foo['indent'])) {
//echo $line . "<br><br>";
// Xml2PdfTextTag::_printLine(string) {{{
$width =
$this->pdf->getStringWidth($line);
$this->pdf->setX($this->_x);
$maxWidth =
190 -
$this->_x;
for($i=
0 ; $i<
$lineLength ; $i++
) {
if($this->pdf->getStringWidth($foo) >
$maxWidth) {
// ca dépasse, faut couper
$foo =
substr($tmp, 0, $spacePos);
$tmp =
substr($tmp, $spacePos, $lineLength-
$spacePos);
$this->pdf->Cell($this->pdf->getStringWidth($foo), $this->lineHeight, $foo, 0, $indent, 'L', 0);
$this->_x =
$this->pdf->GetX();
// Xml2PdfTextTag::_setStyle() {{{
* Search the styles information and put them.
for($i=
$count-
1 ; $i>=
0 ; $i--
) {
if(empty($fontColor) && isset
($this->styleStack[$i]['color'])) {
if(empty($font) && isset
($this->styleStack[$i]['font'])) {
if(empty($fontSize) && isset
($this->styleStack[$i]['font-size'])) {
/*if(!$indentSetted && isset($this->styleStack[$i]['indent'])) {
$this->_indent = $this->styleStack[$i]['indent'];
$this->pdf->setFont($font, $fontStyle, $fontSize);
$this->pdf->setTextColor($fontColor['r'], $fontColor['g'], $fontColor['b']);
// Xml2PdfTextTag::_cleanContent() {{{
* Remove the styles information to the content.
Documentation generated on Wed, 11 Oct 2006 22:27:34 +0200 by phpDocumentor 1.3.0