簡體   English   中英

FPDF表格彼此相鄰

[英]FPDF tables next to each other

日歷年視圖

我正在嘗試使用FPDF創建日歷PDF(如上圖所示),但是我的表格卻在彼此之間顯示。 這是我得到的:

在此處輸入圖片說明

我正在使用以下腳本: http : //www.fpdf.org/en/script/script50.php ,該腳本使我可以將HTML表轉換為PDF。

如果有人對如何實現此想法有所了解,或者有人知道解決此問題的另一種工具,我將不勝感激。

每次開始繪制表格時,都可以使用setXY函數在頁面上移動當前位置。 在每個表格行之后,當前位置將一直返回到左邊距,而不是您以前的X位置,但是您可以使用SetLeftMargin解決該問題。

下面的示例使用您鏈接到的腳本。 您可以調整數字或進行一些更智能的尺寸計算。 為了使示例代碼簡短,我將同一張表打印了12次。

<?php
require('html_table.php');
$pdf = new PDF('L');
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);

$html = '<table border="1">
<tr><td width="100" height="50">cell 1</td><td width="100" height="50">cell 2</td></tr>
<tr><td width="100" height="50">cell 3</td><td width="100" height="50">cell 4</td></tr>
</table>';

// 'origin' is the top left of the January table:
$originX = 10;
$originY = 50;
for ($i = 0; $i < 12; $i++) {
    // Move 70mm to the right after every month:
    $x = $originX + ($i % 4) * 70;
    // Move 60mm down after every 4 months:
    $y = $originY + floor($i / 4) * 60;
    $pdf->SetLeftMargin($x);
    $pdf->SetXY($x, $y);
    $pdf->WriteHTML($html);
}
$pdf->Output();
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM