gofpdi

package
v0.0.0-...-3647939 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MediaBox is a bounding box that includes bleed area and crop marks
	MediaBox = "MediaBox"

	// CropBox is a bounding bos that denotes the area the page should be cropped for display
	CropBox = "CropBox"

	// BleedBox is a bounding box that includes bleed area
	BleedBox = "BleedBox"

	// TrimBox is a bounding box that dentoes the area the page should be trimmed for printing
	TrimBox = "TrimBox"

	// ArtBox is a bounding bxo that denotes an interesting part of the page
	ArtBox = "ArtBox"

	// DefaultBox is the default bounding box to use
	DefaultBox = CropBox
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array []Value

Array is a sequence of value

func (Array) Equals

func (a Array) Equals(v Value) bool

Equals checks if the value is an equivalent array

func (Array) Type

func (a Array) Type() ValueType

Type of an Array value

type Boolean

type Boolean bool

Boolean is a boolean value

func (Boolean) Equals

func (b Boolean) Equals(v Value) bool

Equals checks if the value is an equivalent boolean

func (Boolean) Type

func (b Boolean) Type() ValueType

Type of a Boolean value

type Dictionary

type Dictionary map[string]Value

Dictionary is a mapping from names to values

func (Dictionary) Equals

func (d Dictionary) Equals(v Value) bool

Equals checks if the value is an equivalent dictionary

func (Dictionary) Type

func (d Dictionary) Type() ValueType

Type of a Dictionary value

type Fpdi

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

Fpdi represents a PDF file parser which can load templates to use in other documents

func Open

func Open(file *os.File) (*Fpdi, error)

Open makes an existing PDF file usable for templates

func OpenFromFileName

func OpenFromFileName(filename string) (*Fpdi, error)

Open makes an existing PDF file usable for templates

func (*Fpdi) Close

func (td *Fpdi) Close()

Close releases references and closes the file handle of the parser

func (*Fpdi) CountPages

func (td *Fpdi) CountPages() int

CountPages returns the number of pages in this source document

func (*Fpdi) GetLastUsedPageBox

func (td *Fpdi) GetLastUsedPageBox() string

GetLastUsedPageBox returns the last used page boundary box.

func (*Fpdi) ImportPage

func (td *Fpdi) ImportPage(pageNumber int, boxName string, groupXObject bool) gofpdf.Template

ImportPage imports a single page of the source document to use as a template in another document

func (*Fpdi) Page

func (td *Fpdi) Page(pageNumber int) gofpdf.Template

Page imports a single page of the source document using default settings

type Hex

type Hex string

Hex is a hex value

func (Hex) Equals

func (h Hex) Equals(v Value) bool

Equals checks if the value is an equivalent hex value

func (Hex) Type

func (h Hex) Type() ValueType

Type of a Hex value

type Null

type Null struct{}

Null is an undefined value

func (Null) Equals

func (n Null) Equals(v Value) bool

Equals checks if the value is also null

func (Null) Type

func (n Null) Type() ValueType

Type of a Null value

type Numeric

type Numeric int64

Numeric is an integer value

func (Numeric) Equals

func (n Numeric) Equals(v Value) bool

Equals checks if the value is an equivalent number

func (Numeric) Type

func (n Numeric) Type() ValueType

Type of a Numeric value

type Object

type Object struct {
	Obj   int
	Gen   int
	Value Value
}

Object is a object

func (Object) Equals

func (r Object) Equals(v Value) bool

Equals checks if the value is also null

func (Object) Type

func (r Object) Type() ValueType

Type of a ObjectRef value

type ObjectDeclaration

type ObjectDeclaration struct {
	Obj    int
	Gen    int
	Values []Value
}

ObjectDeclaration is a object identifier

func (ObjectDeclaration) Equals

func (r ObjectDeclaration) Equals(v Value) bool

Equals checks if the value is also null

func (ObjectDeclaration) Type

func (r ObjectDeclaration) Type() ValueType

Type of a ObjectRef value

type ObjectRef

type ObjectRef struct {
	Obj int
	Gen int
}

ObjectRef is an indirect object reference

func (ObjectRef) Equals

func (r ObjectRef) Equals(v Value) bool

Equals checks if the value is also null

func (ObjectRef) Type

func (r ObjectRef) Type() ValueType

Type of a ObjectRef value

type PDFPage

type PDFPage struct {
	Dictionary
	Number int
}

PDFPage is a page extracted from an existing PDF document

type PDFParser

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

PDFParser is a high-level parser for PDF elements See fpdf_pdf_parser.php

func OpenPDFParser

func OpenPDFParser(file *os.File) (*PDFParser, error)

OpenPDFParser opens an existing PDF file and readies it

func (*PDFParser) Close

func (parser *PDFParser) Close()

Close releases references and closes the file handle of the parser

func (*PDFParser) GetPageBoxes

func (parser *PDFParser) GetPageBoxes(pageNumber int, k float64) PageBoxes

GetPageBoxes gets the all the bounding boxes for a given page

pageNumber is 1-indexed k is a scaling factor from user space units to points

type PDFTokenReader

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

PDFTokenReader is a low-level reader for the tokens in a PDF file See pdf_parser.php and pdf_context.php

func NewTokenReader

func NewTokenReader(file *os.File) (*PDFTokenReader, error)

NewTokenReader constructs a low level reader for a PDF file

func (*PDFTokenReader) Close

func (reader *PDFTokenReader) Close()

Close releases references and closes the file handle of the parser

func (*PDFTokenReader) Peek

func (reader *PDFTokenReader) Peek(n int) []byte

Peek looks ahead to get data but doesn't move the file pointer at all

func (*PDFTokenReader) PeekTokens

func (reader *PDFTokenReader) PeekTokens(n int) []Token

PeekTokens looks ahead to get tokens but doesn't move the file pointer at all

func (*PDFTokenReader) ReadByte

func (reader *PDFTokenReader) ReadByte() (byte, bool)

ReadByte gets a single byte

func (*PDFTokenReader) ReadBytes

func (reader *PDFTokenReader) ReadBytes(n int) ([]byte, bool)

ReadBytes reads up to a fixed number of bytes

func (*PDFTokenReader) ReadBytesToToken

func (reader *PDFTokenReader) ReadBytesToToken(token Token) ([]byte, bool)

ReadBytesToToken reads all bytes from current position until the next instance of the given token If the token cannot be found, returns nil

func (*PDFTokenReader) ReadLine

func (reader *PDFTokenReader) ReadLine() []byte

ReadLine gets a line of tokens

func (*PDFTokenReader) ReadLinesToToken

func (reader *PDFTokenReader) ReadLinesToToken(token Token) ([][]byte, bool)

ReadLinesToToken reads all lines from the current position until the next instance of the given token If the token cannot be found, returns nil

func (*PDFTokenReader) ReadToken

func (reader *PDFTokenReader) ReadToken() Token

ReadToken gets the next PDF token

func (*PDFTokenReader) ReadTokens

func (reader *PDFTokenReader) ReadTokens(n int) []Token

ReadTokens reads a fixed number of tokens

func (*PDFTokenReader) ReadTokensToToken

func (reader *PDFTokenReader) ReadTokensToToken(token Token) ([]Token, bool)

ReadTokensToToken reads all tokens from the current position until the next instance of the given token If the token cannot be found, returns nil

func (*PDFTokenReader) Reset

func (reader *PDFTokenReader) Reset() (int64, error)

Reset a reader to the start of the file

func (*PDFTokenReader) Seek

func (reader *PDFTokenReader) Seek(offset int64, whence int) (int64, error)

Seek to a given point in the file

func (*PDFTokenReader) SkipBytes

func (reader *PDFTokenReader) SkipBytes(n int) bool

func (*PDFTokenReader) SkipToToken

func (reader *PDFTokenReader) SkipToToken(token Token) bool

SkipToToken seeks ahead to the first instance of the given token

func (*PDFTokenReader) SplitLines

func (reader *PDFTokenReader) SplitLines(data []byte) [][]byte

SplitLines separates data into lines using the calibrated line ending

func (*PDFTokenReader) SplitTokens

func (reader *PDFTokenReader) SplitTokens(data []byte) []Token

SplitTokens separates data into tokens with PDF syntax

type PageBox

type PageBox struct {
	gofpdf.PointType
	gofpdf.SizeType
	Lower gofpdf.PointType // llx, lly
	Upper gofpdf.PointType // urx, ury
}

PageBox is the bounding box for a page

type PageBoxes

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

PageBoxes is a transient collection of the page boxes used in a document The keys are the constants: MediaBox, CrobBox, BleedBox, TrimBox, ArtBox

type Real

type Real float64

Real is a floating-point value

func (Real) Equals

func (r Real) Equals(v Value) bool

Equals checks if the value is an equivalent number

func (Real) Type

func (r Real) Type() ValueType

Type of a Real value

type Stream

type Stream []byte

Stream is a blob value

func (Stream) Equals

func (s Stream) Equals(v Value) bool

Equals checks if the value is an equivalent stream

func (Stream) GetReader

func (s Stream) GetReader() *bytes.Reader

Equals checks if the value is an equivalent stream

func (Stream) Type

func (s Stream) Type() ValueType

Type of a Stream value

type String

type String string

String is a string value

func (String) Equals

func (s String) Equals(v Value) bool

Equals checks if the value is an equivalent string

func (String) Type

func (s String) Type() ValueType

Type of a String value

type TemplatePage

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

TemplatePage is a page template, read from an existing page, that can be used in other documents.

func (*TemplatePage) Bytes

func (t *TemplatePage) Bytes() []byte

Bytes returns the actual template data, not including resources

func (*TemplatePage) ID

func (t *TemplatePage) ID() int64

ID returns the global template identifier

func (*TemplatePage) Images

func (t *TemplatePage) Images() map[string]*gofpdf.ImageInfoType

Images returns a list of the images used by this template

func (*TemplatePage) Size

Size gives the bounding dimensions of this template

func (*TemplatePage) Templates

func (t *TemplatePage) Templates() []gofpdf.Template

Templates returns a list of templates used within this template

type Token

type Token []byte

Token is a unit of PDF syntax. Not all tokens can be safely represented as strings.

func (Token) Equals

func (t Token) Equals(v Value) bool

Equals tests if the token matches a given object

func (Token) String

func (t Token) String() string

String converts a token to a string

func (Token) ToRegex

func (t Token) ToRegex() string

ToRegex creates a regular expression to match the token

func (Token) Type

func (t Token) Type() ValueType

Type of a token value

type Value

type Value interface {
	Type() ValueType
	Equals(Value) bool
}

Value is one the given types

type ValueType

type ValueType int8

ValueType is an enum of the given types

Jump to

Keyboard shortcuts

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