簡體   English   中英

帶有左縮進的MigraDoc表邊框問題

[英]MigraDoc table border issue with left indent

我正在嘗試使用MigraDoc創建PDF文檔,並且當表格包含左縮進時,表格邊框面臨問題。

我將數據傳遞給以下函數以呈現表。

public void AddTable(int _iNumberOfColumns, double leftInd)
{
    table = section.AddTable();
    if (leftInd != 0d)
    {
        table.Format.LeftIndent = leftInd;
    }

    for (int i = 0; i < _iNumberOfColumns; i++)
    {
        Column col = table.AddColumn();
    }                
}

在上述方法中,我為參數leftInd傳遞了一個雙leftInd值。 我認為,這是問題的起因。

並且添加單元格的代碼如下。 我正在傳遞布爾變量來確定單元格邊框是否需要可見...(要添加一行,我只是在調用row = table.AddRow();

public void AddColumn(int _iCellNum, int iColspan, double dCellWidthInPt, System.Drawing.Color color, bool bTopBorder, bool bLeftBorder, bool bBottomBorder, bool bRightBorder)
{
    cell = row.Cells[_iCellNum];

    if (iColspan > 0)
    {
        cell.MergeRight = iColspan-1;
        for (int i = 0; i < iColspan; i++)
        {
            row.Cells[_iCellNum + i].Column.Width = new Unit(dCellWidthInPt, UnitType.Point);
        }
    }
    else
    {
        cell.Column.Width = new Unit(dCellWidthInPt, UnitType.Point);
    }
    //bRightBorder = bLeftBorder = bTopBorder = bBottomBorder = true;
    cell.Borders.Right.Visible = bRightBorder;
    cell.Borders.Left.Visible = bLeftBorder;
    cell.Borders.Top.Visible = bTopBorder;
    cell.Borders.Bottom.Visible = bBottomBorder;
    if (color!=null)
    {
        cell.Format.Shading.Color = new Color(color.A, color.R, color.G, color.B);
    }

}

我得到以下輸出: 在此處輸入圖片說明

如果刪除左縮進,表格將正確渲染(也就是說,左縮進不會將表格邊框向左移動)。

我不能更改頁面的頁邊距,因為此表是文檔的一部分,具有不同的頁邊距。 同樣,我無法添加新部分,因為這將添加新頁面。

版本:

Migradoc:1.32.3885.0

pdf格式:1.32.2608.0

關於我可能缺少的任何建議嗎?

編輯

這就是我要實現的目標。 與該段落相比,請查看表格的左起位置。 為此,我嘗試使用table.Format.LeftIndent 在此處輸入圖片說明

這就是我得到的 在此處輸入圖片說明

要縮進表,請設置table.Rows.LeftIndent 負值也可以。

如注釋中所寫, table.Format.LeftIndent設置表單元格中所有段落的默認縮進,因此它移動文本,但不移動邊框。

暫無
暫無

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

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