André Hertwig created PDFBOX-4645:
-------------------------------------

             Summary: impossible to use own TrueTypeFonts in acroForm (and font 
also not embedded)
                 Key: PDFBOX-4645
                 URL: https://issues.apache.org/jira/browse/PDFBOX-4645
             Project: PDFBox
          Issue Type: Bug
          Components: AcroForm, PDModel
    Affects Versions: 2.0.16, 2.0.15, 2.0.14, 2.0.13, 2.0.12
            Reporter: André Hertwig


Hi

I have a PDF form and want to add additional Fonts, because the default fonts 
does not allow cyrillic or greek chars.

I Add the font as following (Libertation-Sans-Regular):
{code}
PDResources formResources = acroForm.getDefaultResources();
try (InputStream defaultTTFont1 = new FileInputStream(myFontFile)){
        
        PDFont font2 = PDType0Font.load(pdfDocument, defaultTTFont1, true);
        COSName fontName = formResources.add(font2);
}
acroForm.setDefaultResources(formResources);
{code}
I debugged it, the valiable ttf in 

When filling a text field with for example cyrillic letters an exception 
occurs, than i change the defaultAppereance of that field using the initially 
added Font.
But the original TTF will not really used, instead there wil be created new 
font classes with a TTF of null, so it seems to be impossible to use a 
different TTF.
Furthermore the font will not be embedded in the resulting PDF.

{code}
PDCIDFontType2.<init>(COSDictionary, PDType0Font, TrueTypeFont) line: 75        
<- initialized with TrueTypeFont = null
PDCIDFontType2.<init>(COSDictionary, PDType0Font) line: 62      
PDFontFactory.createDescendantFont(COSDictionary, PDType0Font) line: 139        
PDType0Font.<init>(COSDictionary) line: 192     
PDFontFactory.createFont(COSDictionary, ResourceCache) line: 97 
PDResources.getFont(COSName) line: 146  
PDDefaultAppearanceString.processSetFont(List<COSBase>) line: 173       
PDDefaultAppearanceString.processOperator(Operator, List<COSBase>) line: 132    
PDDefaultAppearanceString.processAppearanceStringOperators(byte[]) line: 108    
PDDefaultAppearanceString.<init>(COSString, PDResources) line: 86       
PDTextField(PDVariableText).getDefaultAppearanceString() line: 93       
AppearanceGeneratorHelper.<init>(PDVariableText) line: 100      
PDTextField.constructAppearances() line: 263    
PDTextField(PDTerminalField).applyChange() line: 228    
PDTextField.setValue(String) line: 219  
{code}

As a result of this behavoir i get the following warning:
{code}
WARN  org.apache.pdfbox.pdmodel.font.PDCIDFontType2 - Using fallback font 
LiberationSans for CID-keyed TrueType font LiberationSans-Regular
{code}

When opening the PDF afterwards, I will get an error from AcrobatReader, that 
the font "LiberationSans" could be found, because the font is not embedded... 
like my own fonts..

I tried it back to version 2.0.12 always the same behavior.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to