PdfFormViewer class

A widget that displays a PDF with interactive form field overlays.

This widget renders a PDF document and overlays editable form fields at the correct positions based on the fields extracted from the PDF.

The form data is managed externally through formData and onFieldChanged, allowing for flexible state management.

Example:

PdfFormViewer(
  pdfPath: '/path/to/form.pdf',
  fields: extractedFields,
  formData: {'firstName': 'John', 'newsletter': true},
  readOnlyFields: {'firstName'}, // These fields will be read-only
  onFieldChanged: (name, value) {
    setState(() => formData[name] = value);
  },
)
Inheritance

Constructors

PdfFormViewer({required String pdfPath, required List<PdfFormField> fields, required Map<String, dynamic> formData, required void onFieldChanged(String fieldName, dynamic value), Set<String> readOnlyFields = const {}, Key? key})
Creates a PdfFormViewer.
const

Properties

fields List<PdfFormField>
The list of form fields extracted from the PDF.
final
formData Map<String, dynamic>
The current form data as a map of field names to values.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onFieldChanged → void Function(String fieldName, dynamic value)
Called when a field value changes.
final
pdfPath String
The path to the PDF file to display.
final
readOnlyFields Set<String>
Set of field names that should be displayed as read-only.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<PdfFormViewer>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited