簡體   English   中英

DynamicPDF表:有一種對行進行分組的方法嗎?

[英]DynamicPDF table: is there a way to group rows?

我們正在用DynamicPDF編寫一個表,但是我們想對行進行“分組”,這樣在分組的中間不會出現分頁符。 這些組從一到六行不等。 有沒有人找到一種方法來做到這一點? 這是我們的代碼:

// Create a PDF Document 
Document document = new Document();

Table2 table = new Table2(0, 0, 200, 700);

// Add columns to the table
table.Columns.Add(100);
table.Columns.Add(100);

// This loop populates the table 
for (int i = 1; i <= 400; i++)
{
   Row2 row = table.Rows.Add(20);
   row.Cells.Add("Row #" + i);
   row.Cells.Add("Item");
}

// This loop outputs the table to as many pages as is required
do
{
   Page page = new Page();
   document.Pages.Add(page);
   page.Elements.Add(table);
   table = table.GetOverflowRows();
} while (table != null);

沒有直接執行此操作的屬性或方法,但是您可以按照以下步驟實現:

  1. 使用Row2.ActualRowHeight屬性獲取每行的高度(這是根據數據輸出時的實際高度)。
  2. 找到要折斷表的位置后(將行組考慮在內),將Table2.Height屬性設置為這些行的總和。
  3. 調用Table2.GetOverflowRows()以獲取帶有剩余行的溢出表。
  4. 請注意Table2.VisibleStartRow值作為溢出表的起始行,並從#1開始重復,直到Table2.GetOverflowRows()返回null。

請記住,如果您將Table2.RepeatRowHeaderCount屬性設置為> 0,則需要在計算中為每個溢出表包括這些標頭行(上面的#2)。

完全公開,我為DynamicPDF的制造商ceTe Software工作。

暫無
暫無

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

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