如何在 itext7 中获取 widthPoint
How get the widthPoint in itext7
在之前版本的itext(5.5.x)中我使用了BaseFont
class如下:
BaseFont bf = BaseFont.createFont ("Arial.ttf", BaseFont.WINANSI, true);
然后用了方法getWidthPoint
bf.getWidthPoint (TEXT_EXAMPLE, fontSize);
但是在 itext 7 的版本中,我没有找到 BaseFont
class 以及一些允许我获得 withPoint 的实用程序某些文字。
欢迎任何帮助。
要在 iText7
中创建类似的字体,请使用:
PdfFont font = PdfFontFactory.createFont("Arial.ttf", PdfEncodings.WINANSI, true);
要获得某个String
的宽度,使用:
float width = font.getWidth(TEXT_EXAMPLE, fontSize);
在之前版本的itext(5.5.x)中我使用了BaseFont
class如下:
BaseFont bf = BaseFont.createFont ("Arial.ttf", BaseFont.WINANSI, true);
然后用了方法getWidthPoint
bf.getWidthPoint (TEXT_EXAMPLE, fontSize);
但是在 itext 7 的版本中,我没有找到 BaseFont
class 以及一些允许我获得 withPoint 的实用程序某些文字。
欢迎任何帮助。
要在 iText7
中创建类似的字体,请使用:
PdfFont font = PdfFontFactory.createFont("Arial.ttf", PdfEncodings.WINANSI, true);
要获得某个String
的宽度,使用:
float width = font.getWidth(TEXT_EXAMPLE, fontSize);