unidoc: github.com/unidoc/unidoc/pdf/model Index | Files | Directories

package model

import "github.com/unidoc/unidoc/pdf/model"

The model package provides a convenient interface for reading, writing and working with PDF files. The package includes many high level PDF data models which can be used to access information or modifications. It is based on the core package which handles core functionality such as file i/o, parsing and handling of primitive PDF objects.

As an example of the interface, the following snippet can read the PDF and output the number of pages:

f, err := os.Open(inputPath)
	if err != nil {
	return nil, err
}
defer f.Close()
pdfReader, err := unipdf.NewPdfReader(f)
if err != nil {
	fmt.Printf("Failed to read PDF file: %v\n", err)
	os.Exit(1)
}
numPages, err := pdfReader.GetNumPages()
if err != nil {
	fmt.Printf("Failed to get number of pages: %v\n", err)
	os.Exit(1)
}
fmt.Printf("The PDF file has %d pages\n", numPages)

For more examples, see the unidoc-examples repository on GitHub: https://github.com/unidoc/unidoc-examples

Index

Package Files

annotations.go colorspace.go const.go doc.go font.go forms.go functions.go image.go model.go outlines.go page.go pattern.go reader.go resources.go shading.go structures.go utils.go writer.go xobject.go

Constants

const (
    // RC4_128bit uses RC4 encryption (128 bit)
    RC4_128bit = EncryptionAlgorithm(iota)
    // AES_128bit uses AES encryption (128 bit, PDF 1.6)
    AES_128bit
    // AES_256bit uses AES encryption (256 bit, PDF 2.0)
    AES_256bit
)

Variables

var (
    ErrRequiredAttributeMissing = errors.New("Required attribute missing")
    ErrInvalidAttribute         = errors.New("Invalid attribute")
    ErrTypeError                = errors.New("Type check error")

    // ErrRangeError typically occurs when an input parameter is out of range or has invalid value.
    ErrRangeError = errors.New("Range check error")
)
var ErrTypeCheck = errors.New("Type check error")

func SetImageHandler Uses

func SetImageHandler(imgHandling ImageHandler)

func SetPdfCreator Uses

func SetPdfCreator(creator string)

type AlphaMapFunc Uses

type AlphaMapFunc func(alpha byte) byte

Threshold alpha channel. Set all alpha values below threshold to transparent.

type BorderEffect Uses

type BorderEffect int

Border effect

const (
    BorderEffectNoEffect BorderEffect = iota
    BorderEffectCloudy   BorderEffect = iota
)

type BorderStyle Uses

type BorderStyle int
const (
    BorderStyleSolid     BorderStyle = iota
    BorderStyleDashed    BorderStyle = iota
    BorderStyleBeveled   BorderStyle = iota
    BorderStyleInset     BorderStyle = iota
    BorderStyleUnderline BorderStyle = iota
)

func (*BorderStyle) GetPdfName Uses

func (this *BorderStyle) GetPdfName() string

type DefaultImageHandler Uses

type DefaultImageHandler struct{}

func (DefaultImageHandler) Compress Uses

func (this DefaultImageHandler) Compress(input *Image, quality int64) (*Image, error)

To be implemented. Should be able to compress in terms of JPEG quality parameter, and DPI threshold (need to know bounding area dimensions).

func (DefaultImageHandler) NewImageFromGoImage Uses

func (this DefaultImageHandler) NewImageFromGoImage(goimg goimage.Image) (*Image, error)

Create a unidoc Image from a golang Image.

func (DefaultImageHandler) Read Uses

func (this DefaultImageHandler) Read(reader io.Reader) (*Image, error)

Reads an image and loads into a new Image object with an RGB colormap and 8 bits per component.

type EncryptOptions Uses

type EncryptOptions struct {
    Permissions AccessPermissions
    Algorithm   EncryptionAlgorithm
}

type EncryptionAlgorithm Uses

type EncryptionAlgorithm int

EncryptionAlgorithm is used in EncryptOptions to change the default algorithm used to encrypt the document.

type Image Uses

type Image struct {
    Width            int64  // The width of the image in samples
    Height           int64  // The height of the image in samples
    BitsPerComponent int64  // The number of bits per color component
    ColorComponents  int    // Color components per pixel
    Data             []byte // Image data stored as bytes.
    // contains filtered or unexported fields
}

Basic representation of an image. The colorspace is not specified, but must be known when handling the image.

func (Image) AlphaMap Uses

func (this Image) AlphaMap(mapFunc AlphaMapFunc)

Allow mapping of alpha data for transformations. Can allow custom filtering of alpha data etc.

func (*Image) GetSamples Uses

func (this *Image) GetSamples() []uint32

Convert the raw byte slice into samples which are stored in a uint32 bit array. Each sample is represented by BitsPerComponent consecutive bits in the raw data.

func (*Image) Resample Uses

func (this *Image) Resample(targetBitsPerComponent int64)

Resample resamples the image data converting from current BitsPerComponent to a target BitsPerComponent value. Sets the image's BitsPerComponent to the target value following resampling.

For example, converting an 8-bit RGB image to 1-bit grayscale (common for scanned images):

// Convert RGB image to grayscale.
rgbColorSpace := pdf.NewPdfColorspaceDeviceRGB()
grayImage, err := rgbColorSpace.ImageToGray(rgbImage)
if err != nil {
  return err
}
// Resample as 1 bit.
grayImage.Resample(1)

func (*Image) SetSamples Uses

func (this *Image) SetSamples(samples []uint32)

Convert samples to byte-data.

func (*Image) ToGoImage Uses

func (this *Image) ToGoImage() (goimage.Image, error)

Converts the unidoc Image to a golang Image structure.

type ImageHandler Uses

type ImageHandler interface {
    // Read any image type and load into a new Image object.
    Read(r io.Reader) (*Image, error)

    // Load a unidoc Image from a standard Go image structure.
    NewImageFromGoImage(goimg goimage.Image) (*Image, error)

    // Compress an image.
    Compress(input *Image, quality int64) (*Image, error)
}

The ImageHandler interface implements common image loading and processing tasks. Implementing as an interface allows for the possibility to use non-standard libraries for faster loading and processing of images.

var ImageHandling ImageHandler = DefaultImageHandler{}

type ModelManager Uses

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

The model manager is used to cache Primitive <-> Model mappings where needed. In many cases only Model -> Primitive mapping is needed and only a reference to the Primitive is stored in the Model. In some cases, the Model needs to be found from the Primitive, and that is where the ModelManager can be used (in both directions).

Note that it is not always used, the Primitive <-> Model mapping needs to be registered for each time it is used. Thus, it is only used for special cases, commonly where the same object is used by two higher level objects. (Example PDF Widgets owned by both Page Annotations, and the interactive form - AcroForm).

func NewModelManager Uses

func NewModelManager() *ModelManager

func (*ModelManager) GetModelFromPrimitive Uses

func (this *ModelManager) GetModelFromPrimitive(primitive PdfObject) PdfModel

func (*ModelManager) GetPrimitiveFromModel Uses

func (this *ModelManager) GetPrimitiveFromModel(model PdfModel) PdfObject

func (*ModelManager) Register Uses

func (this *ModelManager) Register(primitive PdfObject, model PdfModel)

Register (cache) a model to primitive relationship.

type PdfAcroForm Uses

type PdfAcroForm struct {
    Fields          *[]*PdfField
    NeedAppearances *PdfObjectBool
    SigFlags        *PdfObjectInteger
    CO              *PdfObjectArray
    DR              *PdfPageResources
    DA              *PdfObjectString
    Q               *PdfObjectInteger
    XFA             PdfObject
    // contains filtered or unexported fields
}

High level manipulation of forms (AcroForm).

func NewPdfAcroForm Uses

func NewPdfAcroForm() *PdfAcroForm

func (*PdfAcroForm) GetContainingPdfObject Uses

func (this *PdfAcroForm) GetContainingPdfObject() PdfObject

func (*PdfAcroForm) ToPdfObject Uses

func (this *PdfAcroForm) ToPdfObject() PdfObject

type PdfAnnotation Uses

type PdfAnnotation struct {
    Rect         PdfObject
    Contents     PdfObject
    P            PdfObject // Reference to page object.
    NM           PdfObject
    M            PdfObject
    F            PdfObject
    AP           PdfObject
    AS           PdfObject
    Border       PdfObject
    C            PdfObject
    StructParent PdfObject
    OC           PdfObject
    // contains filtered or unexported fields
}

PDFAnnotation contains common attributes of an annotation. The context object contains the subannotation, which can be a markup annotation or other types.

func NewPdfAnnotation Uses

func NewPdfAnnotation() *PdfAnnotation

Construct a new PDF annotation model and initializes the underlying PDF primitive.

func (*PdfAnnotation) GetContainingPdfObject Uses

func (this *PdfAnnotation) GetContainingPdfObject() PdfObject

func (*PdfAnnotation) GetContext Uses

func (this *PdfAnnotation) GetContext() PdfModel

Context in this case is a reference to the subannotation.

func (*PdfAnnotation) SetContext Uses

func (this *PdfAnnotation) SetContext(ctx PdfModel)

Set the sub annotation (context).

func (*PdfAnnotation) String Uses

func (this *PdfAnnotation) String() string

func (*PdfAnnotation) ToPdfObject Uses

func (this *PdfAnnotation) ToPdfObject() PdfObject

Note: Call the sub-annotation's ToPdfObject to set both the generic and non-generic information. TODO/FIXME: Consider doing it here instead.

type PdfAnnotation3D Uses

type PdfAnnotation3D struct {
    *PdfAnnotation
    T3DD PdfObject
    T3DV PdfObject
    T3DA PdfObject
    T3DI PdfObject
    T3DB PdfObject
}

Subtype: 3D

func NewPdfAnnotation3D Uses

func NewPdfAnnotation3D() *PdfAnnotation3D

Create a new 3d annotation.

func (*PdfAnnotation3D) ToPdfObject Uses

func (this *PdfAnnotation3D) ToPdfObject() PdfObject

type PdfAnnotationCaret Uses

type PdfAnnotationCaret struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    RD  PdfObject
    Sy  PdfObject
}

Subtype: Caret

func NewPdfAnnotationCaret Uses

func NewPdfAnnotationCaret() *PdfAnnotationCaret

Create a new caret annotation.

func (*PdfAnnotationCaret) ToPdfObject Uses

func (this *PdfAnnotationCaret) ToPdfObject() PdfObject

type PdfAnnotationCircle Uses

type PdfAnnotationCircle struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    BS  PdfObject
    IC  PdfObject
    BE  PdfObject
    RD  PdfObject
}

Subtype: Circle

func NewPdfAnnotationCircle Uses

func NewPdfAnnotationCircle() *PdfAnnotationCircle

Create a new circle annotation.

func (*PdfAnnotationCircle) ToPdfObject Uses

func (this *PdfAnnotationCircle) ToPdfObject() PdfObject

type PdfAnnotationFileAttachment Uses

type PdfAnnotationFileAttachment struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    FS   PdfObject
    Name PdfObject
}

Subtype: FileAttachment

func NewPdfAnnotationFileAttachment Uses

func NewPdfAnnotationFileAttachment() *PdfAnnotationFileAttachment

Create a new file attachment annotation.

func (*PdfAnnotationFileAttachment) ToPdfObject Uses

func (this *PdfAnnotationFileAttachment) ToPdfObject() PdfObject

type PdfAnnotationFreeText Uses

type PdfAnnotationFreeText struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    DA  PdfObject
    Q   PdfObject
    RC  PdfObject
    DS  PdfObject
    CL  PdfObject
    IT  PdfObject
    BE  PdfObject
    RD  PdfObject
    BS  PdfObject
    LE  PdfObject
}

Subtype: FreeText

func NewPdfAnnotationFreeText Uses

func NewPdfAnnotationFreeText() *PdfAnnotationFreeText

Create a new free text annotation.

func (*PdfAnnotationFreeText) ToPdfObject Uses

func (this *PdfAnnotationFreeText) ToPdfObject() PdfObject

type PdfAnnotationHighlight Uses

type PdfAnnotationHighlight struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    QuadPoints PdfObject
}

Subtype: Highlight

func NewPdfAnnotationHighlight Uses

func NewPdfAnnotationHighlight() *PdfAnnotationHighlight

Create a new text highlight annotation.

func (*PdfAnnotationHighlight) ToPdfObject Uses

func (this *PdfAnnotationHighlight) ToPdfObject() PdfObject

type PdfAnnotationInk Uses

type PdfAnnotationInk struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    InkList PdfObject
    BS      PdfObject
}

Subtype: Ink

func NewPdfAnnotationInk Uses

func NewPdfAnnotationInk() *PdfAnnotationInk

Create a new ink annotation.

func (*PdfAnnotationInk) ToPdfObject Uses

func (this *PdfAnnotationInk) ToPdfObject() PdfObject

type PdfAnnotationLine Uses

type PdfAnnotationLine struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    L       PdfObject
    BS      PdfObject
    LE      PdfObject
    IC      PdfObject
    LL      PdfObject
    LLE     PdfObject
    Cap     PdfObject
    IT      PdfObject
    LLO     PdfObject
    CP      PdfObject
    Measure PdfObject
    CO      PdfObject
}

Subtype: Line

func NewPdfAnnotationLine Uses

func NewPdfAnnotationLine() *PdfAnnotationLine

Create a new line annotation.

func (*PdfAnnotationLine) ToPdfObject Uses

func (this *PdfAnnotationLine) ToPdfObject() PdfObject
type PdfAnnotationLink struct {
    *PdfAnnotation
    A          PdfObject
    Dest       PdfObject
    H          PdfObject
    PA         PdfObject
    QuadPoints PdfObject
    BS         PdfObject
}

Subtype: Link

func NewPdfAnnotationLink() *PdfAnnotationLink

Create a new link annotation.

func (*PdfAnnotationLink) ToPdfObject Uses

func (this *PdfAnnotationLink) ToPdfObject() PdfObject

type PdfAnnotationMarkup Uses

type PdfAnnotationMarkup struct {
    T            PdfObject
    Popup        *PdfAnnotationPopup
    CA           PdfObject
    RC           PdfObject
    CreationDate PdfObject
    IRT          PdfObject
    Subj         PdfObject
    RT           PdfObject
    IT           PdfObject
    ExData       PdfObject
}

Additional elements for mark-up annotations.

type PdfAnnotationMovie Uses

type PdfAnnotationMovie struct {
    *PdfAnnotation
    T     PdfObject
    Movie PdfObject
    A     PdfObject
}

Subtype: Movie

func NewPdfAnnotationMovie Uses

func NewPdfAnnotationMovie() *PdfAnnotationMovie

Create a new movie annotation.

func (*PdfAnnotationMovie) ToPdfObject Uses

func (this *PdfAnnotationMovie) ToPdfObject() PdfObject

type PdfAnnotationPolyLine Uses

type PdfAnnotationPolyLine struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    Vertices PdfObject
    LE       PdfObject
    BS       PdfObject
    IC       PdfObject
    BE       PdfObject
    IT       PdfObject
    Measure  PdfObject
}

Subtype: PolyLine

func NewPdfAnnotationPolyLine Uses

func NewPdfAnnotationPolyLine() *PdfAnnotationPolyLine

Create a new polyline annotation.

func (*PdfAnnotationPolyLine) ToPdfObject Uses

func (this *PdfAnnotationPolyLine) ToPdfObject() PdfObject

type PdfAnnotationPolygon Uses

type PdfAnnotationPolygon struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    Vertices PdfObject
    LE       PdfObject
    BS       PdfObject
    IC       PdfObject
    BE       PdfObject
    IT       PdfObject
    Measure  PdfObject
}

Subtype: Polygon

func NewPdfAnnotationPolygon Uses

func NewPdfAnnotationPolygon() *PdfAnnotationPolygon

Create a new polygon annotation.

func (*PdfAnnotationPolygon) ToPdfObject Uses

func (this *PdfAnnotationPolygon) ToPdfObject() PdfObject

type PdfAnnotationPopup Uses

type PdfAnnotationPopup struct {
    *PdfAnnotation
    Parent PdfObject
    Open   PdfObject
}

Subtype: Popup

func NewPdfAnnotationPopup Uses

func NewPdfAnnotationPopup() *PdfAnnotationPopup

Create a new popup annotation.

func (*PdfAnnotationPopup) ToPdfObject Uses

func (this *PdfAnnotationPopup) ToPdfObject() PdfObject

type PdfAnnotationPrinterMark Uses

type PdfAnnotationPrinterMark struct {
    *PdfAnnotation
    MN  PdfObject
}

Subtype: PrinterMark

func NewPdfAnnotationPrinterMark Uses

func NewPdfAnnotationPrinterMark() *PdfAnnotationPrinterMark

Create a new printermark annotation.

func (*PdfAnnotationPrinterMark) ToPdfObject Uses

func (this *PdfAnnotationPrinterMark) ToPdfObject() PdfObject

type PdfAnnotationProjection Uses

type PdfAnnotationProjection struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
}

Subtype: Projection

func NewPdfAnnotationProjection Uses

func NewPdfAnnotationProjection() *PdfAnnotationProjection

Create a new projection annotation.

func (*PdfAnnotationProjection) ToPdfObject Uses

func (this *PdfAnnotationProjection) ToPdfObject() PdfObject

type PdfAnnotationRedact Uses

type PdfAnnotationRedact struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    QuadPoints  PdfObject
    IC          PdfObject
    RO          PdfObject
    OverlayText PdfObject
    Repeat      PdfObject
    DA          PdfObject
    Q           PdfObject
}

Subtype: Redact

func NewPdfAnnotationRedact Uses

func NewPdfAnnotationRedact() *PdfAnnotationRedact

Create a new redact annotation.

func (*PdfAnnotationRedact) ToPdfObject Uses

func (this *PdfAnnotationRedact) ToPdfObject() PdfObject

type PdfAnnotationRichMedia Uses

type PdfAnnotationRichMedia struct {
    *PdfAnnotation
    RichMediaSettings PdfObject
    RichMediaContent  PdfObject
}

Subtype: Rich Media

func NewPdfAnnotationRichMedia Uses

func NewPdfAnnotationRichMedia() *PdfAnnotationRichMedia

Create a new rich media annotation.

func (*PdfAnnotationRichMedia) ToPdfObject Uses

func (this *PdfAnnotationRichMedia) ToPdfObject() PdfObject

type PdfAnnotationScreen Uses

type PdfAnnotationScreen struct {
    *PdfAnnotation
    T   PdfObject
    MK  PdfObject
    A   PdfObject
    AA  PdfObject
}

Subtype: Screen

func NewPdfAnnotationScreen Uses

func NewPdfAnnotationScreen() *PdfAnnotationScreen

Create a new screen annotation.

func (*PdfAnnotationScreen) ToPdfObject Uses

func (this *PdfAnnotationScreen) ToPdfObject() PdfObject

type PdfAnnotationSound Uses

type PdfAnnotationSound struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    Sound PdfObject
    Name  PdfObject
}

Subtype: Sound

func NewPdfAnnotationSound Uses

func NewPdfAnnotationSound() *PdfAnnotationSound

Create a new sound annotation.

func (*PdfAnnotationSound) ToPdfObject Uses

func (this *PdfAnnotationSound) ToPdfObject() PdfObject

type PdfAnnotationSquare Uses

type PdfAnnotationSquare struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    BS  PdfObject
    IC  PdfObject
    BE  PdfObject
    RD  PdfObject
}

Subtype: Square

func NewPdfAnnotationSquare Uses

func NewPdfAnnotationSquare() *PdfAnnotationSquare

Create a new square annotation.

func (*PdfAnnotationSquare) ToPdfObject Uses

func (this *PdfAnnotationSquare) ToPdfObject() PdfObject

type PdfAnnotationSquiggly Uses

type PdfAnnotationSquiggly struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    QuadPoints PdfObject
}

Subtype: Squiggly

func NewPdfAnnotationSquiggly Uses

func NewPdfAnnotationSquiggly() *PdfAnnotationSquiggly

Create a new text squiggly annotation.

func (*PdfAnnotationSquiggly) ToPdfObject Uses

func (this *PdfAnnotationSquiggly) ToPdfObject() PdfObject

type PdfAnnotationStamp Uses

type PdfAnnotationStamp struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    Name PdfObject
}

Subtype: Stamp

func NewPdfAnnotationStamp Uses

func NewPdfAnnotationStamp() *PdfAnnotationStamp

Create a new stamp annotation.

func (*PdfAnnotationStamp) ToPdfObject Uses

func (this *PdfAnnotationStamp) ToPdfObject() PdfObject

type PdfAnnotationStrikeOut Uses

type PdfAnnotationStrikeOut struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    QuadPoints PdfObject
}

Subtype: StrikeOut

func NewPdfAnnotationStrikeOut Uses

func NewPdfAnnotationStrikeOut() *PdfAnnotationStrikeOut

Create a new text strikeout annotation.

func (*PdfAnnotationStrikeOut) ToPdfObject Uses

func (this *PdfAnnotationStrikeOut) ToPdfObject() PdfObject

type PdfAnnotationText Uses

type PdfAnnotationText struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    Open       PdfObject
    Name       PdfObject
    State      PdfObject
    StateModel PdfObject
}

Subtype: Text

func NewPdfAnnotationText Uses

func NewPdfAnnotationText() *PdfAnnotationText

Create a new text annotation.

func (*PdfAnnotationText) ToPdfObject Uses

func (this *PdfAnnotationText) ToPdfObject() PdfObject

type PdfAnnotationTrapNet Uses

type PdfAnnotationTrapNet struct {
    *PdfAnnotation
}

Subtype: TrapNet

func NewPdfAnnotationTrapNet Uses

func NewPdfAnnotationTrapNet() *PdfAnnotationTrapNet

Create a new trapnet annotation.

func (*PdfAnnotationTrapNet) ToPdfObject Uses

func (this *PdfAnnotationTrapNet) ToPdfObject() PdfObject

type PdfAnnotationUnderline Uses

type PdfAnnotationUnderline struct {
    *PdfAnnotation
    *PdfAnnotationMarkup
    QuadPoints PdfObject
}

Subtype: Underline

func NewPdfAnnotationUnderline Uses

func NewPdfAnnotationUnderline() *PdfAnnotationUnderline

Create a new text underline annotation.

func (*PdfAnnotationUnderline) ToPdfObject Uses

func (this *PdfAnnotationUnderline) ToPdfObject() PdfObject

type PdfAnnotationWatermark Uses

type PdfAnnotationWatermark struct {
    *PdfAnnotation
    FixedPrint PdfObject
}

Subtype: Watermark

func NewPdfAnnotationWatermark Uses

func NewPdfAnnotationWatermark() *PdfAnnotationWatermark

Create a new watermark annotation.

func (*PdfAnnotationWatermark) ToPdfObject Uses

func (this *PdfAnnotationWatermark) ToPdfObject() PdfObject

type PdfAnnotationWidget Uses

type PdfAnnotationWidget struct {
    *PdfAnnotation
    H      PdfObject
    MK     PdfObject
    A      PdfObject
    AA     PdfObject
    BS     PdfObject
    Parent PdfObject
}

Subtype: Widget

func NewPdfAnnotationWidget Uses

func NewPdfAnnotationWidget() *PdfAnnotationWidget

Create a new annotation widget and initializes the underlying primitive.

func (*PdfAnnotationWidget) ToPdfObject Uses

func (this *PdfAnnotationWidget) ToPdfObject() PdfObject

type PdfBorderEffect Uses

type PdfBorderEffect struct {
    S   *BorderEffect // Border effect type
    I   *float64      // Intensity of the effect
}

type PdfBorderStyle Uses

type PdfBorderStyle struct {
    W   *float64     // Border width
    S   *BorderStyle // Border style
    D   *[]int       // Dash array.
    // contains filtered or unexported fields
}

Border style

func NewBorderStyle Uses

func NewBorderStyle() *PdfBorderStyle

func (*PdfBorderStyle) GetBorderWidth Uses

func (this *PdfBorderStyle) GetBorderWidth() float64

func (*PdfBorderStyle) SetBorderWidth Uses

func (this *PdfBorderStyle) SetBorderWidth(width float64)

func (*PdfBorderStyle) ToPdfObject Uses

func (this *PdfBorderStyle) ToPdfObject() PdfObject

type PdfColor Uses

type PdfColor interface {
}

type PdfColorCalGray Uses

type PdfColorCalGray float64

func NewPdfColorCalGray Uses

func NewPdfColorCalGray(grayVal float64) *PdfColorCalGray

func (*PdfColorCalGray) GetNumComponents Uses

func (this *PdfColorCalGray) GetNumComponents() int

func (*PdfColorCalGray) ToInteger Uses

func (this *PdfColorCalGray) ToInteger(bits int) uint32

Convert to an integer format.

func (*PdfColorCalGray) Val Uses

func (this *PdfColorCalGray) Val() float64

type PdfColorCalRGB Uses

type PdfColorCalRGB [3]float64

func NewPdfColorCalRGB Uses

func NewPdfColorCalRGB(a, b, c float64) *PdfColorCalRGB

func (*PdfColorCalRGB) A Uses

func (this *PdfColorCalRGB) A() float64

func (*PdfColorCalRGB) B Uses

func (this *PdfColorCalRGB) B() float64

func (*PdfColorCalRGB) C Uses

func (this *PdfColorCalRGB) C() float64

func (*PdfColorCalRGB) GetNumComponents Uses

func (this *PdfColorCalRGB) GetNumComponents() int

func (*PdfColorCalRGB) ToInteger Uses

func (this *PdfColorCalRGB) ToInteger(bits int) [3]uint32

Convert to an integer format.

type PdfColorDeviceCMYK Uses

type PdfColorDeviceCMYK [4]float64

Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorDeviceCMYK Uses

func NewPdfColorDeviceCMYK(c, m, y, k float64) *PdfColorDeviceCMYK

func (*PdfColorDeviceCMYK) C Uses

func (this *PdfColorDeviceCMYK) C() float64

func (*PdfColorDeviceCMYK) GetNumComponents Uses

func (this *PdfColorDeviceCMYK) GetNumComponents() int

func (*PdfColorDeviceCMYK) K Uses

func (this *PdfColorDeviceCMYK) K() float64

func (*PdfColorDeviceCMYK) M Uses

func (this *PdfColorDeviceCMYK) M() float64

func (*PdfColorDeviceCMYK) ToInteger Uses

func (this *PdfColorDeviceCMYK) ToInteger(bits int) [4]uint32

Convert to an integer format.

func (*PdfColorDeviceCMYK) Y Uses

func (this *PdfColorDeviceCMYK) Y() float64

type PdfColorDeviceGray Uses

type PdfColorDeviceGray float64

A grayscale value shall be represented by a single number in the range 0.0 to 1.0 where 0.0 corresponds to black and 1.0 to white.

func NewPdfColorDeviceGray Uses

func NewPdfColorDeviceGray(grayVal float64) *PdfColorDeviceGray

func (*PdfColorDeviceGray) GetNumComponents Uses

func (this *PdfColorDeviceGray) GetNumComponents() int

func (*PdfColorDeviceGray) ToInteger Uses

func (this *PdfColorDeviceGray) ToInteger(bits int) uint32

Convert to an integer format.

func (*PdfColorDeviceGray) Val Uses

func (this *PdfColorDeviceGray) Val() float64

type PdfColorDeviceRGB Uses

type PdfColorDeviceRGB [3]float64

Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorDeviceRGB Uses

func NewPdfColorDeviceRGB(r, g, b float64) *PdfColorDeviceRGB

func (*PdfColorDeviceRGB) B Uses

func (this *PdfColorDeviceRGB) B() float64

func (*PdfColorDeviceRGB) G Uses

func (this *PdfColorDeviceRGB) G() float64

func (*PdfColorDeviceRGB) GetNumComponents Uses

func (this *PdfColorDeviceRGB) GetNumComponents() int

func (*PdfColorDeviceRGB) R Uses

func (this *PdfColorDeviceRGB) R() float64

func (*PdfColorDeviceRGB) ToGray Uses

func (this *PdfColorDeviceRGB) ToGray() *PdfColorDeviceGray

func (*PdfColorDeviceRGB) ToInteger Uses

func (this *PdfColorDeviceRGB) ToInteger(bits int) [3]uint32

Convert to an integer format.

type PdfColorLab Uses

type PdfColorLab [3]float64

func NewPdfColorLab Uses

func NewPdfColorLab(l, a, b float64) *PdfColorLab

func (*PdfColorLab) A Uses

func (this *PdfColorLab) A() float64

func (*PdfColorLab) B Uses

func (this *PdfColorLab) B() float64

func (*PdfColorLab) GetNumComponents Uses

func (this *PdfColorLab) GetNumComponents() int

func (*PdfColorLab) L Uses

func (this *PdfColorLab) L() float64

func (*PdfColorLab) ToInteger Uses

func (this *PdfColorLab) ToInteger(bits int) [3]uint32

Convert to an integer format.

type PdfColorPattern Uses

type PdfColorPattern struct {
    Color       PdfColor      // Color defined in underlying colorspace.
    PatternName PdfObjectName // Name of the pattern (reference via resource dicts).
}

type PdfColorspace Uses

type PdfColorspace interface {
    String() string
    ImageToRGB(Image) (Image, error)
    ColorToRGB(color PdfColor) (PdfColor, error)
    GetNumComponents() int
    ToPdfObject() PdfObject
    ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)
    ColorFromFloats(vals []float64) (PdfColor, error)

    // Returns the decode array for the CS, i.e. the range of each component.
    DecodeArray() []float64
}

The colorspace defines the data storage format for each color and color representation.

Device based colorspace, specified by name - /DeviceGray - /DeviceRGB - /DeviceCMYK

CIE based colorspace specified by [name, dictionary] - [/CalGray dict] - [/CalRGB dict] - [/Lab dict] - [/ICCBased dict]

Special colorspaces - /Pattern - /Indexed - /Separation - /DeviceN

Work is in progress to support all colorspaces. At the moment ICCBased color spaces fall back to the alternate colorspace which works OK in most cases. For full color support, will need fully featured ICC support.

func NewPdfColorspaceFromPdfObject Uses

func NewPdfColorspaceFromPdfObject(obj PdfObject) (PdfColorspace, error)

NewPdfColorspaceFromPdfObject loads a PdfColorspace from a PdfObject. Returns an error if there is a failure in loading.

type PdfColorspaceCalGray Uses

type PdfColorspaceCalGray struct {
    WhitePoint []float64 // [XW, YW, ZW]: Required
    BlackPoint []float64 // [XB, YB, ZB]
    Gamma      float64
    // contains filtered or unexported fields
}

CalGray color space.

func NewPdfColorspaceCalGray Uses

func NewPdfColorspaceCalGray() *PdfColorspaceCalGray

func (*PdfColorspaceCalGray) ColorFromFloats Uses

func (this *PdfColorspaceCalGray) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceCalGray) ColorFromPdfObjects Uses

func (this *PdfColorspaceCalGray) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceCalGray) ColorToRGB Uses

func (this *PdfColorspaceCalGray) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceCalGray) DecodeArray Uses

func (this *PdfColorspaceCalGray) DecodeArray() []float64

DecodeArray returns the range of color component values in CalGray colorspace.

func (*PdfColorspaceCalGray) GetNumComponents Uses

func (this *PdfColorspaceCalGray) GetNumComponents() int

func (*PdfColorspaceCalGray) ImageToRGB Uses

func (this *PdfColorspaceCalGray) ImageToRGB(img Image) (Image, error)

A, B, C -> X, Y, Z

func (*PdfColorspaceCalGray) String Uses

func (this *PdfColorspaceCalGray) String() string

func (*PdfColorspaceCalGray) ToPdfObject Uses

func (this *PdfColorspaceCalGray) ToPdfObject() PdfObject

Return as PDF object format [name dictionary]

type PdfColorspaceCalRGB Uses

type PdfColorspaceCalRGB struct {
    WhitePoint []float64
    BlackPoint []float64
    Gamma      []float64
    Matrix     []float64 // [XA YA ZA XB YB ZB XC YC ZC] ; default value identity [1 0 0 0 1 0 0 0 1]
    // contains filtered or unexported fields
}

A, B, C components

func NewPdfColorspaceCalRGB Uses

func NewPdfColorspaceCalRGB() *PdfColorspaceCalRGB

require parameters?

func (*PdfColorspaceCalRGB) ColorFromFloats Uses

func (this *PdfColorspaceCalRGB) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceCalRGB) ColorFromPdfObjects Uses

func (this *PdfColorspaceCalRGB) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceCalRGB) ColorToRGB Uses

func (this *PdfColorspaceCalRGB) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceCalRGB) DecodeArray Uses

func (this *PdfColorspaceCalRGB) DecodeArray() []float64

DecodeArray returns the range of color component values in CalRGB colorspace.

func (*PdfColorspaceCalRGB) GetNumComponents Uses

func (this *PdfColorspaceCalRGB) GetNumComponents() int

func (*PdfColorspaceCalRGB) ImageToRGB Uses

func (this *PdfColorspaceCalRGB) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceCalRGB) String Uses

func (this *PdfColorspaceCalRGB) String() string

func (*PdfColorspaceCalRGB) ToPdfObject Uses

func (this *PdfColorspaceCalRGB) ToPdfObject() PdfObject

Return as PDF object format [name dictionary]

type PdfColorspaceDeviceCMYK Uses

type PdfColorspaceDeviceCMYK struct{}

func NewPdfColorspaceDeviceCMYK Uses

func NewPdfColorspaceDeviceCMYK() *PdfColorspaceDeviceCMYK

func (*PdfColorspaceDeviceCMYK) ColorFromFloats Uses

func (this *PdfColorspaceDeviceCMYK) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceDeviceCMYK) ColorFromPdfObjects Uses

func (this *PdfColorspaceDeviceCMYK) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

Get the color from a series of pdf objects (4 for cmyk).

func (*PdfColorspaceDeviceCMYK) ColorToRGB Uses

func (this *PdfColorspaceDeviceCMYK) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceDeviceCMYK) DecodeArray Uses

func (this *PdfColorspaceDeviceCMYK) DecodeArray() []float64

DecodeArray returns the range of color component values in DeviceCMYK colorspace.

func (*PdfColorspaceDeviceCMYK) GetNumComponents Uses

func (this *PdfColorspaceDeviceCMYK) GetNumComponents() int

func (*PdfColorspaceDeviceCMYK) ImageToRGB Uses

func (this *PdfColorspaceDeviceCMYK) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceDeviceCMYK) String Uses

func (this *PdfColorspaceDeviceCMYK) String() string

func (*PdfColorspaceDeviceCMYK) ToPdfObject Uses

func (this *PdfColorspaceDeviceCMYK) ToPdfObject() PdfObject

type PdfColorspaceDeviceGray Uses

type PdfColorspaceDeviceGray struct{}

func NewPdfColorspaceDeviceGray Uses

func NewPdfColorspaceDeviceGray() *PdfColorspaceDeviceGray

func (*PdfColorspaceDeviceGray) ColorFromFloats Uses

func (this *PdfColorspaceDeviceGray) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceDeviceGray) ColorFromPdfObjects Uses

func (this *PdfColorspaceDeviceGray) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceDeviceGray) ColorToRGB Uses

func (this *PdfColorspaceDeviceGray) ColorToRGB(color PdfColor) (PdfColor, error)

Convert gray -> rgb for a single color component.

func (*PdfColorspaceDeviceGray) DecodeArray Uses

func (this *PdfColorspaceDeviceGray) DecodeArray() []float64

DecodeArray returns the range of color component values in DeviceGray colorspace.

func (*PdfColorspaceDeviceGray) GetNumComponents Uses

func (this *PdfColorspaceDeviceGray) GetNumComponents() int

func (*PdfColorspaceDeviceGray) ImageToRGB Uses

func (this *PdfColorspaceDeviceGray) ImageToRGB(img Image) (Image, error)

Convert 1-component grayscale data to 3-component RGB.

func (*PdfColorspaceDeviceGray) String Uses

func (this *PdfColorspaceDeviceGray) String() string

func (*PdfColorspaceDeviceGray) ToPdfObject Uses

func (this *PdfColorspaceDeviceGray) ToPdfObject() PdfObject

type PdfColorspaceDeviceN Uses

type PdfColorspaceDeviceN struct {
    ColorantNames  *PdfObjectArray
    AlternateSpace PdfColorspace
    TintTransform  PdfFunction
    Attributes     *PdfColorspaceDeviceNAttributes
    // contains filtered or unexported fields
}

//////////////////// DeviceN color spaces are similar to Separation color spaces, except they can contain an arbitrary number of color components.

Format: [/DeviceN names alternateSpace tintTransform]

or: [/DeviceN names alternateSpace tintTransform attributes]

func NewPdfColorspaceDeviceN Uses

func NewPdfColorspaceDeviceN() *PdfColorspaceDeviceN

func (*PdfColorspaceDeviceN) ColorFromFloats Uses

func (this *PdfColorspaceDeviceN) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceDeviceN) ColorFromPdfObjects Uses

func (this *PdfColorspaceDeviceN) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceDeviceN) ColorToRGB Uses

func (this *PdfColorspaceDeviceN) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceDeviceN) DecodeArray Uses

func (this *PdfColorspaceDeviceN) DecodeArray() []float64

DecodeArray returns the component range values for the DeviceN colorspace. [0 1.0 0 1.0 ...] for each color component.

func (*PdfColorspaceDeviceN) GetNumComponents Uses

func (this *PdfColorspaceDeviceN) GetNumComponents() int

GetNumComponents returns the number of input color components, i.e. that are input to the tint transform.

func (*PdfColorspaceDeviceN) ImageToRGB Uses

func (this *PdfColorspaceDeviceN) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceDeviceN) String Uses

func (this *PdfColorspaceDeviceN) String() string

func (*PdfColorspaceDeviceN) ToPdfObject Uses

func (this *PdfColorspaceDeviceN) ToPdfObject() PdfObject

type PdfColorspaceDeviceNAttributes Uses

type PdfColorspaceDeviceNAttributes struct {
    Subtype     *PdfObjectName // DeviceN or NChannel (DeviceN default)
    Colorants   PdfObject
    Process     PdfObject
    MixingHints PdfObject
    // contains filtered or unexported fields
}

Additional information about the components of colour space that conforming readers may use. Conforming readers need not use the alternateSpace and tintTransform parameters, and may instead use custom blending algorithms, along with other information provided in the attributes dictionary if present.

func (*PdfColorspaceDeviceNAttributes) ToPdfObject Uses

func (this *PdfColorspaceDeviceNAttributes) ToPdfObject() PdfObject

type PdfColorspaceDeviceRGB Uses

type PdfColorspaceDeviceRGB struct{}

func NewPdfColorspaceDeviceRGB Uses

func NewPdfColorspaceDeviceRGB() *PdfColorspaceDeviceRGB

func (*PdfColorspaceDeviceRGB) ColorFromFloats Uses

func (this *PdfColorspaceDeviceRGB) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceDeviceRGB) ColorFromPdfObjects Uses

func (this *PdfColorspaceDeviceRGB) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

Get the color from a series of pdf objects (3 for rgb).

func (*PdfColorspaceDeviceRGB) ColorToRGB Uses

func (this *PdfColorspaceDeviceRGB) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceDeviceRGB) DecodeArray Uses

func (this *PdfColorspaceDeviceRGB) DecodeArray() []float64

DecodeArray returns the range of color component values in DeviceRGB colorspace.

func (*PdfColorspaceDeviceRGB) GetNumComponents Uses

func (this *PdfColorspaceDeviceRGB) GetNumComponents() int

func (*PdfColorspaceDeviceRGB) ImageToGray Uses

func (this *PdfColorspaceDeviceRGB) ImageToGray(img Image) (Image, error)

func (*PdfColorspaceDeviceRGB) ImageToRGB Uses

func (this *PdfColorspaceDeviceRGB) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceDeviceRGB) String Uses

func (this *PdfColorspaceDeviceRGB) String() string

func (*PdfColorspaceDeviceRGB) ToPdfObject Uses

func (this *PdfColorspaceDeviceRGB) ToPdfObject() PdfObject

type PdfColorspaceICCBased Uses

type PdfColorspaceICCBased struct {
    N         int           // Number of color components (Required). Can be 1,3, or 4.
    Alternate PdfColorspace // Alternate colorspace for non-conforming readers.
    // If omitted ICC not supported: then use DeviceGray,
    // DeviceRGB or DeviceCMYK for N=1,3,4 respectively.
    Range    []float64        // Array of 2xN numbers, specifying range of each color component.
    Metadata *PdfObjectStream // Metadata stream.
    Data     []byte           // ICC colormap data.
    // contains filtered or unexported fields
}

format [/ICCBased stream]

The stream shall contain the ICC profile. A conforming reader shall support ICC.1:2004:10 as required by PDF 1.7, which will enable it to properly render all embedded ICC profiles regardless of the PDF version

In the current implementation, we rely on the alternative colormap provided.

func NewPdfColorspaceICCBased Uses

func NewPdfColorspaceICCBased(N int) (*PdfColorspaceICCBased, error)

func (*PdfColorspaceICCBased) ColorFromFloats Uses

func (this *PdfColorspaceICCBased) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceICCBased) ColorFromPdfObjects Uses

func (this *PdfColorspaceICCBased) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceICCBased) ColorToRGB Uses

func (this *PdfColorspaceICCBased) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceICCBased) DecodeArray Uses

func (this *PdfColorspaceICCBased) DecodeArray() []float64

DecodeArray returns the range of color component values in the ICCBased colorspace.

func (*PdfColorspaceICCBased) GetNumComponents Uses

func (this *PdfColorspaceICCBased) GetNumComponents() int

func (*PdfColorspaceICCBased) ImageToRGB Uses

func (this *PdfColorspaceICCBased) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceICCBased) String Uses

func (this *PdfColorspaceICCBased) String() string

func (*PdfColorspaceICCBased) ToPdfObject Uses

func (this *PdfColorspaceICCBased) ToPdfObject() PdfObject

Return as PDF object format [name stream]

type PdfColorspaceLab Uses

type PdfColorspaceLab struct {
    WhitePoint []float64 // Required.
    BlackPoint []float64
    Range      []float64 // [amin amax bmin bmax]
    // contains filtered or unexported fields
}

L*, a*, b* 3 component colorspace.

func NewPdfColorspaceLab Uses

func NewPdfColorspaceLab() *PdfColorspaceLab

require parameters?

func (*PdfColorspaceLab) ColorFromFloats Uses

func (this *PdfColorspaceLab) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceLab) ColorFromPdfObjects Uses

func (this *PdfColorspaceLab) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceLab) ColorToRGB Uses

func (this *PdfColorspaceLab) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceLab) DecodeArray Uses

func (this *PdfColorspaceLab) DecodeArray() []float64

DecodeArray returns the range of color component values in the Lab colorspace.

func (*PdfColorspaceLab) GetNumComponents Uses

func (this *PdfColorspaceLab) GetNumComponents() int

func (*PdfColorspaceLab) ImageToRGB Uses

func (this *PdfColorspaceLab) ImageToRGB(img Image) (Image, error)

func (*PdfColorspaceLab) String Uses

func (this *PdfColorspaceLab) String() string

func (*PdfColorspaceLab) ToPdfObject Uses

func (this *PdfColorspaceLab) ToPdfObject() PdfObject

Return as PDF object format [name dictionary]

type PdfColorspaceSpecialIndexed Uses

type PdfColorspaceSpecialIndexed struct {
    Base   PdfColorspace
    HiVal  int
    Lookup PdfObject
    // contains filtered or unexported fields
}

//////////////////// Indexed colorspace. An indexed color space is a lookup table, where the input element is an index to the lookup table and the output is a color defined in the lookup table in the Base colorspace. [/Indexed base hival lookup]

func NewPdfColorspaceSpecialIndexed Uses

func NewPdfColorspaceSpecialIndexed() *PdfColorspaceSpecialIndexed

func (*PdfColorspaceSpecialIndexed) ColorFromFloats Uses

func (this *PdfColorspaceSpecialIndexed) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceSpecialIndexed) ColorFromPdfObjects Uses

func (this *PdfColorspaceSpecialIndexed) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceSpecialIndexed) ColorToRGB Uses

func (this *PdfColorspaceSpecialIndexed) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceSpecialIndexed) DecodeArray Uses

func (this *PdfColorspaceSpecialIndexed) DecodeArray() []float64

DecodeArray returns the component range values for the Indexed colorspace.

func (*PdfColorspaceSpecialIndexed) GetNumComponents Uses

func (this *PdfColorspaceSpecialIndexed) GetNumComponents() int

func (*PdfColorspaceSpecialIndexed) ImageToRGB Uses

func (this *PdfColorspaceSpecialIndexed) ImageToRGB(img Image) (Image, error)

Convert an indexed image to RGB.

func (*PdfColorspaceSpecialIndexed) String Uses

func (this *PdfColorspaceSpecialIndexed) String() string

func (*PdfColorspaceSpecialIndexed) ToPdfObject Uses

func (this *PdfColorspaceSpecialIndexed) ToPdfObject() PdfObject

[/Indexed base hival lookup]

type PdfColorspaceSpecialPattern Uses

type PdfColorspaceSpecialPattern struct {
    UnderlyingCS PdfColorspace
    // contains filtered or unexported fields
}

Pattern colorspace. Can be defined either as /Pattern or with an underlying colorspace [/Pattern cs].

func NewPdfColorspaceSpecialPattern Uses

func NewPdfColorspaceSpecialPattern() *PdfColorspaceSpecialPattern

func (*PdfColorspaceSpecialPattern) ColorFromFloats Uses

func (this *PdfColorspaceSpecialPattern) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceSpecialPattern) ColorFromPdfObjects Uses

func (this *PdfColorspaceSpecialPattern) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

The first objects (if present) represent the color in underlying colorspace. The last one represents the name of the pattern.

func (*PdfColorspaceSpecialPattern) ColorToRGB Uses

func (this *PdfColorspaceSpecialPattern) ColorToRGB(color PdfColor) (PdfColor, error)

Only converts color used with uncolored patterns (defined in underlying colorspace). Does not go into the pattern objects and convert those. If that is desired, needs to be done separately. See for example grayscale conversion example in unidoc-examples repo.

func (*PdfColorspaceSpecialPattern) DecodeArray Uses

func (this *PdfColorspaceSpecialPattern) DecodeArray() []float64

DecodeArray returns an empty slice as there are no components associated with pattern colorspace.

func (*PdfColorspaceSpecialPattern) GetNumComponents Uses

func (this *PdfColorspaceSpecialPattern) GetNumComponents() int

func (*PdfColorspaceSpecialPattern) ImageToRGB Uses

func (this *PdfColorspaceSpecialPattern) ImageToRGB(img Image) (Image, error)

An image cannot be defined in a pattern colorspace, returns an error.

func (*PdfColorspaceSpecialPattern) String Uses

func (this *PdfColorspaceSpecialPattern) String() string

func (*PdfColorspaceSpecialPattern) ToPdfObject Uses

func (this *PdfColorspaceSpecialPattern) ToPdfObject() PdfObject

type PdfColorspaceSpecialSeparation Uses

type PdfColorspaceSpecialSeparation struct {
    ColorantName   *PdfObjectName
    AlternateSpace PdfColorspace
    TintTransform  PdfFunction
    // contains filtered or unexported fields
}

//////////////////// Separation colorspace. At the moment the colour space is set to a Separation space, the conforming reader shall determine whether the device has an available colorant (e.g. dye) corresponding to the name of the requested space. If so, the conforming reader shall ignore the alternateSpace and tintTransform parameters; subsequent painting operations within the space shall apply the designated colorant directly, according to the tint values supplied.

Format: [/Separation name alternateSpace tintTransform]

func NewPdfColorspaceSpecialSeparation Uses

func NewPdfColorspaceSpecialSeparation() *PdfColorspaceSpecialSeparation

func (*PdfColorspaceSpecialSeparation) ColorFromFloats Uses

func (this *PdfColorspaceSpecialSeparation) ColorFromFloats(vals []float64) (PdfColor, error)

func (*PdfColorspaceSpecialSeparation) ColorFromPdfObjects Uses

func (this *PdfColorspaceSpecialSeparation) ColorFromPdfObjects(objects []PdfObject) (PdfColor, error)

func (*PdfColorspaceSpecialSeparation) ColorToRGB Uses

func (this *PdfColorspaceSpecialSeparation) ColorToRGB(color PdfColor) (PdfColor, error)

func (*PdfColorspaceSpecialSeparation) DecodeArray Uses

func (this *PdfColorspaceSpecialSeparation) DecodeArray() []float64

DecodeArray returns the component range values for the Separation colorspace.

func (*PdfColorspaceSpecialSeparation) GetNumComponents Uses

func (this *PdfColorspaceSpecialSeparation) GetNumComponents() int

func (*PdfColorspaceSpecialSeparation) ImageToRGB Uses

func (this *PdfColorspaceSpecialSeparation) ImageToRGB(img Image) (Image, error)

ImageToRGB converts an image with samples in Separation CS to an image with samples specified in DeviceRGB CS.

func (*PdfColorspaceSpecialSeparation) String Uses

func (this *PdfColorspaceSpecialSeparation) String() string

func (*PdfColorspaceSpecialSeparation) ToPdfObject Uses

func (this *PdfColorspaceSpecialSeparation) ToPdfObject() PdfObject

type PdfDate Uses

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

A date is a PDF string of the form: (D:YYYYMMDDHHmmSSOHH'mm)

func NewPdfDate Uses

func NewPdfDate(dateStr string) (PdfDate, error)

Make a new PdfDate object from a PDF date string (see 7.9.4 Dates). format: "D: YYYYMMDDHHmmSSOHH'mm"

func (*PdfDate) ToPdfObject Uses

func (date *PdfDate) ToPdfObject() PdfObject

Convert to a PDF string object.

type PdfField Uses

type PdfField struct {
    FT     *PdfObjectName // field type
    Parent *PdfField
    // In a non-terminal field, the Kids array shall refer to field dictionaries that are immediate descendants of this field.
    // In a terminal field, the Kids array ordinarily shall refer to one or more separate widget annotations that are associated
    // with this field. However, if there is only one associated widget annotation, and its contents have been merged into the field
    // dictionary, Kids shall be omitted.
    KidsF []PdfModel // Kids can be array of other fields or widgets (PdfModel).
    KidsA []*PdfAnnotation
    T     PdfObject
    TU    PdfObject
    TM    PdfObject
    Ff    PdfObject // field flag
    V     PdfObject //value
    DV    PdfObject
    AA    PdfObject

    // Variable Text:
    DA  PdfObject
    Q   PdfObject
    DS  PdfObject
    RV  PdfObject
    // contains filtered or unexported fields
}

PdfField represents a field of an interactive form. Implements PdfModel interface.

func NewPdfField Uses

func NewPdfField() *PdfField

func (*PdfField) GetContainingPdfObject Uses

func (this *PdfField) GetContainingPdfObject() PdfObject

func (*PdfField) ToPdfObject Uses

func (this *PdfField) ToPdfObject() PdfObject

If Kids refer only to a single pdf widget annotation widget, then can merge it in. Currently not merging it in.

type PdfFont Uses

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

The PdfFont structure represents an underlying font structure which can be of type: - Type0 - Type1 - TrueType etc.

func NewPdfFontFromTTFFile Uses

func NewPdfFontFromTTFFile(filePath string) (*PdfFont, error)

func (PdfFont) GetGlyphCharMetrics Uses

func (font PdfFont) GetGlyphCharMetrics(glyph string) (fonts.CharMetrics, bool)

func (PdfFont) SetEncoder Uses

func (font PdfFont) SetEncoder(encoder textencoding.TextEncoder)

Set the encoding for the underlying font.

func (PdfFont) ToPdfObject Uses

func (font PdfFont) ToPdfObject() core.PdfObject

type PdfFontDescriptor Uses

type PdfFontDescriptor struct {
    FontName     core.PdfObject
    FontFamily   core.PdfObject
    FontStretch  core.PdfObject
    FontWeight   core.PdfObject
    Flags        core.PdfObject
    FontBBox     core.PdfObject
    ItalicAngle  core.PdfObject
    Ascent       core.PdfObject
    Descent      core.PdfObject
    Leading      core.PdfObject
    CapHeight    core.PdfObject
    XHeight      core.PdfObject
    StemV        core.PdfObject
    StemH        core.PdfObject
    AvgWidth     core.PdfObject
    MaxWidth     core.PdfObject
    MissingWidth core.PdfObject
    FontFile     core.PdfObject
    FontFile2    core.PdfObject
    FontFile3    core.PdfObject
    CharSet      core.PdfObject

    // Additional entries for CIDFonts
    Style  core.PdfObject
    Lang   core.PdfObject
    FD     core.PdfObject
    CIDSet core.PdfObject
    // contains filtered or unexported fields
}

Font descriptors specifies metrics and other attributes of a font.

func (*PdfFontDescriptor) ToPdfObject Uses

func (this *PdfFontDescriptor) ToPdfObject() core.PdfObject

Convert to a PDF dictionary inside an indirect object.

type PdfFunction Uses

type PdfFunction interface {
    Evaluate([]float64) ([]float64, error)
    ToPdfObject() PdfObject
}

type PdfFunctionType0 Uses

type PdfFunctionType0 struct {
    Domain []float64 // required; 2*m length; where m is the number of input values
    Range  []float64 // required (type 0); 2*n length; where n is the number of output values

    NumInputs  int
    NumOutputs int

    Size          []int
    BitsPerSample int
    Order         int // Values 1 or 3 (linear or cubic spline interpolation)
    Encode        []float64
    Decode        []float64
    // contains filtered or unexported fields
}

Type 0 functions use a sequence of sample values (contained in a stream) to provide an approximation for functions whose domains and ranges are bounded. The samples are organized as an m-dimensional table in which each entry has n components

func (*PdfFunctionType0) Evaluate Uses

func (this *PdfFunctionType0) Evaluate(x []float64) ([]float64, error)

func (*PdfFunctionType0) ToPdfObject Uses

func (this *PdfFunctionType0) ToPdfObject() PdfObject

type PdfFunctionType2 Uses

type PdfFunctionType2 struct {
    Domain []float64
    Range  []float64

    C0  []float64
    C1  []float64
    N   float64
    // contains filtered or unexported fields
}

Type 2 functions define an exponential interpolation of one input value and n output values:

f(x) = y_0, ..., y_(n-1)

y_j = C0_j + x^N * (C1_j - C0_j); for 0 <= j < n When N=1 ; linear interpolation between C0 and C1.

func (*PdfFunctionType2) Evaluate Uses

func (this *PdfFunctionType2) Evaluate(x []float64) ([]float64, error)

func (*PdfFunctionType2) ToPdfObject Uses

func (this *PdfFunctionType2) ToPdfObject() PdfObject

type PdfFunctionType3 Uses

type PdfFunctionType3 struct {
    Domain []float64
    Range  []float64

    Functions []PdfFunction // k-1 input functions
    Bounds    []float64     // k-1 numbers; defines the intervals where each function applies
    Encode    []float64     // Array of 2k numbers..
    // contains filtered or unexported fields
}

Type 3 functions define stitching of the subdomains of serveral 1-input functions to produce a single new 1-input function.

func (*PdfFunctionType3) Evaluate Uses

func (this *PdfFunctionType3) Evaluate(x []float64) ([]float64, error)

func (*PdfFunctionType3) ToPdfObject Uses

func (this *PdfFunctionType3) ToPdfObject() PdfObject

type PdfFunctionType4 Uses

type PdfFunctionType4 struct {
    Domain  []float64
    Range   []float64
    Program *ps.PSProgram
    // contains filtered or unexported fields
}

Type 4. Postscript calculator functions.

func (*PdfFunctionType4) Evaluate Uses

func (this *PdfFunctionType4) Evaluate(xVec []float64) ([]float64, error)

Input [x1 x2 x3]

func (*PdfFunctionType4) ToPdfObject Uses

func (this *PdfFunctionType4) ToPdfObject() PdfObject

type PdfModel Uses

type PdfModel interface {
    ToPdfObject() PdfObject
    GetContainingPdfObject() PdfObject
}

A PDFModel is a higher level PDF construct which can be collapsed into a PDF primitive. Each PDFModel has an underlying Primitive and vice versa. Copies can be made, but care must be taken to do it properly.

type PdfOutline Uses

type PdfOutline struct {
    PdfOutlineTreeNode
    Parent *PdfOutlineTreeNode
    Count  *int64
    // contains filtered or unexported fields
}

PDF outline dictionary (Table 152 - p. 376).

func NewPdfOutline Uses

func NewPdfOutline() *PdfOutline

func NewPdfOutlineTree Uses

func NewPdfOutlineTree() *PdfOutline

func (*PdfOutline) GetContainingPdfObject Uses

func (this *PdfOutline) GetContainingPdfObject() PdfObject

func (*PdfOutline) ToPdfObject Uses

func (this *PdfOutline) ToPdfObject() PdfObject

Recursively build the Outline tree PDF object.

type PdfOutlineItem Uses

type PdfOutlineItem struct {
    PdfOutlineTreeNode
    Title  *PdfObjectString
    Parent *PdfOutlineTreeNode
    Prev   *PdfOutlineTreeNode
    Next   *PdfOutlineTreeNode
    Count  *int64
    Dest   PdfObject
    A      PdfObject
    SE     PdfObject
    C      PdfObject
    F      PdfObject
    // contains filtered or unexported fields
}

Pdf outline item dictionary (Table 153 - pp. 376 - 377).

func NewOutlineBookmark Uses

func NewOutlineBookmark(title string, page *PdfIndirectObject) *PdfOutlineItem

func NewPdfOutlineItem Uses

func NewPdfOutlineItem() *PdfOutlineItem

func (*PdfOutlineItem) GetContainingPdfObject Uses

func (this *PdfOutlineItem) GetContainingPdfObject() PdfObject

func (*PdfOutlineItem) ToPdfObject Uses

func (this *PdfOutlineItem) ToPdfObject() PdfObject

Outline item. Recursively build the Outline tree PDF object.

type PdfOutlineTreeNode Uses

type PdfOutlineTreeNode struct {
    First *PdfOutlineTreeNode
    Last  *PdfOutlineTreeNode
    // contains filtered or unexported fields
}

func (*PdfOutlineTreeNode) GetContainingPdfObject Uses

func (this *PdfOutlineTreeNode) GetContainingPdfObject() PdfObject

func (*PdfOutlineTreeNode) ToPdfObject Uses

func (this *PdfOutlineTreeNode) ToPdfObject() PdfObject

type PdfPage Uses

type PdfPage struct {
    Parent               PdfObject
    LastModified         *PdfDate
    Resources            *PdfPageResources
    CropBox              *PdfRectangle
    MediaBox             *PdfRectangle
    BleedBox             *PdfRectangle
    TrimBox              *PdfRectangle
    ArtBox               *PdfRectangle
    BoxColorInfo         PdfObject
    Contents             PdfObject
    Rotate               *int64
    Group                PdfObject
    Thumb                PdfObject
    B                    PdfObject
    Dur                  PdfObject
    Trans                PdfObject
    AA                   PdfObject
    Metadata             PdfObject
    PieceInfo            PdfObject
    StructParents        PdfObject
    ID                   PdfObject
    PZ                   PdfObject
    SeparationInfo       PdfObject
    Tabs                 PdfObject
    TemplateInstantiated PdfObject
    PresSteps            PdfObject
    UserUnit             PdfObject
    VP                   PdfObject

    Annotations []*PdfAnnotation
    // contains filtered or unexported fields
}

PDF page object (7.7.3.3 - Table 30).

func NewPdfPage Uses

func NewPdfPage() *PdfPage

func (*PdfPage) AddContentStreamByString Uses

func (this *PdfPage) AddContentStreamByString(contentStr string)

Add content stream by string. Puts the content string into a stream object and points the content stream towards it.

func (*PdfPage) AddExtGState Uses

func (this *PdfPage) AddExtGState(name PdfObjectName, egs *PdfObjectDictionary) error

Add a graphics state to the XObject resources.

func (*PdfPage) AddFont Uses

func (this *PdfPage) AddFont(name PdfObjectName, font PdfObject) error

Add a font dictionary to the Font resources.

func (*PdfPage) AddImageResource Uses

func (this *PdfPage) AddImageResource(name PdfObjectName, ximg *XObjectImage) error

Add an image to the XObject resources.

func (*PdfPage) AddWatermarkImage Uses

func (this *PdfPage) AddWatermarkImage(ximg *XObjectImage, opt WatermarkImageOptions) error

Add a watermark to the page.

func (*PdfPage) Duplicate Uses

func (this *PdfPage) Duplicate() *PdfPage

func (*PdfPage) GetAllContentStreams Uses

func (this *PdfPage) GetAllContentStreams() (string, error)

Get all the content streams for a page as one string.

func (*PdfPage) GetContainingPdfObject Uses

func (this *PdfPage) GetContainingPdfObject() PdfObject

func (*PdfPage) GetContentStreams Uses

func (this *PdfPage) GetContentStreams() ([]string, error)

Get Content Stream as an array of strings.

func (*PdfPage) GetMediaBox Uses

func (this *PdfPage) GetMediaBox() (*PdfRectangle, error)

Get the inheritable media box value, either from the page or a higher up page/pages struct.

func (*PdfPage) GetPageAsIndirectObject Uses

func (this *PdfPage) GetPageAsIndirectObject() *PdfIndirectObject

Get the page object as an indirect objects. Wraps the Page dictionary into an indirect object.

func (*PdfPage) GetPageDict Uses

func (this *PdfPage) GetPageDict() *PdfObjectDictionary

Convert the Page to a PDF object dictionary.

func (*PdfPage) GetXObjectByName Uses

func (this *PdfPage) GetXObjectByName(name PdfObjectName) (PdfObject, bool)

Get XObject by name.

func (*PdfPage) HasExtGState Uses

func (this *PdfPage) HasExtGState(name PdfObjectName) bool

Check if ExtGState name is available.

func (*PdfPage) HasFontByName Uses

func (this *PdfPage) HasFontByName(name PdfObjectName) bool

Check if has font resource by name.

func (*PdfPage) HasXObjectByName Uses

func (this *PdfPage) HasXObjectByName(name PdfObjectName) bool

Check if has XObject resource by name.

func (*PdfPage) SetContentStreams Uses

func (this *PdfPage) SetContentStreams(cStreams []string, encoder StreamEncoder) error

Set the content streams based on a string array. Will make 1 object stream for each string and reference from the page Contents. Each stream will be encoded using the encoding specified by the StreamEncoder, if empty, will use identity encoding (raw data).

func (*PdfPage) ToPdfObject Uses

func (this *PdfPage) ToPdfObject() PdfObject

type PdfPageResources Uses

type PdfPageResources struct {
    ExtGState  PdfObject
    ColorSpace *PdfPageResourcesColorspaces
    Pattern    PdfObject
    Shading    PdfObject
    XObject    PdfObject
    Font       PdfObject
    ProcSet    PdfObject
    Properties PdfObject
    // contains filtered or unexported fields
}

Page resources model. Implements PdfModel.

func NewPdfPageResources Uses

func NewPdfPageResources() *PdfPageResources

func NewPdfPageResourcesFromDict Uses

func NewPdfPageResourcesFromDict(dict *PdfObjectDictionary) (*PdfPageResources, error)

func (*PdfPageResources) AddExtGState Uses

func (r *PdfPageResources) AddExtGState(gsName PdfObjectName, gsDict PdfObject) error

Add External Graphics State (GState). The gsDict can be specified either directly as a dictionary or an indirect object containing a dictionary.

func (*PdfPageResources) GetColorspaceByName Uses

func (r *PdfPageResources) GetColorspaceByName(keyName PdfObjectName) (PdfColorspace, bool)

func (*PdfPageResources) GetContainingPdfObject Uses

func (r *PdfPageResources) GetContainingPdfObject() PdfObject

func (*PdfPageResources) GetExtGState Uses

func (r *PdfPageResources) GetExtGState(keyName PdfObjectName) (PdfObject, bool)

Get the ExtGState specified by keyName. Returns a bool indicating whether it was found or not.

func (*PdfPageResources) GetFontByName Uses

func (r *PdfPageResources) GetFontByName(keyName PdfObjectName) (PdfObject, bool)

Get the font specified by keyName. Returns the PdfObject which the entry refers to. Returns a bool value indicating whether or not the entry was found.

func (*PdfPageResources) GetPatternByName Uses

func (r *PdfPageResources) GetPatternByName(keyName PdfObjectName) (*PdfPattern, bool)

Get the pattern specified by keyName. Returns nil if not existing. The bool flag indicated whether it was found or not.

func (*PdfPageResources) GetShadingByName Uses

func (r *PdfPageResources) GetShadingByName(keyName PdfObjectName) (*PdfShading, bool)

Get the shading specified by keyName. Returns nil if not existing. The bool flag indicated whether it was found or not.

func (*PdfPageResources) GetXObjectByName Uses

func (r *PdfPageResources) GetXObjectByName(keyName PdfObjectName) (*PdfObjectStream, XObjectType)

Returns the XObject with the specified keyName and the object type.

func (*PdfPageResources) GetXObjectFormByName Uses

func (r *PdfPageResources) GetXObjectFormByName(keyName PdfObjectName) (*XObjectForm, error)

func (*PdfPageResources) GetXObjectImageByName Uses

func (r *PdfPageResources) GetXObjectImageByName(keyName PdfObjectName) (*XObjectImage, error)

func (*PdfPageResources) HasColorspaceByName Uses

func (r *PdfPageResources) HasColorspaceByName(keyName PdfObjectName) bool

func (*PdfPageResources) HasExtGState Uses

func (r *PdfPageResources) HasExtGState(keyName PdfObjectName) bool

Check whether a font is defined by the specified keyName.

func (*PdfPageResources) HasFontByName Uses

func (r *PdfPageResources) HasFontByName(keyName PdfObjectName) bool

Check whether a font is defined by the specified keyName.

func (*PdfPageResources) HasXObjectByName Uses

func (r *PdfPageResources) HasXObjectByName(keyName PdfObjectName) bool

Check if an XObject with a specified keyName is defined.

func (*PdfPageResources) SetColorspaceByName Uses

func (r *PdfPageResources) SetColorspaceByName(keyName PdfObjectName, cs PdfColorspace) error

func (*PdfPageResources) SetFontByName Uses

func (r *PdfPageResources) SetFontByName(keyName PdfObjectName, obj PdfObject) error

Set the font specified by keyName to the given object.

func (*PdfPageResources) SetPatternByName Uses

func (r *PdfPageResources) SetPatternByName(keyName PdfObjectName, pattern PdfObject) error

Set a pattern resource specified by keyName.

func (*PdfPageResources) SetShadingByName Uses

func (r *PdfPageResources) SetShadingByName(keyName PdfObjectName, shadingObj PdfObject) error

Set a shading resource specified by keyName.

func (*PdfPageResources) SetXObjectByName Uses

func (r *PdfPageResources) SetXObjectByName(keyName PdfObjectName, stream *PdfObjectStream) error

func (*PdfPageResources) SetXObjectFormByName Uses

func (r *PdfPageResources) SetXObjectFormByName(keyName PdfObjectName, xform *XObjectForm) error

func (*PdfPageResources) SetXObjectImageByName Uses

func (r *PdfPageResources) SetXObjectImageByName(keyName PdfObjectName, ximg *XObjectImage) error

func (*PdfPageResources) ToPdfObject Uses

func (r *PdfPageResources) ToPdfObject() PdfObject

type PdfPageResourcesColorspaces Uses

type PdfPageResourcesColorspaces struct {
    Names       []string
    Colorspaces map[string]PdfColorspace
    // contains filtered or unexported fields
}

Needs to have matching name and colorspace map entry. The Names define the order.

func NewPdfPageResourcesColorspaces Uses

func NewPdfPageResourcesColorspaces() *PdfPageResourcesColorspaces

func (*PdfPageResourcesColorspaces) Set Uses

func (this *PdfPageResourcesColorspaces) Set(key PdfObjectName, val PdfColorspace)

Set the colorspace corresponding to key. Add to Names if not set.

func (*PdfPageResourcesColorspaces) ToPdfObject Uses

func (this *PdfPageResourcesColorspaces) ToPdfObject() PdfObject

type PdfPattern Uses

type PdfPattern struct {
    // Type: Pattern
    PatternType int64
    // contains filtered or unexported fields
}

A PdfPattern can represent a Pattern, either a tiling pattern or a shading pattern. Note that all patterns shall be treated as colours; a Pattern colour space shall be established with the CS or cs operator just like other colour spaces, and a particular pattern shall be installed as the current colour with the SCN or scn operator.

func (*PdfPattern) GetAsShadingPattern Uses

func (this *PdfPattern) GetAsShadingPattern() *PdfShadingPattern

Check with IsShading() prior to using this, to ensure is a shading pattern.

func (*PdfPattern) GetAsTilingPattern Uses

func (this *PdfPattern) GetAsTilingPattern() *PdfTilingPattern

Check with IsTiling() prior to using this to ensure is a tiling pattern.

func (*PdfPattern) GetContainingPdfObject Uses

func (this *PdfPattern) GetContainingPdfObject() PdfObject

func (*PdfPattern) GetContext Uses

func (this *PdfPattern) GetContext() PdfModel

Context in this case is a reference to the subpattern entry: either PdfTilingPattern or PdfShadingPattern.

func (*PdfPattern) IsShading Uses

func (this *PdfPattern) IsShading() bool

func (*PdfPattern) IsTiling Uses

func (this *PdfPattern) IsTiling() bool

func (*PdfPattern) SetContext Uses

func (this *PdfPattern) SetContext(ctx PdfModel)

Set the sub pattern (context). Either PdfTilingPattern or PdfShadingPattern.

func (*PdfPattern) ToPdfObject Uses

func (this *PdfPattern) ToPdfObject() PdfObject

type PdfReader Uses

type PdfReader struct {
    PageList []*PdfPage

    AcroForm *PdfAcroForm
    // contains filtered or unexported fields
}

PdfReader represents a PDF file reader. It is a frontend to the lower level parsing mechanism and provides a higher level access to work with PDF structure and information, such as the page structure etc.

func NewPdfReader Uses

func NewPdfReader(rs io.ReadSeeker) (*PdfReader, error)

NewPdfReader returns a new PdfReader for an input io.ReadSeeker interface. Can be used to read PDF from memory or file. Immediately loads and traverses the PDF structure including pages and page contents (if not encrypted).

func (*PdfReader) CheckAccessRights Uses

func (this *PdfReader) CheckAccessRights(password []byte) (bool, AccessPermissions, error)

CheckAccessRights checks access rights and permissions for a specified password. If either user/owner password is specified, full rights are granted, otherwise the access rights are specified by the Permissions flag.

The bool flag indicates that the user can access and view the file. The AccessPermissions shows what access the user has for editing etc. An error is returned if there was a problem performing the authentication.

func (*PdfReader) Decrypt Uses

func (this *PdfReader) Decrypt(password []byte) (bool, error)

Decrypt decrypts the PDF file with a specified password. Also tries to decrypt with an empty password. Returns true if successful, false otherwise.

func (*PdfReader) GetEncryptionMethod Uses

func (this *PdfReader) GetEncryptionMethod() string

GetEncryptionMethod returns a string containing some information about the encryption method used. XXX/TODO: May be better to return a standardized struct with information.

func (*PdfReader) GetIndirectObjectByNumber Uses

func (this *PdfReader) GetIndirectObjectByNumber(number int) (PdfObject, error)

GetIndirectObjectByNumber retrieves and returns a specific PdfObject by object number.

func (*PdfReader) GetNumPages Uses

func (this *PdfReader) GetNumPages() (int, error)

GetNumPages returns the number of pages in the document.

func (*PdfReader) GetOCProperties Uses

func (this *PdfReader) GetOCProperties() (PdfObject, error)

GetOCProperties returns the optional content properties PdfObject.

func (*PdfReader) GetObjectNums Uses

func (r *PdfReader) GetObjectNums() []int

GetObjectNums returns the object numbers of the PDF objects in the file Numbered objects are either indirect objects or stream objects. e.g. objNums := pdfReader.GetObjectNums() The underlying objects can then be accessed with pdfReader.GetIndirectObjectByNumber(objNums[0]) for the first available object.

func (*PdfReader) GetOutlineTree Uses

func (this *PdfReader) GetOutlineTree() *PdfOutlineTreeNode

GetOutlineTree returns the outline tree.

func (*PdfReader) GetOutlinesFlattened Uses

func (this *PdfReader) GetOutlinesFlattened() ([]*PdfOutlineTreeNode, []string, error)

GetOutlinesFlattened returns a flattened list of tree nodes and titles.

func (*PdfReader) GetPage Uses

func (this *PdfReader) GetPage(pageNumber int) (*PdfPage, error)

GetPage returns the PdfPage model for the specified page number.

func (*PdfReader) GetPageAsIndirectObject Uses

func (this *PdfReader) GetPageAsIndirectObject(pageNumber int) (PdfObject, error)

GetPageAsIndirectObject returns an indirect object containing the page dictionary for a specified page number.

func (*PdfReader) GetTrailer Uses

func (this *PdfReader) GetTrailer() (*PdfObjectDictionary, error)

GetTrailer returns the PDF's trailer dictionary.

func (*PdfReader) Inspect Uses

func (this *PdfReader) Inspect() (map[string]int, error)

Inspect inspects the object types, subtypes and content in the PDF file returning a map of object type to number of instances of each.

func (*PdfReader) IsEncrypted Uses

func (this *PdfReader) IsEncrypted() (bool, error)

IsEncrypted returns true if the PDF file is encrypted.

func (*PdfReader) LoadAnnotations Uses

func (reader *PdfReader) LoadAnnotations(d *PdfObjectDictionary) ([]*PdfAnnotation, error)

type PdfRectangle Uses

type PdfRectangle struct {
    Llx float64 // Lower left corner (ll).
    Lly float64
    Urx float64 // Upper right corner (ur).
    Ury float64
}

Definition of a rectangle.

func NewPdfRectangle Uses

func NewPdfRectangle(arr PdfObjectArray) (*PdfRectangle, error)

Create a PDF rectangle object based on an input array of 4 integers. Defining the lower left (LL) and upper right (UR) corners with floating point numbers.

func (*PdfRectangle) ToPdfObject Uses

func (rect *PdfRectangle) ToPdfObject() PdfObject

Convert to a PDF object.

type PdfShading Uses

type PdfShading struct {
    ShadingType *PdfObjectInteger
    ColorSpace  PdfColorspace
    Background  *PdfObjectArray
    BBox        *PdfRectangle
    AntiAlias   *PdfObjectBool
    // contains filtered or unexported fields
}

There are 7 types of shading, indicated by the shading type variable: 1: Function-based shading. 2: Axial shading. 3: Radial shading. 4: Free-form Gouraud-shaded triangle mesh. 5: Lattice-form Gouraud-shaded triangle mesh. 6: Coons patch mesh. 7: Tensor-product patch mesh. types 4-7 are contained in a stream object, where the dictionary is given by the stream dictionary.

func (*PdfShading) GetContainingPdfObject Uses

func (this *PdfShading) GetContainingPdfObject() PdfObject

func (*PdfShading) GetContext Uses

func (this *PdfShading) GetContext() PdfModel

Context in this case is a reference to the subshading entry as represented by PdfShadingType1-7.

func (*PdfShading) SetContext Uses

func (this *PdfShading) SetContext(ctx PdfModel)

Set the sub annotation (context).

func (*PdfShading) ToPdfObject Uses

func (this *PdfShading) ToPdfObject() PdfObject

type PdfShadingPattern Uses

type PdfShadingPattern struct {
    *PdfPattern
    Shading   *PdfShading
    Matrix    *PdfObjectArray
    ExtGState PdfObject
}

Shading patterns provide a smooth transition between colors across an area to be painted, i.e. color(x,y) = f(x,y) at each point. It is a type 2 pattern (PatternType = 2).

func (*PdfShadingPattern) ToPdfObject Uses

func (this *PdfShadingPattern) ToPdfObject() PdfObject

type PdfShadingType1 Uses

type PdfShadingType1 struct {
    *PdfShading
    Domain   *PdfObjectArray
    Matrix   *PdfObjectArray
    Function []PdfFunction
}

Shading type 1: Function-based shading.

func (*PdfShadingType1) ToPdfObject Uses

func (this *PdfShadingType1) ToPdfObject() PdfObject

type PdfShadingType2 Uses

type PdfShadingType2 struct {
    *PdfShading
    Coords   *PdfObjectArray
    Domain   *PdfObjectArray
    Function []PdfFunction
    Extend   *PdfObjectArray
}

Shading type 2: Axial shading.

func (*PdfShadingType2) ToPdfObject Uses

func (this *PdfShadingType2) ToPdfObject() PdfObject

type PdfShadingType3 Uses

type PdfShadingType3 struct {
    *PdfShading
    Coords   *PdfObjectArray
    Domain   *PdfObjectArray
    Function []PdfFunction
    Extend   *PdfObjectArray
}

Shading type 3: Radial shading.

func (*PdfShadingType3) ToPdfObject Uses

func (this *PdfShadingType3) ToPdfObject() PdfObject

type PdfShadingType4 Uses

type PdfShadingType4 struct {
    *PdfShading
    BitsPerCoordinate *PdfObjectInteger
    BitsPerComponent  *PdfObjectInteger
    BitsPerFlag       *PdfObjectInteger
    Decode            *PdfObjectArray
    Function          []PdfFunction
}

Shading type 4: Free-form Gouraud-shaded triangle mesh.

func (*PdfShadingType4) ToPdfObject Uses

func (this *PdfShadingType4) ToPdfObject() PdfObject

type PdfShadingType5 Uses

type PdfShadingType5 struct {
    *PdfShading
    BitsPerCoordinate *PdfObjectInteger
    BitsPerComponent  *PdfObjectInteger
    VerticesPerRow    *PdfObjectInteger
    Decode            *PdfObjectArray
    Function          []PdfFunction
}

Shading type 5: Lattice-form Gouraud-shaded triangle mesh.

func (*PdfShadingType5) ToPdfObject Uses

func (this *PdfShadingType5) ToPdfObject() PdfObject

type PdfShadingType6 Uses

type PdfShadingType6 struct {
    *PdfShading
    BitsPerCoordinate *PdfObjectInteger
    BitsPerComponent  *PdfObjectInteger
    BitsPerFlag       *PdfObjectInteger
    Decode            *PdfObjectArray
    Function          []PdfFunction
}

Shading type 6: Coons patch mesh.

func (*PdfShadingType6) ToPdfObject Uses

func (this *PdfShadingType6) ToPdfObject() PdfObject

type PdfShadingType7 Uses

type PdfShadingType7 struct {
    *PdfShading
    BitsPerCoordinate *PdfObjectInteger
    BitsPerComponent  *PdfObjectInteger
    BitsPerFlag       *PdfObjectInteger
    Decode            *PdfObjectArray
    Function          []PdfFunction
}

Shading type 7: Tensor-product patch mesh.

func (*PdfShadingType7) ToPdfObject Uses

func (this *PdfShadingType7) ToPdfObject() PdfObject

type PdfTilingPattern Uses

type PdfTilingPattern struct {
    *PdfPattern
    PaintType  *PdfObjectInteger // Colored or uncolored tiling pattern.
    TilingType *PdfObjectInteger // Constant spacing, no distortion or constant spacing/faster tiling.
    BBox       *PdfRectangle
    XStep      *PdfObjectFloat
    YStep      *PdfObjectFloat
    Resources  *PdfPageResources
    Matrix     *PdfObjectArray // Pattern matrix (6 numbers).
}

A Tiling pattern consists of repetitions of a pattern cell with defined intervals. It is a type 1 pattern. (PatternType = 1). A tiling pattern is represented by a stream object, where the stream content is a content stream that describes the pattern cell.

func (*PdfTilingPattern) GetContentStream Uses

func (this *PdfTilingPattern) GetContentStream() ([]byte, error)

GetContentStream returns the pattern cell's content stream

func (*PdfTilingPattern) GetContentStreamWithEncoder Uses

func (this *PdfTilingPattern) GetContentStreamWithEncoder() ([]byte, StreamEncoder, error)

GetContentStreamWithEncoder returns the pattern cell's content stream and its encoder TODO (v3): Change GetContentStreamWithEncoder to GetContentStream

func (*PdfTilingPattern) IsColored Uses

func (this *PdfTilingPattern) IsColored() bool

func (*PdfTilingPattern) SetContentStream Uses

func (this *PdfTilingPattern) SetContentStream(content []byte, encoder StreamEncoder) error

Set the pattern cell's content stream.

func (*PdfTilingPattern) ToPdfObject Uses

func (this *PdfTilingPattern) ToPdfObject() PdfObject

type PdfValue Uses

type PdfValue interface{}

type PdfWriter Uses

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

func NewPdfWriter Uses

func NewPdfWriter() PdfWriter

func (*PdfWriter) AddOutlineTree Uses

func (this *PdfWriter) AddOutlineTree(outlineTree *PdfOutlineTreeNode)

Add outlines to a PDF file.

func (*PdfWriter) AddPage Uses

func (this *PdfWriter) AddPage(page *PdfPage) error

Add a page to the PDF file. The new page should be an indirect object.

func (*PdfWriter) Encrypt Uses

func (this *PdfWriter) Encrypt(userPass, ownerPass []byte, options *EncryptOptions) error

Encrypt the output file with a specified user/owner password.

func (*PdfWriter) SetForms Uses

func (this *PdfWriter) SetForms(form *PdfAcroForm) error

Add Acroforms to a PDF file. Sets the specified form for writing.

func (*PdfWriter) SetOCProperties Uses

func (this *PdfWriter) SetOCProperties(ocProperties PdfObject) error

Set the optional content properties.

func (*PdfWriter) SetVersion Uses

func (this *PdfWriter) SetVersion(majorVersion, minorVersion int)

Set the PDF version of the output file.

func (*PdfWriter) Write Uses

func (this *PdfWriter) Write(ws io.WriteSeeker) error

Write the pdf out.

type WatermarkImageOptions Uses

type WatermarkImageOptions struct {
    Alpha               float64
    FitToWidth          bool
    PreserveAspectRatio bool
}

type XObjectForm Uses

type XObjectForm struct {
    Filter StreamEncoder

    FormType      PdfObject
    BBox          PdfObject
    Matrix        PdfObject
    Resources     *PdfPageResources
    Group         PdfObject
    Ref           PdfObject
    MetaData      PdfObject
    PieceInfo     PdfObject
    LastModified  PdfObject
    StructParent  PdfObject
    StructParents PdfObject
    OPI           PdfObject
    OC            PdfObject
    Name          PdfObject

    // Stream data.
    Stream []byte
    // contains filtered or unexported fields
}

XObjectForm (Table 95 in 8.10.2).

func NewXObjectForm Uses

func NewXObjectForm() *XObjectForm

Create a brand new XObject Form. Creates a new underlying PDF object stream primitive.

func NewXObjectFormFromStream Uses

func NewXObjectFormFromStream(stream *PdfObjectStream) (*XObjectForm, error)

Build the Form XObject from a stream object. XXX: Should this be exposed? Consider different access points.

func (*XObjectForm) GetContainingPdfObject Uses

func (xform *XObjectForm) GetContainingPdfObject() PdfObject

func (*XObjectForm) GetContentStream Uses

func (xform *XObjectForm) GetContentStream() ([]byte, error)

func (*XObjectForm) SetContentStream Uses

func (xform *XObjectForm) SetContentStream(content []byte, encoder StreamEncoder) error

Update the content stream with specified encoding. If encoding is null, will use the xform.Filter object or Raw encoding if not set.

func (*XObjectForm) ToPdfObject Uses

func (xform *XObjectForm) ToPdfObject() PdfObject

Return a stream object.

type XObjectImage Uses

type XObjectImage struct {
    //ColorSpace       PdfObject
    Width            *int64
    Height           *int64
    ColorSpace       PdfColorspace
    BitsPerComponent *int64
    Filter           StreamEncoder

    Intent       PdfObject
    ImageMask    PdfObject
    Mask         PdfObject
    Matte        PdfObject
    Decode       PdfObject
    Interpolate  PdfObject
    Alternatives PdfObject
    SMask        PdfObject
    SMaskInData  PdfObject
    Name         PdfObject // Obsolete. Currently read if available and write if available. Not setting on new created files.
    StructParent PdfObject
    ID           PdfObject
    OPI          PdfObject
    Metadata     PdfObject
    OC           PdfObject
    Stream       []byte
    // contains filtered or unexported fields
}

XObjectImage (Table 89 in 8.9.5.1). Implements PdfModel interface.

func NewXObjectImage Uses

func NewXObjectImage() *XObjectImage

func NewXObjectImageFromImage Uses

func NewXObjectImageFromImage(img *Image, cs PdfColorspace, encoder StreamEncoder) (*XObjectImage, error)

Creates a new XObject Image from an image object with default options. If encoder is nil, uses raw encoding (none).

func NewXObjectImageFromStream Uses

func NewXObjectImageFromStream(stream *PdfObjectStream) (*XObjectImage, error)

Build the image xobject from a stream object. An image dictionary is the dictionary portion of a stream object representing an image XObject.

func UpdateXObjectImageFromImage Uses

func UpdateXObjectImageFromImage(xobjIn *XObjectImage, img *Image, cs PdfColorspace,
    encoder StreamEncoder) (*XObjectImage, error)

UpdateXObjectImageFromImage creates a new XObject Image from an Image object `img` and default

masks from xobjIn.

The default masks are overriden if img.hasAlpha If `encoder` is nil, uses raw encoding (none).

func (*XObjectImage) GetContainingPdfObject Uses

func (ximg *XObjectImage) GetContainingPdfObject() PdfObject

func (*XObjectImage) SetFilter Uses

func (ximg *XObjectImage) SetFilter(encoder StreamEncoder) error

Set compression filter. Decodes with current filter sets and encodes the data with the new filter.

func (*XObjectImage) SetImage Uses

func (ximg *XObjectImage) SetImage(img *Image, cs PdfColorspace) error

Update XObject Image with new image data.

func (*XObjectImage) ToImage Uses

func (ximg *XObjectImage) ToImage() (*Image, error)

This will convert to an Image which can be transformed or saved out. The image data is decoded and the Image returned.

func (*XObjectImage) ToPdfObject Uses

func (ximg *XObjectImage) ToPdfObject() PdfObject

Return a stream object.

type XObjectType Uses

type XObjectType int
const (
    XObjectTypeUndefined XObjectType = iota
    XObjectTypeImage     XObjectType = iota
    XObjectTypeForm      XObjectType = iota
    XObjectTypePS        XObjectType = iota
    XObjectTypeUnknown   XObjectType = iota
)

Directories

PathSynopsis
fonts
sampling
textencoding

Package model imports 25 packages (graph) and is imported by 15 packages. Updated 2019-05-22. Refresh now. Tools for package owners.