2016-12-25 5 views
2

GDライブラリを使用して別のテキストの後にテキストを貼り付ける必要があります。 Example here。私はそれをPHP GDライブラリ、別のテキストブロックの後にテキストを貼り付ける方法

$text = wordwrap($text, 80, "\n"); 
$count = substr_count($text, "\n"); 
$string_number = 14; 
$pos = 0; 
if ($count >= $string_number) { 
    for ($i = 0; $i < 14; $i++) { 
     $pos = stripos($text, "\n", $pos) + 1; 
    } 
    $text = substr($text, 0, $pos); 
    //Attempt to calculate coordinates of a text block 
    $text_cord = imagettfbbox(14, 0, $font_300_path, $text); 
    //And paste text after the end coordinate 
    imagettftext($image, 14, 0, 130, $text_cord[3], $blue, font_300_path, 'Need to paste'); 
} 

imagettftext($image, 14, 0, 130, 293, $black, $font_300_path, $text); 

を以下の方法を実行しようとしました。しかし、私はこのようにそれを行う場合、私は、私の質問は、どのように私は他のテキストブロックの後のテキストを貼り付けることができているので

thisを取得しますか?

+0

あなたは貼り付けを意味しますか? – HddnTHA

+0

ああ、はい!一定。 – DarkyDash

+0

あなたのコードは不完全です。問題を再現できるように画像を作成するために使用しているコードをすべて貼り付けてください。 [最小限の完全かつ検証可能なサンプルを作成する方法](https://stackoverflow.com/help/mcve)を参照してください。 – timclutton

答えて

0

問題を解決しました。私は最後の座標を見つけるのにfont_size * line_height * number_of_new_linesを使用しました

関連する問題