xfa

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPDFFromXFAStreams

func BuildPDFFromXFAStreams(streams *XFAStreams, verbose bool) ([]byte, error)

BuildPDFFromXFAStreams creates a new PDF entirely from XFA stream data This is useful when you need a clean PDF with only the XFA content

func CompressStream

func CompressStream(data []byte) ([]byte, error)

CompressStream compresses data using FlateDecode

func ConfigToXFA

func ConfigToXFA(config *types.XFAConfig, verbose bool) (string, error)

ConfigToXFA converts XFAConfig to XFA XML

func ConnectionSetToXFA

func ConnectionSetToXFA(connectionSet *types.XFAConnectionSet, verbose bool) (string, error)

ConnectionSetToXFA converts XFAConnectionSet to XFA XML

func DatasetsToXFA

func DatasetsToXFA(datasets *types.XFADatasets, verbose bool) (string, error)

DatasetsToXFA converts XFADatasets to XFA XML

func DecompressStream

func DecompressStream(streamBytes []byte) ([]byte, bool, error)

DecompressStream attempts to decompress a stream (handles FlateDecode) FlateDecode can be either raw deflate or zlib-wrapped

func FindXFADatasetsStream

func FindXFADatasetsStream(pdfBytes []byte, encryptInfo *types.PDFEncryption, verbose bool) ([]byte, int, error)

FindXFADatasetsStream finds and extracts the XFA datasets stream This is a convenience function that uses ExtractAllXFAStreams and returns only the datasets stream

func FormToXFA

func FormToXFA(formSchema *types.FormSchema, verbose bool) (string, error)

FormToXFA converts a FormSchema to XFA XML

func LocaleSetToXFA

func LocaleSetToXFA(localeSet *types.XFALocaleSet, verbose bool) (string, error)

LocaleSetToXFA converts XFALocaleSet to XFA XML

func ParseXFAConfig

func ParseXFAConfig(xfaConfigXML string, verbose bool) (*types.XFAConfig, error)

ParseXFAConfig parses XFA config XML and converts it to XFAConfig type

func ParseXFAConnectionSet

func ParseXFAConnectionSet(xfaConnectionSetXML string, verbose bool) (*types.XFAConnectionSet, error)

ParseXFAConnectionSet parses XFA connectionSet XML and converts it to XFAConnectionSet type

func ParseXFADatasets

func ParseXFADatasets(xfaDatasetsXML string, verbose bool) (*types.XFADatasets, error)

ParseXFADatasets parses XFA datasets XML and converts it to XFADatasets type

func ParseXFAForm

func ParseXFAForm(xfaXML string, verbose bool) (*types.FormSchema, error)

ParseXFAForm parses raw XFA XML and converts it to a strongly-typed FormSchema

func ParseXFALocaleSet

func ParseXFALocaleSet(xfaLocaleSetXML string, verbose bool) (*types.XFALocaleSet, error)

ParseXFALocaleSet parses XFA localeSet XML and converts it to XFALocaleSet type

func ParseXFAStylesheet

func ParseXFAStylesheet(xfaStylesheetXML string, verbose bool) (*types.XFAStylesheet, error)

ParseXFAStylesheet parses XFA stylesheet XML and converts it to XFAStylesheet type

func ReadObjectFromXRef

func ReadObjectFromXRef(pdfBytes []byte, objNum, genNum int, xrefOffset int64, encryptInfo *types.PDFEncryption, verbose bool) ([]byte, error)

ReadObjectFromXRef reads an object using xref offset (PyPDF approach) Matches PyPDF's get_object method (lines 413-490)

func RebuildPDFFromXFAStreams

func RebuildPDFFromXFAStreams(originalPDFBytes []byte, streams *XFAStreams, encryptInfo *types.PDFEncryption, verbose bool) ([]byte, error)

RebuildPDFFromXFAStreams rebuilds a PDF from extracted XFA streams using proper PDF writer

func ReplaceStreamInPDF

func ReplaceStreamInPDF(pdfBytes []byte, streamObjNum int, newStream []byte, verbose bool) ([]byte, error)

ReplaceStreamInPDF replaces a stream in the PDF and updates the length

func StylesheetToXFA

func StylesheetToXFA(stylesheet *types.XFAStylesheet, verbose bool) (string, error)

StylesheetToXFA converts XFAStylesheet to XFA XML

func UpdateXFAFieldValues

func UpdateXFAFieldValues(xfaXML string, formData types.FormData, verbose bool) (string, error)

UpdateXFAFieldValues updates individual field values in XFA XML

func UpdateXFAInPDF

func UpdateXFAInPDF(pdfBytes []byte, formData types.FormData, encryptInfo *types.PDFEncryption, verbose bool) ([]byte, error)

UpdateXFAInPDF updates XFA field values in PDF bytes

func UpdateXFAValues

func UpdateXFAValues(xfaXML string, formData types.FormData, verbose bool) (string, error)

UpdateXFAValues updates field values in XFA XML

Types

type PDFStream

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

PDFStream represents a stream-like interface for reading PDF bytes

func NewPDFStream

func NewPDFStream(data []byte) *PDFStream

func (*PDFStream) Peek

func (s *PDFStream) Peek(n int) []byte

func (*PDFStream) Read

func (s *PDFStream) Read(n int) ([]byte, error)

func (*PDFStream) ReadByte

func (s *PDFStream) ReadByte() (byte, error)

func (*PDFStream) Seek

func (s *PDFStream) Seek(offset int64, whence int) (int64, error)

func (*PDFStream) Tell

func (s *PDFStream) Tell() int64

type ParsedDictEntry

type ParsedDictEntry struct {
	Key   []byte // Key (e.g., "/XFA")
	Value []byte // Value (raw bytes, may be encrypted)
}

ParsedDictEntry represents a key-value pair in a parsed dictionary

type XFAEvent

type XFAEvent struct {
	Type   string // "initialize", "change", "enter", "exit", etc.
	Script string
	Target string
	Action string
}

XFAEvent represents an event in XFA (for rules extraction)

type XFAFieldData

type XFAFieldData struct {
	Name        string
	FullName    string
	Type        string
	Value       string
	Default     string
	Label       string
	Description string
	Required    bool
	ReadOnly    bool
	Hidden      bool
	PageNumber  int
	Options     []XFAOption
	Validation  *XFAValidation
	Properties  map[string]interface{}
	Events      []XFAEvent
}

XFAFieldData represents a field extracted from XFA XML

type XFAOption

type XFAOption struct {
	Value    string
	Label    string
	Selected bool
}

XFAOption represents an option for choice fields

type XFAStreamInfo

type XFAStreamInfo struct {
	Data         []byte `json:"data"`
	ObjectNumber int    `json:"objectNumber"`
	Compressed   bool   `json:"compressed"`
}

XFAStreamInfo contains stream data and metadata

type XFAStreams

type XFAStreams struct {
	Template      *XFAStreamInfo `json:"template,omitempty"`
	Datasets      *XFAStreamInfo `json:"datasets,omitempty"`
	Config        *XFAStreamInfo `json:"config,omitempty"`
	LocaleSet     *XFAStreamInfo `json:"localeSet,omitempty"`
	ConnectionSet *XFAStreamInfo `json:"connectionSet,omitempty"`
	Stylesheet    *XFAStreamInfo `json:"stylesheet,omitempty"`
	XMP           *XFAStreamInfo `json:"xmp,omitempty"`
	Signature     *XFAStreamInfo `json:"signature,omitempty"`
	SourceSet     *XFAStreamInfo `json:"sourceSet,omitempty"`
}

XFAStreams represents all XFA streams extracted from a PDF

func ExtractAllXFAStreams

func ExtractAllXFAStreams(pdfBytes []byte, encryptInfo *types.PDFEncryption, verbose bool) (*XFAStreams, error)

ExtractAllXFAStreams extracts all XFA streams from a PDF without using UniPDF

type XFAStructure

type XFAStructure struct {
	Title       string
	Description string
	Version     string
	Fields      []XFAFieldData
	Subforms    []XFASubformData
}

XFAStructure represents the parsed XFA XML structure

type XFASubformData

type XFASubformData struct {
	Name   string
	Fields []XFAFieldData
}

XFASubformData represents a subform in XFA

type XFAValidation

type XFAValidation struct {
	MinLength    *int
	MaxLength    *int
	MinValue     *float64
	MaxValue     *float64
	Pattern      string
	Script       string
	ErrorMessage string
}

XFAValidation represents validation rules from XFA

Jump to

Keyboard shortcuts

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