PDF にテキストを書き込もうとしていますが、ページの上部に奇妙な余白があるようです。
これは私の次のコードです:
require_once('fpdf.php');
require_once('fpdi/fpdi.php');
//Start the FPDI
$pdf = new FPDI('P', 'pt');
//Set the source PDF file
$source_file = $pdf->setSourceFile("template.pdf");
//Import the first page of the file
$tppl = $pdf->importPage(1);
$pdf->AddPage();
//get size of pdf page
$size = $pdf->getTemplateSize($tppl);
$pdf->useTemplate($tppl, null, null, $size['w'], $size['h'], true);
$pdf->SetMargins(0, 0, 0);
$pdf->SetTextColor(0, 0, 0);
font-size pt 12 を使用してテキストを書き込むと、次のようになります。
$pdf->SetFont('Arial', '', 12);
$pdf->SetXY(0, 0);
$pdf->Write(0, "Hi");
私がするとき、私は$pdf->SetXY(0, 7.5)
これを手に入れます
上記は、Y に 7.5 ポイントを簡単に追加できるように見えます。
ただし、font-size を変更すると、上部とテキストの間の距離が少し大きくなります。
$pdf->SetFont('Arial', '', 8);
これを中和して少なくともそれを作成する方法を誰かが理解するのを手伝ってくれますか? さまざまなPDFを試しましたが、すべて同じように機能します。
編集:
私はやった$pdf->GetY()
、私は得る28.35