0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

memo2

Posted at
<?php
require_once('tcpdf_include.php');

$pdf = new TCPDF('P', 'mm', 'postcard', true, 'UTF-8', false);
$pdf->AddPage();

// フォント設定
$pdf->SetFont('kozminproregular', '', 14);

// ハガキ全体の幅
$pageWidth = 100;

// --- 角丸枠 ---
$boxX = 20;
$boxY = 20;
$boxW = 60;
$boxH = 20;
$pdf->RoundedRect($boxX, $boxY, $boxW, $boxH, 3, '1111', 'D');
$pdf->SetXY($boxX, $boxY + 5);
$pdf->Cell($boxW, 10, '通知書', 0, 0, 'C');

// --- 2列4行の角丸枠(foreach 使用) ---
$texts = ['テキスト1', 'テキスト2', 'テキスト3', 'テキスト4'];
$rowH = 15;
$col1W = 30;
$col2W = 50;
$gapX = ($pageWidth - ($col1W + $col2W)) / 2;
$startY = $boxY + $boxH + 10;

foreach ($texts as $index => $text) {
    $currentY = $startY + ($index * $rowH);

    // 左列(ラベル)
    $pdf->RoundedRect($gapX, $currentY, $col1W, $rowH, 2, '1111', 'D');
    $pdf->SetXY($gapX, $currentY + 4);
    $pdf->Cell($col1W, 5, $text, 0, 0, 'C');

    // 右列(空の枠)
    $pdf->RoundedRect($gapX + $col1W, $currentY, $col2W, $rowH, 2, '1111', 'D');
}

// 出力
$pdf->Output('postcard_layout.pdf', 'I');
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?