Chain allows to use sequence of optimizers. It implements interface model.Optimizer.
type Chain struct {
// contains filtered or unexported fields
}
func New(options Options) *Chain
New creates a optimizers chain from options.
func (c *Chain) Append(optimizers ...model.Optimizer)
Append appends optimizers to the chain.
func (c *Chain) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CleanContentstream cleans up redundant operands in content streams, including Page and XObject Form contents. This process includes: 1. Marked content operators are removed. 2. Some operands are simplified (shorter form). TODO: Add more reduction methods and improving the methods for identifying unnecessary operands.
type CleanContentstream struct { }
func (c *CleanContentstream) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CleanFonts cleans up embedded fonts, reducing font sizes.
type CleanFonts struct { // Subset embedded fonts if encountered (if true). // Otherwise attempts to reduce the font program. Subset bool }
func (c *CleanFonts) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CombineDuplicateDirectObjects combines duplicated direct objects by its data hash. It implements interface model.Optimizer.
type CombineDuplicateDirectObjects struct { }
func (dup *CombineDuplicateDirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CombineDuplicateStreams combines duplicated streams by its data hash. It implements interface model.Optimizer.
type CombineDuplicateStreams struct { }
func (dup *CombineDuplicateStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CombineIdenticalIndirectObjects combines identical indirect objects. It implements interface model.Optimizer.
type CombineIdenticalIndirectObjects struct { }
func (c *CombineIdenticalIndirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
CompressStreams compresses uncompressed streams. It implements interface model.Optimizer.
type CompressStreams struct { }
func (c *CompressStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
Image optimizes images by rewrite images into JPEG format with quality equals to ImageQuality. TODO(a5i): Add support for inline images. It implements interface model.Optimizer.
type Image struct { ImageQuality int }
func (i *Image) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
ImagePPI optimizes images by scaling images such that the PPI (pixels per inch) is never higher than ImageUpperPPI. TODO(a5i): Add support for inline images. It implements interface model.Optimizer.
type ImagePPI struct { ImageUpperPPI float64 }
func (i *ImagePPI) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
ObjectStreams groups PDF objects to object streams. It implements interface model.Optimizer.
type ObjectStreams struct { }
func (o *ObjectStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
Optimize optimizes PDF objects to decrease PDF size.
Options describes PDF optimization parameters.
type Options struct { CombineDuplicateStreams bool CombineDuplicateDirectObjects bool ImageUpperPPI float64 ImageQuality int UseObjectStreams bool CombineIdenticalIndirectObjects bool CompressStreams bool CleanFonts bool SubsetFonts bool CleanContentstream bool }