forms

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package forms provides a unified interface for working with PDF forms It supports both AcroForm and XFA form types with automatic detection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAcroForm

func ExtractAcroForm(pdfBytes []byte, password []byte, verbose bool) (*acroform.AcroForm, error)

ExtractAcroForm extracts an AcroForm (type-specific)

func ExtractXFA

func ExtractXFA(pdfBytes []byte, password []byte, verbose bool) (*types.FormSchema, *types.XFADatasets, error)

ExtractXFA extracts XFA form data (type-specific) Returns the FormSchema and Datasets separately

Types

type AcroFormWrapper

type AcroFormWrapper struct {
	// contains filtered or unexported fields
}

AcroFormWrapper wraps an AcroForm to implement the Form interface

func (*AcroFormWrapper) Fill

func (w *AcroFormWrapper) Fill(pdfBytes []byte, data types.FormData, password []byte, verbose bool) ([]byte, error)

func (*AcroFormWrapper) GetValues

func (w *AcroFormWrapper) GetValues() map[string]interface{}

func (*AcroFormWrapper) Schema

func (w *AcroFormWrapper) Schema() *types.FormSchema

func (*AcroFormWrapper) Type

func (w *AcroFormWrapper) Type() FormType

func (*AcroFormWrapper) Validate

func (w *AcroFormWrapper) Validate(data types.FormData) []error

type Form

type Form interface {
	// Type returns the form type (AcroForm or XFA)
	Type() FormType

	// Schema returns the form schema (structure and fields)
	Schema() *types.FormSchema

	// Fill fills the form with the provided data and returns modified PDF bytes
	Fill(pdfBytes []byte, data types.FormData, password []byte, verbose bool) ([]byte, error)

	// Validate validates form data against the form's validation rules
	Validate(data types.FormData) []error

	// GetValues returns the current values of all form fields
	GetValues() map[string]interface{}
}

Form represents a unified form interface

func Extract

func Extract(pdfBytes []byte, password []byte, verbose bool) (Form, error)

Extract extracts and returns a unified Form interface It automatically detects whether the PDF contains AcroForm or XFA forms

type FormType

type FormType string

FormType represents the type of form

const (
	FormTypeAcroForm FormType = "acroform"
	FormTypeXFA      FormType = "xfa"
	FormTypeUnknown  FormType = "unknown"
)

func Detect

func Detect(pdfBytes []byte, password []byte, verbose bool) (FormType, error)

Detect detects the form type in a PDF

type XFAFormWrapper

type XFAFormWrapper struct {
	// contains filtered or unexported fields
}

XFAFormWrapper wraps XFA form data to implement the Form interface

func (*XFAFormWrapper) Fill

func (w *XFAFormWrapper) Fill(pdfBytes []byte, data types.FormData, password []byte, verbose bool) ([]byte, error)

func (*XFAFormWrapper) GetValues

func (w *XFAFormWrapper) GetValues() map[string]interface{}

func (*XFAFormWrapper) Schema

func (w *XFAFormWrapper) Schema() *types.FormSchema

func (*XFAFormWrapper) Type

func (w *XFAFormWrapper) Type() FormType

func (*XFAFormWrapper) Validate

func (w *XFAFormWrapper) Validate(data types.FormData) []error

Directories

Path Synopsis
Package acroform provides action support for form fields
Package acroform provides action support for form fields

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL