在之前的itext (5.5.x)版本中,我使用了BaseFont如下类:
BaseFont bf = BaseFont.createFont ("Arial.ttf", BaseFont.WINANSI, true);
Run Code Online (Sandbox Code Playgroud)
然后用了这个方法 getWidthPoint
bf.getWidthPoint (TEXT_EXAMPLE, fontSize);
Run Code Online (Sandbox Code Playgroud)
但是在itext 7的版本中,我没有找到BaseFont该类以及一些允许我获取某个文本的 withPoint 的实用程序。
欢迎任何帮助。
要在 中创建类似的字体iText7,请使用:
PdfFont font = PdfFontFactory.createFont("Arial.ttf", PdfEncodings.WINANSI, true);
Run Code Online (Sandbox Code Playgroud)
要获得某个 的宽度String,请使用:
float width = font.getWidth(TEXT_EXAMPLE, fontSize);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
337 次 |
| 最近记录: |