AppearanceGeneratorHelper.java (pdfbox-2.0.23-src) | : | AppearanceGeneratorHelper.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 135 | skipping to change at line 135 | |||
private void validateAndEnsureAcroFormResources() { | private void validateAndEnsureAcroFormResources() { | |||
// add font resources which might be available at the field | // add font resources which might be available at the field | |||
// level but are not at the AcroForm level to the AcroForm | // level but are not at the AcroForm level to the AcroForm | |||
// to match Adobe Reader/Acrobat behavior | // to match Adobe Reader/Acrobat behavior | |||
if (field.getAcroForm().getDefaultResources() == null) { | if (field.getAcroForm().getDefaultResources() == null) { | |||
return; | return; | |||
} | } | |||
PDResources acroFormResources = field.getAcroForm().getDefaultResources( ); | PDResources acroFormResources = field.getAcroForm().getDefaultResources( ); | |||
for (PDAnnotationWidget widget : field.getWidgets()) { | for (PDAnnotationWidget widget : field.getWidgets()) | |||
if (widget.getNormalAppearanceStream() != null | { | |||
&& widget.getNormalAppearanceStream().getResources() != null | PDAppearanceStream stream = widget.getNormalAppearanceStream(); | |||
) { | if (stream == null) | |||
PDResources widgetResources = widget.getNormalAppearanceStream() | { | |||
.getResources(); | continue; | |||
for (COSName fontResourceName : widgetResources.getFontNames()) | } | |||
{ | PDResources widgetResources = stream.getResources(); | |||
try { | if (widgetResources == null) | |||
if (acroFormResources.getFont(fontResourceName) == null) | { | |||
{ | continue; | |||
LOG.debug("Adding font resource " + fontResourceName | } | |||
+ " from widget to AcroForm"); | for (COSName fontResourceName : widgetResources.getFontNames()) | |||
acroFormResources.put(fontResourceName, widgetResour | { | |||
ces.getFont(fontResourceName)); | try | |||
} | { | |||
} catch (IOException e) { | if (acroFormResources.getFont(fontResourceName) == null) | |||
LOG.warn("Unable to match field level font with AcroForm | { | |||
font"); | LOG.debug("Adding font resource " + fontResourceName + " | |||
from widget to AcroForm"); | ||||
acroFormResources.put(fontResourceName, widgetResources. | ||||
getFont(fontResourceName)); | ||||
} | } | |||
} | } | |||
catch (IOException e) | ||||
{ | ||||
LOG.warn("Unable to match field level font with AcroForm fon | ||||
t"); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
/** | /** | |||
* This is the public method for setting the appearance stream. | * This is the public method for setting the appearance stream. | |||
* | * | |||
* @param apValue the String value which the appearance should represent | * @param apValue the String value which the appearance should represent | |||
* @throws IOException If there is an error creating the stream. | * @throws IOException If there is an error creating the stream. | |||
*/ | */ | |||
End of changes. 2 change blocks. | ||||
19 lines changed or deleted | 27 lines changed or added |