convert from Font to FormFont

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v4)  /  convert from Font to FormFont

DynamicPDF Generator for Java (v4) Forum

 Mar 03 2010 1:57 PM
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
 Mar 03 2010 2:51 PM
Posted by a ceTe Software moderator
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
 Mar 08 2010 4:16 AM
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
 Mar 08 2010 5:30 AM
Posted by a ceTe Software moderator
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.
 Mar 08 2010 5:45 AM
Hello,

Are the any workarounds for this limitation?

Thanks in advance,
Best regards,
Giovanni
 Mar 08 2010 5:46 AM
Hello,

Are there any workarounds for this limitation?

Thanks in advance,
Best regards,
Giovanni
 Mar 08 2010 7:18 AM
Posted by a ceTe Software moderator
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.

All times are US Eastern Standard time. The time now is 7:39 AM.