You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "André Hertwig (Jira)" <ji...@apache.org> on 2019/09/06 14:16:00 UTC

[jira] [Closed] (PDFBOX-4645) impossible to use own TrueTypeFonts in acroForm (and font also not embedded)

     [ https://issues.apache.org/jira/browse/PDFBOX-4645?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

André Hertwig closed PDFBOX-4645.
---------------------------------
    Resolution: Not A Bug

> 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.12, 2.0.13, 2.0.14, 2.0.15, 2.0.16
>            Reporter: André Hertwig
>            Priority: Major
>
> Hi
> I have a PDF form and want to add additional fonts, because the default fonts does not allow cyrillic or greek chars for example.
> I add the font as following (LiberationSans-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 is set.
> 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-Regular" 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org