iTextSharp:如何在表格中找到第一行和第二行的高度? [英] iTextSharp: How to find the first and second row height in a table?

查看:121
本文介绍了iTextSharp:如何在表格中找到第一行和第二行的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得第一列和第二列高度以了解我是否需要调用 document.NewPage()。但是,如果不将表格添加到文档中,我无法找到方法。

I want to get the first and second column height to know if I need to call document.NewPage() or not. But, I can't find a way to do this without adding the table to the document.

示例:

PdfPRow firstRow = new PdfPRow(cells1.ToArray());
table.Rows.Add(firstRow);
PdfPRow secondRow = new PdfPRow(cells2.ToArray());
table.Rows.Add(secondRow);

float h1 = table.GetRowHeight(0), h2 = table.GetRowHeight(1);

if (currentY - h1 - h2 < 30) document.NewPage();

document.Add(table);


推荐答案

参见我的答案在这里。基本上,在呈现表之前,您无法知道表的尺寸。但是,您可以将表格渲染到刚刚丢弃的文档,然后再重新渲染。

See my answer here. Basically, you can't know the dimensions of a table until it renders. However, you can render the table to a document that you just throw away and then re-render it later.

这篇关于iTextSharp:如何在表格中找到第一行和第二行的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆