签名PDF

时间:2013-10-08 10:18:21

标签: php image tcpdf gdlib

通过使用TCPDf我自然地创建了一个pdf,但在将pdf图像放在pdf上时遇到了问题。我尝试使用GD Librery,但它没有用。请有人指导我。

以下是我用于TCPDF的代码

$output = 'Soumya Biswas';

require_once('tcpdf.php');
require_once('config/tcpdf_config_alt.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
//echo PDF_HEADER_LOGO;
// set default header data
$pdf->SetPrintHeader(false);

$pdf->SetHeaderData('', '', '', '');

// 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('25', PDF_MARGIN_TOP,'25');
$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('dejavusans', '', 10);

// add a page
$pdf->AddPage();

// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)

// create some HTML content


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


// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('Test','I');

上面的代码工作得很好,并且正确地使用pdf,但是我如何能够将我的名字转换成图像并放入pdf中。以下是我使用和失败的代码。

// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,   $output, $text_color);

// Set the content type header - in this case image/jpeg
header('Content-Type: image/jpeg');

// Output the image
imagejpeg($im);

// Free up memory
imagedestroy($im);

0 个答案:

没有答案