added <tr> tag for PDF to fix layout issues

This commit is contained in:
Roland Gruber 2005-07-28 09:01:41 +00:00
parent fdda8f8e4c
commit c2de13f7c1
3 changed files with 32 additions and 18 deletions

View File

@ -1053,11 +1053,16 @@ name<span style="font-weight: bold; font-style: italic;">&lt;/key&gt;&lt;value&g
value<span style="font-weight: bold; font-style: italic;">&lt;/value&gt;&lt;/block&gt;</span></li>
<li><span style="font-weight: bold;">table:</span> <span
style="font-weight: bold; font-style: italic;">&lt;block&gt;&lt;key&gt;</span>attribute
name<span style="font-weight: bold; font-style: italic;">&lt;/key&gt;&lt;td&gt;</span>first
value<span style="font-weight: bold; font-style: italic;">&lt;td&gt;&lt;/block&gt;&lt;block&gt;&lt;td&gt;</span>second
value<span style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/block&gt;&lt;block&gt;&lt;td&gt;</span><span
style="font-weight: bold;"></span>third value<span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/block&gt;</span></li>
name<span style="font-weight: bold; font-style: italic;">&lt;/key&gt;&lt;tr&gt;&lt;td&gt;</span>value<span
style="font-weight: bold; font-style: italic;">&lt;td&gt;</span><span
style="font-weight: bold; font-style: italic;">&lt;td&gt;</span>value<span
style="font-weight: bold; font-style: italic;">&lt;td&gt;</span><span
style="font-weight: bold; font-style: italic;">&lt;/tr&gt;&lt;/block&gt;&lt;block&gt;&lt;tr&gt;&lt;td&gt;</span>value<span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;</span><span
style="font-weight: bold; font-style: italic;">&lt;td&gt;</span>value<span
style="font-weight: bold; font-style: italic;">&lt;td&gt;</span><span
style="font-weight: bold; font-style: italic;">&lt;/tr&gt;&lt;/block&gt;</span><span
style="font-weight: bold; font-style: italic;"></span></li>
</ul>
<br>
Special commands:<br style="font-weight: bold;">
@ -1066,11 +1071,14 @@ Special commands:<br style="font-weight: bold;">
You can specify the alignment in &lt;td&gt; tags with <span
style="font-weight: bold; font-style: italic;">align=(L|R|C)</span>
(e.g. &lt;td align=\"L\"&gt;)</li>
<li><span style="font-weight: bold;">Cell width: &lt;td&gt;</span>
allows an attribute "width" to set the cell width (e.g. &lt;td
width=20%&gt; or &lt;td width=30&gt;).<br>
</li>
<li><span style="font-weight: bold;">Line breaks:</span> Line breaks
can be specified by adding a <span
style="font-weight: bold; font-style: italic;">&lt;br /&gt;</span>
tag. The new line will start at the left border of the PDF document.<br>
</li>
tag. The new line will start at the left border of the PDF document.</li>
</ul>
<br>
<span style="font-weight: bold; text-decoration: underline;">Examples:</span><br
@ -1105,13 +1113,13 @@ to display more columns.<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">'myAttribute'</span>
=&gt; <span style="font-weight: bold;">'<span
style="font-style: italic;">&lt;block&gt;&lt;key&gt;</span></span>AttrName<span
style="font-weight: bold; font-style: italic;">&lt;/key&gt;&lt;td
style="font-weight: bold; font-style: italic;">&lt;/key&gt;&lt;tr&gt;&lt;td
align=\"L\"&gt;</span>123<span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/block&gt;&lt;block&gt;&lt;td
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/tr&gt;&lt;/block&gt;&lt;block&gt;&lt;tr&gt;&lt;td
align=\"L\"&gt;</span>456<span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/block&gt;&lt;block&gt;&lt;td
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/tr&gt;&lt;/block&gt;&lt;block&gt;&lt;tr&gt;&lt;td
align=\"L\"&gt;</span>789<span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/block&gt;</span><span
style="font-weight: bold; font-style: italic;">&lt;/td&gt;&lt;/tr&gt;&lt;/block&gt;</span><span
style="font-weight: bold;">'</span><br>
<br>
This will give the following PDF output: <br>

View File

@ -449,19 +449,19 @@ class quota extends baseModule {
function get_pdfEntries($account_type = "user") {
if (sizeof($this->quota) > 0) {
$quotas = array();
$quotas[] = '<block>' .
$quotas[] = '<block><tr>' .
'<td width="20%"><b>' . _('Mountpoint') . '</b></td>' .
'<td width="20%"><b>' . _('Soft block') . '</b></td>' .
'<td width="20%"><b>' . _('Hard block') . '</b></td>' .
'<td width="20%"><b>' . _('Soft inode') . '</b></td>' .
'<td width="20%"><b>' . _('Hard inode') . '</b></td></block>';
'<td width="20%"><b>' . _('Hard inode') . '</b></td></tr></block>';
for ($i = 0; $i < sizeof($this->quota); $i++) {
$quotas[] = '<block>' .
$quotas[] = '<block><tr>' .
'<td width="20%" align=\"L\">' . $this->quota[$i][0] . '</td>' .
'<td width="20%" align=\"L\">' . $this->quota[$i][2] . '</td>' .
'<td width="20%" align=\"L\">' . $this->quota[$i][3] . '</td>' .
'<td width="20%" align=\"L\">' . $this->quota[$i][6] . '</td>' .
'<td width="20%" align=\"L\">' . $this->quota[$i][7] . '</td></block>';
'<td width="20%" align=\"L\">' . $this->quota[$i][7] . '</td></tr></block>';
}
return array(
'quota_quotas' => $quotas);

View File

@ -225,6 +225,8 @@ function processLine($line,$first_td = true, $fontName) {
$value_pattern = '/(<block>.*)<value>(.*)<\/value>(<\/block>)/';
// PCRE matching a <td> tag
$td_pattern = '/(<block>.*?)<td(.*?)>(.+?)<\/td>(.*<\/block>)/';
// PCRE matching <tr> tag
$tr_pattern = '/<tr><\/tr>/';
// PCRE matching a <p> tag
$p_pattern = '/(<block>.*)<p>(.+)<\/p>(.*<\/block>)/';
// PCRE matching a <br> tag
@ -236,14 +238,14 @@ function processLine($line,$first_td = true, $fontName) {
$line_width = $line_width - 50;
$format = processFormatTags($matches[2],'B');
$return[] = array('setFont',array($fontName,$format[0],9));
$return[] = array('Cell',array(50,0,$format[1] . ':',0,0,'R',0));
$return[] = array('Cell',array(50,5,$format[1] . ':',0,0,'R',0));
$return[] = array('setFont',array($fontName,'',9));
return array_merge($return,processLine($matches[1] . $matches[3],false,$fontName));
}
elseif(preg_match($value_pattern,$line,$matches)) {
$format = processFormatTags($matches[2],'');
$return[] = array('setFont',array($fontName,$format[0],9));
$return[] = array('MultiCell',array(0,0,$format[1],0,'L',0));
$return[] = array('MultiCell',array(0,5,$format[1],0,'L',0));
$return[] = array('setFont',array($fontName,'',9));
return array_merge($return,processLine($matches[1] . $matches[3],true,$fontName));
}
@ -260,7 +262,7 @@ function processLine($line,$first_td = true, $fontName) {
$return[] = array('Cell',array(50,5,'',0,0,'L',0));
}
$format = processFormatTags($matches[3],'');
$attrs = processAttributes($matches[2],array('width' => $line_width,'height' => 0,'align' => 'L'));
$attrs = processAttributes($matches[2],array('width' => $line_width,'height' => 5,'align' => 'L'));
$return[] = array('setFont',array($fontName,$format[0],9));
$return[] = array('Cell',array($attrs['width'],$attrs['height'],$format[1],0,0,$attrs['align'],0));
$return[] = array('setFont',array($fontName,'',9));
@ -270,6 +272,10 @@ function processLine($line,$first_td = true, $fontName) {
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)));
}