Hallo,
when I do this:
DefaultAppearance defaultAppearance = new DefaultAppearance();
defaultAppearance.setFontName(anno.getFontname());
defaultAppearance.setFontSize(anno.getFontsize());
defaultAppearance.setTextColor(color);
com.aspose.pdf.Font font = defaultAppearance.getFont();
Aspose gives me a null. Why I need this? Because I want to calculate the appropriate width of a rectangle for generating a freetextAnnotation with some text in it. I thought I can do it with font.measureString().
Do you want to generate a rectangle around some text? Please share some more details by sharing a sample source and expected output PDF. We will test the scenario in our environment and address it accordingly.
Thank you, I solved this myself:
com.aspose.pdf.Font font = FontRepository.findFont(fontName);
dwidthNeeded = font.measureString(text+“MM”, new Double(fontsize).floatValue());
I added “MM” because otherwise the resulting width is too small.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.