/*!
Insert footer/header into PDF document

\param text
\param text parameters
180229
function ezInsertFrame( $text, $textParameters )
    {
        $size = $this->fontSize();
        if ( isset( $textParameters['size'] ) )
        {
            $size = $textParameters['size'];
        }

        $previousFont = $this->currentFont();
        if ( isset( $textParameters['font'] ) )
        {
            $this->selectFont( $textParameters['font'] );
        }

        $justification = $this->justification();
        if ( isset( $textParameters['justification'] ) )
        {
            $justification = $textParameters['justification'];
        }

        switch( $textParameters['location'] )
        {
            case 'footer':
            {
                $frameCoords =& $this->ezFrame['footer'];
            } break;

            case 'frame_header':
            {
                $frameCoords =& $this->ezFrame['header'];
            } break;

            default:
            {
                $frameCoords =& $this->ezFrame[0];
            } break;
        }

        foreach ( $this->ezPages as $pageNum => $pageID )
        {
            if ( $pageNum < $textParameters['pageOffset'] )
                continue;

            $frameText = $text; //Create copy of text
            if( $textParameters['page'] == 'even' &&
                $pageNum % 2 == 1 )
                continue;
            else if ( $textParameters['page'] == 'odd' &&
                      $pageNum % 2 == 0 )
                continue;

            $countIdentifier = '';
            if ( strstr( $frameText, self::PAGENUM ) !== false )
            {
                foreach ( array_keys( $this->PageCounter ) as $identifier )
                {
                    if ( $this->PageCounter[$identifier]['start'] <= $pageNum &&
                         $this->PageCounter[$identifier]['stop'] >= $pageNum )
                    {
                        $frameText = str_replace( self::PAGENUM,
                                                  $this->ezWhatPageNumber( $pageNum, $identifier ),
                                                  $frameText );

                        if ( strstr( $frameText, self::TOTAL_PAGENUM ) !== false )
                        {
                            $frameText = str_replace( self::TOTAL_PAGENUM,
                                                      $this->PageCounter[$identifier]['stop'] - $this->PageCounter[$identifier]['start'] + 1,
                                                      $frameText );
                        }
                    }
                }
            }

            for( $levelCount = 0; $levelCount < 9; $levelCount++ )
            {
                if ( strstr( $frameText, self::HEADER_LEVEL.$levelCount ) !== false )
                {
                    $frameText = str_replace( self::HEADER_LEVEL.$levelCount,
                                              $this->headerLabel( $pageNum, $levelCount ),
                                              $frameText );
                }

                if ( strstr( $frameText, self::HEADER_LEVEL_INDEX.$levelCount ) !== false )
                {
                    $frameText = str_replace( self::HEADER_LEVEL_INDEX.$levelCount,
                                              $this->headerIndex( $pageNum, $levelCount ),
                                              $frameText );
                }
            }

            $yOffset = $frameCoords['y0'] - $frameCoords['topMargin'];
            if ( $textParameters['newline'] )
            {
                $yOffset -= $this->getFontHeight( $size );
            }

            $yOffset -= $this->getFontHeight( $size );
            $xOffset = $frameCoords['leftMargin'];
            $pageWidth = $this->ez['pageWidth'] - $frameCoords['leftMargin'] - $frameCoords['rightMargin'];

            $this->reopenObject($pageID);

            $lines = explode( "\n", $frameText );
            foreach ( array_keys( $lines ) as $key )
            {
                $start=1;
                $line = $lines[$key];
                while (strlen($line) || $start){
                    $start = 0;
                    $textInfo = $this->addTextWrap( $xOffset, $yOffset, $pageWidth, $size, $line, $justification );
                    $line = $textInfo['text'];

                    if ( strlen( $line ) )
                    {
                        $yOffset -= $this->getFontHeight( $size );
                    }
                }
            }

            $this->closeObject();
        }

        $this->selectFont( $previousFont );
    }
27075
@Override
	public void onEndPage(final PdfWriter writer, final Document document) {
		final int pageN = writer.getPageNumber();
		final String text = pageN + " / ";
		final float len = bf.getWidthPoint(text, 8);
		cb.beginText();
		cb.setFontAndSize(bf, 8);
		final float width = document.getPageSize().getWidth();
		cb.setTextMatrix(width / 2, 30);
		cb.showText(text);
		cb.endText();
		cb.addTemplate(template, width / 2 + len, 30);
	}
386752
static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) {
    $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'");

    // Ensure that the fonts needed by the cached document are loaded into
    // the pdf
    while ($row = pg_fetch_assoc($res)) 
      $pdf->get_cpdf()->selectFont($row["font_name"]);
    
    $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'");

    if ( $new_page )
      $pdf->new_page();

    $first = true;
    while ($row = pg_fetch_assoc($res)) {

      if ( !$first ) 
        $pdf->new_page();
      else 
        $first = false;        
      
      $page = $pdf->reopen_serialized_object($row["data"]);
      //$pdf->close_object();
      $pdf->add_object($page, "add");

    }
      
  }
933740
function writeParameters(entry, out) {
    // If headers are in an object, convert them to an array for better
    // display.
    entry = reformatHeaders(entry);

    // Use any parameter writer available for this event type.
    const paramsWriter = getParameterWriterForEventType(entry.type);
    const consumedParams = {};
    if (paramsWriter) {
      paramsWriter(entry, out, consumedParams);
    }

    // Write any un-consumed parameters.
    for (const k in entry.params) {
      if (consumedParams[k]) {
        continue;
      }
      defaultWriteParameter(k, entry.params[k], out);
    }
  }
185774
function insertArticle(summary, article, level) {
    article = SummaryArticle(article);
    level = is.string(level)? level : level.getLevel();

    var parent = summary.getParent(level);
    if (!parent) {
        return summary;
    }

    // Find the index to insert at
    var articles = parent.getArticles();
    var index = getLeafIndex(level);

    // Insert the article at the right index
    articles = articles.insert(index, article);

    // Reindex the level from here
    parent = parent.set('articles', articles);
    parent = indexArticleLevels(parent);

    return mergeAtLevel(summary, parent.getLevel(), parent);
}
798724
function (text) {
            var preview = panels.preview;
            var parent = preview.parentNode;
            var sibling = preview.nextSibling;
            parent.removeChild(preview);
            preview.innerHTML = text;
            if (!sibling)
                parent.appendChild(preview);
            else
                parent.insertBefore(preview, sibling);
        }
220442
function ( text, parameters ) {

	parameters = parameters || {};

	var font = parameters.font;

	if ( ! ( font && font.isFont ) ) {

		console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
		return new Geometry();

	}

	var shapes = font.generateShapes( text, parameters.size );

	// translate parameters to ExtrudeGeometry API

	parameters.depth = parameters.height !== undefined ? parameters.height : 50;

	// defaults

	if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;

	ExtrudeBufferGeometry.call( this, shapes, parameters );

	this.type = '';

}
101445
function(bodyContents) {
            // Cleanup
            this.$main.html('');

            if (this.$header) {
                this.$hud.removeClass('has-header');
                this.$header.remove();
                this.$header = null;
            }

            if (this.$footer) {
                this.$hud.removeClass('has-footer');
                this.$footer.remove();
                this.$footer = null;
            }

            // Append the new body contents
            this.$main.append(bodyContents);

            // Look for a header and footer
            var $header = this.$main.find('.' + this.settings.headerClass + ':first'),
                $footer = this.$main.find('.' + this.settings.footerClass + ':first');

            if ($header.length) {
                this.$header = $header.insertBefore(this.$mainContainer);
                this.$hud.addClass('has-header');
            }

            if ($footer.length) {
                this.$footer = $footer.insertAfter(this.$mainContainer);
                this.$hud.addClass('has-footer');
            }
        }
1062553
function callTable( $params, $text )
    {
        $textLen = strlen( $text );
        $tableData = array();
        $cellData = array();
        $showLines = 2;
        $rowCount = 0;
        $columnCount = 0;

        $columnText = '';

        $keyArray = array ( 'c', 'm', 'y', 'k' );
        if ( isset( $params['titleCellCMYK'] ) )
        {
            $params['titleCellCMYK'] = explode( ',', $params['titleCellCMYK'] );
            foreach ( array_keys( $params['titleCellCMYK'] ) as $key )
            {
                $params['titleCellCMYK'][$keyArray[$key]] = $params['titleCellCMYK'][$key];
                unset( $params['titleCellCMYK'][$key] );
            }
        }

        if ( isset( $params['cellCMYK'] ) )
        {
            $params['cellCMYK'] = explode( ',', $params['cellCMYK'] );
            foreach ( array_keys( $params['cellCMYK'] ) as $key )
            {
                $params['cellCMYK'][$keyArray[$key]] = $params['cellCMYK'][$key];
                unset( $params['cellCMYK'][$key] );
            }
            $params['shaded'] = 2;
            $params['shadeCol'] = $params['cellCMYK'];
            $params['shadeCol2'] = $params['cellCMYK'];
        }

        if ( isset( $params['textCMYK'] ) )
        {
            $params['textCMYK'] = explode( ',', $params['textCMYK'] );
            foreach ( array_keys( $params['textCMYK'] ) as $key )
            {
                $params['textCMYK'][$keyArray[$key]] = $params['textCMYK'][$key];
                unset( $params['textCMYK'][$key] );
            }
            $params['textCol'] = $params['textCMYK'];
        }

        if ( isset( $params['titleTextCMYK'] ) )
        {
            $params['titleTextCMYK'] = explode( ',', $params['titleTextCMYK'] );
            foreach ( array_keys( $params['titleTextCMYK'] ) as $key )
            {
                $params['titleTextCMYK'][$keyArray[$key]] = $params['titleTextCMYK'][$key];
                unset( $params['titleTextCMYK'][$key] );
            }
            $params['titleTextCMYK'] = $params['titleTextCMYK'];
        }

        if ( isset( $params['showLines'] ) )
        {
            $showLines = $params['showLines'];
        }

        for ( $offSet = 0; $offSet < $textLen; $offSet++ )
        {
            if ( $text[$offSet] == '<' )
            {
                if ( strcmp( substr($text, $offSet+1, strlen( 'tr' ) ), 'tr' ) == 0 )
                {
                    $tableData[] = array();
                    $offSet++;
                    $offSet += strlen( 'tr' );
                    continue;
                }
                else if ( strcmp( substr($text, $offSet+1, strlen( 'td' ) ), 'td' ) == 0 )
                {
                    $tdParams = array();
                    $offSet++;
                    $offSet += strlen( 'td' );
                    $offSet = eZPDFTable::extractParameters( $text, $offSet, $tdParams );

                    if ( count( $tdParams ) > 0 )
                    {
                        $cellData[$columnCount. ',' .$rowCount] = array();
                        if ( isset( $tdParams['colspan'] ) )
                        {
                            $cellData[$columnCount. ',' .$rowCount]['size'] = (int)$tdParams['colspan'];
                        }
                        if ( isset( $tdParams['align'] ) )
                        {
                            $cellData[$columnCount. ',' .$rowCount]['justification'] = $tdParams['align'];
                        }
                        if ( isset( $tdParams['width'] ) )
                        {
                            $cellData[$columnCount. ',' .$rowCount]['width'] = $tdParams['width'];
                        }
                    }
                    continue;
                }
                else if ( strcmp( substr($text, $offSet+1, strlen( 'th' ) ), 'th' ) == 0 )
                {
                    $thParams = array();
                    $offSet++;
                    $offSet += strlen( 'th' );
                    $offSet = eZPDFTable::extractParameters( $text, $offSet, $thParams );

                    $cellData[$columnCount. ',' .$rowCount] = array();
                    $cellData[$columnCount.','.$rowCount]['title'] = true;
                    if ( isset( $thParams['colspan'] ) )
                    {
                        $cellData[$columnCount. ',' .$rowCount]['size'] = (int)$thParams['colspan'];
                    }
                    if ( isset( $thParams['align'] ) )
                    {
                        $cellData[$columnCount. ',' .$rowCount]['justification'] = $thParams['align'];
                    }
                    if ( isset( $thParams['width'] ) )
                    {
                        $cellData[$columnCount. ',' .$rowCount]['width'] = $thParams['width'];
                    }
                    continue;
                }
                else if ( strcmp( substr($text, $offSet+1, strlen( '/tr' ) ), '/tr' ) == 0 )
                {
                    $rowCount++;
                    $columnCount = 0;
                    $offSet++;
                    $offSet += strlen( '/tr' );
                    continue;
                }
                else if ( strcmp( substr($text, $offSet+1, strlen( '/td' ) ), '/td' ) == 0 )
                {
                    if ( $columnCount == 0 )
                    {
                        $tableData[$rowCount] = array();
                    }
                    $tableData[$rowCount][$columnCount] = $columnText;
                    $columnText = '';
                    $columnCount++;
                    $offSet++;
                    $offSet += strlen( '/td' );
                    continue;
                }
                else if ( strcmp( substr($text, $offSet+1, strlen( '/th' ) ), '/th' ) == 0 )
                {
                    if ( $columnCount == 0 )
                    {
                        $tableData[$rowCount] = array();
                    }
                    $tableData[$rowCount][$columnCount] = $columnText;
                    $columnText = '';
                    $columnCount++;
                    $offSet++;
                    $offSet += strlen( '/th' );
                    continue;
                }
            }
            $columnText .= $text[$offSet];
        }
        $this->addDocSpecFunction( 'ezTable', array( &$tableData, '', '', array_merge( array( 'cellData' => $cellData,
                                                                                             'showLines' => $showLines ),
                                                                                      $params ) ) );
    }
1205372
public ExcelWriter setHeaderOrFooter(String text, Align align, boolean isFooter) {
		final HeaderFooter headerFooter = isFooter ? this.sheet.getFooter() : this.sheet.getHeader();
		switch (align) {
		case LEFT:
			headerFooter.setLeft(text);
			break;
		case RIGHT:
			headerFooter.setRight(text);
			break;
		case CENTER:
			headerFooter.setCenter(text);
			break;
		default:
			break;
		}
		return this;
	}
1017425
function add_link($url, $x, $y, $width, $height) {
		//Helpers::dompdf_debug("trace", "($url, $x, $y, $width, $height)");

		if (strpos($url, '#') === 0) {
			// Local link
			$name = substr($url, 1);
			if ($name) {
				$page = $this->_pdf->PageNo();
				//$this->_pdf->Link($x, $y, $width, $height, $this->_nameddest[$name]);
				$this->_internal_links[] = compact('page', 'name', 'x', 'y', 'width', 'height');	//array($this->_pdf->PageNo(), $name, $x, $y, $width, $height);
			}
		}
		else {
			$this->_pdf->Link($x, $y, $width, $height, rawurldecode($url));
		}
	}
1296178
private String replaceParameters(String text) {
    	Map<String, Object> params  = bean.getParametersBean().getParamValues();
        for  (String param : params.keySet()) {
             text = StringUtil.replace(text, "\\$P\\{" + param + "\\}", StringUtil.getValueAsString(params.get(param), null));
        }
        return text;
    }
717569
function OverWrite($file_in, $search, $replacement, $dest = Destination::DOWNLOAD, $file_out = "mpdf")
	{
		$pdf = file_get_contents($file_in);

		if (!is_array($search)) {
			$x = $search;
			$search = [$x];
		}
		if (!is_array($replacement)) {
			$x = $replacement;
			$replacement = [$x]; // mPDF 5.7.4
		}

		if (!$this->onlyCoreFonts && !$this->usingCoreFont) {
			foreach ($search as $k => $val) {
				$search[$k] = $this->writer->utf8ToUtf16BigEndian($search[$k], false);
				$search[$k] = $this->writer->escape($search[$k]);
				$replacement[$k] = $this->writer->utf8ToUtf16BigEndian($replacement[$k], false);
				$replacement[$k] = $this->writer->escape($replacement[$k]);
			}
		} else {
			foreach ($replacement as $k => $val) {
				$replacement[$k] = mb_convert_encoding($replacement[$k], $this->mb_enc, 'utf-8');
				$replacement[$k] = $this->writer->escape($replacement[$k]);
			}
		}

		// Get xref into array
		$xref = [];
		preg_match("/xref\n0 (\d+)\n(.*?)\ntrailer/s", $pdf, $m);
		$xref_objid = $m[1];
		preg_match_all('/(\d{10}) (\d{5}) (f|n)/', $m[2], $x);
		for ($i = 0; $i < count($x[0]); $i++) {
			$xref[] = [intval($x[1][$i]), $x[2][$i], $x[3][$i]];
		}

		$changes = [];
		preg_match("/<<\s*\/Type\s*\/Pages\s*\/Kids\s*\[(.*?)\]\s*\/Count/s", $pdf, $m);
		preg_match_all("/(\d+) 0 R /s", $m[1], $o);
		$objlist = $o[1];

		foreach ($objlist as $obj) {
			if ($this->compress) {
				preg_match("/" . ($obj + 1) . " 0 obj\n<<\s*\/Filter\s*\/FlateDecode\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s", $pdf, $m);
			} else {
				preg_match("/" . ($obj + 1) . " 0 obj\n<<\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s", $pdf, $m);
			}

			$s = $m[2];
			if (!$s) {
				continue;
			}

			$oldlen = $m[1];

			if ($this->encrypted) {
				$s = $this->protection->rc4($this->protection->objectKey($obj + 1), $s);
			}

			if ($this->compress) {
				$s = gzuncompress($s);
			}

			foreach ($search as $k => $val) {
				$s = str_replace($search[$k], $replacement[$k], $s);
			}

			if ($this->compress) {
				$s = gzcompress($s);
			}

			if ($this->encrypted) {
				$s = $this->protection->rc4($this->protection->objectKey($obj + 1), $s);
			}

			$newlen = strlen($s);

			$changes[($xref[$obj + 1][0])] = ($newlen - $oldlen) + (strlen($newlen) - strlen($oldlen));

			if ($this->compress) {
				$newstr = ($obj + 1) . " 0 obj\n<</Filter /FlateDecode /Length " . $newlen . ">>\nstream\n" . $s . "\nendstream\n";
			} else {
				$newstr = ($obj + 1) . " 0 obj\n<</Length " . $newlen . ">>\nstream\n" . $s . "\nendstream\n";
			}

			$pdf = str_replace($m[0], $newstr, $pdf);
		}

		// Update xref in PDF
		krsort($changes);
		$newxref = "xref\n0 " . $xref_objid . "\n";
		foreach ($xref as $v) {
			foreach ($changes as $ck => $cv) {
				if ($v[0] > $ck) {
					$v[0] += $cv;
				}
			}
			$newxref .= sprintf('%010d', $v[0]) . ' ' . $v[1] . ' ' . $v[2] . " \n";
		}
		$newxref .= "trailer";
		$pdf = preg_replace("/xref\n0 \d+\n.*?\ntrailer/s", $newxref, $pdf);

		// Update startxref in PDF
		preg_match("/startxref\n(\d+)\n%%EOF/s", $pdf, $m);
		$startxref = $m[1];
		$startxref += array_sum($changes);
		$pdf = preg_replace("/startxref\n(\d+)\n%%EOF/s", "startxref\n" . $startxref . "\n%%EOF", $pdf);

		// OUTPUT
		switch ($dest) {
			case Destination::INLINE:
				if (isset($_SERVER['SERVER_NAME'])) {
					// We send to a browser
					header('Content-Type: application/pdf');
					header('Content-Length: ' . strlen($pdf));
					header('Content-disposition: inline; filename=' . $file_out);
				}

				echo $pdf;

				break;

			case Destination::FILE:
				if (!$file_out) {
					$file_out = 'mpdf.pdf';
				}

				$f = fopen($file_out, 'wb');

				if (!$f) {
					throw new \Mpdf\MpdfException('Unable to create output file: ' . $file_out);
				}

				fwrite($f, $pdf, strlen($pdf));

				fclose($f);

				break;

			case Destination::STRING_RETURN:
				return $pdf;

			case Destination::DOWNLOAD: // Download file
			default:
				if (isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
					header('Content-Type: application/force-download');
				} else {
					header('Content-Type: application/octet-stream');
				}

				header('Content-Length: ' . strlen($pdf));
				header('Content-disposition: attachment; filename=' . $file_out);

				echo $pdf;

				break;
		}
	}
480492
public function addFootnote($noteText, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null)
    {
        $footnote = new PHPRtfLite_Footnote($this->_rtf, $noteText, $font, $parFormat);
        $this->_elements[] = $footnote;
        return $footnote;
    }
752286
private PdfPCell createFooterCell(Object val) throws VectorPrintException {
      try {
         return elementProducer.createElement(val, PdfPCell.class, getStylers(PAGEFOOTERSTYLEKEY));
      } catch (InstantiationException | IllegalAccessException ex) {
         throw new VectorPrintException(ex);
      }
   }
550936
function insertTextFrame( $params, $text )
    {
        $prevColor = $this->currentColour;
        $prevFontSize = $this->fontSize();
        $prevFont = $this->currentFont();

        if ( isset( $params['fontSize'] ) )
        {
            $this->setFontSize( $params['fontSize'] );
        }

        if ( isset( $params['fontName'] ) )
        {
            $this->selectFont( $params['fontName'] );
        }

        $cmykKeys = array( 'c', 'm', 'y', 'k' );
        if ( isset( $params ['frameCMYK'] ) )
        {
            $params['frameCMYK'] = explode( ',', $params['frameCMYK'] );
            foreach ( $cmykKeys as $oldKey => $newKey )
            {
                $params['frameCMYK'][$newKey] = $params['frameCMYK'][$oldKey];
                unset( $params['frameCMYK'][$oldKey] );
            }
        }
        if ( isset( $params['textCMYK'] ) )
        {
            $params['textCMYK'] = explode( ',', $params['textCMYK'] );
            foreach ( $cmykKeys as $oldKey => $newKey )
            {
                $params['textCMYK'][$newKey] = $params['textCMYK'][$oldKey];
                unset( $params['textCMYK'][$oldKey] );
            }
        }

        $padding = 0;
        if ( isset( $params['padding'] ) )
        {
            $padding = $params['padding'];
        }

        $leftPadding = $padding;
        $rightPadding = $padding;
        $topPadding = $padding;
        $bottomPadding = $padding;

        if ( isset( $params['leftPadding'] ) )
        {
            $leftPadding = $params['leftPadding'];
        }
        if ( isset( $params['rightPadding'] ) )
        {
            $rightPadding = $params['rightPadding'];
        }
        if ( isset( $params['topPadding'] ) )
        {
            $topPadding = $params['topPadding'];
        }
        if ( isset( $params['bottomPadding'] ) )
        {
            $bottomPadding = $params['bottomPadding'];
        }

        $yOffset = $this->yOffset();
        $xOffset = $this->xOffset();

        $fontHeight = $this->getFontHeight( $this->ez['fontSize'] );
        $fontDecender = $this->getFontDecender( $this->ez['fontSize'] );
        $textWidth = $this->getTextWidth( $this->ez['fontSize'], $text );

        $totalHeight = $fontHeight + $topPadding;
        $totalWidth = $textWidth + $leftPadding + $rightPadding;

        if ( $rightPadding == -1 )
        {
            $totalWidth = $leftPadding + $this->ez['pageWidth'] - $xOffset + 10;
        }

        if ( isset( $params['frameCMYK'] ) )
        {
            $this->setColor( $params['frameCMYK'] );
        }
        $this->filledRectangle( $xOffset - $leftPadding,
                                $yOffset - $bottomPadding,
                                $totalWidth,
                                $totalHeight );

        if ( isset( $params['roundEnds'] ) )
        {
            if ( $rightPadding != -1 )
            {
                $this->filledEllipse( $xOffset + $textWidth + $rightPadding, $yOffset - $bottomPadding + ( $totalHeight / 2 ), $totalHeight / 2 );
            }
            if ( $leftPadding != -1 )
            {
                $this->filledEllipse( $xOffset - $leftPadding, $yOffset - $bottomPadding + ( $totalHeight / 2 ), $totalHeight / 2 );
            }
        }

        if ( isset( $params['textCMYK'] ) )
        {
            $this->setColor( $params['textCMYK'] );
        }
        else
        {
            $this->setColor( $prevColor );
        }
        $this->addText( $xOffset, $yOffset, $this->fontSize(), $text );

        $this->setColor( $prevColor );
        $this->setFontSize( $prevFontSize );
        $this->selectFont( $prevFont );
    }
255689
static function TextToHtml($txt) 
	{
		//Kills double spaces and spaces inside tags.
		while( !( strpos($txt,'  ') === FALSE ) ) $txt = str_replace('  ',' ',$txt);
		$txt = str_replace(' >','>',$txt);
		$txt = str_replace('< ','<',$txt);
	
		//Transforms accents in html entities.
		$txt = htmlentities($txt);
	
		//We need some HTML entities back!
		$txt = str_replace('&quot;','"',$txt);
		$txt = str_replace('&lt;','<',$txt);
		$txt = str_replace('&gt;','>',$txt);
		$txt = str_replace('&amp;','&',$txt);
	
		//Ajdusts links - anything starting with HTTP opens in a new window
		//$txt = str_ireplace("<a href=\"http://","<a target=\"_blank\" href=\"http://",$txt);
		//$txt = str_ireplace("<a href=http://","<a target=\"_blank\" href=http://",$txt);

		
		//Basic formatting
		$eol = ( strpos($txt,"\r") === FALSE ) ? "\n" : "\r\n";
		$html = '<p>'.str_replace("$eol$eol","</p><p>",$txt).'</p>';
		$html = str_replace("$eol","<br />\n",$html);
		$html = str_replace("</p>","</p>\n\n",$html);
		$html = str_replace("<p></p>","<p>&nbsp;</p>",$html);
	
		//Wipes <br> after block tags (for when the user includes some html in the text).
		$wipebr = Array("table","tr","td","blockquote","ul","ol","li");
	
		for($x = 0; $x < count($wipebr); $x++) 
		{
			$tag = $wipebr[$x];
			$html = str_ireplace("<$tag><br />","<$tag>",$html);
			$html = str_ireplace("</$tag><br />","</$tag>",$html);
		}
	
		return $html;
	}