gpt4 book ai didi

插入 PdfCell 时图像会调整大小

转载 作者:行者123 更新时间:2023-12-04 05:04:08 25 4
gpt4 key购买 nike

我正在尝试使用 itextsharp 创建 Pdf。我添加了一张包含两列的表格,其中一列包含文本和其他图像。我想要恒定的图像大小

  • 如果另一个单元格中的文本增加并且其他单元格中的图像大小不同,我的图像会自动调整大小
      for (int i = 0; i < visitInfo.VisitsiteComplience.Count; ++i)
    {

    cellprop.Colspan = 1;
    cellprop.Pharse = visitInfo.VisitsiteComplience[i].Compliencedescription;
    cellprop.BaseColor = null;
    table.AddCell(AddCelltoTable(cellprop));
    yesicon.ScaleAbsolute(35f, 35f);
    noicon.ScaleAbsolute(35f, 35f);

    if (visitInfo.VisitsiteComplience[i].Status == "1")
    {

    statuscell.AddElement(new Chunk(noicon, 0, 0));

    }
    else
    {

    // statuscell.AddElement(new Chunk(noicon, 0, 0));
    }


    statuscell.FixedHeight = 10;


    //headerLeftCell.Border = PdfPCell.NO_BORDER;
    table.AddCell(statuscell);
    }

  • enter image description here
    2.然后我更改了代码,但现在图像大小增加并占据了整个单元格
         for (int i = 0; i < visitInfo.VisitsiteComplience.Count; ++i)
    {

    cellprop.Colspan = 1;
    cellprop.Pharse = visitInfo.VisitsiteComplience[i].Compliencedescription;
    cellprop.BaseColor = null;
    table.AddCell(AddCelltoTable(cellprop));
    yesicon.ScaleAbsolute(35f, 35f);
    noicon.ScaleAbsolute(35f, 35f);

    if (visitInfo.VisitsiteComplience[i].Status == "1")
    {

    statuscell.AddElement(new Chunk(noicon, 0, 0));

    }
    else
    {

    // statuscell.AddElement(new Chunk(noicon, 0, 0));
    }





    //headerLeftCell.Border = PdfPCell.NO_BORDER;
    table.AddCell(statuscell);
    }

    enter image description here

    最佳答案

    我认为您自己缩放图像是这样的:noicon.ScaleAbsolute(35f, 35f);
    这也让我感到困惑,为什么要将图像包装在 Chunk 中.您可以创建一个 PdfPCell这需要一个 Image作为参数以及 Bool to 定义 iText 是否应该缩放 Image .参见本书第 109 页 iText in Action (其中我是作者)并查看 chapter 4 的 XMen 示例.

    关于插入 PdfCell 时图像会调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15741980/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com