如何使用tcpdf沿y轴移动文本? $ pdf->写(150上下移动,我无法从左到右弄清楚。
http://i.imgur.com/DCBzJNw.png
<?php
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// 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);
// -------------------------------------------------------------------
// add a page
$pdf->AddPage();
// set JPEG quality
$pdf->setJPEGQuality(75);
// Image example with resizing
$pdf->Image('../../edit1forbrad_program.jpg', 10, 10, 480, 680, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$txt = "Some sample text";
$pdf->SetFont('times', '', 16);
$pdf->Write(150, $txt, '', 0, 'L', true, 0, false, false, 0);
//$pdf->Annotation(83, 27, 10, 10, "Text annotation example\naccented letters test: aaeeiioouu", array('Subtype'=>'Text', 'Name' => 'Comment', 'T' => 'title example', 'Subj' => 'example', 'C' => array(255, 255, 0)));
// -------------------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_009.pdf', 'I');
?>
答案 0 :(得分:1)
您可以在致电SetY()
之前致电Write()
来手动调整Y轴。
例如:
$pdf->SetY(30);
$pdf->Write( //Etc. );
但是在将文本装入盒子的情况下,在我看来,最好的方法是创建一个MultiCell。您可以通过调整X en Y参数来定位MultiCell,并且正确大小的MultiCell将确保没有文本将超出框,因为它会在到达Cell的右端时自动中断该行。