function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
{
// Output a cell
$k = $this->k;
if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) {
// Automatic page break
$x = $this->x;
$ws = $this->ws;
if ($ws > 0) {
$this->ws = 0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation, $this->CurPageSize);
$this->x = $x;
if ($ws > 0) {
$this->ws = $ws;
$this->_out(sprintf('%.3F Tw', $ws * $k));
}
}
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
}
$s = '';
if ($fill || $border == 1) {
if ($fill) {
$op = $border == 1 ? 'B' : 'f';
} else {
$op = 'S';
}
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
}
if (is_string($border)) {
$x = $this->x;
$y = $this->y;
if (strpos($border, 'L') !== false) {
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
}
if (strpos($border, 'T') !== false) {
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
}
if (strpos($border, 'R') !== false) {
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
}
if (strpos($border, 'B') !== false) {
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
}
}
if ($txt !== '') {
if ($align == 'R') {
$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
} elseif ($align == 'C') {
$dx = ($w - $this->GetStringWidth($txt)) / 2;
} else {
$dx = $this->cMargin;
}
if ($this->ColorFlag) {
$s .= 'q ' . $this->TextColor . ' ';
}
// If multibyte, Tw has no effect - do word spacing using an adjustment before each space
if ($this->ws && $this->unifontSubset) {
foreach ($this->UTF8StringToArray($txt) as $uni) {
$this->CurrentFont['subset'][$uni] = $uni;
}
$space = $this->_escape($this->UTF8ToUTF16BE(' ', false));
$s .= sprintf('BT 0 Tw %.2F %.2F Td [', ($this->x + $dx) * $k, ($this->h - ($this->y + 0.5 * $h + 0.3 * $this->FontSize)) * $k);
$t = explode(' ', $txt);
$numt = count($t);
for ($i = 0; $i < $numt; $i++) {
$tx = $t[$i];
$tx = '(' . $this->_escape($this->UTF8ToUTF16BE($tx, false)) . ')';
$s .= sprintf('%s ', $tx);
if ($i + 1 < $numt) {
$adj = -($this->ws * $this->k) * 1000 / $this->FontSizePt;
$s .= sprintf('%d(%s) ', $adj, $space);
}
}
$s .= '] TJ';
$s .= ' ET';
} else {
if ($this->unifontSubset) {
$txt2 = '(' . $this->_escape($this->UTF8ToUTF16BE($txt, false)) . ')';
foreach ($this->UTF8StringToArray($txt) as $uni) {
$this->CurrentFont['subset'][$uni] = $uni;
}
} else {
$txt2 = '(' . str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))) . ')';
}
$s .= sprintf('BT %.2F %.2F Td %s Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + 0.5 * $h + 0.3 * $this->FontSize)) * $k, $txt2);
}
if ($this->underline) {
$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + 0.5 * $h + 0.3 * $this->FontSize, $txt);
}
if ($this->ColorFlag) {
$s .= ' Q';
}
if ($link) {
$this->Link($this->x + $dx, $this->y + 0.5 * $h - 0.5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
}
}
if ($s) {
$this->_out($s);
}
$this->lasth = $h;
if ($ln > 0) {
// Go to next line
$this->y += $h;
if ($ln == 1) {
$this->x = $this->lMargin;
}
} else {
$this->x += $w;
}
}