Documentation
¶
Index ¶
- Variables
- type Document
- func (d *Document) ContentType() (string, error)
- func (d *Document) Fingerprint() (string, error)
- func (d *Document) ParsePages(ctx context.Context, r pagerange.Range) ([]*Page, error)
- func (d *Document) Path() string
- func (d *Document) RenderPageUsing(ctx context.Context, num int, r renderformat.Renderer) error
- func (d *Document) Validate(ctx context.Context) error
- type DocumentOption
- type DocumentParserFactory
- type MuPdfParserFactory
- type Page
- func (p *Page) Document() *Document
- func (p *Page) Number() int
- func (p *Page) RenderUsing(ctx context.Context, r renderformat.Renderer) error
- func (p *Page) Size() geometry.Size
- func (p *Page) VisitElements(visitor PageElementVisitorFunc) error
- func (p *Page) VisitElementsIntersecting(bounds geometry.Rect, visitor PageElementVisitorFunc) error
- type PageElementVisitorFunc
- type Parser
Constants ¶
This section is empty.
Variables ¶
var ErrStopVisitation = errors.New("stop visitation")
var ErrUnsupportedFileFormat = errors.New("unsupported file format")
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func NewDocument ¶
func NewDocument(path string, opts ...DocumentOption) *Document
NewDocument constructs a new document. The file must not be modified while it's being used. Operations may open and close the file multiple times.
func (*Document) ContentType ¶
ContentType determines and returns the MIME content-type of the source file. The returned string may contain parameters (e.g. charset). Use mime.ParseMediaType or similar to parse the type.
func (*Document) Fingerprint ¶
Fingerprint returns a best-effort file version identifier in the form of an opaque, non-empty string. While a changed fingerprint is indicative of a modified file, the fingerprint may also change for an unchanged file.
func (*Document) ParsePages ¶
ParsePages uses the underlying document parser to read and parse pages. The returned slice may contain fewer or more pages than requested by the given range, depending on what the document actually contains and the parser's behaviour. Page numbers can be determined via Page.Number.
func (*Document) Path ¶
Path returns the file path given to NewDocument.
func (*Document) RenderPageUsing ¶
RenderPageUsing writes a single page using the given renderer, e.g. as a PNG image via renderformat.PNG.
type DocumentOption ¶
type DocumentOption func(*Document)
func WithDocumentParserFactory ¶
func WithDocumentParserFactory(f DocumentParserFactory) DocumentOption
Configure a custom factory function to create parser instances. When left unconfigured an appropriate parser is automatically chosen based on the source file's content.
func WithStaticDocumentParser ¶
func WithStaticDocumentParser(p Parser) DocumentOption
Use a fixed parser for all documents without considering the content type.
type DocumentParserFactory ¶
type MuPdfParserFactory ¶
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func (*Page) RenderUsing ¶
func (*Page) VisitElements ¶
func (p *Page) VisitElements(visitor PageElementVisitorFunc) error
VisitElements invokes the visitor function for all elements. The visitation continues until either all elements have been visited or the visitor function returns a non-nil error. ErrStopVisitation stops the search immediately without failing the overall search. The visitation order is undefined.
func (*Page) VisitElementsIntersecting ¶
func (p *Page) VisitElementsIntersecting(bounds geometry.Rect, visitor PageElementVisitorFunc) error
VisitElementsIntersecting is like [VisitElements] with the additional restriction that only elements within the specified bounds are visited.
type PageElementVisitorFunc ¶
func AsPageElementVisitor ¶
func AsPageElementVisitor[T content.Element](fn func(T) error) PageElementVisitorFunc
AsPageElementVisitor returns a visitor function wrapper filtering for elements of type T.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
mutool
Package mutool wraps MuPDF's "mutool" command line program.
|
Package mutool wraps MuPDF's "mutool" command line program. |
webui/template
templ: version: v0.2.778
|
templ: version: v0.2.778 |
pkg
|
|