model

package
v0.0.0-...-90a1d6d Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: AGPL-3.0, AGPL-3.0-only Imports: 33 Imported by: 0

Documentation

Overview

Package model provides an interface for working with high-level objects (models) in PDF files, including reading and writing documents.

The document structure of a PDF is constructed of a hierarchy of data models, representing a tree of information starting from the Document catalog (Figure 5 p. 80). It is based on the core package which handles core functionality such as file i/o, parsing and handling of primitive PDF objects (core.PdfObject).

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

Constants

View Source
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

View Source
var (
	ErrRequiredAttributeMissing = errors.New("required attribute missing")
	ErrInvalidAttribute         = errors.New("invalid attribute")
	ErrTypeCheck                = errors.New("type check")

	ErrEncrypted              = errors.New("file needs to be decrypted first")
	ErrNoFont                 = errors.New("font not defined")
	ErrFontNotSupported       = errors.New("unsupported font")
	ErrType1CFontNotSupported = errors.New("Type1C fonts are not currently supported")
	ErrType3FontNotSupported  = errors.New("Type3 fonts are not currently supported")
	ErrTTCmapNotSupported     = errors.New("unsupported TrueType cmap format")
)

Errors when parsing/loading data in PDF. TODO(gunnsth): Unexport errors except if there is a clear use case.

View Source
var (
	CourierName              = fonts.CourierName
	CourierBoldName          = fonts.CourierBoldName
	CourierObliqueName       = fonts.CourierObliqueName
	CourierBoldObliqueName   = fonts.CourierBoldObliqueName
	HelveticaName            = fonts.HelveticaName
	HelveticaBoldName        = fonts.HelveticaBoldName
	HelveticaObliqueName     = fonts.HelveticaObliqueName
	HelveticaBoldObliqueName = fonts.HelveticaBoldObliqueName
	SymbolName               = fonts.SymbolName
	ZapfDingbatsName         = fonts.ZapfDingbatsName
	TimesRomanName           = fonts.TimesRomanName
	TimesBoldName            = fonts.TimesBoldName
	TimesItalicName          = fonts.TimesItalicName
	TimesBoldItalicName      = fonts.TimesBoldItalicName
)

Names of the standard 14 fonts.

Functions

func DetermineColorspaceNameFromPdfObject

func DetermineColorspaceNameFromPdfObject(obj core.PdfObject) (core.PdfObjectName, error)

DetermineColorspaceNameFromPdfObject determines PDF colorspace from a PdfObject. Returns the colorspace name and an error on failure. If the colorspace was not found, will return an empty string.

func GetAlphabet

func GetAlphabet(text string) map[rune]int

GetAlphabet returns a map of the runes in `text` and their frequencies.

func SetImageHandler

func SetImageHandler(imgHandling ImageHandler)

SetImageHandler sets the image handler used by the package.

func SetPdfAuthor

func SetPdfAuthor(author string)

SetPdfAuthor sets the Author attribute of the output PDF.

func SetPdfCreationDate

func SetPdfCreationDate(creationDate time.Time)

SetPdfCreationDate sets the CreationDate attribute of the output PDF.

func SetPdfCreator

func SetPdfCreator(creator string)

SetPdfCreator sets the Creator attribute of the output PDF.

func SetPdfKeywords

func SetPdfKeywords(keywords string)

SetPdfKeywords sets the Keywords attribute of the output PDF.

func SetPdfModifiedDate

func SetPdfModifiedDate(modifiedDate time.Time)

SetPdfModifiedDate sets the ModDate attribute of the output PDF.

func SetPdfProducer

func SetPdfProducer(producer string)

SetPdfProducer sets the Producer attribute of the output PDF.

func SetPdfSubject

func SetPdfSubject(subject string)

SetPdfSubject sets the Subject attribute of the output PDF.

func SetPdfTitle

func SetPdfTitle(title string)

SetPdfTitle sets the Title attribute of the output PDF.

Types

type AlphaMapFunc

type AlphaMapFunc func(alpha byte) byte

AlphaMapFunc represents a alpha mapping function: byte -> byte. Can be used for thresholding the alpha channel, i.e. setting all alpha values below threshold to transparent.

type BorderEffect

type BorderEffect int

BorderEffect represents a border effect (Table 167 p. 395).

const (
	// BorderEffectNoEffect represents no border effect.
	BorderEffectNoEffect BorderEffect = iota

	// BorderEffectCloudy represents a cloudy border effect.
	BorderEffectCloudy BorderEffect = iota
)

type BorderStyle

type BorderStyle int

BorderStyle defines border type, typically used for annotations.

const (
	// BorderStyleSolid represents a solid border.
	BorderStyleSolid BorderStyle = iota

	// BorderStyleDashed represents a dashed border.
	BorderStyleDashed BorderStyle = iota

	// BorderStyleBeveled represents a beveled border.
	BorderStyleBeveled BorderStyle = iota

	// BorderStyleInset represents an inset border.
	BorderStyleInset BorderStyle = iota

	// BorderStyleUnderline represents an underline border.
	BorderStyleUnderline BorderStyle = iota
)

func (*BorderStyle) GetPdfName

func (bs *BorderStyle) GetPdfName() string

GetPdfName returns the PDF name used to indicate the border style. (Table 166 p. 395).

type ButtonType

type ButtonType int

ButtonType represents the subtype of a button field, can be one of: - Checkbox (ButtonTypeCheckbox) - PushButton (ButtonTypePushButton) - RadioButton (ButtonTypeRadioButton)

const (
	ButtonTypeCheckbox ButtonType = iota
	ButtonTypePush     ButtonType = iota
	ButtonTypeRadio    ButtonType = iota
)

Definitions for field button types

type CharMetrics

type CharMetrics = fonts.CharMetrics

CharMetrics represents width and height metrics of a glyph.

type ContentStreamWrapper

type ContentStreamWrapper interface {
	WrapContentStream(page *PdfPage) error
}

ContentStreamWrapper wraps the Page's contentstream into q ... Q blocks.

type DefaultImageHandler

type DefaultImageHandler struct{}

DefaultImageHandler is the default implementation of the ImageHandler using the standard go library.

func (DefaultImageHandler) Compress

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

Compress is yet 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) NewGrayImageFromGoImage

func (ih DefaultImageHandler) NewGrayImageFromGoImage(goimg goimage.Image) (*Image, error)

NewGrayImageFromGoImage creates a new grayscale unidoc Image from a golang Image.

func (DefaultImageHandler) NewImageFromGoImage

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

NewImageFromGoImage creates a new RGBA unidoc Image from a golang Image. If `goimg` is grayscale (*goimage.Gray) then calls NewGrayImageFromGoImage instead.

func (DefaultImageHandler) Read

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

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

type EncryptOptions

type EncryptOptions struct {
	Permissions security.Permissions
	Algorithm   EncryptionAlgorithm
}

EncryptOptions represents encryption options for an output PDF.

type EncryptionAlgorithm

type EncryptionAlgorithm int

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

type FieldAppearanceGenerator

type FieldAppearanceGenerator interface {
	ContentStreamWrapper
	GenerateAppearanceDict(form *PdfAcroForm, field *PdfField, wa *PdfAnnotationWidget) (*core.PdfObjectDictionary, error)
}

FieldAppearanceGenerator generates appearance stream for a given field.

type FieldFlag

type FieldFlag uint32

FieldFlag represents form field flags. Some of the flags can apply to all types of fields whereas other flags are specific.

const (
	// FieldFlagClear has no flags.
	FieldFlagClear FieldFlag = 0

	FieldFlagReadOnly FieldFlag = 1
	FieldFlagRequired FieldFlag = (1 << 1)
	FieldFlagNoExport FieldFlag = (2 << 1)

	FieldFlagNoToggleToOff   FieldFlag = (1 << 14)
	FieldFlagRadio           FieldFlag = (1 << 15)
	FieldFlagPushbutton      FieldFlag = (1 << 16)
	FieldFlagRadiosInUnision FieldFlag = (1 << 25)

	FieldFlagMultiline   FieldFlag = (1 << 12)
	FieldFlagPassword    FieldFlag = (1 << 13)
	FieldFlagFileSelect  FieldFlag = (1 << 20)
	FieldFlagDoNotScroll FieldFlag = (1 << 23)
	FieldFlagComb        FieldFlag = (1 << 24)
	FieldFlagRichText    FieldFlag = (1 << 25)

	FieldFlagDoNotSpellCheck FieldFlag = (1 << 22)

	FieldFlagCombo             FieldFlag = (1 << 17)
	FieldFlagEdit              FieldFlag = (1 << 18)
	FieldFlagSort              FieldFlag = (1 << 19)
	FieldFlagMultiSelect       FieldFlag = (1 << 21)
	FieldFlagCommitOnSelChange FieldFlag = (1 << 26)
)

The following constants define bitwise flag representing different attributes of a form field.

func (FieldFlag) Clear

func (flag FieldFlag) Clear(fl FieldFlag) FieldFlag

Clear clears flag fl from the flag and returns the resulting flag.

func (FieldFlag) Has

func (flag FieldFlag) Has(fl FieldFlag) bool

Has checks if flag fl is set in flag and returns true if so, false otherwise.

func (FieldFlag) Mask

func (flag FieldFlag) Mask() uint32

Mask returns the uin32 bitmask for the specific flag.

func (FieldFlag) Set

func (flag FieldFlag) Set(fl FieldFlag) FieldFlag

Set applies flag fl to the flag's bitmask and returns the combined flag.

func (FieldFlag) String

func (flag FieldFlag) String() string

String returns a string representation of what flags are set.

type FieldValueProvider

type FieldValueProvider interface {
	FieldValues() (map[string]core.PdfObject, error)
}

FieldValueProvider provides field values from a data source such as FDF, JSON or any other.

type Hasher

type Hasher interface {
	Write(p []byte) (n int, err error)
}

Hasher is the interface that wraps the basic Write method.

type Image

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
}

Image interface is a basic representation of an image used in PDF. The colorspace is not specified, but must be known when handling the image.

func (*Image) AlphaMap

func (img *Image) AlphaMap(mapFunc AlphaMapFunc)

AlphaMap performs mapping of alpha data for transformations. Allows custom filtering of alpha data etc.

func (*Image) ColorAt

func (img *Image) ColorAt(x, y int) (gocolor.Color, error)

ColorAt returns the color of the image pixel specified by the x and y coordinates.

func (*Image) ConvertToBinary

func (img *Image) ConvertToBinary() error

ConvertToBinary converts current image into binary (bi-level) format. Binary images are composed of single bits per pixel (only black or white). If provided image has more color components, then it would be converted into binary image using histogram auto threshold function.

func (*Image) GetParamsDict

func (img *Image) GetParamsDict() *core.PdfObjectDictionary

GetParamsDict returns *core.PdfObjectDictionary with a set of basic image parameters.

func (*Image) GetSamples

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

GetSamples converts 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. NOTE: The method resamples the image byte data before returning the result and this could lead to high memory usage, especially on large images. It should be avoided, when possible. It is recommended to access the Data field of the image directly or use the ColorAt method to extract individual pixels.

func (*Image) Resample

func (img *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

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

SetSamples convert samples to byte-data and sets for the image. NOTE: The method resamples the data and this could lead to high memory usage, especially on large images. It should be used only when it is not possible to work with the image byte data directly.

func (*Image) ToGoImage

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

ToGoImage converts the unidoc Image to a golang Image structure.

func (*Image) ToJBIG2Image

func (img *Image) ToJBIG2Image() (*core.JBIG2Image, error)

ToJBIG2Image converts current image to the core.JBIG2Image.

type ImageHandler

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

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

	// NewGrayImageFromGoImage loads a grayscale unidoc Image from a standard Go image structure.
	NewGrayImageFromGoImage(goimg goimage.Image) (*Image, error)

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

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{}

ImageHandling is used for handling images.

type Optimizer

type Optimizer interface {
	Optimize(objects []core.PdfObject) ([]core.PdfObject, error)
}

Optimizer is the interface that performs optimization of PDF object structure for output writing.

Optimize receives a slice of input `objects`, performs optimization, including removing, replacing objects and output the optimized slice of objects.

type Outline

type Outline struct {
	Entries []*OutlineItem `json:"entries,omitempty"`
}

Outline represents a PDF outline dictionary (Table 152 - p. 376). Currently, the Outline object can only be used to construct PDF outlines.

func NewOutline

func NewOutline() *Outline

NewOutline returns a new outline instance.

func (*Outline) Add

func (o *Outline) Add(item *OutlineItem)

Add appends a top level outline item to the outline.

func (*Outline) Insert

func (o *Outline) Insert(index uint, item *OutlineItem)

Insert adds a top level outline item in the outline, at the specified index.

func (*Outline) Items

func (o *Outline) Items() []*OutlineItem

Items returns all children outline items.

func (*Outline) ToOutlineTree

func (o *Outline) ToOutlineTree() *PdfOutlineTreeNode

ToOutlineTree returns a low level PdfOutlineTreeNode object, based on the current instance.

func (*Outline) ToPdfObject

func (o *Outline) ToPdfObject() core.PdfObject

ToPdfObject returns a PDF object representation of the outline.

func (*Outline) ToPdfOutline

func (o *Outline) ToPdfOutline() *PdfOutline

ToPdfOutline returns a low level PdfOutline object, based on the current instance.

type OutlineDest

type OutlineDest struct {
	Page int64   `json:"page"`
	Mode string  `json:"mode"`
	X    float64 `json:"x"`
	Y    float64 `json:"y"`
	Zoom float64 `json:"zoom"`
}

OutlineDest represents the destination of an outline item. It holds the page and the position on the page an outline item points to.

func NewOutlineDest

func NewOutlineDest(page int64, x, y float64) OutlineDest

NewOutlineDest returns a new outline destination which can be used with outline items.

func (OutlineDest) ToPdfObject

func (od OutlineDest) ToPdfObject() core.PdfObject

ToPdfObject returns a PDF object representation of the outline destination.

type OutlineItem

type OutlineItem struct {
	Title   string         `json:"title"`
	Dest    OutlineDest    `json:"dest"`
	Entries []*OutlineItem `json:"entries,omitempty"`
}

OutlineItem represents a PDF outline item dictionary (Table 153 - pp. 376 - 377).

func NewOutlineItem

func NewOutlineItem(title string, dest OutlineDest) *OutlineItem

NewOutlineItem returns a new outline item instance.

func (*OutlineItem) Add

func (oi *OutlineItem) Add(item *OutlineItem)

Add appends an outline item as a child of the current outline item.

func (*OutlineItem) Insert

func (oi *OutlineItem) Insert(index uint, item *OutlineItem)

Insert adds an outline item as a child of the current outline item, at the specified index.

func (*OutlineItem) Items

func (oi *OutlineItem) Items() []*OutlineItem

Items returns all children outline items.

func (*OutlineItem) ToPdfObject

func (oi *OutlineItem) ToPdfObject() core.PdfObject

ToPdfObject returns a PDF object representation of the outline item.

func (*OutlineItem) ToPdfOutlineItem

func (oi *OutlineItem) ToPdfOutlineItem() (*PdfOutlineItem, int64)

ToPdfOutlineItem returns a low level PdfOutlineItem object, based on the current instance.

type PdfAcroForm

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

PdfAcroForm represents the AcroForm dictionary used for representation of form data in PDF.

func NewPdfAcroForm

func NewPdfAcroForm() *PdfAcroForm

NewPdfAcroForm returns a new PdfAcroForm with an intialized container (indirect object).

func (*PdfAcroForm) AllFields

func (form *PdfAcroForm) AllFields() []*PdfField

AllFields returns a flattened list of all fields in the form.

func (*PdfAcroForm) Fill

func (form *PdfAcroForm) Fill(provider FieldValueProvider) error

Fill populates `form` with values provided by `provider`.

func (*PdfAcroForm) FillWithAppearance

func (form *PdfAcroForm) FillWithAppearance(provider FieldValueProvider, appGen FieldAppearanceGenerator) error

FillWithAppearance populates `form` with values provided by `provider`. If not nil, `appGen` is used to generate appearance dictionaries for the field annotations, based on the specified settings. Otherwise, appearance generation is skipped. e.g.: appGen := annotator.FieldAppearance{OnlyIfMissing: true, RegenerateTextFields: true} NOTE: In next major version this functionality will be part of Fill. (v4)

func (*PdfAcroForm) GetContainingPdfObject

func (form *PdfAcroForm) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the PdfAcroForm (indirect object).

func (*PdfAcroForm) ToPdfObject

func (form *PdfAcroForm) ToPdfObject() core.PdfObject

ToPdfObject converts PdfAcroForm to a PdfObject, i.e. an indirect object containing the AcroForm dictionary.

type PdfAction

type PdfAction struct {
	Type core.PdfObject
	S    core.PdfObject
	Next core.PdfObject
	// contains filtered or unexported fields
}

PdfAction represents an action in PDF (section 12.6 p. 412).

func NewPdfAction

func NewPdfAction() *PdfAction

NewPdfAction returns an initialized generic PDF action model.

func (*PdfAction) GetContainingPdfObject

func (a *PdfAction) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject implements interface PdfModel.

func (*PdfAction) GetContext

func (a *PdfAction) GetContext() PdfModel

GetContext returns the action context which contains the specific type-dependent context. The context represents the subaction.

func (*PdfAction) SetContext

func (a *PdfAction) SetContext(ctx PdfModel)

SetContext sets the sub action (context).

func (*PdfAction) String

func (a *PdfAction) String() string

String implements interface PdfObject.

func (*PdfAction) ToPdfObject

func (a *PdfAction) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionGoTo

type PdfActionGoTo struct {
	*PdfAction
	D core.PdfObject // name, byte string or array
}

PdfActionGoTo represents a GoTo action.

func NewPdfActionGoTo

func NewPdfActionGoTo() *PdfActionGoTo

NewPdfActionGoTo returns a new "go to" action.

func (*PdfActionGoTo) ToPdfObject

func (gotoAct *PdfActionGoTo) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionGoTo3DView

type PdfActionGoTo3DView struct {
	*PdfAction
	TA core.PdfObject
	V  core.PdfObject
}

PdfActionGoTo3DView represents a GoTo3DView action.

func NewPdfActionGoTo3DView

func NewPdfActionGoTo3DView() *PdfActionGoTo3DView

NewPdfActionGoTo3DView returns a new "goTo3DView" action.

func (*PdfActionGoTo3DView) ToPdfObject

func (goTo3DViewAct *PdfActionGoTo3DView) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionGoToE

type PdfActionGoToE struct {
	*PdfAction
	F         *PdfFilespec
	D         core.PdfObject // name, byte string or array
	NewWindow core.PdfObject
	T         core.PdfObject
}

PdfActionGoToE represents a GoToE action.

func NewPdfActionGoToE

func NewPdfActionGoToE() *PdfActionGoToE

NewPdfActionGoToE returns a new "go to embedded" action.

func (*PdfActionGoToE) ToPdfObject

func (gotoEAct *PdfActionGoToE) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionGoToR

type PdfActionGoToR struct {
	*PdfAction
	F         *PdfFilespec
	D         core.PdfObject // name, byte string or array
	NewWindow core.PdfObject
}

PdfActionGoToR represents a GoToR action.

func NewPdfActionGoToR

func NewPdfActionGoToR() *PdfActionGoToR

NewPdfActionGoToR returns a new "go to remote" action.

func (*PdfActionGoToR) ToPdfObject

func (gotoRAct *PdfActionGoToR) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionHide

type PdfActionHide struct {
	*PdfAction
	T core.PdfObject
	H core.PdfObject
}

PdfActionHide represents a hide action.

func NewPdfActionHide

func NewPdfActionHide() *PdfActionHide

NewPdfActionHide returns a new "hide" action.

func (*PdfActionHide) ToPdfObject

func (hideAct *PdfActionHide) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionImportData

type PdfActionImportData struct {
	*PdfAction
	F *PdfFilespec
}

PdfActionImportData represents a importData action.

func NewPdfActionImportData

func NewPdfActionImportData() *PdfActionImportData

NewPdfActionImportData returns a new "import data" action.

func (*PdfActionImportData) ToPdfObject

func (importDataAct *PdfActionImportData) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionJavaScript

type PdfActionJavaScript struct {
	*PdfAction
	JS core.PdfObject
}

PdfActionJavaScript represents a javaScript action.

func NewPdfActionJavaScript

func NewPdfActionJavaScript() *PdfActionJavaScript

NewPdfActionJavaScript returns a new "javaScript" action.

func (*PdfActionJavaScript) ToPdfObject

func (javaScriptAct *PdfActionJavaScript) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionLaunch

type PdfActionLaunch struct {
	*PdfAction
	F         *PdfFilespec
	Win       core.PdfObject
	Mac       core.PdfObject
	Unix      core.PdfObject
	NewWindow core.PdfObject
}

PdfActionLaunch represents a launch action.

func NewPdfActionLaunch

func NewPdfActionLaunch() *PdfActionLaunch

NewPdfActionLaunch returns a new "launch" action.

func (*PdfActionLaunch) ToPdfObject

func (launchAct *PdfActionLaunch) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionMovie

type PdfActionMovie struct {
	*PdfAction
	Annotation core.PdfObject
	T          core.PdfObject
	Operation  core.PdfObject
}

PdfActionMovie represents a movie action.

func NewPdfActionMovie

func NewPdfActionMovie() *PdfActionMovie

NewPdfActionMovie returns a new "movie" action.

func (*PdfActionMovie) ToPdfObject

func (movieAct *PdfActionMovie) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionNamed

type PdfActionNamed struct {
	*PdfAction
	N core.PdfObject
}

PdfActionNamed represents a named action.

func NewPdfActionNamed

func NewPdfActionNamed() *PdfActionNamed

NewPdfActionNamed returns a new "named" action.

func (*PdfActionNamed) ToPdfObject

func (namedAct *PdfActionNamed) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionRendition

type PdfActionRendition struct {
	*PdfAction
	R  core.PdfObject
	AN core.PdfObject
	OP core.PdfObject
	JS core.PdfObject
}

PdfActionRendition represents a Rendition action.

func NewPdfActionRendition

func NewPdfActionRendition() *PdfActionRendition

NewPdfActionRendition returns a new "rendition" action.

func (*PdfActionRendition) ToPdfObject

func (renditionAct *PdfActionRendition) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionResetForm

type PdfActionResetForm struct {
	*PdfAction
	Fields core.PdfObject
	Flags  core.PdfObject
}

PdfActionResetForm represents a resetForm action.

func NewPdfActionResetForm

func NewPdfActionResetForm() *PdfActionResetForm

NewPdfActionResetForm returns a new "reset form" action.

func (*PdfActionResetForm) ToPdfObject

func (resetFormAct *PdfActionResetForm) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionSetOCGState

type PdfActionSetOCGState struct {
	*PdfAction
	State      core.PdfObject
	PreserveRB core.PdfObject
}

PdfActionSetOCGState represents a SetOCGState action.

func NewPdfActionSetOCGState

func NewPdfActionSetOCGState() *PdfActionSetOCGState

NewPdfActionSetOCGState returns a new "named" action.

func (*PdfActionSetOCGState) ToPdfObject

func (setOCGStateAct *PdfActionSetOCGState) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionSound

type PdfActionSound struct {
	*PdfAction
	Sound       core.PdfObject
	Volume      core.PdfObject
	Synchronous core.PdfObject
	Repeat      core.PdfObject
	Mix         core.PdfObject
}

PdfActionSound represents a sound action.

func NewPdfActionSound

func NewPdfActionSound() *PdfActionSound

NewPdfActionSound returns a new "sound" action.

func (*PdfActionSound) ToPdfObject

func (soundAct *PdfActionSound) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionSubmitForm

type PdfActionSubmitForm struct {
	*PdfAction
	F      *PdfFilespec
	Fields core.PdfObject
	Flags  core.PdfObject
}

PdfActionSubmitForm represents a submitForm action.

func NewPdfActionSubmitForm

func NewPdfActionSubmitForm() *PdfActionSubmitForm

NewPdfActionSubmitForm returns a new "submit form" action.

func (*PdfActionSubmitForm) ToPdfObject

func (submitFormAct *PdfActionSubmitForm) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionThread

type PdfActionThread struct {
	*PdfAction
	F *PdfFilespec
	D core.PdfObject
	B core.PdfObject
}

PdfActionThread represents a thread action.

func NewPdfActionThread

func NewPdfActionThread() *PdfActionThread

NewPdfActionThread returns a new "thread" action.

func (*PdfActionThread) ToPdfObject

func (threadAct *PdfActionThread) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionTrans

type PdfActionTrans struct {
	*PdfAction
	Trans core.PdfObject
}

PdfActionTrans represents a trans action.

func NewPdfActionTrans

func NewPdfActionTrans() *PdfActionTrans

NewPdfActionTrans returns a new "trans" action.

func (*PdfActionTrans) ToPdfObject

func (transAct *PdfActionTrans) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfActionType

type PdfActionType string

PdfActionType represents an action type in PDF (section 12.6.4 p. 417).

const (
	ActionTypeGoTo        PdfActionType = "GoTo"        // Go to a destination in the current document
	ActionTypeGoTo3DView  PdfActionType = "GoTo3DView"  // Set the current view of a 3D annotation
	ActionTypeGoToE       PdfActionType = "GoToE"       // Go to embedded, PDF 1.6, Got to a destination in an embedded file
	ActionTypeGoToR       PdfActionType = "GoToR"       // Go to remote, Go to a destination in another document
	ActionTypeHide        PdfActionType = "Hide"        // Set an annotation's Hidden flag
	ActionTypeImportData  PdfActionType = "ImportData"  // Import field values from a file
	ActionTypeJavaScript  PdfActionType = "JavaScript"  // Execute a JavaScript script
	ActionTypeLaunch      PdfActionType = "Launch"      // Launch an application, usually to open a file
	ActionTypeMovie       PdfActionType = "Movie"       // Play a movie
	ActionTypeNamed       PdfActionType = "Named"       // Execute an action predefined by the conforming reader
	ActionTypeRendition   PdfActionType = "Rendition"   // Controls the playing of multimedia content
	ActionTypeResetForm   PdfActionType = "ResetForm"   // Set fields to their default values
	ActionTypeSetOCGState PdfActionType = "SetOCGState" // Set the states of optional content groups
	ActionTypeSound       PdfActionType = "Sound"       // Play a sound
	ActionTypeSubmitForm  PdfActionType = "SubmitForm"  // Send data to a uniform resource locator
	ActionTypeThread      PdfActionType = "Thread"      // Begin reading an article thread
	ActionTypeTrans       PdfActionType = "Trans"       // Updates the display of a document, using a transition dictionary
	ActionTypeURI         PdfActionType = "URI"         // Resolves a uniform resource identifier
)

(Section 12.6.4 p. 417). See Table 198 - Action types

type PdfActionURI

type PdfActionURI struct {
	*PdfAction
	URI   core.PdfObject
	IsMap core.PdfObject
}

PdfActionURI represents an URI action.

func NewPdfActionURI

func NewPdfActionURI() *PdfActionURI

NewPdfActionURI returns a new "Uri" action.

func (*PdfActionURI) ToPdfObject

func (uriAct *PdfActionURI) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotation

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

PdfAnnotation represents an annotation in PDF (section 12.5 p. 389).

func NewPdfAnnotation

func NewPdfAnnotation() *PdfAnnotation

NewPdfAnnotation returns an initialized generic PDF annotation model.

func (*PdfAnnotation) GetContainingPdfObject

func (a *PdfAnnotation) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject implements interface PdfModel.

func (*PdfAnnotation) GetContext

func (a *PdfAnnotation) GetContext() PdfModel

GetContext returns the annotation context which contains the specific type-dependent context. The context represents the subannotation.

func (*PdfAnnotation) SetContext

func (a *PdfAnnotation) SetContext(ctx PdfModel)

SetContext sets the sub annotation (context).

func (*PdfAnnotation) String

func (a *PdfAnnotation) String() string

func (*PdfAnnotation) ToPdfObject

func (a *PdfAnnotation) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel. Note: Call the sub-annotation's ToPdfObject to set both the generic and non-generic information.

type PdfAnnotation3D

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

PdfAnnotation3D represents 3D annotations. (Section 13.6.2).

func NewPdfAnnotation3D

func NewPdfAnnotation3D() *PdfAnnotation3D

NewPdfAnnotation3D returns a new 3d annotation.

func (*PdfAnnotation3D) ToPdfObject

func (a3d *PdfAnnotation3D) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationCaret

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

PdfAnnotationCaret represents Caret annotations. (Section 12.5.6.11).

func NewPdfAnnotationCaret

func NewPdfAnnotationCaret() *PdfAnnotationCaret

NewPdfAnnotationCaret returns a new caret annotation.

func (*PdfAnnotationCaret) ToPdfObject

func (caret *PdfAnnotationCaret) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationCircle

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

PdfAnnotationCircle represents Circle annotations. (Section 12.5.6.8).

func NewPdfAnnotationCircle

func NewPdfAnnotationCircle() *PdfAnnotationCircle

NewPdfAnnotationCircle returns a new circle annotation.

func (*PdfAnnotationCircle) ToPdfObject

func (circle *PdfAnnotationCircle) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationFileAttachment

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

PdfAnnotationFileAttachment represents FileAttachment annotations. (Section 12.5.6.15).

func NewPdfAnnotationFileAttachment

func NewPdfAnnotationFileAttachment() *PdfAnnotationFileAttachment

NewPdfAnnotationFileAttachment returns a new file attachment annotation.

func (*PdfAnnotationFileAttachment) ToPdfObject

func (file *PdfAnnotationFileAttachment) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationFreeText

PdfAnnotationFreeText represents FreeText annotations. (Section 12.5.6.6).

func NewPdfAnnotationFreeText

func NewPdfAnnotationFreeText() *PdfAnnotationFreeText

NewPdfAnnotationFreeText returns a new free text annotation.

func (*PdfAnnotationFreeText) ToPdfObject

func (ft *PdfAnnotationFreeText) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationHighlight

type PdfAnnotationHighlight struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
	QuadPoints core.PdfObject
}

PdfAnnotationHighlight represents Highlight annotations. (Section 12.5.6.10).

func NewPdfAnnotationHighlight

func NewPdfAnnotationHighlight() *PdfAnnotationHighlight

NewPdfAnnotationHighlight returns a new text highlight annotation.

func (*PdfAnnotationHighlight) ToPdfObject

func (hl *PdfAnnotationHighlight) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationInk

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

PdfAnnotationInk represents Ink annotations. (Section 12.5.6.13).

func NewPdfAnnotationInk

func NewPdfAnnotationInk() *PdfAnnotationInk

NewPdfAnnotationInk returns a new ink annotation.

func (*PdfAnnotationInk) ToPdfObject

func (ink *PdfAnnotationInk) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationLine

PdfAnnotationLine represents Line annotations. (Section 12.5.6.7).

func NewPdfAnnotationLine

func NewPdfAnnotationLine() *PdfAnnotationLine

NewPdfAnnotationLine returns a new line annotation.

func (*PdfAnnotationLine) ToPdfObject

func (line *PdfAnnotationLine) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationLink struct {
	*PdfAnnotation
	A          core.PdfObject
	Dest       core.PdfObject
	H          core.PdfObject
	PA         core.PdfObject
	QuadPoints core.PdfObject
	BS         core.PdfObject
	// contains filtered or unexported fields
}

PdfAnnotationLink represents Link annotations. (Section 12.5.6.5 p. 403).

func NewPdfAnnotationLink() *PdfAnnotationLink

NewPdfAnnotationLink returns a new link annotation.

func (*PdfAnnotationLink) GetAction

func (a *PdfAnnotationLink) GetAction() (*PdfAction, error)

GetAction returns the PDF action for the annotation link.

func (*PdfAnnotationLink) SetAction

func (a *PdfAnnotationLink) SetAction(action *PdfAction)

SetAction sets the PDF action for the annotation link.

func (*PdfAnnotationLink) ToPdfObject

func (link *PdfAnnotationLink) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationMarkup

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

PdfAnnotationMarkup represents additional fields for mark-up annotations. (Section 12.5.6.2 p. 399).

type PdfAnnotationMovie

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

PdfAnnotationMovie represents Movie annotations. (Section 12.5.6.17).

func NewPdfAnnotationMovie

func NewPdfAnnotationMovie() *PdfAnnotationMovie

NewPdfAnnotationMovie returns a new movie annotation.

func (*PdfAnnotationMovie) ToPdfObject

func (mov *PdfAnnotationMovie) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationPolyLine

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

PdfAnnotationPolyLine represents PolyLine annotations. (Section 12.5.6.9).

func NewPdfAnnotationPolyLine

func NewPdfAnnotationPolyLine() *PdfAnnotationPolyLine

NewPdfAnnotationPolyLine returns a new polyline annotation.

func (*PdfAnnotationPolyLine) ToPdfObject

func (polyl *PdfAnnotationPolyLine) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationPolygon

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

PdfAnnotationPolygon represents Polygon annotations. (Section 12.5.6.9).

func NewPdfAnnotationPolygon

func NewPdfAnnotationPolygon() *PdfAnnotationPolygon

NewPdfAnnotationPolygon returns a new polygon annotation.

func (*PdfAnnotationPolygon) ToPdfObject

func (poly *PdfAnnotationPolygon) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationPopup

type PdfAnnotationPopup struct {
	*PdfAnnotation
	Parent core.PdfObject
	Open   core.PdfObject
}

PdfAnnotationPopup represents Popup annotations. (Section 12.5.6.14).

func NewPdfAnnotationPopup

func NewPdfAnnotationPopup() *PdfAnnotationPopup

NewPdfAnnotationPopup returns a new popup annotation.

func (*PdfAnnotationPopup) ToPdfObject

func (popup *PdfAnnotationPopup) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationPrinterMark

type PdfAnnotationPrinterMark struct {
	*PdfAnnotation
	MN core.PdfObject
}

PdfAnnotationPrinterMark represents PrinterMark annotations. (Section 12.5.6.20).

func NewPdfAnnotationPrinterMark

func NewPdfAnnotationPrinterMark() *PdfAnnotationPrinterMark

NewPdfAnnotationPrinterMark returns a new printermark annotation.

func (*PdfAnnotationPrinterMark) ToPdfObject

func (pm *PdfAnnotationPrinterMark) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationProjection

type PdfAnnotationProjection struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
}

PdfAnnotationProjection represents Projection annotations.

func NewPdfAnnotationProjection

func NewPdfAnnotationProjection() *PdfAnnotationProjection

NewPdfAnnotationProjection returns a new projection annotation.

func (*PdfAnnotationProjection) ToPdfObject

func (proj *PdfAnnotationProjection) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationRedact

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

PdfAnnotationRedact represents Redact annotations. (Section 12.5.6.23).

func NewPdfAnnotationRedact

func NewPdfAnnotationRedact() *PdfAnnotationRedact

NewPdfAnnotationRedact returns a new redact annotation.

func (*PdfAnnotationRedact) ToPdfObject

func (redact *PdfAnnotationRedact) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationRichMedia

type PdfAnnotationRichMedia struct {
	*PdfAnnotation
	RichMediaSettings core.PdfObject
	RichMediaContent  core.PdfObject
}

PdfAnnotationRichMedia represents Rich Media annotations.

func NewPdfAnnotationRichMedia

func NewPdfAnnotationRichMedia() *PdfAnnotationRichMedia

NewPdfAnnotationRichMedia returns a new rich media annotation.

func (*PdfAnnotationRichMedia) ToPdfObject

func (rm *PdfAnnotationRichMedia) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationScreen

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

PdfAnnotationScreen represents Screen annotations. (Section 12.5.6.18).

func NewPdfAnnotationScreen

func NewPdfAnnotationScreen() *PdfAnnotationScreen

NewPdfAnnotationScreen returns a new screen annotation.

func (*PdfAnnotationScreen) ToPdfObject

func (scr *PdfAnnotationScreen) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationSound

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

PdfAnnotationSound represents Sound annotations. (Section 12.5.6.16).

func NewPdfAnnotationSound

func NewPdfAnnotationSound() *PdfAnnotationSound

NewPdfAnnotationSound returns a new sound annotation.

func (*PdfAnnotationSound) ToPdfObject

func (snd *PdfAnnotationSound) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationSquare

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

PdfAnnotationSquare represents Square annotations. (Section 12.5.6.8).

func NewPdfAnnotationSquare

func NewPdfAnnotationSquare() *PdfAnnotationSquare

NewPdfAnnotationSquare returns a new square annotation.

func (*PdfAnnotationSquare) ToPdfObject

func (sq *PdfAnnotationSquare) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationSquiggly

type PdfAnnotationSquiggly struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
	QuadPoints core.PdfObject
}

PdfAnnotationSquiggly represents Squiggly annotations. (Section 12.5.6.10).

func NewPdfAnnotationSquiggly

func NewPdfAnnotationSquiggly() *PdfAnnotationSquiggly

NewPdfAnnotationSquiggly returns a new text squiggly annotation.

func (*PdfAnnotationSquiggly) ToPdfObject

func (squiggly *PdfAnnotationSquiggly) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationStamp

type PdfAnnotationStamp struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
	Name core.PdfObject
}

PdfAnnotationStamp represents Stamp annotations. (Section 12.5.6.12).

func NewPdfAnnotationStamp

func NewPdfAnnotationStamp() *PdfAnnotationStamp

NewPdfAnnotationStamp returns a new stamp annotation.

func (*PdfAnnotationStamp) ToPdfObject

func (stamp *PdfAnnotationStamp) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationStrikeOut

type PdfAnnotationStrikeOut struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
	QuadPoints core.PdfObject
}

PdfAnnotationStrikeOut represents StrikeOut annotations. (Section 12.5.6.10).

func NewPdfAnnotationStrikeOut

func NewPdfAnnotationStrikeOut() *PdfAnnotationStrikeOut

NewPdfAnnotationStrikeOut returns a new text strikeout annotation.

func (*PdfAnnotationStrikeOut) ToPdfObject

func (strikeo *PdfAnnotationStrikeOut) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationText

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

PdfAnnotationText represents Text annotations. (Section 12.5.6.4 p. 402).

func NewPdfAnnotationText

func NewPdfAnnotationText() *PdfAnnotationText

NewPdfAnnotationText returns a new text annotation.

func (*PdfAnnotationText) ToPdfObject

func (text *PdfAnnotationText) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationTrapNet

type PdfAnnotationTrapNet struct {
	*PdfAnnotation
}

PdfAnnotationTrapNet represents TrapNet annotations. (Section 12.5.6.21).

func NewPdfAnnotationTrapNet

func NewPdfAnnotationTrapNet() *PdfAnnotationTrapNet

NewPdfAnnotationTrapNet returns a new trapnet annotation.

func (*PdfAnnotationTrapNet) ToPdfObject

func (trapn *PdfAnnotationTrapNet) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationUnderline

type PdfAnnotationUnderline struct {
	*PdfAnnotation
	*PdfAnnotationMarkup
	QuadPoints core.PdfObject
}

PdfAnnotationUnderline represents Underline annotations. (Section 12.5.6.10).

func NewPdfAnnotationUnderline

func NewPdfAnnotationUnderline() *PdfAnnotationUnderline

NewPdfAnnotationUnderline returns a new text underline annotation.

func (*PdfAnnotationUnderline) ToPdfObject

func (underline *PdfAnnotationUnderline) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationWatermark

type PdfAnnotationWatermark struct {
	*PdfAnnotation
	FixedPrint core.PdfObject
}

PdfAnnotationWatermark represents Watermark annotations. (Section 12.5.6.22).

func NewPdfAnnotationWatermark

func NewPdfAnnotationWatermark() *PdfAnnotationWatermark

NewPdfAnnotationWatermark returns a new watermark annotation.

func (*PdfAnnotationWatermark) ToPdfObject

func (wm *PdfAnnotationWatermark) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAnnotationWidget

type PdfAnnotationWidget struct {
	*PdfAnnotation
	H      core.PdfObject
	MK     core.PdfObject
	A      core.PdfObject
	AA     core.PdfObject
	BS     core.PdfObject
	Parent core.PdfObject
	// contains filtered or unexported fields
}

PdfAnnotationWidget represents Widget annotations. Note: Widget annotations are used to display form fields. (Section 12.5.6.19).

func NewPdfAnnotationWidget

func NewPdfAnnotationWidget() *PdfAnnotationWidget

NewPdfAnnotationWidget returns an initialized annotation widget.

func (*PdfAnnotationWidget) ToPdfObject

func (widget *PdfAnnotationWidget) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfAppender

type PdfAppender struct {
	Reader *PdfReader
	// contains filtered or unexported fields
}

PdfAppender appends new PDF content to an existing PDF document via incremental updates.

func NewPdfAppender

func NewPdfAppender(reader *PdfReader) (*PdfAppender, error)

NewPdfAppender creates a new Pdf appender from a Pdf reader.

func (*PdfAppender) AddPages

func (a *PdfAppender) AddPages(pages ...*PdfPage)

AddPages adds pages to be appended to the end of the source PDF.

func (*PdfAppender) MergePageWith

func (a *PdfAppender) MergePageWith(pageNum int, page *PdfPage) error

MergePageWith appends page content to source Pdf file page content.

func (*PdfAppender) RemovePage

func (a *PdfAppender) RemovePage(pageNum int)

RemovePage removes a page by number.

func (*PdfAppender) ReplaceAcroForm

func (a *PdfAppender) ReplaceAcroForm(acroForm *PdfAcroForm)

ReplaceAcroForm replaces the acrobat form. It appends a new form to the Pdf which replaces the original AcroForm.

func (*PdfAppender) ReplacePage

func (a *PdfAppender) ReplacePage(pageNum int, page *PdfPage)

ReplacePage replaces the original page to a new page.

func (*PdfAppender) Sign

func (a *PdfAppender) Sign(pageNum int, field *PdfFieldSignature) error

Sign signs a specific page with a digital signature. The signature field parameter must have a valid signature dictionary specified by its V field.

func (*PdfAppender) UpdateObject

func (a *PdfAppender) UpdateObject(obj core.PdfObject)

UpdateObject marks `obj` as updated and to be included in the following revision.

func (*PdfAppender) UpdatePage

func (a *PdfAppender) UpdatePage(page *PdfPage)

UpdatePage updates the `page` in the new revision if it has changed.

func (*PdfAppender) Write

func (a *PdfAppender) Write(w io.Writer) error

Write writes the Appender output to io.Writer. It can only be called once and further invocations will result in an error.

func (*PdfAppender) WriteToFile

func (a *PdfAppender) WriteToFile(outputPath string) error

WriteToFile writes the Appender output to file specified by path.

type PdfBorderEffect

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

PdfBorderEffect represents a PDF border effect.

type PdfBorderStyle

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

PdfBorderStyle represents a border style dictionary (12.5.4 Border Styles p. 394).

func NewBorderStyle

func NewBorderStyle() *PdfBorderStyle

NewBorderStyle returns an initialized PdfBorderStyle.

func (*PdfBorderStyle) GetBorderWidth

func (bs *PdfBorderStyle) GetBorderWidth() float64

GetBorderWidth returns the border style's width.

func (*PdfBorderStyle) SetBorderWidth

func (bs *PdfBorderStyle) SetBorderWidth(width float64)

SetBorderWidth sets the style's border width.

func (*PdfBorderStyle) ToPdfObject

func (bs *PdfBorderStyle) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfColor

type PdfColor interface {
}

PdfColor interface represents a generic color in PDF.

type PdfColorCalGray

type PdfColorCalGray float64

PdfColorCalGray represents a CalGray colorspace.

func NewPdfColorCalGray

func NewPdfColorCalGray(grayVal float64) *PdfColorCalGray

NewPdfColorCalGray returns a new CalGray color.

func (*PdfColorCalGray) GetNumComponents

func (col *PdfColorCalGray) GetNumComponents() int

GetNumComponents returns the number of color components (1 for CalGray).

func (*PdfColorCalGray) ToInteger

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

ToInteger convert to an integer format.

func (*PdfColorCalGray) Val

func (col *PdfColorCalGray) Val() float64

Val returns the value of the color.

type PdfColorCalRGB

type PdfColorCalRGB [3]float64

PdfColorCalRGB represents a color in the Colorimetric CIE RGB colorspace. A, B, C components Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorCalRGB

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

NewPdfColorCalRGB returns a new CalRBG color.

func (*PdfColorCalRGB) A

func (col *PdfColorCalRGB) A() float64

A returns the value of the A component of the color.

func (*PdfColorCalRGB) B

func (col *PdfColorCalRGB) B() float64

B returns the value of the B component of the color.

func (*PdfColorCalRGB) C

func (col *PdfColorCalRGB) C() float64

C returns the value of the C component of the color.

func (*PdfColorCalRGB) GetNumComponents

func (col *PdfColorCalRGB) GetNumComponents() int

GetNumComponents returns the number of color components (3 for CalRGB).

func (*PdfColorCalRGB) ToInteger

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

ToInteger convert to an integer format.

type PdfColorDeviceCMYK

type PdfColorDeviceCMYK [4]float64

PdfColorDeviceCMYK is a CMYK color, where each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorDeviceCMYK

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

NewPdfColorDeviceCMYK returns a new CMYK color.

func (*PdfColorDeviceCMYK) C

func (col *PdfColorDeviceCMYK) C() float64

C returns the value of the cyan component of the color.

func (*PdfColorDeviceCMYK) GetNumComponents

func (col *PdfColorDeviceCMYK) GetNumComponents() int

GetNumComponents returns the number of color components (4 for CMYK).

func (*PdfColorDeviceCMYK) K

func (col *PdfColorDeviceCMYK) K() float64

K returns the value of the key component of the color.

func (*PdfColorDeviceCMYK) M

func (col *PdfColorDeviceCMYK) M() float64

M returns the value of the magenta component of the color.

func (*PdfColorDeviceCMYK) ToInteger

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

ToInteger convert to an integer format.

func (*PdfColorDeviceCMYK) Y

func (col *PdfColorDeviceCMYK) Y() float64

Y returns the value of the yellow component of the color.

type PdfColorDeviceGray

type PdfColorDeviceGray float64

PdfColorDeviceGray represents a grayscale color value that 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

func NewPdfColorDeviceGray(grayVal float64) *PdfColorDeviceGray

NewPdfColorDeviceGray returns a new grayscale color based on an input grayscale float value in range [0-1].

func (*PdfColorDeviceGray) GetNumComponents

func (col *PdfColorDeviceGray) GetNumComponents() int

GetNumComponents returns the number of color components (1 for grayscale).

func (*PdfColorDeviceGray) ToInteger

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

ToInteger convert to an integer format.

func (*PdfColorDeviceGray) Val

func (col *PdfColorDeviceGray) Val() float64

Val returns the color value.

type PdfColorDeviceRGB

type PdfColorDeviceRGB [3]float64

PdfColorDeviceRGB represents a color in DeviceRGB colorspace with R, G, B components, where component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorDeviceRGB

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

NewPdfColorDeviceRGB returns a new PdfColorDeviceRGB based on the r,g,b component values.

func (*PdfColorDeviceRGB) B

func (col *PdfColorDeviceRGB) B() float64

B returns the value of the blue component of the color.

func (*PdfColorDeviceRGB) G

func (col *PdfColorDeviceRGB) G() float64

G returns the value of the green component of the color.

func (*PdfColorDeviceRGB) GetNumComponents

func (col *PdfColorDeviceRGB) GetNumComponents() int

GetNumComponents returns the number of color components (3 for RGB).

func (*PdfColorDeviceRGB) R

func (col *PdfColorDeviceRGB) R() float64

R returns the value of the red component of the color.

func (*PdfColorDeviceRGB) ToGray

func (col *PdfColorDeviceRGB) ToGray() *PdfColorDeviceGray

ToGray returns a PdfColorDeviceGray color based on the current RGB color.

func (*PdfColorDeviceRGB) ToInteger

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

ToInteger convert to an integer format.

type PdfColorLab

type PdfColorLab [3]float64

PdfColorLab represents a color in the L*, a*, b* 3 component colorspace. Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.

func NewPdfColorLab

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

NewPdfColorLab returns a new Lab color.

func (*PdfColorLab) A

func (col *PdfColorLab) A() float64

A returns the value of the A component of the color.

func (*PdfColorLab) B

func (col *PdfColorLab) B() float64

B returns the value of the B component of the color.

func (*PdfColorLab) GetNumComponents

func (col *PdfColorLab) GetNumComponents() int

GetNumComponents returns the number of color components (3 for Lab).

func (*PdfColorLab) L

func (col *PdfColorLab) L() float64

L returns the value of the L component of the color.

func (*PdfColorLab) ToInteger

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

ToInteger convert to an integer format.

type PdfColorPattern

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

PdfColorPattern represents a pattern color.

type PdfColorspace

type PdfColorspace interface {
	// String returns the PdfColorspace's name.
	String() string
	// ImageToRGB converts an Image in a given PdfColorspace to an RGB image.
	ImageToRGB(Image) (Image, error)
	// ColorToRGB converts a single color in a given PdfColorspace to an RGB color.
	ColorToRGB(color PdfColor) (PdfColor, error)
	// GetNumComponents returns the number of components in the PdfColorspace.
	GetNumComponents() int
	// ToPdfObject returns a PdfObject representation of the PdfColorspace.
	ToPdfObject() core.PdfObject
	// ColorFromPdfObjects returns a PdfColor in the given PdfColorspace from an array of PdfObject where each
	// PdfObject represents a numeric value.
	ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
	// ColorFromFloats returns a new PdfColor based on input color components for a given PdfColorspace.
	ColorFromFloats(vals []float64) (PdfColor, error)
	// DecodeArray returns the Decode array for the PdfColorSpace, i.e. the range of each component.
	DecodeArray() []float64
}

PdfColorspace interface defines the common methods of a PDF colorspace. 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

func NewPdfColorspaceFromPdfObject(obj core.PdfObject) (PdfColorspace, error)

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

type PdfColorspaceCalGray

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

PdfColorspaceCalGray represents CalGray color space.

func NewPdfColorspaceCalGray

func NewPdfColorspaceCalGray() *PdfColorspaceCalGray

NewPdfColorspaceCalGray returns a new CalGray colorspace object.

func (*PdfColorspaceCalGray) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element between 0 and 1.

func (*PdfColorspaceCalGray) ColorFromPdfObjects

func (cs *PdfColorspaceCalGray) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element in range 0-1.

func (*PdfColorspaceCalGray) ColorToRGB

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

ColorToRGB converts a CalGray color to an RGB color.

func (*PdfColorspaceCalGray) DecodeArray

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

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

func (*PdfColorspaceCalGray) GetNumComponents

func (cs *PdfColorspaceCalGray) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 1 for a CalGray device.

func (*PdfColorspaceCalGray) ImageToRGB

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

ImageToRGB converts image in CalGray color space to RGB (A, B, C -> X, Y, Z).

func (*PdfColorspaceCalGray) String

func (cs *PdfColorspaceCalGray) String() string

func (*PdfColorspaceCalGray) ToPdfObject

func (cs *PdfColorspaceCalGray) ToPdfObject() core.PdfObject

ToPdfObject return the CalGray colorspace as a PDF object (name dictionary).

type PdfColorspaceCalRGB

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
}

PdfColorspaceCalRGB stores A, B, C components

func NewPdfColorspaceCalRGB

func NewPdfColorspaceCalRGB() *PdfColorspaceCalRGB

NewPdfColorspaceCalRGB returns a new CalRGB colorspace object.

func (*PdfColorspaceCalRGB) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the A, B and C components of the color. The values of the elements should be between 0 and 1.

func (*PdfColorspaceCalRGB) ColorFromPdfObjects

func (cs *PdfColorspaceCalRGB) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain three PdfObjectFloat elements representing the A, B and C components of the color.

func (*PdfColorspaceCalRGB) ColorToRGB

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

ColorToRGB converts a CalRGB color to an RGB color.

func (*PdfColorspaceCalRGB) DecodeArray

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

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

func (*PdfColorspaceCalRGB) GetNumComponents

func (cs *PdfColorspaceCalRGB) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 3 for a CalRGB device.

func (*PdfColorspaceCalRGB) ImageToRGB

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

ImageToRGB converts CalRGB colorspace image to RGB and returns the result.

func (*PdfColorspaceCalRGB) String

func (cs *PdfColorspaceCalRGB) String() string

func (*PdfColorspaceCalRGB) ToPdfObject

func (cs *PdfColorspaceCalRGB) ToPdfObject() core.PdfObject

ToPdfObject returns colorspace in a PDF object format [name dictionary]

type PdfColorspaceDeviceCMYK

type PdfColorspaceDeviceCMYK struct{}

PdfColorspaceDeviceCMYK represents a CMYK colorspace.

func NewPdfColorspaceDeviceCMYK

func NewPdfColorspaceDeviceCMYK() *PdfColorspaceDeviceCMYK

NewPdfColorspaceDeviceCMYK returns a new CMYK colorspace object.

func (*PdfColorspaceDeviceCMYK) ColorFromFloats

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

ColorFromFloats returns a new PdfColorDevice based on the input slice of color components. The slice should contain four elements representing the cyan, magenta, yellow and key components of the color. The values of the elements should be between 0 and 1.

func (*PdfColorspaceDeviceCMYK) ColorFromPdfObjects

func (cs *PdfColorspaceDeviceCMYK) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

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

func (*PdfColorspaceDeviceCMYK) ColorToRGB

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

ColorToRGB converts a CMYK color to an RGB color.

func (*PdfColorspaceDeviceCMYK) DecodeArray

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

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

func (*PdfColorspaceDeviceCMYK) GetNumComponents

func (cs *PdfColorspaceDeviceCMYK) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 4 for a CMYK device.

func (*PdfColorspaceDeviceCMYK) ImageToRGB

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

ImageToRGB converts an image in CMYK colorspace to an RGB image.

func (*PdfColorspaceDeviceCMYK) String

func (cs *PdfColorspaceDeviceCMYK) String() string

func (*PdfColorspaceDeviceCMYK) ToPdfObject

func (cs *PdfColorspaceDeviceCMYK) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfColorspaceDeviceGray

type PdfColorspaceDeviceGray struct{}

PdfColorspaceDeviceGray represents a grayscale colorspace.

func NewPdfColorspaceDeviceGray

func NewPdfColorspaceDeviceGray() *PdfColorspaceDeviceGray

NewPdfColorspaceDeviceGray returns a new grayscale colorspace.

func (*PdfColorspaceDeviceGray) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element between 0 and 1.

func (*PdfColorspaceDeviceGray) ColorFromPdfObjects

func (cs *PdfColorspaceDeviceGray) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element in range 0-1.

func (*PdfColorspaceDeviceGray) ColorToRGB

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

ColorToRGB converts gray -> rgb for a single color component.

func (*PdfColorspaceDeviceGray) DecodeArray

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

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

func (*PdfColorspaceDeviceGray) GetNumComponents

func (cs *PdfColorspaceDeviceGray) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 1 for a grayscale device.

func (*PdfColorspaceDeviceGray) ImageToRGB

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

ImageToRGB convert 1-component grayscale data to 3-component RGB.

func (*PdfColorspaceDeviceGray) String

func (cs *PdfColorspaceDeviceGray) String() string

func (*PdfColorspaceDeviceGray) ToPdfObject

func (cs *PdfColorspaceDeviceGray) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfColorspaceDeviceN

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

PdfColorspaceDeviceN represents a DeviceN color space. 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

func NewPdfColorspaceDeviceN() *PdfColorspaceDeviceN

NewPdfColorspaceDeviceN returns an initialized PdfColorspaceDeviceN.

func (*PdfColorspaceDeviceN) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on input color components.

func (*PdfColorspaceDeviceN) ColorFromPdfObjects

func (cs *PdfColorspaceDeviceN) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on input color components. The input PdfObjects should be numeric.

func (*PdfColorspaceDeviceN) ColorToRGB

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

ColorToRGB converts a DeviceN color to an RGB color.

func (*PdfColorspaceDeviceN) DecodeArray

func (cs *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

func (cs *PdfColorspaceDeviceN) GetNumComponents() int

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

func (*PdfColorspaceDeviceN) ImageToRGB

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

ImageToRGB converts an Image in a given PdfColorspace to an RGB image.

func (*PdfColorspaceDeviceN) String

func (cs *PdfColorspaceDeviceN) String() string

String returns the name of the colorspace (DeviceN).

func (*PdfColorspaceDeviceN) ToPdfObject

func (cs *PdfColorspaceDeviceN) ToPdfObject() core.PdfObject

ToPdfObject returns a *PdfIndirectObject containing a *PdfObjectArray representation of the DeviceN colorspace. Format: [/DeviceN names alternateSpace tintTransform]

or: [/DeviceN names alternateSpace tintTransform attributes]

type PdfColorspaceDeviceNAttributes

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

PdfColorspaceDeviceNAttributes contains 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 a custom blending algorithms, along with other information provided in the attributes dictionary if present.

func (*PdfColorspaceDeviceNAttributes) ToPdfObject

func (cs *PdfColorspaceDeviceNAttributes) ToPdfObject() core.PdfObject

ToPdfObject returns a PdfObject representation of PdfColorspaceDeviceNAttributes as a PdfObjectDictionary directly or indirectly within an indirect object container.

type PdfColorspaceDeviceRGB

type PdfColorspaceDeviceRGB struct{}

PdfColorspaceDeviceRGB represents an RGB colorspace.

func NewPdfColorspaceDeviceRGB

func NewPdfColorspaceDeviceRGB() *PdfColorspaceDeviceRGB

NewPdfColorspaceDeviceRGB returns a new RGB colorspace object.

func (*PdfColorspaceDeviceRGB) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the red, green and blue components of the color. The values of the elements should be between 0 and 1.

func (*PdfColorspaceDeviceRGB) ColorFromPdfObjects

func (cs *PdfColorspaceDeviceRGB) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

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

func (*PdfColorspaceDeviceRGB) ColorToRGB

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

ColorToRGB verifies that the input color is an RGB color. Method exists in order to satisfy the PdfColorspace interface.

func (*PdfColorspaceDeviceRGB) DecodeArray

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

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

func (*PdfColorspaceDeviceRGB) GetNumComponents

func (cs *PdfColorspaceDeviceRGB) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 3 for an RGB device.

func (*PdfColorspaceDeviceRGB) ImageToGray

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

ImageToGray returns a new grayscale image based on the passed in RGB image.

func (*PdfColorspaceDeviceRGB) ImageToRGB

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

ImageToRGB returns the passed in image. Method exists in order to satisfy the PdfColorspace interface.

func (*PdfColorspaceDeviceRGB) String

func (cs *PdfColorspaceDeviceRGB) String() string

func (*PdfColorspaceDeviceRGB) ToPdfObject

func (cs *PdfColorspaceDeviceRGB) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfColorspaceICCBased

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 *core.PdfObjectStream // Metadata stream.
	Data     []byte                // ICC colormap data.
	// contains filtered or unexported fields
}

PdfColorspaceICCBased 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

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

NewPdfColorspaceICCBased returns a new ICCBased colorspace object.

func (*PdfColorspaceICCBased) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components.

func (*PdfColorspaceICCBased) ColorFromPdfObjects

func (cs *PdfColorspaceICCBased) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color component PDF objects.

func (*PdfColorspaceICCBased) ColorToRGB

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

ColorToRGB converts a ICCBased color to an RGB color.

func (*PdfColorspaceICCBased) DecodeArray

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

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

func (*PdfColorspaceICCBased) GetNumComponents

func (cs *PdfColorspaceICCBased) GetNumComponents() int

GetNumComponents returns the number of color components.

func (*PdfColorspaceICCBased) ImageToRGB

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

ImageToRGB converts ICCBased colorspace image to RGB and returns the result.

func (*PdfColorspaceICCBased) String

func (cs *PdfColorspaceICCBased) String() string

func (*PdfColorspaceICCBased) ToPdfObject

func (cs *PdfColorspaceICCBased) ToPdfObject() core.PdfObject

ToPdfObject returns colorspace in a PDF object format [name stream]

type PdfColorspaceLab

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

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

func NewPdfColorspaceLab

func NewPdfColorspaceLab() *PdfColorspaceLab

NewPdfColorspaceLab returns a new Lab colorspace object.

func (*PdfColorspaceLab) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the L (range 0-100), A (range -100-100) and B (range -100-100) components of the color.

func (*PdfColorspaceLab) ColorFromPdfObjects

func (cs *PdfColorspaceLab) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain three PdfObjectFloat elements representing the L, A and B components of the color.

func (*PdfColorspaceLab) ColorToRGB

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

ColorToRGB converts a Lab color to an RGB color.

func (*PdfColorspaceLab) DecodeArray

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

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

func (*PdfColorspaceLab) GetNumComponents

func (cs *PdfColorspaceLab) GetNumComponents() int

GetNumComponents returns the number of color components of the colorspace device. Returns 3 for a Lab device.

func (*PdfColorspaceLab) ImageToRGB

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

ImageToRGB converts Lab colorspace image to RGB and returns the result.

func (*PdfColorspaceLab) String

func (cs *PdfColorspaceLab) String() string

func (*PdfColorspaceLab) ToPdfObject

func (cs *PdfColorspaceLab) ToPdfObject() core.PdfObject

ToPdfObject returns colorspace in a PDF object format [name dictionary]

type PdfColorspaceSpecialIndexed

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

PdfColorspaceSpecialIndexed is 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

func NewPdfColorspaceSpecialIndexed() *PdfColorspaceSpecialIndexed

NewPdfColorspaceSpecialIndexed returns a new Indexed color.

func (*PdfColorspaceSpecialIndexed) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element.

func (*PdfColorspaceSpecialIndexed) ColorFromPdfObjects

func (cs *PdfColorspaceSpecialIndexed) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element.

func (*PdfColorspaceSpecialIndexed) ColorToRGB

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

ColorToRGB converts an Indexed color to an RGB color.

func (*PdfColorspaceSpecialIndexed) DecodeArray

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

DecodeArray returns the component range values for the Indexed colorspace.

func (*PdfColorspaceSpecialIndexed) GetNumComponents

func (cs *PdfColorspaceSpecialIndexed) GetNumComponents() int

GetNumComponents returns the number of color components (1 for Indexed).

func (*PdfColorspaceSpecialIndexed) ImageToRGB

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

ImageToRGB convert an indexed image to RGB.

func (*PdfColorspaceSpecialIndexed) String

func (cs *PdfColorspaceSpecialIndexed) String() string

func (*PdfColorspaceSpecialIndexed) ToPdfObject

func (cs *PdfColorspaceSpecialIndexed) ToPdfObject() core.PdfObject

ToPdfObject converts colorspace to a PDF object. [/Indexed base hival lookup]

type PdfColorspaceSpecialPattern

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

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

func NewPdfColorspaceSpecialPattern

func NewPdfColorspaceSpecialPattern() *PdfColorspaceSpecialPattern

NewPdfColorspaceSpecialPattern returns a new pattern color.

func (*PdfColorspaceSpecialPattern) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components.

func (*PdfColorspaceSpecialPattern) ColorFromPdfObjects

func (cs *PdfColorspaceSpecialPattern) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

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

func (*PdfColorspaceSpecialPattern) ColorToRGB

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

ColorToRGB 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

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

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

func (*PdfColorspaceSpecialPattern) GetNumComponents

func (cs *PdfColorspaceSpecialPattern) GetNumComponents() int

GetNumComponents returns the number of color components of the underlying colorspace device.

func (*PdfColorspaceSpecialPattern) ImageToRGB

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

ImageToRGB returns an error since an image cannot be defined in a pattern colorspace.

func (*PdfColorspaceSpecialPattern) String

func (cs *PdfColorspaceSpecialPattern) String() string

func (*PdfColorspaceSpecialPattern) ToPdfObject

func (cs *PdfColorspaceSpecialPattern) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfColorspaceSpecialSeparation

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

PdfColorspaceSpecialSeparation is a 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

func NewPdfColorspaceSpecialSeparation() *PdfColorspaceSpecialSeparation

NewPdfColorspaceSpecialSeparation returns a new separation color.

func (*PdfColorspaceSpecialSeparation) ColorFromFloats

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

ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element.

func (*PdfColorspaceSpecialSeparation) ColorFromPdfObjects

func (cs *PdfColorspaceSpecialSeparation) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)

ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element.

func (*PdfColorspaceSpecialSeparation) ColorToRGB

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

ColorToRGB converts a color in Separation colorspace to RGB colorspace.

func (*PdfColorspaceSpecialSeparation) DecodeArray

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

DecodeArray returns the component range values for the Separation colorspace.

func (*PdfColorspaceSpecialSeparation) GetNumComponents

func (cs *PdfColorspaceSpecialSeparation) GetNumComponents() int

GetNumComponents returns the number of color components (1 for Separation).

func (*PdfColorspaceSpecialSeparation) ImageToRGB

func (cs *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

func (*PdfColorspaceSpecialSeparation) ToPdfObject

func (cs *PdfColorspaceSpecialSeparation) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfDate

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

PdfDate represents a date, which is a PDF string of the form: (D:YYYYMMDDHHmmSSOHH'mm)

func NewPdfDate

func NewPdfDate(dateStr string) (PdfDate, error)

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

func NewPdfDateFromTime

func NewPdfDateFromTime(timeObj time.Time) (PdfDate, error)

NewPdfDateFromTime will create a PdfDate based on the given time

func (PdfDate) ToGoTime

func (d PdfDate) ToGoTime() time.Time

ToGoTime returns the date in time.Time format.

func (*PdfDate) ToPdfObject

func (d *PdfDate) ToPdfObject() core.PdfObject

ToPdfObject converts date to a PDF string object.

type PdfField

type PdfField struct {
	Parent      *PdfField
	Annotations []*PdfAnnotationWidget
	Kids        []*PdfField

	FT *core.PdfObjectName
	T  *core.PdfObjectString
	TU *core.PdfObjectString
	TM *core.PdfObjectString
	Ff *core.PdfObjectInteger
	V  core.PdfObject
	DV core.PdfObject
	AA core.PdfObject
	// contains filtered or unexported fields
}

PdfField contains the common attributes of a form field. The context object contains the specific field data which can represent a button, text, choice or signature. The PdfField is typically not used directly, but is encapsulated by the more specific field types such as PdfFieldButton etc (i.e. the context attribute).

func NewPdfField

func NewPdfField() *PdfField

NewPdfField returns an initialized PdfField.

func (*PdfField) Flags

func (f *PdfField) Flags() FieldFlag

Flags returns the field flags for the field accounting for any inherited flags.

func (*PdfField) FullName

func (f *PdfField) FullName() (string, error)

FullName returns the full name of the field as in rootname.parentname.partialname.

func (*PdfField) GetContainingPdfObject

func (f *PdfField) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the containing object for the PdfField, i.e. an indirect object containing the field dictionary.

func (*PdfField) GetContext

func (f *PdfField) GetContext() PdfModel

GetContext returns the PdfField context which is the more specific field data type, e.g. PdfFieldButton for a button field.

func (*PdfField) IsTerminal

func (f *PdfField) IsTerminal() bool

IsTerminal returns true for terminal fields, false otherwise. Terminal fields are fields whose descendants are only widget annotations.

func (*PdfField) PartialName

func (f *PdfField) PartialName() string

PartialName returns the partial name of the field.

func (*PdfField) SetContext

func (f *PdfField) SetContext(ctx PdfModel)

SetContext sets the specific fielddata type, e.g. would be PdfFieldButton for a button field.

func (*PdfField) SetFlag

func (f *PdfField) SetFlag(flag FieldFlag)

SetFlag sets the flag for the field.

func (*PdfField) String

func (f *PdfField) String() string

String returns a string representation of the field.

func (*PdfField) ToPdfObject

func (f *PdfField) ToPdfObject() core.PdfObject

ToPdfObject sets the common field elements. Note: Call the more field context's ToPdfObject to set both the generic and non-generic information.

type PdfFieldButton

type PdfFieldButton struct {
	*PdfField
	Opt *core.PdfObjectArray
}

PdfFieldButton represents a button field which includes push buttons, checkboxes, and radio buttons.

func (*PdfFieldButton) GetType

func (fb *PdfFieldButton) GetType() ButtonType

GetType returns the button field type which returns one of the following - PdfFieldButtonPush for push button fields - PdfFieldButtonCheckbox for checkbox fields - PdfFieldButtonRadio for radio button fields

func (*PdfFieldButton) IsCheckbox

func (fb *PdfFieldButton) IsCheckbox() bool

IsCheckbox returns true if the button field represents a checkbox, false otherwise.

func (*PdfFieldButton) IsPush

func (fb *PdfFieldButton) IsPush() bool

IsPush returns true if the button field represents a push button, false otherwise.

func (*PdfFieldButton) IsRadio

func (fb *PdfFieldButton) IsRadio() bool

IsRadio returns true if the button field represents a radio button, false otherwise.

func (*PdfFieldButton) SetType

func (fb *PdfFieldButton) SetType(btype ButtonType)

SetType sets the field button's type. Can be one of: - PdfFieldButtonPush for push button fields - PdfFieldButtonCheckbox for checkbox fields - PdfFieldButtonRadio for radio button fields This sets the field's flag appropriately.

func (*PdfFieldButton) ToPdfObject

func (fb *PdfFieldButton) ToPdfObject() core.PdfObject

ToPdfObject returns the button field dictionary within an indirect object.

type PdfFieldChoice

type PdfFieldChoice struct {
	*PdfField
	Opt *core.PdfObjectArray
	TI  *core.PdfObjectInteger
	I   *core.PdfObjectArray
}

PdfFieldChoice represents a choice field which includes scrollable list boxes and combo boxes.

func (*PdfFieldChoice) ToPdfObject

func (ch *PdfFieldChoice) ToPdfObject() core.PdfObject

ToPdfObject returns the choice field dictionary within an indirect object (container).

type PdfFieldSignature

type PdfFieldSignature struct {
	*PdfField
	*PdfAnnotationWidget

	V    *PdfSignature
	Lock *core.PdfIndirectObject
	SV   *core.PdfIndirectObject
}

PdfFieldSignature signature field represents digital signatures and optional data for authenticating the name of the signer and verifying document contents.

func NewPdfFieldSignature

func NewPdfFieldSignature(signature *PdfSignature) *PdfFieldSignature

NewPdfFieldSignature returns an initialized signature field.

func (*PdfFieldSignature) ToPdfObject

func (sig *PdfFieldSignature) ToPdfObject() core.PdfObject

ToPdfObject returns an indirect object containing the signature field dictionary.

type PdfFieldText

PdfFieldText represents a text field where user can enter text.

func (*PdfFieldText) ToPdfObject

func (ft *PdfFieldText) ToPdfObject() core.PdfObject

ToPdfObject returns the text field dictionary within an indirect object (container).

type PdfFilespec

type PdfFilespec struct {
	Type core.PdfObject
	FS   core.PdfObject
	F    core.PdfObject // A file specification string
	UF   core.PdfObject // A Unicode text string that provides file specification
	DOS  core.PdfObject // A file specification string representing a DOS file name. OBSOLETE
	Mac  core.PdfObject // A file specification string representing a Mac OS file name. OBSOLETE
	Unix core.PdfObject // A file specification string representing a UNIX file name. OBSOLETE
	ID   core.PdfObject // An array of two byte strings constituting a file identifier
	V    core.PdfObject // A flag indicating whether the file referenced by the file specification is volatile (changes frequently with time).
	EF   core.PdfObject // A dictionary containing a subset of the keys F, UF, DOS, Mac, and Unix, corresponding to the entries by those names in the file specification dictionary
	RF   core.PdfObject
	Desc core.PdfObject // Descriptive text associated with the file specification
	CI   core.PdfObject // A collection item dictionary, which shall be used to create the user interface for portable collections
	// contains filtered or unexported fields
}

PdfFilespec represents a file specification which can either refer to an external or embedded file.

func NewPdfFilespec

func NewPdfFilespec() *PdfFilespec

NewPdfFilespec returns an initialized generic PDF filespec model.

func NewPdfFilespecFromObj

func NewPdfFilespecFromObj(obj core.PdfObject) (*PdfFilespec, error)

NewPdfFilespecFromObj creates and returns a new PdfFilespec object.

func (*PdfFilespec) GetContainingPdfObject

func (f *PdfFilespec) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject implements interface PdfModel.

func (*PdfFilespec) ToPdfObject

func (f *PdfFilespec) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfFont

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

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

func DefaultFont

func DefaultFont() *PdfFont

DefaultFont returns the default font, which is currently the built in Helvetica.

func NewCompositePdfFontFromTTFFile

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

NewCompositePdfFontFromTTFFile loads a composite font from a TTF font file. Composite fonts can be used to represent unicode fonts which can have multi-byte character codes, representing a wide range of values. It is represented by a Type0 Font with an underlying CIDFontType2 and an Identity-H encoding map. TODO: May be extended in the future to support a larger variety of CMaps and vertical fonts.

func NewPdfFontFromPdfObject

func NewPdfFontFromPdfObject(fontObj core.PdfObject) (*PdfFont, error)

NewPdfFontFromPdfObject loads a PdfFont from the dictionary `fontObj`. If there is a problem an error is returned.

func NewPdfFontFromTTF

func NewPdfFontFromTTF(r io.ReadSeeker) (*PdfFont, error)

NewPdfFontFromTTF loads a TTF font and returns a PdfFont type that can be used in text styling functions. Uses a WinAnsiTextEncoder and loads only character codes 32-255.

func NewPdfFontFromTTFFile

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

NewPdfFontFromTTFFile loads a TTF font file and returns a PdfFont type that can be used in text styling functions. Uses a WinAnsiTextEncoder and loads only character codes 32-255.

func NewStandard14Font

func NewStandard14Font(basefont StdFontName) (*PdfFont, error)

NewStandard14Font returns the standard 14 font named `basefont` as a *PdfFont, or an error if it `basefont` is not one of the standard 14 font names.

func NewStandard14FontMustCompile

func NewStandard14FontMustCompile(basefont StdFontName) *PdfFont

NewStandard14FontMustCompile returns the standard 14 font named `basefont` as a *PdfFont. If `basefont` is one of the 14 Standard14Font values defined above then NewStandard14FontMustCompile is guaranteed to succeed.

func NewStandard14FontWithEncoding

func NewStandard14FontWithEncoding(basefont StdFontName, alphabet map[rune]int) (*PdfFont,
	textencoding.SimpleEncoder, error)

NewStandard14FontWithEncoding returns the standard 14 font named `basefont` as a *PdfFont and a TextEncoder that encodes all the runes in `alphabet`, or an error if this is not possible. An error can occur if `basefont` is not one the standard 14 font names.

func (*PdfFont) BaseFont

func (font *PdfFont) BaseFont() string

BaseFont returns the font's "BaseFont" field.

func (*PdfFont) BytesToCharcodes

func (font *PdfFont) BytesToCharcodes(data []byte) []textencoding.CharCode

BytesToCharcodes converts the bytes in a PDF string to character codes.

func (*PdfFont) CharcodeBytesToUnicode

func (font *PdfFont) CharcodeBytesToUnicode(data []byte) (string, int, int)

CharcodeBytesToUnicode converts PDF character codes `data` to a Go unicode string.

9.10 Extraction of Text Content (page 292) The process of finding glyph descriptions in OpenType fonts by a conforming reader shall be the following:

  • For Type 1 fonts using “CFF” tables, the process shall be as described in 9.6.6.2, "Encodings for Type 1 Fonts".
  • For TrueType fonts using “glyf” tables, the process shall be as described in 9.6.6.4, "Encodings for TrueType Fonts". Since this process sometimes produces ambiguous results, conforming writers, instead of using a simple font, shall use a Type 0 font with an Identity-H encoding and use the glyph indices as character codes, as described following Table 118.

func (*PdfFont) CharcodesToUnicode

func (font *PdfFont) CharcodesToUnicode(charcodes []textencoding.CharCode) []rune

CharcodesToUnicode converts the character codes `charcodes` to a slice of runes. How it works:

  1. Use the ToUnicode CMap if there is one.
  2. Use the underlying font's encoding.

func (*PdfFont) CharcodesToUnicodeWithStats

func (font *PdfFont) CharcodesToUnicodeWithStats(charcodes []textencoding.CharCode) (runelist []rune, numHits, numMisses int)

CharcodesToUnicodeWithStats is identical to CharcodesToUnicode except returns more statistical information about hits and misses from the reverse mapping process.

func (*PdfFont) Encoder

func (font *PdfFont) Encoder() textencoding.TextEncoder

Encoder returns the font's text encoder.

func (*PdfFont) FontDescriptor

func (font *PdfFont) FontDescriptor() *PdfFontDescriptor

FontDescriptor returns font's PdfFontDescriptor. This may be a builtin descriptor for standard 14 fonts but must be an explicit descriptor for other fonts.

func (*PdfFont) GetCharMetrics

func (font *PdfFont) GetCharMetrics(code textencoding.CharCode) (CharMetrics, bool)

GetCharMetrics returns the char metrics for character code `code`. How it works:

  1. It calls the GetCharMetrics function for the underlying font, either a simple font or a Type0 font. The underlying font GetCharMetrics() functions do direct charcode ➞ metrics mappings.
  2. If the underlying font's GetCharMetrics() doesn't have a CharMetrics for `code` then a a CharMetrics with the FontDescriptor's /MissingWidth is returned.
  3. If there is no /MissingWidth then a failure is returned.

TODO(peterwilliams97) There is nothing callers can do if no CharMetrics are found so we might as

well give them 0 width. There is no need for the bool return.

TODO(gunnsth): Reconsider whether needed or if can map via GlyphName.

func (PdfFont) GetFontDescriptor

func (font PdfFont) GetFontDescriptor() (*PdfFontDescriptor, error)

GetFontDescriptor returns the font descriptor for `font`.

func (*PdfFont) GetRuneMetrics

func (font *PdfFont) GetRuneMetrics(r rune) (CharMetrics, bool)

GetRuneMetrics returns the char metrics for a rune. TODO(peterwilliams97) There is nothing callers can do if no CharMetrics are found so we might as

well give them 0 width. There is no need for the bool return.

func (*PdfFont) IsCID

func (font *PdfFont) IsCID() bool

IsCID returns true if the underlying font is CID.

func (*PdfFont) RunesToCharcodeBytes

func (font *PdfFont) RunesToCharcodeBytes(data []rune) ([]byte, int)

RunesToCharcodeBytes maps the provided runes to charcode bytes and it returns the resulting slice of bytes, along with the number of runes which could not be converted. If the number of misses is 0, all runes were successfully converted.

func (*PdfFont) String

func (font *PdfFont) String() string

String returns a string that describes `font`.

func (*PdfFont) StringToCharcodeBytes

func (font *PdfFont) StringToCharcodeBytes(str string) ([]byte, int)

StringToCharcodeBytes maps the provided string runes to charcode bytes and it returns the resulting slice of bytes, along with the number of runes which could not be converted. If the number of misses is 0, all string runes were successfully converted.

func (*PdfFont) Subtype

func (font *PdfFont) Subtype() string

Subtype returns the font's "Subtype" field.

func (*PdfFont) ToPdfObject

func (font *PdfFont) ToPdfObject() core.PdfObject

ToPdfObject converts the PdfFont object to its PDF representation.

func (*PdfFont) ToUnicode

func (font *PdfFont) ToUnicode() string

ToUnicode returns the name of the font's "ToUnicode" field if there is one, or "" if there isn't.

type PdfFontDescriptor

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 // PFB
	FontFile2    core.PdfObject // TTF
	FontFile3    core.PdfObject // OTF / CFF
	CharSet      core.PdfObject

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

PdfFontDescriptor specifies metrics and other attributes of a font and can refer to a FontFile for embedded fonts. 9.8 Font Descriptors (page 281)

func (*PdfFontDescriptor) GetAscent

func (desc *PdfFontDescriptor) GetAscent() (float64, error)

GetAscent returns the Ascent of the font `descriptor`.

func (*PdfFontDescriptor) GetCapHeight

func (desc *PdfFontDescriptor) GetCapHeight() (float64, error)

GetCapHeight returns the CapHeight of the font `descriptor`.

func (*PdfFontDescriptor) GetDescent

func (desc *PdfFontDescriptor) GetDescent() (float64, error)

GetDescent returns the Descent of the font `descriptor`.

func (*PdfFontDescriptor) String

func (desc *PdfFontDescriptor) String() string

String returns a string describing the font descriptor.

func (*PdfFontDescriptor) ToPdfObject

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

ToPdfObject returns the PdfFontDescriptor as a PDF dictionary inside an indirect object.

type PdfFunction

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

PdfFunction interface represents the common methods of a function in PDF.

type PdfFunctionType0

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
}

PdfFunctionType0 uses 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

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

Evaluate runs the function on the passed in slice and returns the results.

func (*PdfFunctionType0) ToPdfObject

func (f *PdfFunctionType0) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the function.

type PdfFunctionType2

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

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

PdfFunctionType2 defines 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

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

Evaluate runs the function on the passed in slice and returns the results.

func (*PdfFunctionType2) ToPdfObject

func (f *PdfFunctionType2) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the function.

type PdfFunctionType3

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
}

PdfFunctionType3 defines stitching of the subdomains of several 1-input functions to produce a single new 1-input function.

func (*PdfFunctionType3) Evaluate

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

Evaluate runs the function on the passed in slice and returns the results.

func (*PdfFunctionType3) ToPdfObject

func (f *PdfFunctionType3) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the function.

type PdfFunctionType4

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

PdfFunctionType4 is a Postscript calculator functions.

func (*PdfFunctionType4) Evaluate

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

Evaluate runs the function. Input is [x1 x2 x3].

func (*PdfFunctionType4) ToPdfObject

func (f *PdfFunctionType4) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the function.

type PdfModel

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

PdfModel is a higher level PDF construct which can be collapsed into a PdfObject. Each PdfModel has an underlying PdfObject and vice versa (one-to-one). Under normal circumstances there should only be one copy of each. Copies can be made, but care must be taken to do it properly.

type PdfOutline

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

PdfOutline represents a PDF outline dictionary (Table 152 - p. 376).

func NewPdfOutline

func NewPdfOutline() *PdfOutline

NewPdfOutline returns an initialized PdfOutline.

func NewPdfOutlineTree

func NewPdfOutlineTree() *PdfOutline

NewPdfOutlineTree returns an initialized PdfOutline tree.

func (*PdfOutline) GetContainingPdfObject

func (o *PdfOutline) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the outline (indirect object).

func (*PdfOutline) ToPdfObject

func (o *PdfOutline) ToPdfObject() core.PdfObject

ToPdfObject recursively builds the Outline tree PDF object.

type PdfOutlineItem

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

PdfOutlineItem represents an outline item dictionary (Table 153 - pp. 376 - 377).

func NewOutlineBookmark

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

NewOutlineBookmark returns an initialized PdfOutlineItem for a given bookmark title and page.

func NewPdfOutlineItem

func NewPdfOutlineItem() *PdfOutlineItem

NewPdfOutlineItem returns an initialized PdfOutlineItem.

func (*PdfOutlineItem) GetContainingPdfObject

func (oi *PdfOutlineItem) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the outline item (indirect object).

func (*PdfOutlineItem) ToPdfObject

func (oi *PdfOutlineItem) ToPdfObject() core.PdfObject

ToPdfObject recursively builds the Outline tree PDF object.

type PdfOutlineTreeNode

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

PdfOutlineTreeNode contains common fields used by the outline and outline item objects.

func (*PdfOutlineTreeNode) GetContainingPdfObject

func (n *PdfOutlineTreeNode) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the outline tree node (indirect object).

func (*PdfOutlineTreeNode) GetContext

func (n *PdfOutlineTreeNode) GetContext() PdfModel

GetContext returns the context of the outline tree node, which is either a *PdfOutline or a *PdfOutlineItem. The method returns nil for uninitialized tree nodes.

func (*PdfOutlineTreeNode) ToPdfObject

func (n *PdfOutlineTreeNode) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the outline tree node.

type PdfPage

type PdfPage struct {
	Parent               core.PdfObject
	LastModified         *PdfDate
	Resources            *PdfPageResources
	CropBox              *PdfRectangle
	MediaBox             *PdfRectangle
	BleedBox             *PdfRectangle
	TrimBox              *PdfRectangle
	ArtBox               *PdfRectangle
	BoxColorInfo         core.PdfObject
	Contents             core.PdfObject
	Rotate               *int64
	Group                core.PdfObject
	Thumb                core.PdfObject
	B                    core.PdfObject
	Dur                  core.PdfObject
	Trans                core.PdfObject
	AA                   core.PdfObject
	Metadata             core.PdfObject
	PieceInfo            core.PdfObject
	StructParents        core.PdfObject
	ID                   core.PdfObject
	PZ                   core.PdfObject
	SeparationInfo       core.PdfObject
	Tabs                 core.PdfObject
	TemplateInstantiated core.PdfObject
	PresSteps            core.PdfObject
	UserUnit             core.PdfObject
	VP                   core.PdfObject
	Annots               core.PdfObject
	// contains filtered or unexported fields
}

PdfPage represents a page in a PDF document. (7.7.3.3 - Table 30).

func NewPdfPage

func NewPdfPage() *PdfPage

NewPdfPage returns a new PDF page.

func (*PdfPage) AddAnnotation

func (page *PdfPage) AddAnnotation(annot *PdfAnnotation)

AddAnnotation appends `annot` to the list of page annotations.

func (*PdfPage) AddContentStreamByString

func (p *PdfPage) AddContentStreamByString(contentStr string) error

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

func (*PdfPage) AddExtGState

func (p *PdfPage) AddExtGState(name core.PdfObjectName, egs *core.PdfObjectDictionary) error

AddExtGState adds a graphics state to the XObject resources.

func (*PdfPage) AddFont

func (p *PdfPage) AddFont(name core.PdfObjectName, font core.PdfObject) error

AddFont adds a font dictionary to the Font resources.

func (*PdfPage) AddImageResource

func (p *PdfPage) AddImageResource(name core.PdfObjectName, ximg *XObjectImage) error

AddImageResource adds an image to the XObject resources.

func (*PdfPage) AddWatermarkImage

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

AddWatermarkImage adds a watermark to the page.

func (*PdfPage) AppendContentStream

func (p *PdfPage) AppendContentStream(contentStr string) error

AppendContentStream adds content stream by string. Appends to the last contentstream instance if many.

func (*PdfPage) Duplicate

func (p *PdfPage) Duplicate() *PdfPage

Duplicate creates a duplicate page based on the current one and returns it.

func (*PdfPage) GetAllContentStreams

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

GetAllContentStreams gets all the content streams for a page as one string.

func (*PdfPage) GetAnnotations

func (page *PdfPage) GetAnnotations() ([]*PdfAnnotation, error)

GetAnnotations returns the list of page annotations for `page`. If not loaded attempts to load the annotations, otherwise returns the loaded list.

func (*PdfPage) GetContainingPdfObject

func (p *PdfPage) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the page as a dictionary within an PdfIndirectObject.

func (*PdfPage) GetContentStreams

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

GetContentStreams returns the content stream as an array of strings.

func (*PdfPage) GetMediaBox

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

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

func (*PdfPage) GetPageAsIndirectObject

func (p *PdfPage) GetPageAsIndirectObject() *core.PdfIndirectObject

GetPageAsIndirectObject returns the page as a dictionary within an PdfIndirectObject.

func (*PdfPage) GetPageDict

func (p *PdfPage) GetPageDict() *core.PdfObjectDictionary

GetPageDict converts the Page to a PDF object dictionary.

func (*PdfPage) GetXObjectByName

func (p *PdfPage) GetXObjectByName(name core.PdfObjectName) (core.PdfObject, bool)

GetXObjectByName gets XObject by name.

func (*PdfPage) HasExtGState

func (p *PdfPage) HasExtGState(name core.PdfObjectName) bool

HasExtGState checks if ExtGState name is available.

func (*PdfPage) HasFontByName

func (p *PdfPage) HasFontByName(name core.PdfObjectName) bool

HasFontByName checks if has font resource by name.

func (*PdfPage) HasXObjectByName

func (p *PdfPage) HasXObjectByName(name core.PdfObjectName) bool

HasXObjectByName checks if has XObject resource by name.

func (*PdfPage) SetAnnotations

func (page *PdfPage) SetAnnotations(annotations []*PdfAnnotation)

SetAnnotations sets the annotations list.

func (*PdfPage) SetContentStreams

func (p *PdfPage) SetContentStreams(cStreams []string, encoder core.StreamEncoder) error

SetContentStreams sets 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

func (p *PdfPage) ToPdfObject() core.PdfObject

ToPdfObject converts the PdfPage to a dictionary within an indirect object container.

type PdfPageResources

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

PdfPageResources is a Page resources model. Implements PdfModel.

func NewPdfPageResources

func NewPdfPageResources() *PdfPageResources

NewPdfPageResources returns a new PdfPageResources object.

func NewPdfPageResourcesFromDict

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

NewPdfPageResourcesFromDict creates and returns a new PdfPageResources object from the input dictionary.

func (*PdfPageResources) AddExtGState

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

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

func (*PdfPageResources) GenerateXObjectName

func (r *PdfPageResources) GenerateXObjectName() core.PdfObjectName

GenerateXObjectName generates an unused XObject name that can be used for adding new XObjects. Uses format XObj1, XObj2, ...

func (*PdfPageResources) GetColorspaceByName

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

GetColorspaceByName returns the colorspace with the specified name from the page resources.

func (*PdfPageResources) GetColorspaces

func (r *PdfPageResources) GetColorspaces() (*PdfPageResourcesColorspaces, error)

GetColorspaces loads PdfPageResourcesColorspaces from `r.ColorSpace` and returns an error if there is a problem loading. Once loaded, the same object is returned on multiple calls.

func (*PdfPageResources) GetContainingPdfObject

func (r *PdfPageResources) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the resources object (indirect object).

func (*PdfPageResources) GetExtGState

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

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

func (*PdfPageResources) GetFontByName

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

GetFontByName gets 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

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

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

func (*PdfPageResources) GetShadingByName

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

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

func (*PdfPageResources) GetXObjectByName

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

GetXObjectByName returns the XObject with the specified keyName and the object type.

func (*PdfPageResources) GetXObjectFormByName

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

GetXObjectFormByName returns the XObjectForm with the specified name from the page resources, if it exists.

func (*PdfPageResources) GetXObjectImageByName

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

GetXObjectImageByName returns the XObjectImage with the specified name from the page resources, if it exists.

func (*PdfPageResources) HasColorspaceByName

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

HasColorspaceByName checks if the colorspace with the specified name exists in the page resources.

func (*PdfPageResources) HasExtGState

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

HasExtGState checks whether a font is defined by the specified keyName.

func (*PdfPageResources) HasFontByName

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

HasFontByName checks whether a font is defined by the specified keyName.

func (*PdfPageResources) HasXObjectByName

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

HasXObjectByName checks if an XObject with a specified keyName is defined.

func (*PdfPageResources) SetColorSpace

func (r *PdfPageResources) SetColorSpace(colorspace *PdfPageResourcesColorspaces)

SetColorSpace sets `r` colorspace object to `colorspace`.

func (*PdfPageResources) SetColorspaceByName

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

SetColorspaceByName adds the provided colorspace to the page resources.

func (*PdfPageResources) SetFontByName

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

SetFontByName sets the font specified by keyName to the given object.

func (*PdfPageResources) SetPatternByName

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

SetPatternByName sets a pattern resource specified by keyName.

func (*PdfPageResources) SetShadingByName

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

SetShadingByName sets a shading resource specified by keyName.

func (*PdfPageResources) SetXObjectByName

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

SetXObjectByName adds the XObject from the passed in stream to the page resources. The added XObject is identified by the specified name.

func (*PdfPageResources) SetXObjectFormByName

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

SetXObjectFormByName adds the provided XObjectForm to the page resources. The added XObjectForm is identified by the specified name.

func (*PdfPageResources) SetXObjectImageByName

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

SetXObjectImageByName adds the provided XObjectImage to the page resources. The added XObjectImage is identified by the specified name.

func (*PdfPageResources) ToPdfObject

func (r *PdfPageResources) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the page resources.

type PdfPageResourcesColorspaces

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

PdfPageResourcesColorspaces contains the colorspace in the PdfPageResources. Needs to have matching name and colorspace map entry. The Names define the order.

func NewPdfPageResourcesColorspaces

func NewPdfPageResourcesColorspaces() *PdfPageResourcesColorspaces

NewPdfPageResourcesColorspaces returns a new PdfPageResourcesColorspaces object.

func (*PdfPageResourcesColorspaces) Set

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

func (*PdfPageResourcesColorspaces) ToPdfObject

func (rcs *PdfPageResourcesColorspaces) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the colorspace.

type PdfPattern

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

func (p *PdfPattern) GetAsShadingPattern() *PdfShadingPattern

GetAsShadingPattern returns a shading pattern. Check with IsShading() prior to using this.

func (*PdfPattern) GetAsTilingPattern

func (p *PdfPattern) GetAsTilingPattern() *PdfTilingPattern

GetAsTilingPattern returns a tiling pattern. Check with IsTiling() prior to using this.

func (*PdfPattern) GetContainingPdfObject

func (p *PdfPattern) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the pattern object (indirect object).

func (*PdfPattern) GetContext

func (p *PdfPattern) GetContext() PdfModel

GetContext returns a reference to the subpattern entry: either PdfTilingPattern or PdfShadingPattern.

func (*PdfPattern) IsShading

func (p *PdfPattern) IsShading() bool

IsShading specifies if the pattern is a shading pattern.

func (*PdfPattern) IsTiling

func (p *PdfPattern) IsTiling() bool

IsTiling specifies if the pattern is a tiling pattern.

func (*PdfPattern) SetContext

func (p *PdfPattern) SetContext(ctx PdfModel)

SetContext sets the sub pattern (context). Either PdfTilingPattern or PdfShadingPattern.

func (*PdfPattern) ToPdfObject

func (p *PdfPattern) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the pattern.

type PdfReader

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

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). Loads entire document structure into memory. Alternatively a lazy-loading reader can be created with NewPdfReaderLazy which loads only references, and references are loaded from disk into memory on an as-needed basis.

func NewPdfReaderLazy

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

NewPdfReaderLazy creates a new PdfReader for `rs` in lazy-loading mode. The difference from NewPdfReader is that in lazy-loading mode, objects are only loaded into memory when needed rather than entire structure being loaded into memory on reader creation. Note that it may make sense to use the lazy-load reader when processing only parts of files, rather than loading entire file into memory. Example: splitting a few pages from a large PDF file.

func NewReaderForText

func NewReaderForText(txt string) *PdfReader

NewReaderForText makes a new PdfReader for an input PDF content string. For use in testing.

func (*PdfReader) CheckAccessRights

func (r *PdfReader) CheckAccessRights(password []byte) (bool, security.Permissions, 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

func (r *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) FlattenFields

func (r *PdfReader) FlattenFields(allannots bool, appgen FieldAppearanceGenerator) error

FlattenFields flattens the form fields and annotations for the PDF loaded in `pdf` and makes non-editable. Looks up all widget annotations corresponding to form fields and flattens them by drawing the content through the content stream rather than annotations. References to flattened annotations will be removed from Page Annots array. For fields the AcroForm entry will be emptied. When `allannots` is true, all annotations will be flattened. Keep false if want to keep non-form related annotations intact. When `appgen` is not nil, it will be used to generate appearance streams for the field annotations.

func (*PdfReader) GetEncryptionMethod

func (r *PdfReader) GetEncryptionMethod() string

GetEncryptionMethod returns a descriptive information string about the encryption method used.

func (*PdfReader) GetIndirectObjectByNumber

func (r *PdfReader) GetIndirectObjectByNumber(number int) (core.PdfObject, error)

GetIndirectObjectByNumber retrieves and returns a specific PdfObject by object number.

func (*PdfReader) GetNamedDestinations

func (r *PdfReader) GetNamedDestinations() (core.PdfObject, error)

GetNamedDestinations returns the Names entry in the PDF catalog. See section 12.3.2.3 "Named Destinations" (p. 367 PDF32000_2008).

func (*PdfReader) GetNumPages

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

GetNumPages returns the number of pages in the document.

func (*PdfReader) GetOCProperties

func (r *PdfReader) GetOCProperties() (core.PdfObject, error)

GetOCProperties returns the optional content properties PdfObject.

func (*PdfReader) GetObjectNums

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

func (r *PdfReader) GetOutlineTree() *PdfOutlineTreeNode

GetOutlineTree returns the outline tree.

func (*PdfReader) GetOutlines

func (r *PdfReader) GetOutlines() (*Outline, error)

GetOutlines returns a high-level Outline object, based on the outline tree of the reader.

func (*PdfReader) GetOutlinesFlattened

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

GetOutlinesFlattened returns a flattened list of tree nodes and titles. NOTE: for most use cases, it is recommended to use the high-level GetOutlines method instead, which also provides information regarding the destination of the outline items.

func (*PdfReader) GetPage

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

GetPage returns the PdfPage model for the specified page number.

func (*PdfReader) GetTrailer

func (r *PdfReader) GetTrailer() (*core.PdfObjectDictionary, error)

GetTrailer returns the PDF's trailer dictionary.

func (*PdfReader) Inspect

func (r *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

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

IsEncrypted returns true if the PDF file is encrypted.

func (*PdfReader) PageFromIndirectObject

func (r *PdfReader) PageFromIndirectObject(ind *core.PdfIndirectObject) (*PdfPage, int, error)

PageFromIndirectObject returns the PdfPage and page number for a given indirect object.

func (*PdfReader) PdfVersion

func (r *PdfReader) PdfVersion() core.Version

PdfVersion returns version of the PDF file.

func (*PdfReader) ValidateSignatures

func (r *PdfReader) ValidateSignatures(handlers []SignatureHandler) ([]SignatureValidationResult, error)

ValidateSignatures validates digital signatures in the document.

type PdfRectangle

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

PdfRectangle is a definition of a rectangle.

func NewPdfRectangle

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

NewPdfRectangle creates 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) Height

func (rect *PdfRectangle) Height() float64

Height returns the height of `rect`.

func (*PdfRectangle) ToPdfObject

func (rect *PdfRectangle) ToPdfObject() core.PdfObject

ToPdfObject converts rectangle to a PDF object.

func (*PdfRectangle) Width

func (rect *PdfRectangle) Width() float64

Width returns the width of `rect`.

type PdfShading

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

PdfShading represents a shading dictionary. There are 7 types of shading, indicatedby 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

func (s *PdfShading) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the shading object (indirect object).

func (*PdfShading) GetContext

func (s *PdfShading) GetContext() PdfModel

GetContext returns a reference to the subshading entry as represented by PdfShadingType1-7.

func (*PdfShading) SetContext

func (s *PdfShading) SetContext(ctx PdfModel)

SetContext set the sub annotation (context).

func (*PdfShading) ToPdfObject

func (s *PdfShading) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingPattern

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

PdfShadingPattern is a Shading patterns that 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

func (p *PdfShadingPattern) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading pattern.

type PdfShadingType1

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

PdfShadingType1 is a Function-based shading.

func (*PdfShadingType1) ToPdfObject

func (s *PdfShadingType1) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType2

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

PdfShadingType2 is an Axial shading.

func (*PdfShadingType2) ToPdfObject

func (s *PdfShadingType2) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType3

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

PdfShadingType3 is a Radial shading.

func (*PdfShadingType3) ToPdfObject

func (s *PdfShadingType3) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType4

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

PdfShadingType4 is a Free-form Gouraud-shaded triangle mesh.

func (*PdfShadingType4) ToPdfObject

func (s *PdfShadingType4) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType5

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

PdfShadingType5 is a Lattice-form Gouraud-shaded triangle mesh.

func (*PdfShadingType5) ToPdfObject

func (s *PdfShadingType5) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType6

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

PdfShadingType6 is a Coons patch mesh.

func (*PdfShadingType6) ToPdfObject

func (s *PdfShadingType6) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfShadingType7

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

PdfShadingType7 is a Tensor-product patch mesh.

func (*PdfShadingType7) ToPdfObject

func (s *PdfShadingType7) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the shading dictionary.

type PdfSignature

type PdfSignature struct {
	Handler SignatureHandler

	// Type: Sig/DocTimeStamp
	Type         *core.PdfObjectName
	Filter       *core.PdfObjectName
	SubFilter    *core.PdfObjectName
	Contents     *core.PdfObjectString
	Cert         core.PdfObject
	ByteRange    *core.PdfObjectArray
	Reference    *core.PdfObjectArray
	Changes      *core.PdfObjectArray
	Name         *core.PdfObjectString
	M            *core.PdfObjectString
	Location     *core.PdfObjectString
	Reason       *core.PdfObjectString
	ContactInfo  *core.PdfObjectString
	R            *core.PdfObjectInteger
	V            *core.PdfObjectInteger
	PropBuild    *core.PdfObjectDictionary
	PropAuthTime *core.PdfObjectInteger
	PropAuthType *core.PdfObjectName
	// contains filtered or unexported fields
}

PdfSignature represents a PDF signature dictionary and is used for signing via form signature fields. (Section 12.8, Table 252 - Entries in a signature dictionary p. 475 in PDF32000_2008).

func NewPdfSignature

func NewPdfSignature(handler SignatureHandler) *PdfSignature

NewPdfSignature creates a new PdfSignature object.

func (*PdfSignature) GetContainingPdfObject

func (sig *PdfSignature) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject implements interface PdfModel.

func (*PdfSignature) Initialize

func (sig *PdfSignature) Initialize() error

Initialize initializes the PdfSignature.

func (*PdfSignature) SetDate

func (sig *PdfSignature) SetDate(date time.Time, format string)

SetDate sets the `M` field of the signature.

func (*PdfSignature) SetLocation

func (sig *PdfSignature) SetLocation(location string)

SetLocation sets the `Location` field of the signature.

func (*PdfSignature) SetName

func (sig *PdfSignature) SetName(name string)

SetName sets the `Name` field of the signature.

func (*PdfSignature) SetReason

func (sig *PdfSignature) SetReason(reason string)

SetReason sets the `Reason` field of the signature.

func (*PdfSignature) ToPdfObject

func (sig *PdfSignature) ToPdfObject() core.PdfObject

ToPdfObject implements interface PdfModel.

type PdfTilingPattern

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

PdfTilingPattern is a Tiling pattern that 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

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

GetContentStream returns the pattern cell's content stream

func (*PdfTilingPattern) GetContentStreamWithEncoder

func (p *PdfTilingPattern) GetContentStreamWithEncoder() ([]byte, core.StreamEncoder, error)

GetContentStreamWithEncoder returns the pattern cell's content stream and its encoder

func (*PdfTilingPattern) IsColored

func (p *PdfTilingPattern) IsColored() bool

IsColored specifies if the pattern is colored.

func (*PdfTilingPattern) SetContentStream

func (p *PdfTilingPattern) SetContentStream(content []byte, encoder core.StreamEncoder) error

SetContentStream sets the pattern cell's content stream.

func (*PdfTilingPattern) ToPdfObject

func (p *PdfTilingPattern) ToPdfObject() core.PdfObject

ToPdfObject returns the PDF representation of the tiling pattern.

type PdfWriter

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

PdfWriter handles outputing PDF content.

func NewPdfWriter

func NewPdfWriter() PdfWriter

NewPdfWriter initializes a new PdfWriter.

func (*PdfWriter) AddOutlineTree

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

AddOutlineTree adds outlines to a PDF file.

func (*PdfWriter) AddPage

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

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

func (*PdfWriter) Encrypt

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

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

func (*PdfWriter) GetOptimizer

func (w *PdfWriter) GetOptimizer() Optimizer

GetOptimizer returns current PDF optimizer.

func (*PdfWriter) SetForms

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

SetForms sets the Acroform for a PDF file.

func (*PdfWriter) SetNamedDestinations

func (w *PdfWriter) SetNamedDestinations(names core.PdfObject) error

SetNamedDestinations sets the Names entry in the PDF catalog. See section 12.3.2.3 "Named Destinations" (p. 367 PDF32000_2008).

func (*PdfWriter) SetOCProperties

func (w *PdfWriter) SetOCProperties(ocProperties core.PdfObject) error

SetOCProperties sets the optional content properties.

func (*PdfWriter) SetOptimizer

func (w *PdfWriter) SetOptimizer(optimizer Optimizer)

SetOptimizer sets the optimizer to optimize PDF before writing.

func (*PdfWriter) SetVersion

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

SetVersion sets the PDF version of the output file.

func (*PdfWriter) Write

func (w *PdfWriter) Write(writer io.Writer) error

Write writes out the PDF.

type SignatureHandler

type SignatureHandler interface {
	IsApplicable(sig *PdfSignature) bool
	Validate(sig *PdfSignature, digest Hasher) (SignatureValidationResult, error)
	// InitSignature sets the PdfSignature parameters.
	InitSignature(*PdfSignature) error
	NewDigest(sig *PdfSignature) (Hasher, error)
	Sign(sig *PdfSignature, digest Hasher) error
}

SignatureHandler interface defines the common functionality for PDF signature handlers, which need to be capable of validating digital signatures and signing PDF documents.

type SignatureValidationResult

type SignatureValidationResult struct {
	// List of errors when validating the signature.
	Errors      []string
	IsSigned    bool
	IsVerified  bool
	IsTrusted   bool
	Fields      []*PdfField
	Name        string
	Date        PdfDate
	Reason      string
	Location    string
	ContactInfo string
}

SignatureValidationResult defines the response from the signature validation handler.

func (SignatureValidationResult) String

func (v SignatureValidationResult) String() string

type StdFontName

type StdFontName = fonts.StdFontName

StdFontName represents name of a standard font.

type WatermarkImageOptions

type WatermarkImageOptions struct {
	Alpha               float64
	FitToWidth          bool
	PreserveAspectRatio bool
}

WatermarkImageOptions contains options for configuring the watermark process.

type XObjectForm

type XObjectForm struct {
	Filter core.StreamEncoder

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

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

XObjectForm (Table 95 in 8.10.2).

func NewXObjectForm

func NewXObjectForm() *XObjectForm

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

func NewXObjectFormFromStream

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

NewXObjectFormFromStream builds the Form XObject from a stream object. TODO: Should this be exposed? Consider different access points.

func (*XObjectForm) GetContainingPdfObject

func (xform *XObjectForm) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the XObject Form's containing object (indirect object).

func (*XObjectForm) GetContentStream

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

GetContentStream returns the XObject Form's content stream.

func (*XObjectForm) SetContentStream

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

SetContentStream updates 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

func (xform *XObjectForm) ToPdfObject() core.PdfObject

ToPdfObject returns a stream object.

type XObjectImage

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

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

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

func NewXObjectImage

func NewXObjectImage() *XObjectImage

NewXObjectImage returns a new XObjectImage.

func NewXObjectImageFromImage

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

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

func NewXObjectImageFromStream

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

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

func UpdateXObjectImageFromImage

func UpdateXObjectImageFromImage(xobjIn *XObjectImage, img *Image, cs PdfColorspace,
	encoder core.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

func (ximg *XObjectImage) GetContainingPdfObject() core.PdfObject

GetContainingPdfObject returns the container of the image object (indirect object).

func (*XObjectImage) SetFilter

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

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

func (*XObjectImage) SetImage

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

SetImage updates XObject Image with new image data.

func (*XObjectImage) ToImage

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

ToImage converts an object to an Image which can be transformed or saved out. The image data is decoded and the Image returned.

func (*XObjectImage) ToPdfObject

func (ximg *XObjectImage) ToPdfObject() core.PdfObject

ToPdfObject returns a stream object.

type XObjectType

type XObjectType int

XObjectType represents the type of an XObject.

const (
	XObjectTypeUndefined XObjectType = iota
	XObjectTypeImage
	XObjectTypeForm
	XObjectTypePS
	XObjectTypeUnknown
)

XObject types.

Directories

Path Synopsis
internal
fonts
Package fonts is used for internal representation for working with fonts in PDF.
Package fonts is used for internal representation for working with fonts in PDF.
Package sighandler implements digital signature handlers for PDF signature validation and signing.
Package sighandler implements digital signature handlers for PDF signature validation and signing.

Jump to

Keyboard shortcuts

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