Hi Aspose,
I have the following code:
DefaultAppearance appearance = new DefaultAppearance();
appearance.setTextColor(annoInfo.getColor());
appearance.setFontName(fontName);
appearance.setFontSize(fontSize);
FreeTextAnnotation anno = new FreeTextAnnotation(page, rect, appearance);
It works fine. The question is how can I update the DefaultAppearance? I see that there is setDefaultAppearance API but it accepts a String instead of a DefaultAppearance so I don’t know how to update it.
What I want is to update text color, font name, font size like in the above. Thank you.
Best Regards,
Tuyen
Hi Tuyen,
Thanks for your inquiry. DefaultAppearance string contains sequence of graphics and state operators which defines text properties such as color and text size.
FreeTextAnnotation.setDefaultAppearance(“1 1 1 rg /Times-Roman 16 Tf”);
- rg is operator to set color of nonstroking operators (this defines text color in this case)
- 1 1 1 is color components (reg, green, blue, value range is 0…1). Thus, 1 1 1 defines white color.
- Tf is set font operator. This operator selects font used for text.
- First operand is key of font resource and second of font size. second operand is size of text. This, /Times-Roman 16 Tf means that Time-roman font of size 16 will be used.
If you still face issue or need further assistance, please feel free to contact us.
Best Regards,