Documentation ¶
Index ¶
- Variables
- func GetInfo(pdf string, options ...CallOption) (map[string]string, error)
- func GetPagesCount(pdfPath string, options ...CallOption) (int, error)
- type BatchTask
- type CallOption
- func WithContext(ctx context.Context) CallOption
- func WithDpi(dpi int) CallOption
- func WithFirstPage(firstPage int) CallOption
- func WithFormat(fmt string) CallOption
- func WithGrayScale() CallOption
- func WithHideAnnotations() CallOption
- func WithJPEGOpt(jpegOpt map[string]string) CallOption
- func WithJPEGOptimize(optimize bool) CallOption
- func WithJPEGProgressive(progressive bool) CallOption
- func WithJPEGQuality(quality int) CallOption
- func WithJob(job int) CallOption
- func WithLastPage(lastPage int) CallOption
- func WithOutputFile(outputFile string) CallOption
- func WithOutputFileFn(fn nameFn) CallOption
- func WithOutputFolder(outputFolder string) CallOption
- func WithOwnerPw(ownerPw string) CallOption
- func WithPageRange(firstPage, lastPage int) CallOption
- func WithPopplerPath(popplerPath string) CallOption
- func WithScaleTo(size int) CallOption
- func WithScaleToX(size int) CallOption
- func WithScaleToY(size int) CallOption
- func WithSingleFile() CallOption
- func WithStrict() CallOption
- func WithTimeout(timeout time.Duration) CallOption
- func WithTransparent() CallOption
- func WithUseCropBox() CallOption
- func WithUsePdftocario() CallOption
- func WithUserPw(userPw string) CallOption
- func WithVerbose() CallOption
- type ChanProvider
- type ConversionError
- type Convertor
- type GetBinaryVersionError
- type Observable
- type PDFSyntaxError
- type Parameters
- type PdfProvider
- type PerPageTimeoutError
- type Progress
- type SingleTask
- type SliceFileProvider
- type Task
- type WrongArgumentError
Constants ¶
This section is empty.
Variables ¶
var ErrProviderClosed = errors.New("provider is closed")
var WithSize = WithScaleTo
WithSize is the alias of WithScaleTo
Functions ¶
func GetPagesCount ¶
func GetPagesCount(pdfPath string, options ...CallOption) (int, error)
Types ¶
type BatchTask ¶
type BatchTask struct {
Task
}
BatchTask deals with multiple documents conversion where each convertor converts single document.
func ConvertFiles ¶
func ConvertFiles(files interface{}, options ...CallOption) (*BatchTask, error)
ConvertFiles converts multiple PDF files to images
files could be type `[]string`, `chan string`, or `PdfProvider`
func (*BatchTask) Start ¶
func (t *BatchTask) Start(provider PdfProvider) error
type CallOption ¶
type CallOption func(o *Parameters, command []string) []string
func WithContext ¶
func WithContext(ctx context.Context) CallOption
func WithFirstPage ¶
func WithFirstPage(firstPage int) CallOption
WithFirstPage sets the first page to convert
func WithGrayScale ¶
func WithGrayScale() CallOption
func WithHideAnnotations ¶
func WithHideAnnotations() CallOption
func WithJPEGOpt ¶
func WithJPEGOpt(jpegOpt map[string]string) CallOption
func WithJPEGOptimize ¶
func WithJPEGOptimize(optimize bool) CallOption
func WithJPEGProgressive ¶
func WithJPEGProgressive(progressive bool) CallOption
func WithJPEGQuality ¶
func WithJPEGQuality(quality int) CallOption
func WithLastPage ¶
func WithLastPage(lastPage int) CallOption
WithLastPage sets the last page to convert
func WithOutputFile ¶
func WithOutputFile(outputFile string) CallOption
func WithOutputFileFn ¶
func WithOutputFileFn(fn nameFn) CallOption
func WithOutputFolder ¶
func WithOutputFolder(outputFolder string) CallOption
Write the resulting images to a folder (instead of directly in memory)
func WithOwnerPw ¶
func WithOwnerPw(ownerPw string) CallOption
WithOwnerPw sets PDF's owner password
func WithPageRange ¶
func WithPageRange(firstPage, lastPage int) CallOption
WithPageRange sets the range of pages to convert
func WithPopplerPath ¶
func WithPopplerPath(popplerPath string) CallOption
WithPopplerPath sets poppler binaries lookup path
func WithScaleTo ¶
func WithScaleTo(size int) CallOption
WithScaleTo sets the size of the resulting images, size=400 will fit the image to a 400x400 box, preserving aspect ratio
func WithScaleToX ¶
func WithScaleToX(size int) CallOption
func WithScaleToY ¶
func WithScaleToY(size int) CallOption
func WithSingleFile ¶
func WithSingleFile() CallOption
func WithStrict ¶
func WithStrict() CallOption
WithStrict sets to strict mode, when a Syntax Error is thrown, it will be raised as an Exception
func WithTransparent ¶
func WithTransparent() CallOption
func WithUseCropBox ¶
func WithUseCropBox() CallOption
func WithUsePdftocario ¶
func WithUsePdftocario() CallOption
func WithVerbose ¶
func WithVerbose() CallOption
WithVerbose will prints useful debugging information
type ChanProvider ¶
type ChanProvider struct {
// contains filtered or unexported fields
}
func (*ChanProvider) Count ¶
func (p *ChanProvider) Count() int
func (*ChanProvider) Source ¶
func (p *ChanProvider) Source() <-chan string
type ConversionError ¶
type ConversionError struct {
// contains filtered or unexported fields
}
func (*ConversionError) Cause ¶
func (e *ConversionError) Cause() error
func (*ConversionError) Error ¶
func (e *ConversionError) Error() string
type Convertor ¶
type Convertor struct { Progress // contains filtered or unexported fields }
func (*Convertor) Errors ¶
func (c *Convertor) Errors() []*ConversionError
type GetBinaryVersionError ¶
type GetBinaryVersionError struct {
// contains filtered or unexported fields
}
func NewGetBinaryVersionError ¶
func NewGetBinaryVersionError(binary string) *GetBinaryVersionError
func (*GetBinaryVersionError) Error ¶
func (e *GetBinaryVersionError) Error() string
type Observable ¶
type Observable interface { // Total is the total Total() int32 // Finished counts finished conversion, since the conversion may be a // part of a file, like from `firstPage` to `lastPage`, thus the total // count may less than `lastPage` and Finished() <= Current() always holds Finished() int32 // Current is the current page number we've just converted Current() int32 Completed() bool Aborted() bool }
type PDFSyntaxError ¶
type PDFSyntaxError struct {
// contains filtered or unexported fields
}
func NewOldPDFSyntaxError ¶
func NewOldPDFSyntaxError(line, filename string, page int32) *PDFSyntaxError
func NewPDFSyntaxError ¶
func NewPDFSyntaxError(line string) *PDFSyntaxError
func (*PDFSyntaxError) Error ¶
func (e *PDFSyntaxError) Error() string
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
type PdfProvider ¶
func FromChan ¶
func FromChan(ch chan string) PdfProvider
func FromGlob ¶
func FromGlob(pattern string) PdfProvider
func FromInterface ¶
func FromInterface(i interface{}) PdfProvider
func FromMultiSource ¶
func FromMultiSource(patterns []string) PdfProvider
func FromMultiSourceAsync ¶
func FromMultiSourceAsync(patterns []string) PdfProvider
func FromSlice ¶
func FromSlice(files []string) PdfProvider
type PerPageTimeoutError ¶
type PerPageTimeoutError struct {
// contains filtered or unexported fields
}
func NewPerPageTimeoutError ¶
func NewPerPageTimeoutError(page string) *PerPageTimeoutError
func (*PerPageTimeoutError) Error ¶
func (e *PerPageTimeoutError) Error() string
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
func (*Progress) SetCurrent ¶
type SingleTask ¶
type SingleTask struct {
Task
}
SingleTask deals with single document conversion where usually the given pdf is a large file so we split it (evenly) into parts by page ranges and dispatch them to every convertor.
func Convert ¶
func Convert(pdf string, options ...CallOption) (*SingleTask, error)
Convert converts single PDF to images. This function is solely a options parser and command builder
func (*SingleTask) Start ¶
func (t *SingleTask) Start(pdf string) error
Start initiates the conversion process
type SliceFileProvider ¶
type SliceFileProvider struct { ChanProvider // contains filtered or unexported fields }
func (*SliceFileProvider) Count ¶
func (p *SliceFileProvider) Count() int
type Task ¶
type Task struct { // FileProgress is measured by file counts Progress // Convertors are used to convert PDF to images Convertors []*Convertor // Entries is the channel of conversion progress entry // the format will be ["currentPage" "lastPage" "filename" "workerId"] Entries chan []string // contains filtered or unexported fields }
func (*Task) Errors ¶
func (t *Task) Errors() (errs []*ConversionError)
func (*Task) Wait ¶
func (t *Task) Wait()
Wait hijacks the EntryChan and wait for all the workers finish
func (*Task) WaitAndCollect ¶
WaitAndCollect acts like Wait() but collects all the entries into a slice. A empty array is returned if there is no entry received.
type WrongArgumentError ¶
type WrongArgumentError struct {
// contains filtered or unexported fields
}
func (*WrongArgumentError) Error ¶
func (e *WrongArgumentError) Error() string