convert from Font to FormFont

convert from Font to FormFont

Forum member · Mar 3, 2010
Hello, How can I convert from Font to FormFont. The following method requires a FormFont but I only have a Font (loaded from an existing true Font installed in the local system): com.cete.dynamicpdf.pageelements.forms.TextField#setFont(com.cete.dynamicpdf.text.FormFont) Thanks in advance, Best regards, Giovanni

Re: convert from Font to FormFont

Support · Mar 3, 2010
Hello Giovanni, You can use the com.cete.dynamicpdf.Font object in the SetFont method since the FormFont inherits from "com.cete.dynamicpdf.Font" class. Thanks, ceTe Software Support Team

Re: convert from Font to FormFont

Forum member · Mar 8, 2010
Hello, Precisely, Font is the base abstract class. FormFont inherits from Font i.e. Font ^ | FormFont But the signature of setFont requires a FormFont and not a Font i.e. TextField#setFont(com.cete.dynamicpdf.text.FormFont) and I can not pass a Font when a FormFont is expected without downcasting first. If my Font comes from an OpenTypeFont type as we do need then doing the following casting: TextField field = ...; ... field.setFont((FormFont) new OpenTypeFont("myfont")); leads to: Exception in thread "main" java.lang.ClassCastException: com.cete.dynamicpdf.text.OpenTypeFont at concept.LetterDynamicPDF.getContent(LetterDynamicPDF.java:315) at concept.LetterDynamicPDF.main(LetterDynamicPDF.java:46) I guess TextField should receive a Font rather than a FormFont. Thanks in advance, Best regards, Giovanni

Re: convert from Font to FormFont

Support · Mar 8, 2010
Hello Giovanni, It is not possible to pass an OpenTypeFont object in the setFont method of the text field object. You can use only the core fonts present in our product with form fields. field.setFont(Font.getHelvetica()); You can refer to the core fonts on our help documentation. We will support adding open type, true type fonts to the form fields in a future version of our product but currently we do not have an exact time line for this. Thanks, ceTe Software Support Team.

Re: convert from Font to FormFont

Forum member · Mar 8, 2010
Hello, Are the any workarounds for this limitation? Thanks in advance, Best regards, Giovanni

Re: convert from Font to FormFont

Forum member · Mar 8, 2010
Hello, Are there any workarounds for this limitation? Thanks in advance, Best regards, Giovanni

Re: convert from Font to FormFont

Support · Mar 8, 2010
Hello Giovanni, Currently there is no workarounds for this. You will have to use only the core fonts for the form fields. We will add support for adding open type, true type fonts in the next version of our product but currently we do not have any exact time line for this. Thanks, ceTe Software Support Team.