Форматирование изображений и текста в TCPDF

Использование TCPDF для создания моего HTML в PDF. Но форматирование текста не идет, а изображения нет в PDF. В чем проблема. ?

Код PHP:

require_once('tcpdf/tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
// set default header data
// $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 021', PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}

// set font
$pdf->SetFont('helvetica', '', 9);

// add a page
$pdf->AddPage();
// create some HTML content

/*---------*/
$html  = 'HTML Content Which is pasted under the HTML head in this Question'; 

// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);

// reset pointer to the last page
$pdf->lastPage();
ob_end_clean();
//Close and output PDF document
$pdf->Output('rec_users.pdf','D');

HTML

<table>
        <tbody>
            <tr>
                <td style='background:red'>&nbsp;</td>

                <td><img alt='' height='129' src=
                'demo-300x300.jpg'
                width='300'></td>

                <td>
                    <div class='header'>
                        <div class='right'>
                            <p>1790 lee Travino</p>

                            <p>CL paso xyz</p>

                            <p>T-123456789</p>

                            <p>F-45678903</p>

                            <p>wwww.xyz.com</p>
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td style='background:red'>&nbsp;</td>

                <td>
                    <div class='letter_section'>
                        <h1>Service Agreement</h1>

                        <p style=
                        'color: #5d605f; font-family: arial; font-size: 20px; margin: 40px 0;'>
                        December 30,2013</p>

                        <h3 class='address'>Ms.jenifer Carter</h3>

                        <h3 class='address'>Ms.jenifer Carter</h3>

                        <h3 class='address'>Ms.jenifer Carter</h3>

                        <h3 class='address'>Ms.jenifer Carter</h3>

                        <h3 class='address'>Ms.jenifer Carter</h3>
                    </div>
                </td>

                <td>&nbsp;</td>
            </tr>

            <tr>
                <td style='background:red'>&nbsp;</td>

                <td colspan='2'>
                    <p>lorem ipum is the dolor sit amet lorem ipum is the dolor
                    sit amet lorem ipum is the dolor sit ametlorem ipum is the
                    dolor sit ametlorem ipum is the dolor sit amet lorem ipum
                    is the dolor sit amet lorem ipum is the dolor sit amet</p>

                    <p>lorem ipum is the dolor sit amet lorem ipum is the dolor
                    sit amet lorem ipum is the dolor sit ametlorem ipum is the
                    dolor sit ametlorem ipum is the dolor sit amet lorem ipum
                    is the dolor sit ametlorem ipum is the dolor sit amet lorem
                    ipum is the dolor sit amet lorem ipum is the dolor sit
                    ametlorem ipum is the dolor sit ametlorem ipum is the dolor
                    sit amet lorem ipum is the dolor sit amet</p>
                </td>
            </tr>
        </tbody>
    </table>

Необходимые выходные данные:

введите здесь описание изображения


person Puzzled Boy    schedule 27.11.2014    source источник
comment
Итак, вы показали код и желаемый результат, вам все еще нужно показать нам, что вы на самом деле получаете в своем выводе, чтобы мы знали, на что смотреть.   -  person Duniyadnd    schedule 27.11.2014


Ответы (1)


1) Проверьте путь к изображению. Подтвердите изображение внутри заданного пути. 2) Для печати изображения используйте следующий код

$pdf->Image($image_path.'imageName.jpg',$x_im+32.8,$y_im+32,$w_im,$h_im);

person user2148134    schedule 28.11.2014