reader

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package reader provides application-layer PDF reading functionality.

This package wraps the infrastructure-layer parser to provide a clean application-layer API for PDF document reading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PdfReader

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

PdfReader is an application-layer wrapper around the infrastructure parser.Reader.

It provides a clean separation between infrastructure (low-level parsing) and application concerns (document structure navigation).

func NewPdfReader

func NewPdfReader(path string) (*PdfReader, error)

NewPdfReader creates a new PDF reader from a file path.

The file is opened and parsed immediately. Remember to call Close() when done to release resources.

Example:

reader, err := reader.NewPdfReader("document.pdf")
if err != nil {
    log.Fatal(err)
}
defer reader.Close()

func NewPdfReaderWithPassword added in v0.6.0

func NewPdfReaderWithPassword(path, password string) (*PdfReader, error)

NewPdfReaderWithPassword creates a new PDF reader from a password-protected file.

Use this for encrypted PDFs that require a non-empty password. For PDFs with empty user password, NewPdfReader handles them transparently.

func (*PdfReader) Close

func (r *PdfReader) Close() error

Close closes the PDF file and releases resources.

func (*PdfReader) GetPage

func (r *PdfReader) GetPage(pageIndex int) (*parser.Dictionary, error)

GetPage returns the page dictionary for the specified page index (0-based).

func (*PdfReader) GetParserReader

func (r *PdfReader) GetParserReader() *parser.Reader

GetParserReader returns the underlying parser.Reader for advanced operations.

This is used internally by extractors that need direct access to the parser. Most users should not need this method - use the higher-level methods instead.

func (*PdfReader) PageCount

func (r *PdfReader) PageCount() int

PageCount returns the total number of pages in the PDF.

func (*PdfReader) Version

func (r *PdfReader) Version() string

Version returns the PDF version string (e.g., "1.7").

Jump to

Keyboard shortcuts

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