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 ¶
- Variables
- func ExtractAcroForm(pdfBytes []byte, password []byte, verbose bool) (*acroform.AcroForm, error)
- func ExtractXFA(pdfBytes []byte, password []byte, verbose bool) (*types.FormSchema, *types.XFADatasets, error)
- type AcroFormWrapper
- func (w *AcroFormWrapper) Fill(pdfBytes []byte, data types.FormData, password []byte, verbose bool) ([]byte, error)
- func (w *AcroFormWrapper) GetValues() map[string]interface{}
- func (w *AcroFormWrapper) Schema() *types.FormSchema
- func (w *AcroFormWrapper) Type() FormType
- func (w *AcroFormWrapper) Validate(data types.FormData) []error
- type FillOptions
- type FillStrategy
- type Form
- type FormType
- type XFAFormWrapper
- func (w *XFAFormWrapper) Fill(pdfBytes []byte, data types.FormData, password []byte, verbose bool) ([]byte, error)
- func (w *XFAFormWrapper) FillWithOptions(pdfBytes []byte, data types.FormData, password []byte, opts FillOptions, ...) ([]byte, error)
- func (w *XFAFormWrapper) GetValues() map[string]interface{}
- func (w *XFAFormWrapper) Schema() *types.FormSchema
- func (w *XFAFormWrapper) Type() FormType
- func (w *XFAFormWrapper) Validate(data types.FormData) []error
Constants ¶
This section is empty.
Variables ¶
var ErrCryptFilterDecodeParmsConflict = errors.New("stream dict has /Filter array with /Crypt plus other filters and an array-form /DecodeParms; dropping /Crypt would misalign /DecodeParms (not supported)")
ErrCryptFilterDecodeParmsConflict is returned by xfaStripCryptFilter when a stream dict contains both /Filter[/Crypt /Other...] and an array-form /DecodeParms entry. Per PDF 7.4.1 the two arrays are positionally aligned, so dropping /Crypt from /Filter would shift the parametrisation of every remaining filter by one — a bug we can't fix without also rewriting the /DecodeParms array. The eSTAR templates this code targets never combine /Crypt with other filters, so this case is unreachable in practice; we error rather than silently miscoding it for future inputs.
Functions ¶
func ExtractAcroForm ¶
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) 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
type FillOptions ¶ added in v2.7.0
type FillOptions struct {
Strategy FillStrategy // default StrategyByteRewrite (current Fill behavior)
}
FillOptions configures XFAFormWrapper.FillWithOptions.
type FillStrategy ¶ added in v2.7.0
type FillStrategy int
FillStrategy selects how XFA form fills modify the PDF.
const ( // StrategyByteRewrite patches the datasets stream in place, decrypting the // whole document first when the source is encrypted (output is plaintext). // Only works for classical-xref sources; xref-stream sources automatically // use the incremental path instead. That automatic routing means the // plaintext-output rule above holds only for classical-xref sources: an // encrypted xref-stream source filled with this (default) strategy goes // through the incremental path and produces encrypted output, same as // StrategyIncrementalUpdate. StrategyByteRewrite FillStrategy = iota // StrategyIncrementalUpdate appends a PDF incremental update (ISO 32000-1 // §7.5.6): original bytes are preserved verbatim, the source's encryption // is preserved (the new datasets stream is re-encrypted with the document // key), and signatures over the original revision are not invalidated. StrategyIncrementalUpdate )
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
type XFAFormWrapper ¶
type XFAFormWrapper struct {
// contains filtered or unexported fields
}
XFAFormWrapper wraps XFA form data to implement the Form interface
func (*XFAFormWrapper) FillWithOptions ¶ added in v2.7.0
func (w *XFAFormWrapper) FillWithOptions(pdfBytes []byte, data types.FormData, password []byte, opts FillOptions, verbose bool) ([]byte, error)
FillWithOptions fills the form like Fill, with an explicit strategy choice. StrategyIncrementalUpdate works directly on the supplied (possibly encrypted) bytes and preserves the source's encryption in the output, unlike the default path which returns plaintext for encrypted sources.
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