pdf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	// Warn logs a warning message with optional fields.
	// Fields should be key-value pairs (e.g., "category", "image", "error", err).
	Warn(msg string, fields ...interface{})
	// Debug logs a debug message with optional fields.
	Debug(msg string, fields ...interface{})
}

Logger defines the interface for structured logging. Implementations can use any logging library (e.g., zerolog, zap, logrus). If nil, no logging is performed.

type Parser

type Parser struct {
	HeadingDetectionEnabled bool // Enable heading detection using heuristics
	TableExtractionEnabled  bool // Enable table extraction using layout analysis
	// contains filtered or unexported fields
}

Parser handles PDF parsing and content extraction using pdfcpu. PDF parsing is more complex than DOCX because PDFs have less semantic structure. Tables, headings, and formatting often require layout analysis rather than direct extraction.

func NewParser

func NewParser() *Parser

NewParser creates a new PDF parser instance with default settings.

func NewParserWithLogger

func NewParserWithLogger(logger Logger) *Parser

NewParserWithLogger creates a new PDF parser instance with structured logging.

func (*Parser) Parse

func (p *Parser) Parse(filePath string) (*types.DocumentData, error)

Parse extracts content from a PDF file and returns structured document data. Warnings are collected for non-fatal issues (e.g., failed image extraction, table extraction issues) and returned in DocumentData.Warnings.

type TextBlock

type TextBlock struct {
	Text     string
	FontSize float64
	FontName string
	X        float64
	Y        float64
	Page     int
	Bold     bool
	Italic   bool
}

TextBlock represents a block of text with position and formatting information.

Jump to

Keyboard shortcuts

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