@@ -1624,6 +1624,10 @@ public PdfString getDefaultAppearance() {
1624
1624
}
1625
1625
}
1626
1626
}
1627
+ //DA is an inherited key, therefore AcroForm shall be checked if there is no parent or no DA in parent.
1628
+ if (defaultAppearance == null ) {
1629
+ defaultAppearance = (PdfString ) getAcroFormKey (PdfName .DA , PdfObject .STRING );
1630
+ }
1627
1631
return defaultAppearance ;
1628
1632
}
1629
1633
@@ -2019,9 +2023,7 @@ public boolean regenerateField() {
2019
2023
if (appearance == null ) {
2020
2024
appearance = new PdfFormXObject (new Rectangle (0 , 0 , bBox .toRectangle ().getWidth (), bBox .toRectangle ().getHeight ()));
2021
2025
}
2022
- if (matrix != null ) {
2023
- appearance .put (PdfName .Matrix , matrix );
2024
- }
2026
+ appearance .put (PdfName .Matrix , matrix );
2025
2027
//Create text appearance
2026
2028
if (PdfName .Tx .equals (type )) {
2027
2029
if (!isMultiline ()) {
@@ -2585,19 +2587,15 @@ protected Object[] getFontAndSize(PdfDictionary asNormal) throws IOException {
2585
2587
PdfDictionary normalResources = null ;
2586
2588
PdfDictionary defaultResources = null ;
2587
2589
PdfDocument document = getDocument ();
2588
- if (document != null ) {
2589
- PdfDictionary acroformDictionary = document .getCatalog ().getPdfObject ().getAsDictionary (PdfName .AcroForm );
2590
- if (acroformDictionary != null ) {
2591
- defaultResources = acroformDictionary .getAsDictionary (PdfName .DR );
2592
- }
2593
- }
2590
+ defaultResources = (PdfDictionary ) getAcroFormKey (PdfName .DR , PdfObject .DICTIONARY );
2594
2591
if (asNormal != null ) {
2595
2592
normalResources = asNormal .getAsDictionary (PdfName .Resources );
2596
2593
}
2597
2594
if (defaultResources != null || normalResources != null ) {
2598
2595
PdfDictionary normalFontDic = normalResources != null ? normalResources .getAsDictionary (PdfName .Font ) : null ;
2599
2596
PdfDictionary defaultFontDic = defaultResources != null ? defaultResources .getAsDictionary (PdfName .Font ) : null ;
2600
2597
PdfString defaultAppearance = getDefaultAppearance ();
2598
+
2601
2599
if ((normalFontDic != null || defaultFontDic != null ) && defaultAppearance != null ) {
2602
2600
Object [] dab = splitDAelements (defaultAppearance .toUnicodeString ());
2603
2601
PdfName fontName = new PdfName (dab [DA_FONT ].toString ());
@@ -3210,6 +3208,18 @@ protected void drawPdfACheckBox(PdfCanvas canvas, float width, float height, boo
3210
3208
}
3211
3209
}
3212
3210
3211
+ private PdfObject getAcroFormKey (PdfName key , int type ) {
3212
+ PdfObject acroFormKey = null ;
3213
+ PdfDocument document = getDocument ();
3214
+ if (document != null ) {
3215
+ PdfDictionary acroFormDictionary = document .getCatalog ().getPdfObject ().getAsDictionary (PdfName .AcroForm );
3216
+ if (acroFormDictionary != null ) {
3217
+ acroFormKey = acroFormDictionary .get (key );
3218
+ }
3219
+ }
3220
+ return (acroFormKey != null && acroFormKey .getType () == type ) ? acroFormKey : null ;
3221
+ }
3222
+
3213
3223
private TextAlignment convertJustificationToTextAlignment () {
3214
3224
Integer justification = getJustification ();
3215
3225
if (justification == null ) {
0 commit comments