日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 文字换行,用Php中的Fpdf换行文本

發布時間:2025/3/20 php 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 文字换行,用Php中的Fpdf换行文本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用MultiCell()代替Cell()

改變這個:

$pdf->Cell(20,7,'Hi5(xtra)',1);

至:

$pdf->MultiCell( 20, 7, 'Hi5(xtra)', 1);

編輯:

我可以看到MultiCell()打破了這條線,因此新單元格將被放置在當前位置之下.

在這種情況下,您可以計算x和y坐標,并在輸出每個單元格后計算新位置和設置位置.

require('fpdf.php');

$pdf = new FPDF();

$pdf->AddPage();

$start_x=$pdf->GetX(); //initial x (start of column position)

$current_y = $pdf->GetY();

$current_x = $pdf->GetX();

$cell_width = 20; //define cell width

$cell_height=7; //define cell height

$pdf->SetFont('Arial','',16);

$pdf->MultiCell($cell_width,$cell_height,'Hi1',1); //print one cell value

$current_x+=$cell_width; //calculate position for next cell

$pdf->SetXY($current_x, $current_y); //set position for next cell to print

$pdf->MultiCell($cell_width,$cell_height,'Hi2',1); //printing next cell

$current_x+=$cell_width; //re-calculate position for next cell

$pdf->SetXY($current_x, $current_y); //set position for next cell

$pdf->MultiCell($cell_width,$cell_height,'Hi3',1);

$current_x+=$cell_width;

$pdf->Ln();

$current_x=$start_x; //set x to start_x (beginning of line)

$current_y+=$cell_height; //increase y by cell_height to print on next line

$pdf->SetXY($current_x, $current_y);

$pdf->MultiCell($cell_width,$cell_height,'Hi4',1);

$current_x+=$cell_width;

$pdf->SetXY($current_x, $current_y);

$pdf->MultiCell($cell_width,$cell_height,'Hi5(xtra)',1);

$current_x+=$cell_width;

$pdf->SetXY($current_x, $current_y);

$pdf->MultiCell($cell_width,$cell_height,'Hi5',1);

$current_x+=$cell_width;

$pdf->SetXY($current_x, $current_y);

$pdf->Output();

?>

總結

以上是生活随笔為你收集整理的php 文字换行,用Php中的Fpdf换行文本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。