Font value
)
{
// Ensuring that the font exists within the context resources...
Resources resources = scanner.getContentContext().getResources();
FontResources fonts = resources.getFonts();
// No font resources collection?
if(fonts == null)
{
// Create the font resources collection!
fonts = new FontResources(scanner.getContents().getDocument());
resources.setFonts(fonts); resources.update();
}
// Get the key associated to the font!
PdfName name = fonts.getBaseDataObject().getKey(value.getBaseObject());
// No key found?
if(name == null)
{
// Insert the font within the resources!
int fontIndex = fonts.size();
do
{name = new PdfName(String.valueOf(++fontIndex));}
while(fonts.containsKey(name));
fonts.put(name,value); fonts.update();
}
return name;
}