Documentation
¶
Index ¶
- Constants
- Variables
- func AddPaperStandard(name string, widthMm float64, heightMm float64)
- func GetPageSizeToleranceMM() float64
- func RemovePaperStandard(name string)
- func SetPageSizeToleranceMM(tolerance float64)
- type QuoteConfig
- type QuoteResult
- type Quoter
- type SizePricesByColor
- type SizeQuantitiesByColor
- type StandardSize
Constants ¶
const (
PS_TO_MM_CONVERSION_FACTOR = 0.352778
)
Variables ¶
var ( // PAGE_SIZE_TOLERANCE_MM is the tolerance for page size matching. // Defaults to 6.0 mm. PAGE_SIZE_TOLERANCE_MM = 6.0 )
Functions ¶
func AddPaperStandard ¶
AddPaperStandard adds a new paper size to the list.
func GetPageSizeToleranceMM ¶ added in v0.1.3
func GetPageSizeToleranceMM() float64
GetPageSizeToleranceMM returns the current tolerance for page size matching.
func RemovePaperStandard ¶
func RemovePaperStandard(name string)
RemovePaperStandard removes a paper size from the list.
func SetPageSizeToleranceMM ¶ added in v0.1.3
func SetPageSizeToleranceMM(tolerance float64)
SetPageSizeToleranceMM sets the tolerance for page size matching. Defaults to 6.0 mm.
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
ColorThreshold float64 // Minimum percentage of color pixels to consider the page "Color" (not B&W) (e.g., 0.05 for 5%)
FullColorThreshold float64 // Percentage of color pixels to consider the page "Full color" (e.g., 0.25 for 25%)
FullBlackThreshold float64 // Minimum percentage of non-white pixels to classify a B&W page as "Full black" (high ink coverage) (e.g., 0.3 for 30%)
IsDoubleSided bool // When true, two printed sides share one physical sheet
BWQuote bool // When true, the entire document is treated as black-and-white: pages that would be classified as "Color" become "BW", and pages that would be "FullColor" become "FullBlack"
}
QuoteConfig holds the price per page type
type QuoteResult ¶
type QuoteResult struct {
Pages map[string]SizeQuantitiesByColor // Key is "A4", "Legal", etc.
IsDoubleSided bool
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). The BWQuote flag is read from the Quoter's Config.
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
type SizePricesByColor struct {
PaperSheet float64
BW float64
FullBlack float64
Color float64
FullColor float64
}
SizePricesByColor holds the price per color category. PaperSheet is the cost of one physical sheet. BW, FullBlack, Color and FullColor are the costs per printed side.
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.