Documentation
¶
Index ¶
- Constants
- func IsSupportedColorDepth(depth uint) error
- type Config
- type FormatConfig
- type FormattingProgressFunc
- type GrayscaleConfig
- type Info
- type InputSource
- type Orientation
- type Page
- func (left *Page) Connect(right *Page, logger log.Logger) (*Page, error)
- func (p *Page) ConvertToGrayscale(cfg GrayscaleConfig, logger log.Logger) error
- func (p *Page) Destroy()
- func (p Page) Filename(suffix string) string
- func (p Page) Filepath(dir string, suffix string) string
- func (p *Page) Format(cfg FormatConfig, keepOrientation bool, logger log.Logger) (*format.Page, error)
- func (left *Page) IsDoublePageSpread(right *Page, cfg SpreadConfig, logger log.Logger) (bool, error)
- func (p *Page) LeftRight(other *Page) (left *Page, right *Page)
- func (p Page) Rect() Rect
- func (p *Page) ResizeToFit(cfg ResizeConfig, keepOrientation bool, logger log.Logger) error
- func (p Page) Size() Size
- func (p *Page) Trim(cfg TrimConfig, logger log.Logger) error
- func (p Page) WriteFile(filepath string, logger log.Logger) error
- type PageRange
- func (pr *PageRange) Add(start int, end int)
- func (pr PageRange) All() []int
- func (pr PageRange) Contains(page int) bool
- func (pr PageRange) First() int
- func (pr PageRange) Last() int
- func (pr PageRange) PageCount() int
- func (pr *PageRange) Parse(str string, total int) error
- func (pr PageRange) String() string
- type PdfPageExtractor
- type Point
- type Rect
- func (r Rect) BoundBy(frame Rect) Rect
- func (r Rect) InsetBy(dx int, dy int) Rect
- func (r Rect) MaxX() int
- func (r Rect) MaxY() int
- func (r Rect) MinX() int
- func (r Rect) MinY() int
- func (r Rect) MoveInside(frame Rect) Rect
- func (r Rect) String() string
- func (r Rect) ToRectangle() image.Rectangle
- func (r Rect) TranslateBy(dx int, dy int) Rect
- type ResizeConfig
- type Size
- type SkipReason
- type SkippedPage
- type SkippedPages
- type SourceMetadata
- type SpreadConfig
- type TrimConfig
- type Volume
Constants ¶
const ( OrientationPortrait = iota OrientationLandscape OrientationSquare )
Variables ¶
This section is empty.
Functions ¶
func IsSupportedColorDepth ¶
Types ¶
type Config ¶
type Config struct {
Density float64
IsRTL bool
// IsRTLSet is true when the read direction is explicitly set by the user.
// It takes precedence over the read direction in the input file.
IsRTLSet bool
// SkipUnreadablePage is true when a page which cannot be read is skipped
// instead of stopping the formatting.
SkipUnreadablePage bool
}
type FormatConfig ¶
type FormatConfig struct {
Spread SpreadConfig
Trim TrimConfig
Resize ResizeConfig
Grayscale GrayscaleConfig
WorkDir string
}
type FormattingProgressFunc ¶
type GrayscaleConfig ¶
type InputSource ¶ added in v0.8.0
type InputSource interface {
// Name is the input format name. It is used in log messages.
Name() string
// PageCount is the total number of pages in the input file.
PageCount() int
// Skipped is the pages in the input file which are skipped and left out of
// the page count.
Skipped() SkippedPages
// Metadata is the volume information found in the input file. Its fields
// are left empty if the input file has no such information.
Metadata() SourceMetadata
// LoadImage loads the image of the page number(1-based) in the input file.
LoadImage(pageNo int, cfg Config, workDir string, logger log.Logger) (image.Image, error)
}
InputSource reads pages from an input volume file. Each supported input file format has its own implementation.
type Orientation ¶
type Orientation int
func (Orientation) String ¶
func (o Orientation) String() string
type Page ¶
type Page struct {
PageNo int
OtherPageNo int // the other page number that this page connected with
// contains filtered or unexported fields
}
func (*Page) ConvertToGrayscale ¶
func (p *Page) ConvertToGrayscale(cfg GrayscaleConfig, logger log.Logger) error
func (*Page) IsDoublePageSpread ¶
func (*Page) ResizeToFit ¶
type PageRange ¶
type PageRange struct {
// contains filtered or unexported fields
}
func NewPageRange ¶
func NewPageRange() *PageRange
type PdfPageExtractor ¶
type PdfPageExtractor interface {
Name() string
Detect() error
Extract(inputFile string, page int, dpi float64, outputFile string, logger log.Logger) error
}
func FindPdfExtractor ¶
func FindPdfExtractor(logger log.Logger) (PdfPageExtractor, error)
type Rect ¶
type Rect struct {
// contains filtered or unexported fields
}
TODO: Use image.Rectange
func FromRectangle ¶
func (Rect) MoveInside ¶
func (Rect) ToRectangle ¶
type ResizeConfig ¶
type SkipReason ¶ added in v0.8.0
type SkipReason int
SkipReason tells why a page in the input file cannot be read
const ( NotSkipped SkipReason = iota SkipNoImage SkipEncrypted )
func (SkipReason) String ¶ added in v0.8.0
func (r SkipReason) String() string
String is why the page cannot be read. It is a part of the error message. It is empty when the page is not skipped.
type SkippedPage ¶ added in v0.8.0
type SkippedPage struct {
PageNo int // the page number in the input file
Reason SkipReason // why the page cannot be read
}
SkippedPage is a page in the input file which is skipped so it is not in the output file
type SkippedPages ¶ added in v0.8.0
type SkippedPages []SkippedPage
SkippedPages are the pages in the input file which are skipped so they are not in the output file
func (SkippedPages) Count ¶ added in v0.8.0
func (s SkippedPages) Count(reason SkipReason) int
Count is the number of the skipped pages with the reason
type SourceMetadata ¶ added in v0.8.0
type SourceMetadata struct {
Title string
Author string
Language string
Identifier string
IsRTL *bool // nil means the input file does not specify the read direction
// Epub is the metadata which only an epub input file has
Epub format.EpubMetadata
}
SourceMetadata is the volume information read from the input file
type SpreadConfig ¶
type Volume ¶
type Volume struct {
Filepath string
Info Info
PageCount int
Config Config
// contains filtered or unexported fields
}
func (*Volume) Format ¶
func (v *Volume) Format(pr PageRange, cfg FormatConfig, logger log.Logger, progress FormattingProgressFunc) (*format.Volume, error)
func (*Volume) Metadata ¶ added in v0.8.0
func (v *Volume) Metadata() SourceMetadata
Metadata is the volume information found in the input file
func (*Volume) Skipped ¶ added in v0.8.0
func (v *Volume) Skipped() SkippedPages
Skipped is the pages in the input file which are skipped so they are not in the output file