Shahid Ghafoor
Shahid Ghafoor

Reputation: 3103

PDField set default appearances multiple fonts - pdfbox 2.0

There are two type of font glyphs

  1. • (U+2022) Bullet Unicode Character which is supported by one Japanese font
  2. U+200B - Zero Width Space which is supported by one Japanese font

Can we set (PDField)field.defaultAppearance to multiple fonts instead of one ? My code snippet as follow:

val subsetFont=true
val pdType0Font1: PDType0Font = PDType0Font.load(inputPdf, File(bulletSportFontPth).inputStream(),subsetFont)
val pdType0Font2: PDType0Font = PDType0Font.load(inputPdf, File(widhtSpaceFontPath).inputStream(),subsetFont)

inputPdf.documentCatalog?.acroForm?.defaultResources?.add(pdType0Font1)
inputPdf.documentCatalog?.acroForm?.defaultResources?.add(pdType0Font2)

Now How can we set both appearances to PDField?

field.defaultAppearance = field.defaultAppearance.replace(Regex("/\\w*"),"/${pdType0Font1.name}")
field.defaultAppearance = field.defaultAppearance.replace(Regex("/\\w*"),"/${pdType0Font2.name}")

Upvotes: 0

Views: 121

Answers (0)

Related Questions