HomeUniDoc
...

Package optimize

Overview ▾

Index ▾

type Chain
    func New(options Options) *Chain
    func (c *Chain) Append(optimizers ...model.Optimizer)
    func (c *Chain) GetOptimizers() []model.Optimizer
    func (c *Chain) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CleanContentstream
    func (c *CleanContentstream) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CleanFonts
    func (c *CleanFonts) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CleanUnusedResources
    func (cleaner *CleanUnusedResources) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CombineDuplicateDirectObjects
    func (dup *CombineDuplicateDirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CombineDuplicateStreams
    func (dup *CombineDuplicateStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CombineIdenticalIndirectObjects
    func (c *CombineIdenticalIndirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type CompressStreams
    func (c *CompressStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type Image
    func (i *Image) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type ImagePPI
    func (i *ImagePPI) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type ObjectStreams
    func (o *ObjectStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)
type Options

Package files

chain.go clean_contentstream.go clean_fonts.go clean_unused_resources.go combine_duplicate_direct_objects.go combine_duplicate_streams.go combine_identical_indirect_objects.go compress_streams.go image.go image_ppi.go object_streams.go optimizer.go options.go utils.go

type Chain

Chain allows to use sequence of optimizers. It implements interface model.Optimizer.

type Chain struct {
    // contains filtered or unexported fields
}

func New

func New(options Options) *Chain

New creates a optimizers chain from options.

func (*Chain) Append

func (c *Chain) Append(optimizers ...model.Optimizer)

Append appends optimizers to the chain.

func (*Chain) GetOptimizers

func (c *Chain) GetOptimizers() []model.Optimizer

GetOptimizers gets the list of optimizers in chain `c`.

func (*Chain) Optimize

func (c *Chain) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CleanContentstream

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 (*CleanContentstream) Optimize

func (c *CleanContentstream) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CleanFonts

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 (*CleanFonts) Optimize

func (c *CleanFonts) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CleanUnusedResources

CleanUnusedResources represents an optimizer used to clean unused resources.

type CleanUnusedResources struct {
}

func (*CleanUnusedResources) Optimize

func (cleaner *CleanUnusedResources) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize implements Optimizer interface.

type CombineDuplicateDirectObjects

CombineDuplicateDirectObjects combines duplicated direct objects by its data hash. It implements interface model.Optimizer.

type CombineDuplicateDirectObjects struct {
}

func (*CombineDuplicateDirectObjects) Optimize

func (dup *CombineDuplicateDirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CombineDuplicateStreams

CombineDuplicateStreams combines duplicated streams by its data hash. It implements interface model.Optimizer.

type CombineDuplicateStreams struct {
}

func (*CombineDuplicateStreams) Optimize

func (dup *CombineDuplicateStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CombineIdenticalIndirectObjects

CombineIdenticalIndirectObjects combines identical indirect objects. It implements interface model.Optimizer.

type CombineIdenticalIndirectObjects struct {
}

func (*CombineIdenticalIndirectObjects) Optimize

func (c *CombineIdenticalIndirectObjects) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type CompressStreams

CompressStreams compresses uncompressed streams. It implements interface model.Optimizer.

type CompressStreams struct {
}

func (*CompressStreams) Optimize

func (c *CompressStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type Image

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 (*Image) Optimize

func (i *Image) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type ImagePPI

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 (*ImagePPI) Optimize

func (i *ImagePPI) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type ObjectStreams

ObjectStreams groups PDF objects to object streams. It implements interface model.Optimizer.

type ObjectStreams struct {
}

func (*ObjectStreams) Optimize

func (o *ObjectStreams) Optimize(objects []core.PdfObject) (optimizedObjects []core.PdfObject, err error)

Optimize optimizes PDF objects to decrease PDF size.

type Options

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
    CleanUnusedResources            bool
}

Subdirectories

Name Synopsis
..
tests Package tests provides integration tests for the UniPDF optimizer.