How can I truncate text within a bounding box?

前端 未结 1 501
梦谈多话
梦谈多话 2021-01-24 01:43

I am writing content to a PdfContentByte object directly using PdfContentByte.showTextAligned, I\'d like to know how I can stop the text overflowing a

1条回答
  •  一向
    一向 (楼主)
    2021-01-24 02:31

    Use this:

    int status = ColumnText.START_COLUMN;
    ColumnText ct = new ColumnText(cb);
    ct.setSimpleColumn(rectangle);
    status = ct.go();
    

    Make sure that you define rectangle in a way so that only one line fits, use ColumnText.hasMoreText(status) to find out if you need to add an ellipsis character.

    0 讨论(0)
提交回复
热议问题