4

TCPDF で作成した PDF のカスタム ヘッダーを作成しました。ここで、ヘッダーの下部でページを横切る青い線 (幅約 2px) を追加したいのですが、方法がわかりませんか?

4

6 に答える 6

10

私はあなたが次のようにすると信じています:

$style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0));

$pdf->Line(5, 10, 80, 30, $style);

ここに完全な例があります

http://www.tcpdf.org/examples/example_012.phps

于 2011-05-01T06:23:23.513 に答える
9

線を引く最も簡単な方法を見つけました

$pdf->writeHTML("<hr>", true, false, false, false, '');
于 2016-02-28T14:34:59.230 に答える
5

ページ軸も使用できます。

$pdf->Line(5, $pdf->y, $pdf->w - 5, $pdf->y);

ただし、色付きの<hr>html タグをレンダリングしようとしている場合は、次のように調整する必要があります(この抜粋は、およびTCPDF::DrawColorに従って、データ レポートの各行にグラフ バーを追加するコードからのものです)。$twidth$lengthmm

$htmlbar = '<hr style="width:' . $lengthmm . 'mm;">';
$oldDrawColor = $pdf->DrawColor;
$pdf->setDrawColor(121, 161, 46);
$pdf->MultiCell($twidth,'2',$htmlbar,0,'L',$fill,1,'','',true,0,true,false,4,'T',false);
$pdf->DrawColor = $oldDrawColor;
于 2013-04-11T13:27:58.833 に答える
0

ポイントは、2 番目のポイントの x 値を取得することです。これは私がそれを行う方法です:

$pageWidth    = $pdf->getPageWidth();   // Get total page width, without margins
$pageMargins  = $pdf->getMargins();     // Get all margins as array
$headerMargin = $pageMargins['header']; // Get the header margin
$px2          = $pageWidth - $headerMargin; // Compute x value for second point of line

$p1x   = $this->getX();
$p1y   = $this->getY();
$p2x   = $px2;
$p2y   = $p1y;  // Use same y for a straight line
$style = array();
$this->Line($p1x, $p1y, $p2x, $p2y, $style);

リンク TCPDF::getMargins()
http://www.tcpdf.org/doc/code/classTCPDF.html#ae9bd660bf5b5e00eea82f1168cc67b5b

TCPDF::getPageWidth()
http://www.tcpdf.org/doc/code/classTCPDF.html#a510ab21d6a373934bcd3bd4683704b7e

楽しむ!

于 2014-05-17T05:43:51.533 に答える