Committed by
GitHub
fixes display problems (randomly disappearing text) with textfields (#1699)
Showing
1 changed file
with
13 additions
and
0 deletions
@@ -141,12 +141,25 @@ class PdfCatalog extends PdfObject<PdfDict> { | @@ -141,12 +141,25 @@ class PdfCatalog extends PdfObject<PdfDict> { | ||
141 | acroForm['/SigFlags'] = PdfNum(pdfDocument.sign?.flagsValue ?? 0) | | 141 | acroForm['/SigFlags'] = PdfNum(pdfDocument.sign?.flagsValue ?? 0) | |
142 | (acroForm['/SigFlags'] as PdfNum? ?? const PdfNum(0)); | 142 | (acroForm['/SigFlags'] as PdfNum? ?? const PdfNum(0)); |
143 | final fields = (acroForm['/Fields'] ??= PdfArray()) as PdfArray; | 143 | final fields = (acroForm['/Fields'] ??= PdfArray()) as PdfArray; |
144 | + final fontRefs = PdfDict(); | ||
144 | for (final w in widgets) { | 145 | for (final w in widgets) { |
146 | + if (w.annot is PdfTextField) { | ||
147 | + // collect textfield font references | ||
148 | + PdfTextField tf = w.annot as PdfTextField; | ||
149 | + fontRefs.addAll(PdfDict.values( | ||
150 | + {tf.font.name: tf.font.ref()} | ||
151 | + )); | ||
152 | + } | ||
145 | final ref = w.ref(); | 153 | final ref = w.ref(); |
146 | if (!fields.values.contains(ref)) { | 154 | if (!fields.values.contains(ref)) { |
147 | fields.add(ref); | 155 | fields.add(ref); |
148 | } | 156 | } |
149 | } | 157 | } |
158 | + if (fontRefs.isNotEmpty) { | ||
159 | + acroForm['/DR'] = PdfDict.values( // "Document Resources" | ||
160 | + {'/Font': fontRefs} | ||
161 | + ); | ||
162 | + } | ||
150 | } | 163 | } |
151 | } | 164 | } |
152 | } | 165 | } |
-
Please register or login to post a comment