Documentation
¶
Index ¶
Constants ¶
const ( PAGE_SIZE_TOLERANCE_MM = 6 PS_TO_MM_CONVERSION_FACTOR = 0.352778 )
Variables ¶
This section is empty.
Functions ¶
func AddPaperStandard ¶
AddPaperStandard adds a new paper size to the list.
func RemovePaperStandard ¶
func RemovePaperStandard(name string)
RemovePaperStandard removes a paper size from the list.
Types ¶
type QuoteConfig ¶
type QuoteConfig struct {
PricesPerPage map[string]SizePricesByColor // Key is "A4", "Legal", etc. Make sure to add a "Fallback" key for unknown sizes; otherwise, unknown sizes will be unsupported and will return an error
FullColorThreshold float64 // Percentage of color pixels to consider the page "Full color" (e.g., 0.25 for 25%)
}
QuoteConfig holds the price per page type
type QuoteResult ¶
type QuoteResult struct {
Pages map[string]SizeQuantitiesByColor // Key is "A4", "Legal", etc.
TotalPrice float64
}
QuoteResult holds the result of the quote
type Quoter ¶
type Quoter struct {
Config QuoteConfig
}
Quoter holds the configuration and provides methods to calculate the quote
func NewQuoter ¶
func NewQuoter(config QuoteConfig) *Quoter
NewQuoter creates a new Quoter with the given configuration
func (*Quoter) Estimate ¶
func (q *Quoter) Estimate(r io.ReadSeeker) (QuoteResult, error)
Estimate receives any Go file-like object or bytes and returns the quote. It is equivalent to EstimateWithWorkers(r, 1).
func (*Quoter) EstimateWithWorkers ¶ added in v0.1.1
func (q *Quoter) EstimateWithWorkers(r io.ReadSeeker, workers int) (QuoteResult, error)
EstimateWithWorkers is like Estimate but renders pages concurrently using the given number of workers. Use workers > 1 to speed up large documents.
func (*Quoter) IdentifyPageSize ¶
func (q *Quoter) IdentifyPageSize(wPts float64, hPts float64) StandardSize
IdentifyPageSize receives the width and height in points and returns the closest standard size. If no standard size is found, returns a fallback size.
type SizePricesByColor ¶ added in v0.1.1
SizePricesByColor holds the price per color category
type SizeQuantitiesByColor ¶ added in v0.1.1
SizeQuantitiesByColor holds the quantity per color category
type StandardSize ¶
StandardSize represents a standard paper size.
func GetPaperStandard ¶
func GetPaperStandard(name string) StandardSize
GetPaperStandard returns the paper size with the given name.
func GetPaperStandards ¶
func GetPaperStandards() []StandardSize
GetPaperStandards returns the list of standard paper sizes.