Documentation
¶
Overview ¶
Package document renders document files as text: notebooks, Word, Excel and PowerPoint files old and new, OpenDocument, RTF, EPUB, PDF and SQLite databases
Index ¶
Constants ¶
const MaxBytes = 50 << 20
Largest document converted, in bytes
Variables ¶
var ErrNotDocument = errors.New("not a document anydoc reads")
Bytes that neither their content nor their name mark as a document the converter reads
Functions ¶
Types ¶
type Error ¶
type Error struct{ Message string }
Failure the model reads: why a document could not be rendered as text
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reads documents, keeping the converter it compiles once for every later call
func (*Reader) Extract ¶
func (r *Reader) Extract(ctx context.Context, data []byte, name string, using Using) (string, error)
Text of the document as Markdown, the name giving its extension and the path shown in notes. Notebooks, docx, xlsx and SQLite databases have readers of their own, everything else goes through the converter, which tells the format from the content first. A *Error says why the document could not be read, ErrNotDocument that it is no document at all
func (*Reader) Pages ¶
func (r *Reader) Pages(ctx context.Context, data []byte, name string, first, last int, using Using) (string, error)
Text of the pages from first to last of a PDF, each headed by its number: pdftotext's, page by page, where it is on the search path of the read; else each page asked for taken out of the PDF as a file of its own (split.go) and read by the converter, which reads a PDF whole and marks no page, a page without a text layer going to OCR as a whole document does. A PDF whose structure can't be read is given whole, said so with why. A *Error says why there is none
type Using ¶
type Using struct {
// Reads a PDF without a text layer through a hosted service, tried before local OCR; nil when there is none
Parse func(ctx context.Context, data []byte, filename string) (string, error)
// Environment of the commands local OCR runs, the session's own, which their search path is looked up in; this machine's variables
// alone when nil
Env map[string]string
// Folder the read's passing files go in, the profile's scratch folder; the system's own when empty
Scratch string
}
What a read of a document runs on for the session it reads for