私は現在PDFエディタを構築しています。タグの処理の実装に問題があります。
次のタグを許可したい: [h1]、[h2]、[h3]、[h4]、[h4]、[h5]、[h6]、[strong]
drawText(以下のコード) というメソッドを使用してクラスを作成しました。
[h1]タグはフォントサイズとフォントの太さを変更します。コードでわかるように、テキスト行を出力しています。テキスト行の例: これはあなたの [strong]搭乗券[/strong] です。この PDF ファイルをスマートフォンまたはタブレットに保存し、[strong]ゲートで提示してください[/strong]。
【強】の間の文字を太字にしたいです。Zend_PDF でこれを行うには、TTF ファイルに太字のテキストを設定し、現在の X 座標を見つけて $this->pdf()->drawText(text, X-coordinate, Y-coordinate, charset) を呼び出す必要があります。私はこれを可能にするコードを書くために何時間も考え、試みてきました(explode、preg_match_allなどを使用してみました)が、動作させることができません...
この問題を抱えているのは私だけではないと思います。誰かがこれについて考え、どのようにそれをしたかを伝えることで少し助けてくれることを願っています...
誰かからの連絡をお待ちしております。事前に感謝します。
/**
* drawSplittedText()
*
* @param array $text
* @return object Application_Plugin_PdfPlugin
*/
public function drawSplittedText(Array $text)
{
// Count the number of rows.
$textRowCount = count($text);
$i = 0;
foreach ($text as $row)
{
// Replace tabs, because they're not outputted properly.
$row = str_replace("\t", ' ', $row);
// If the character encoding of the currrent row not is UTF-8, convert the row characters to UTF-8.
if (($rowEncoding = mb_detect_encoding($row)) != 'UTF-8') {
$row = iconv($rowEncoding, 'UTF-8', $row);
}
// Output row on PDF
$this->pdf()->drawText($row, $this->_defaultMarginleft, $this->currentY, 'UTF-8');
$this->newLine();
++$i;
}
return $this;
}