12

ドキュメントの PDF コピーを生成するために、PHP、Smarty、TCPDF ライブラリを使用しています。ドキュメントには、WIRIS エディタの数式の画像とテキスト コンテンツが含まれています。

表現画像の横に来るテキストを適切に配置するのに問題があります。

CSSfloatプロパティであらゆることを試しましたが、何も起こりませんでした。このメールに必要なスクリーン ショットを添付します。

これは、質問とそのオプションを印刷するためのスマートなテンプレート コードです。

{foreach from=$question_data item=qstn_ans key=key}
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
        <tr>
            <td valign="top" >{if $qstn_ans.question_directions}{$qstn_ans.question_directions}<br /><b>Question {$que_seq_no} : </b>{/if}{$qstn_ans.question_text}</td>
        </tr>
        {if $qstn_ans.question_file}
        <tr>
            <td><img src="{$ques_thum_image_path}{$qstn_ans.question_id}_{$qstn_ans.question_file}" /></td>
        </tr>
        {/if}
        {if $qstn_ans.question_has_sub_ques==0}
            {if $qstn_ans.answer}
                {foreach from=$qstn_ans.answer item=ans key=ans_no}
                    <td valign="top" >
                        {if $ans.answer_is_right==1}{assign var='correct_ans' value=$ans_no+1}{/if}
                            <b>{$ans_no+1}.</b>&nbsp;&nbsp;{if $ans.answer_text!=''}{$ans.answer_text}{/if}
                            {if $ans.answer_file!=''}<img src="{$ans_thumb_img_path}{$ans.answer_id}_{$ans.answer_file}" />{/if}
                     </td>
                </tr>
                {/foreach}
        <tr>
            <td></td>
        </tr>
    </table>
{/foreach}

このコード スニペットには、ループとブラケットの完了を確認せずにランダムに貼り付けたため、エラーが含まれている可能性がありますが、ここでは問題ではありません。

このコードの唯一の重要な部分は、質問テキストと質問画像 (存在する場合) を出力する行です。

適切な解決策を調査しましたが、目的の解決策を得ることができませんでした。誰でも私を助けることができますか?

スクリーンショット

4

5 に答える 5

1

ずれている情報はすべて から来ているように見える$qstn_ans.question_textので、上記のコードには実際には問題はありません。

その質問のテキストの各「ステートメント」を別の段落に保存することをお勧めします。例えば

<p>Statement I: The variance of first n even natural numbers is <img src="?" /></p>
<p>Statement II: The sum of first n natural numbers is <img src="?" /></p>
<p>and the sum of squares of first n natural numbers is <img src="?" /></p>

これにより、質問テキストの各「行」が互いに衝突することなく個別に表示されるはずです。

于 2013-04-12T02:15:58.430 に答える
1

TCPDF の HTML は完全ではないためwidth、それぞれに属性を使用する必要があり<td>ます。

...
<tr>
    <td valign="top" width="250" >
        {if $qstn_ans.question_directions}{$qstn_ans.question_directions}<br /><b>Question {$que_seq_no} : </b>{/if}{$qstn_ans.question_text}
    </td>
</tr>
    {if $qstn_ans.question_file}
<tr>
    <td width="100">
        <img src="{$ques_thum_image_path}{$qstn_ans.question_id}_{$qstn_ans.question_file}" />
    </td>
</tr>
    {/if}
...
于 2013-05-21T14:25:19.550 に答える
1

このコードが正しく機能していることを確認してください

$html = <<<EOD
<h1><img src="http://www.google.com/logos/2013/wangari_maathai_73rd_birthday-1400005-hp.jpg" height="50px" width="150px"> Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
<i>This is the first example of TCPDF library.</i>
<p>This text <img src="http://www.google.com/logos/2013/wangari_maathai_73rd_birthday-1400005-hp.jpg" height="50px" width="150px"> <br>is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;

// Print text using writeHTMLCell()
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
于 2013-04-04T09:47:44.850 に答える