/** * Print out text to the PDF * * @param $x * @param $y * @param $txt * @return PdfDocument */ public function addText($x, $y, $txt) { $document = $this->_pdfDocument; $pdfOutput = $document->getOutputter(); if ($this->_pdfDocument->getUnifontSubset()) { $txt2 = '(' . $pdfOutput->escape($pdfOutput->UTF8ToUTF16BE($txt, false)) . ')'; $fontOutputter = $pdfOutput->getFontOutputter(); $currentFont =& $fontOutputter->fonts[$document->getCurrentFont()]; foreach ($pdfOutput->UTF8StringToArray($txt) as $uni) { $currentFont['subset'][$uni] = $uni; } } else { $txt2 = '(' . $pdfOutput->escape($txt) . ')'; } $scaleFactor = $document->getScaleFactor(); $height = $document->getPage()->getHeight(); $s = sprintf('BT %.2F %.2F Td %s Tj ET', $x * $scaleFactor, ($height - $y) * $scaleFactor, $txt2); if ($document->getUnderline() && $txt != '') { $s .= ' ' . $this->_dounderline($x, $y, $txt); } if ($document->getColorFlag()) { $s = 'q ' . $document->getTextColor() . ' ' . $s . ' Q'; } $pdfOutput->out($s); return $document; }