pdf

package module
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 10 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pdf package

GoDev

The pdf package provides functionality for reading and writing images from PDF files.

Documentation

Index

Constants

View Source
const DefaultQuality = 75

DefaultQuality is the default quality encoding parameter.

Variables

This section is empty.

Functions

func Append

func Append(rs io.ReadSeeker, w io.Writer, imgs []io.Reader) error

Append appends images to w.

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode decodes a PDF file from r and returns first image as image.Image.

func DecodeAll

func DecodeAll(r io.Reader) ([]image.Image, error)

DecodeAll decodes a PDF file from r and returns all images as image.Image.

func DecodeConfig

func DecodeConfig(r io.Reader) (cfg image.Config, err error)

DecodeConfig returns the color model and dimensions of a PDF first image without decoding the entire image.

func Encode

func Encode(w io.Writer, imgs []image.Image, o *Options) error

Encode writes images to w.

func EncodeFile

func EncodeFile(outFile string, imgFiles []string, o *Options) (err error)

EncodeFile appends images to outFile which will be created if necessary.

func EncodeReader

func EncodeReader(w io.Writer, r []io.Reader) error

EncodeReader writes r to w.

Types

type Options

type Options struct {
	Quality int
}

Options are the encoding parameters. Quality ranges from 1 to 100 inclusive, higher is better.

type Reader

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

Reader struct represents a PDF reader that holds a *model.Context.

func NewReader

func NewReader(rs io.ReadSeeker, conf *model.Configuration) (*Reader, error)

NewReader creates a new Reader from an io.ReadSeeker and a *model.Configuration. If conf is nil, model.NewDefaultConfiguration() will be used.

func (*Reader) Extract

func (r *Reader) Extract() ([]model.Image, error)

Extract extracts all images from the current page as []model.Image.

func (*Reader) ExtractImages

func (r *Reader) ExtractImages() ([]image.Image, error)

ExtractImages extracts all images from the current page as []image.Image.

func (*Reader) ExtractPage

func (r *Reader) ExtractPage(pageNr int) (imgs []model.Image, err error)

ExtractPage extracts all images from the specified page as []model.Image.

func (*Reader) ExtractPageImages

func (r *Reader) ExtractPageImages(pageNr int) (imgs []image.Image, err error)

ExtractPageImages extracts all images from the specified page as []image.Image.

func (*Reader) Next

func (r *Reader) Next() bool

Next advances the Reader to the next page and returns true if there are more pages to read.

func (*Reader) PageCount

func (r *Reader) PageCount() int

PageCount returns the number of pages in the PDF.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址