Draw a rectangle at the *current position* and then get its position coordinates

柔情痞子 提交于 2019-12-02 12:24:38

Seems that you are looking for the Chunk.setBackground() method. This draws a colored background underneath some text. There's also a variation of the method that takes extra parameters if you need a larger or smaller rectangle.

Suppose that you don't want a colored rectangle, but a custom type of shape, then you'd use the page event onGenericTag(). See Chunk > Generic tag for more info.

The onGenericTag() method is triggered every time a Chunk that is marked as generic (using the setGenericTag() method) is rendered to a page. Your implementation of the page event can then use the Rectangle value that is passed to the event method. It is important to understand that a single Chunk marked as a generic tag can result in multiple invocations of this method: if the contents of a single Chunk needs to be distributed over different lines, the event will be triggered as many times as there are lines (giving you a separate Rectangle value for every separate line).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!