Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotSupported is returned when an operation (e.g. Image) is not // available for a given format. ErrNotSupported = errors.New("extraction: operation not supported for this format") // ErrUnsupportedFormat is returned by Open when the file extension is // not recognised. ErrUnsupportedFormat = errors.New("extraction: unsupported file format") )
Functions ¶
func ExtractText ¶
ExtractText extracts all text from a document, concatenating every page. The result is sanitised with strings.ToValidUTF8.
func IsDocumentContentType ¶
IsDocumentContentType checks whether the given Content-Type header value corresponds to a supported document format. It returns the file extension and true if so, or ("", false) otherwise.
func IsDocumentFile ¶
IsDocumentFile returns true for document formats supported by the extraction package.
func IsPlainTextFile ¶
IsPlainTextFile reports whether path has a known plain-text extension.
func ReadTextFile ¶
ReadTextFile reads a plain-text file and returns its content coerced to valid UTF-8. HTML/RTF are returned verbatim (no tag stripping) — a documented v1 limit.
Types ¶
type Document ¶
type Document interface {
// NumPage returns the number of logical pages (sheets, slides, chapters).
NumPage() int
// Text returns the text content of page pageIndex (0-based).
Text(pageIndex int) (string, error)
// Image renders page pageIndex as an image.
// Returns ErrNotSupported for formats that cannot render pages.
Image(pageIndex int) (image.Image, error)
// Close releases all resources held by the document.
Close() error
}
Document provides page-oriented access to text and rendered images.