tag
- $p_pattern = '/( (.+)<\/p>(.*<\/block>)/';
- // PCRE matching a
tag
- $br_pattern = '/
/';
-
- $return = array();
- if(preg_match($key_pattern,$line,$matches)) {
- $key = true;
- $line_width = $line_width - 50;
- $format = processFormatTags($matches[2],'B');
- $return[] = array('setFont',array($fontName,$format[0],7));
- $return[] = array('Cell',array(50,5,$format[1] . ':',0,0,'R',0));
- $return[] = array('setFont',array($fontName,'',7));
- return array_merge($return,processLine($matches[1] . $matches[3],false,$fontName));
+function printTable(&$pdf, $table, $fontName) {
+ if (!empty($table->getHeadline())) {
+ $pdf->SetFont($fontName, 'B', LAMPDF_FONT_SIZE);
+ $pdf->Cell(LAMPDF_LABELWIDTH, LAMPDF_LINEHEIGHT, $table->getHeadline() . ':', 0 , 0, 'L', 0);
+ $pdf->Ln(LAMPDF_LINEHEIGHT);
}
- elseif(preg_match($value_pattern,$line,$matches)) {
- $format = processFormatTags($matches[2],'');
- $return[] = array('setFont',array($fontName,$format[0],7));
- $return[] = array('MultiCell',array(0,5,$format[1],0,'L',0));
- $return[] = array('setFont',array($fontName,'',7));
- return array_merge($return,processLine($matches[1] . $matches[3],true,$fontName));
- }
- elseif(preg_match($p_pattern,$line,$matches)) {
- $format = processFormatTags($matches[2],'');
- $return[] = array('setFont',array($fontName,$format[0],7));
- $return[] = array('Write',array(5,$format[1]));
- $return[] = array('setFont',array($fontName,'',7));
- return array_merge($return,processLine($matches[1] . $matches[3],true,$fontName));
- }
- elseif(preg_match($td_pattern,$line,$matches)) {
- if($first_td && $key) {
- $first_td = !$first_td;
- $return[] = array('Cell',array(50,5,'',0,0,'L',0));
+ foreach ($table->rows as $row) {
+ foreach ($row->cells as $cell) {
+ $width = $cell->width;
+ if (!empty($width) && (strpos($width, '%') !== false)) {
+ $width = ceil(LAMPDF_LINEWIDTH * substr($width, 0, -1) / 100);
+ }
+ if ($cell->bold) {
+ $pdf->SetFont($fontName, 'B', LAMPDF_FONT_SIZE);
+ }
+ $pdf->Cell($width, LAMPDF_LINEHEIGHT, $cell->content, 0, 0, $cell->align, 0);
+ if ($cell->bold) {
+ $pdf->SetFont($fontName, '', LAMPDF_FONT_SIZE);
+ }
}
- $format = processFormatTags($matches[3],'');
- $attrs = processAttributes($matches[2],array('width' => $line_width,'height' => 5,'align' => 'L'));
- $return[] = array('setFont',array($fontName,$format[0],7));
- $return[] = array('Cell',array($attrs['width'],$attrs['height'],$format[1],0,0,$attrs['align'],0));
- $return[] = array('setFont',array($fontName,'',7));
- return array_merge($return,processLine($matches[1] . $matches[4],$first_td,$fontName));
- }
- elseif(preg_match($br_pattern,$line,$matches)) {
- return array(array('Ln',array(5)));
- }
- elseif(preg_match($block_pattern,$line,$matches)) {
- $line_width = LAMPDF_LINEWIDTH;
- return array();
- }
- elseif(preg_match($tr_pattern,$line,$matches)) {
- $line_width = LAMPDF_LINEWIDTH;
- return array(array('Ln',array(5)));
- }
-}
-
-/**
- * Formats the XML code.
- *
- * @param string $line XML code of PDF entry
- * @param string $style style commands
- *
- * @return array XML code
- */
-function processFormatTags($line,$style) {
- // PCRE matching a tag
- $i_pattern = '/(.*)(.+)<\/i>(.*)/';
- // PCRE matching a tag
- $b_pattern = '/(.*)(.+)<\/b>(.*)/';
- // PCRE matching a tag
- $u_pattern = '/(.*)(.+)<\/u>(.*)/';
- // Replacement pattern when one of the above pattern matched
- $replace = "\$1\$2\$3";
-
- if(preg_match($i_pattern,$line,$matches)) {
- $style .= "I";
- $line = preg_replace($i_pattern,$replace,$line);
- }
- if(preg_match($b_pattern,$line,$matches)) {
- $style .= "B";
- $line = preg_replace($b_pattern,$replace,$line);
- }
- if(preg_match($u_pattern,$line,$matches)) {
- $style .= "U";
- $line = preg_replace($u_pattern,$replace,$line);
- }
- return array($style,$line);
-}
-
-/**
- * Processes width, height and alignment attributes.
- *
- * @param string $attrs attributes
- * @param array $return XML code
- *
- * @return array XML code
- */
-function processAttributes($attrs,$return = array()) {
- global $line_width;
-
- // PCRE matching width attribute
- $width_pattern = '/(.*)width\=\"(\\d+)(\%?)\"(.*)/';
- // PCRE matching height attribute
- $height_pattern = '/(.*)height\=\"(\\d+)\"(.*)/';
- // PCRE matching align attribute
- $align_pattern = '/(.*)align\=\"(L|R|C)\"(.*)/';
-
- // Remove leading and trailing whitespaces
- $attrs = trim($attrs);
-
- if(preg_match($width_pattern,$attrs,$matches)) {
- if($matches[3] == '%') {
- $return['width'] = ceil($line_width * $matches[2] / 100);
- }
- else {
- $return['width'] = ceil($matches[2]);
- }
- return processAttributes($matches[1] . $matches[4],$return);
- }
- elseif(preg_match($height_pattern,$attrs,$matches)) {
- $return['height'] = $matches[2];
- return processAttributes($matches[1] . $matches[3],$return);
- }
- elseif(preg_match($align_pattern,$attrs,$matches)) {
- $return['align'] = $matches[2];
- return processAttributes($matches[1] . $matches[3],$return);
- }
- else {
- return $return;
+ $pdf->Ln(LAMPDF_LINEHEIGHT);
}
+ $pdf->Ln(LAMPDF_LINEHEIGHT);
}
/**
@@ -409,15 +275,6 @@ class PDFTable implements PDFEntry {
$this->label = $label;
}
- /**
- * Returns the label.
- *
- * @return string $label label
- */
- public function getLabel() {
- return $this->label;
- }
-
/**
* {@inheritDoc}
* @see PDFEntry::getHeadline()
diff --git a/lam/lib/xml_parser.inc b/lam/lib/xml_parser.inc
index f06bb328..fb425911 100644
--- a/lam/lib/xml_parser.inc
+++ b/lam/lib/xml_parser.inc
@@ -60,7 +60,8 @@ class xmlParser {
if(file_exists($filename)) {
$xmlStructure = array();
$xmlIndex = array();
- xml_parse_into_struct($this->xmlParser, implode("\n", file($filename)), $xmlStructure, $xmlIndex);
+ $xmlContent =
+ xml_parse_into_struct($this->xmlParser, implode("", file($filename)), $xmlStructure, $xmlIndex);
return array($xmlStructure, $xmlIndex);
}
return array();
diff --git a/lam/templates/pdfedit/pdfpage.php b/lam/templates/pdfedit/pdfpage.php
index aa295ac2..e31b46f1 100644
--- a/lam/templates/pdfedit/pdfpage.php
+++ b/lam/templates/pdfedit/pdfpage.php
@@ -143,11 +143,11 @@ if(isset($_GET['submit'])) {
// add a new text field
elseif(isset($_GET['add_text'])) {
// Check if text for static text field is specified
- if(!isset($_GET['text_text']) || ($_GET['text_text'] == '')) {
+ if(empty($_GET['text_text'])) {
StatusMessage('ERROR',_('No static text specified'),_('The static text must contain at least one character.'));
}
else {
- $entry = array(array('tag' => 'TEXT','type' => 'complete','level' => '2','value' => $_GET['text_text']));
+ $entry = array(array('tag' => 'TEXT','type' => 'complete','level' => '2','value' => str_replace("\r", "\n", $_GET['text_text'])));
// Insert new field in structure
array_splice($_SESSION['currentPDFStructure'],$_GET['add_text_position'],0,$entry);
}