Hi Maruan, Thanks a lot for quick response. How to get font to construct the defaultAppearanceString? E.g. String defaultAppearanceString = "/Helv 12 Tf 0 0 0 rg"; in this "Helv" is used. If I have to use font supported by PDFBox like COURIER_BOLD_OBLIQUE then how to get the name/string to be used in defaultAppearanceString?
Thanks, Bharat On Thu, Jan 12, 2017 at 12:50 PM, Maruan Sahyoun <[email protected]> wrote: > Hi, > > > Am 12.01.2017 um 08:10 schrieb Bharat Bhatt <[email protected]>: > > > > Hi, > > > > I want to change the appearance of drop down list (PDListBox). How to use > > different font, font size and color of text? > > I tried using following code > > String defaultAppearanceString = "/Helv 12 Tf 0 0 0 rg"; > > PDListBox.setDefaultAppearance(defaultAppearanceString); > > that's the correct way of doing it. In addition if you'd like to style > border, background color etc. you can set the > PDAppearanceCharacteristicsDictionary > http://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/ > pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDic > tionary.html. Please note that this setting applies to the > PDAnnotationWidget. > > If you load a font and set the resource with that font using > PDResources.add(PDFont font) it will return the COSName for that resource > which you can use for your defaultAppearanceString. > http://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/ > pdfbox/pdmodel/PDResources.html#add(org.apache.pdfbox.pdmodel.font.PDFont) > > You could also use PDResources.put and choose a name yourself. > http://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/ > pdfbox/pdmodel/PDResources.html#put(org.apache.pdfbox. > cos.COSName,%20org.apache.pdfbox.pdmodel.font.PDFont) > > BR > Maruan > > > > > Please let me know what will be better approach? > > How to get the font name like "Helv" for different font > > from PDType1Font.HELVETICA > > > > Thanks, > > Bharat > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

