Table iText 7 中的 NoWrap 选项?

Table NoWrap Option in iText 7?

我正在将 iText5 代码转换为 iText7。我们在某些单元格上使用的属性之一是 NoWrap (= true)。什么是 iText 7 等价物?谢谢!

new PdfPCell { NoWrap = true, ... }

可以使用Property.OVERFLOW_X来控制内容的溢出策略。但需要在包含内容的元素上设置,一般在段落上。

下面是一个代码示例,其中添加了 table 以及包含不适合给定单元格宽度 (100pt) 的内容的单元格:

PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));

Document document = new Document(pdfDocument);

Table table = new Table(new float[] {100, 100, 100});
table.setFixedLayout();
table.setWidth(300);
table.addCell("Hello world");
Paragraph p = new Paragraph("ThisIsAVeryLongLongWordWhichOverflowsCellWidth").setFontColor(ColorConstants.GREEN);
table.addCell(p);
p.setProperty(Property.OVERFLOW_X, OverflowPropertyValue.VISIBLE);
table.addCell("Last cell");
document.add(table);

document.close();