Skip to content

Commit

Permalink
fixes display problems (randomly disappearing text) with textfields
Browse files Browse the repository at this point in the history
  • Loading branch information
ilaurillard committed Jul 18, 2024
1 parent c9d0996 commit c3164ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pdf/lib/src/pdf/obj/catalog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,25 @@ class PdfCatalog extends PdfObject<PdfDict> {
acroForm['/SigFlags'] = PdfNum(pdfDocument.sign?.flagsValue ?? 0) |
(acroForm['/SigFlags'] as PdfNum? ?? const PdfNum(0));
final fields = (acroForm['/Fields'] ??= PdfArray()) as PdfArray;
final fontRefs = PdfDict();
for (final w in widgets) {
if (w.annot is PdfTextField) {
// collect textfield font references
PdfTextField tf = w.annot as PdfTextField;
fontRefs.addAll(PdfDict.values(
{tf.font.name: tf.font.ref()}
));
}
final ref = w.ref();
if (!fields.values.contains(ref)) {
fields.add(ref);
}
}
if (fontRefs.isNotEmpty) {
acroForm['/DR'] = PdfDict.values( // "Document Resources"
{'/Font': fontRefs}
);
}
}
}
}

0 comments on commit c3164ac

Please sign in to comment.