Documentation ¶
Index ¶
- Constants
- Variables
- func AnchorPosition(a Anchor, r *Rectangle, w, h float64) (x float64, y float64)
- func BestFitRectIntoRect(rSrc, rDest *Rectangle, enforceOrient, scaleUp bool) (w, h, dx, dy, rot float64)
- func ByteForOctalString(octalBytes string) (b byte)
- func CP1252ToUTF8(s string) string
- func DateString(t time.Time) string
- func DateTime(s string, relaxed bool) (time.Time, bool)
- func DecodeName(s string) (string, error)
- func DecodeUTF16String(s string) (string, error)
- func EncodeName(s string) string
- func EncodeUTF16String(s string) string
- func EqualSlices(a, b []string) bool
- func Escape(s string) (*string, error)
- func EscapeUTF16String(s string) (*string, error)
- func HexLiteralToString(hl HexLiteral) (string, error)
- func IndRefMemberOf(i IndirectRef, arr Array) bool
- func IntMemberOf(i int, list []int) bool
- func IsStringUTF16BE(s string) bool
- func IsUTF16BE(b []byte) bool
- func MemberOf(s string, list []string) bool
- func NormalizeCoord(x, y float64, r *Rectangle, origin Corner, absolute bool) (float64, float64)
- func NormalizeOffset(x, y float64, origin Corner) (float64, float64)
- func Reverse(s string) string
- func StringLiteralToString(sl StringLiteral) (string, error)
- func StringOrHexLiteral(obj Object) (*string, error)
- func ToUserSpace(f float64, unit DisplayUnit) float64
- func UTF8ToCP1252(s string) string
- func Unescape(s string) ([]byte, error)
- type Anchor
- type Array
- type Boolean
- type ByteSize
- type Corner
- type DecodeLazyObjectStreamObjectFunc
- type Dict
- func (d Dict) ArrayEntry(key string) Array
- func (d Dict) BooleanEntry(key string) *bool
- func (d Dict) Clone() Object
- func (d Dict) Delete(key string) (value Object)
- func (d Dict) DictEntry(key string) Dict
- func (d Dict) Entry(dictName, key string, required bool) (Object, error)
- func (d Dict) Find(key string) (Object, bool)
- func (d Dict) First() *int
- func (d Dict) HexLiteralEntry(key string) *HexLiteral
- func (d *Dict) Increment(key string) error
- func (d *Dict) IncrementBy(key string, i int) error
- func (d Dict) Index() Array
- func (d Dict) IndirectRefEntry(key string) *IndirectRef
- func (d Dict) Insert(k string, v Object) bool
- func (d Dict) InsertBool(key string, value bool)
- func (d Dict) InsertFloat(key string, value float32)
- func (d Dict) InsertInt(key string, value int)
- func (d Dict) InsertName(key, value string)
- func (d Dict) InsertString(key, value string)
- func (d Dict) Int64Entry(key string) *int64
- func (d Dict) IntEntry(key string) *int
- func (d Dict) IsLinearizationParmDict() bool
- func (d Dict) IsObjStm() bool
- func (d Dict) IsPage() bool
- func (d Dict) Len() int
- func (d Dict) Length() (*int64, *int)
- func (d Dict) N() *int
- func (d Dict) NameEntry(key string) *string
- func (d Dict) NewIDForPrefix(prefix string, i int) string
- func (d Dict) PDFString() string
- func (d Dict) Prev() *int64
- func (d Dict) Size() *int
- func (d Dict) StreamDictEntry(key string) *StreamDict
- func (d Dict) String() string
- func (d Dict) StringEntry(key string) *string
- func (d Dict) StringEntryBytes(key string) ([]byte, error)
- func (d Dict) StringLiteralEntry(key string) *StringLiteral
- func (d Dict) StringOrHexLiteralEntry(key string) (*string, error)
- func (d Dict) Subtype() *string
- func (d Dict) Type() *string
- func (d Dict) Update(key string, value Object)
- func (d Dict) W() Array
- type Dim
- type DisplayUnit
- type Float
- type HAlignment
- type HexLiteral
- type IndirectRef
- type IntSet
- type Integer
- type LazyObjectStreamObject
- type LineJoinStyle
- type Name
- type Object
- type ObjectStreamDict
- type Orientation
- type PDFFilter
- type Point
- type QuadLiteral
- type QuadPoints
- type Rectangle
- func (r Rectangle) Array() Array
- func (r Rectangle) AspectRatio() float64
- func (r Rectangle) Center() Point
- func (r Rectangle) Clone() *Rectangle
- func (r Rectangle) Contains(p Point) bool
- func (r *Rectangle) ConvertToUnit(unit DisplayUnit) *Rectangle
- func (r Rectangle) CroppedCopy(margin float64) *Rectangle
- func (r Rectangle) Dimensions() Dim
- func (r Rectangle) Equals(r2 Rectangle) bool
- func (r Rectangle) FitsWithin(r2 *Rectangle) bool
- func (r Rectangle) Format(unit DisplayUnit) string
- func (r Rectangle) Height() float64
- func (r Rectangle) Landscape() bool
- func (r Rectangle) Portrait() bool
- func (r Rectangle) ScaledHeight(w float64) float64
- func (r Rectangle) ScaledWidth(h float64) float64
- func (r Rectangle) ShortString() string
- func (r Rectangle) String() string
- func (r Rectangle) ToCentimetres() *Rectangle
- func (r Rectangle) ToInches() *Rectangle
- func (r Rectangle) ToMillimetres() *Rectangle
- func (r *Rectangle) Translate(dx, dy float64)
- func (r Rectangle) Width() float64
- type RelPosition
- type StreamDict
- type StringLiteral
- type StringSet
- type VAlignment
- type XRefStreamDict
Constants ¶
const ( EolLF = "\x0A" EolCR = "\x0D" EolCRLF = "\x0D\x0A" )
Supported line delimiters
const FreeHeadGeneration = 65535
FreeHeadGeneration is the predefined generation number for the head of the free list.
Variables ¶
var ErrInvalidUTF16BE = errors.New("pdfcpu: invalid UTF-16BE detected")
ErrInvalidUTF16BE represents an error that gets raised for invalid UTF-16BE byte sequences.
var PaperSize = map[string]*Dim{}/* 150 elements not displayed */
PaperSize is a map of known paper sizes in user units (=72 dpi pixels).
Functions ¶
func AnchorPosition ¶
func BestFitRectIntoRect ¶
func ByteForOctalString ¶
Convert a 1,2 or 3 digit unescaped octal string into the corresponding byte value.
func DateString ¶
DateString returns a string representation of t.
func DecodeName ¶
DecodeName applies name decoding according to PDF spec.
func DecodeUTF16String ¶
DecodeUTF16String decodes a UTF16BE string from a hex string.
func EncodeName ¶
EncodeName applies name encoding according to PDF spec.
func EncodeUTF16String ¶
func EqualSlices ¶
func EscapeUTF16String ¶
func HexLiteralToString ¶
func HexLiteralToString(hl HexLiteral) (string, error)
HexLiteralToString returns a possibly UTF16 encoded string for a hex string.
func IndRefMemberOf ¶
func IndRefMemberOf(i IndirectRef, arr Array) bool
IntMemberOf returns true if list contains i.
func IntMemberOf ¶
IntMemberOf returns true if list contains i.
func IsStringUTF16BE ¶
IsStringUTF16BE checks a string for Big Endian byte order BOM.
func NormalizeCoord ¶
NormalizeCoord transfers P(x,y) from pdfcpu user space into PDF user space, which uses a coordinate system with origin in the lower left corner of r.
pdfcpu user space coordinate systems have the origin in one of four corners of r:
LowerLeft corner (default = PDF user space)
x extends to the right, y extends upward
LowerRight corner:
x extends to the left, y extends upward
UpperLeft corner:
x extends to the right, y extends downward
UpperRight corner:
x extends to the left, y extends downward
func NormalizeOffset ¶
Normalize offset transfers x and y into offsets in the PDF user space.
func StringLiteralToString ¶
func StringLiteralToString(sl StringLiteral) (string, error)
StringLiteralToString returns the best possible string rep for a string literal.
func StringOrHexLiteral ¶
func ToUserSpace ¶
func ToUserSpace(f float64, unit DisplayUnit) float64
Types ¶
type Anchor ¶
type Anchor int
Anchor represents symbolic positions within a rectangular region.
const ( TopLeft Anchor = iota TopCenter TopRight Left Center // default Right BottomLeft BottomCenter BottomRight Full // special case, no anchor needed, imageSize = pageSize )
These are the defined anchors for relative positioning.
func ParseAnchor ¶
func ParsePositionAnchor ¶
type Array ¶
type Array []Object
Array represents a PDF array object.
func NewHexLiteralArray ¶
NewHexLiteralArray returns a PDFArray with HexLiteralLiteral entries.
func NewIntegerArray ¶
NewIntegerArray returns a PDFArray with Integer entries.
func NewNameArray ¶
NewNameArray returns a PDFArray with Name entries.
func NewNumberArray ¶
NewNumberArray returns a PDFArray with Float entries.
func NewStringLiteralArray ¶
NewStringLiteralArray returns a PDFArray with StringLiteral entries.
type Boolean ¶
type Boolean bool
Boolean represents a PDF boolean object.
type Dict ¶
Dict represents a PDF dict object.
func (Dict) ArrayEntry ¶
ArrayEntry expects and returns a Array entry for given key.
func (Dict) BooleanEntry ¶
BooleanEntry expects and returns a BooleanEntry for given key.
func (Dict) HexLiteralEntry ¶
func (d Dict) HexLiteralEntry(key string) *HexLiteral
HexLiteralEntry returns a HexLiteral object for given key.
func (*Dict) IncrementBy ¶
IncrementBy increments the integer value for given key by i.
func (Dict) IndirectRefEntry ¶
func (d Dict) IndirectRefEntry(key string) *IndirectRef
IndirectRefEntry returns an indirectRefEntry for given key for this dictionary.
func (Dict) InsertBool ¶
InsertBool adds a new bool entry to this PDFDict.
func (Dict) InsertFloat ¶
InsertFloat adds a new float entry to this PDFDict.
func (Dict) InsertName ¶
InsertName adds a new name entry to this PDFDict.
func (Dict) InsertString ¶
InsertString adds a new string entry to this PDFDict.
func (Dict) Int64Entry ¶
Int64Entry expects and returns a Integer entry representing an int64 value for given key.
func (Dict) IsLinearizationParmDict ¶
IsLinearizationParmDict returns true if this dict has an int entry for key "Linearized".
func (Dict) Length ¶
Length returns a *int64 for entry with key "Length". Stream length may be referring to an indirect object.
func (Dict) NewIDForPrefix ¶
NewIDForPrefix returns next id with prefix.
func (Dict) PDFString ¶
PDFString returns a string representation as found in and written to a PDF file.
func (Dict) StreamDictEntry ¶
func (d Dict) StreamDictEntry(key string) *StreamDict
StreamDictEntry expects and returns a StreamDict entry for given key. unused.
func (Dict) StringEntry ¶
StringEntry expects and returns a StringLiteral entry for given key.
func (Dict) StringEntryBytes ¶
StringEntryBytes returns the byte slice representing the string value for key.
func (Dict) StringLiteralEntry ¶
func (d Dict) StringLiteralEntry(key string) *StringLiteral
StringLiteralEntry returns a StringLiteral object for given key.
func (Dict) StringOrHexLiteralEntry ¶
type Dim ¶
Dim represents the dimensions of a rectangular view medium like a PDF page, a sheet of paper or an image grid in user space, inches, centimetres or millimetres.
func (Dim) AspectRatio ¶
AspectRatio returns the relation between width and height.
func (Dim) ConvertToUnit ¶
func (d Dim) ConvertToUnit(unit DisplayUnit) Dim
ConvertToUnit converts d to unit.
func (Dim) ToCentimetres ¶
ToCentimetres converts d to centimetres.
func (Dim) ToMillimetres ¶
ToMillimetres converts d to millimetres.
type DisplayUnit ¶
type DisplayUnit int
DisplayUnit is the metric unit used to output paper sizes.
const ( POINTS DisplayUnit = iota INCHES CENTIMETRES MILLIMETRES )
Options for display unit in effect.
type Float ¶
type Float float64
Float represents a PDF float object.
type HAlignment ¶
type HAlignment int
HAlignment represents the horizontal alignment of text.
const ( AlignLeft HAlignment = iota AlignCenter AlignRight AlignJustify )
These are the options for horizontal aligned text.
func ParseHorAlignment ¶
func ParseHorAlignment(s string) (HAlignment, error)
type HexLiteral ¶
type HexLiteral string
HexLiteral represents a PDF hex literal object.
func NewHexLiteral ¶
func NewHexLiteral(b []byte) HexLiteral
NewHexLiteral creates a new HexLiteral for b..
func (HexLiteral) Bytes ¶
func (hexliteral HexLiteral) Bytes() ([]byte, error)
Bytes returns the byte representation.
func (HexLiteral) Clone ¶
func (hexliteral HexLiteral) Clone() Object
Clone returns a clone of hexliteral.
func (HexLiteral) PDFString ¶
func (hexliteral HexLiteral) PDFString() string
PDFString returns the string representation as found in and written to a PDF file.
func (HexLiteral) String ¶
func (hexliteral HexLiteral) String() string
func (HexLiteral) Value ¶
func (hexliteral HexLiteral) Value() string
Value returns a string value for this PDF object.
type IndirectRef ¶
IndirectRef represents a PDF indirect object.
func NewIndirectRef ¶
func NewIndirectRef(objectNumber, generationNumber int) *IndirectRef
NewIndirectRef returns a new PDFIndirectRef object.
func (IndirectRef) PDFString ¶
func (ir IndirectRef) PDFString() string
PDFString returns a string representation as found in and written to a PDF file.
func (IndirectRef) String ¶
func (ir IndirectRef) String() string
type Integer ¶
type Integer int
Integer represents a PDF integer object.
type LazyObjectStreamObject ¶
type LazyObjectStreamObject struct {
// contains filtered or unexported fields
}
func (LazyObjectStreamObject) Clone ¶
func (l LazyObjectStreamObject) Clone() Object
func (*LazyObjectStreamObject) DecodedObject ¶
func (l *LazyObjectStreamObject) DecodedObject(c context.Context) (Object, error)
func (*LazyObjectStreamObject) GetData ¶
func (l *LazyObjectStreamObject) GetData() ([]byte, error)
func (LazyObjectStreamObject) PDFString ¶
func (l LazyObjectStreamObject) PDFString() string
func (LazyObjectStreamObject) String ¶
func (l LazyObjectStreamObject) String() string
type LineJoinStyle ¶
type LineJoinStyle int
LineJoinStyle represents the shape to be used at the corners of paths that are stroked (see 8.4.3.4)
const ( LJMiter LineJoinStyle = iota LJRound LJBevel )
Render mode
type Name ¶
type Name string
Name represents a PDF name object.
type Object ¶
Object defines an interface for all Objects.
func NewLazyObjectStreamObject ¶
func NewLazyObjectStreamObject(osd *ObjectStreamDict, startOffset, endOffset int, decodeFunc DecodeLazyObjectStreamObjectFunc) Object
type ObjectStreamDict ¶
type ObjectStreamDict struct { StreamDict Prolog []byte ObjCount int FirstObjOffset int ObjArray Array }
ObjectStreamDict represents a object stream dictionary.
func NewObjectStreamDict ¶
func NewObjectStreamDict() *ObjectStreamDict
NewObjectStreamDict creates a new ObjectStreamDict object.
func (*ObjectStreamDict) AddObject ¶
func (osd *ObjectStreamDict) AddObject(objNumber int, pdfString string) error
AddObject adds another object to this object stream. Relies on decoded content!
func (*ObjectStreamDict) Finalize ¶
func (osd *ObjectStreamDict) Finalize()
Finalize prepares the final content of the objectstream.
func (*ObjectStreamDict) IndexedObject ¶
func (osd *ObjectStreamDict) IndexedObject(index int) (Object, error)
IndexedObject returns the object at given index from a ObjectStreamDict.
type Orientation ¶
type Orientation int
TODO Refactor because of orientation in nup.go
const ( Horizontal Orientation = iota Vertical )
type QuadLiteral ¶
type QuadLiteral struct {
P1, P2, P3, P4 Point
}
QuadLiteral is a polygon with four edges and four vertices. The four vertices are assumed to be specified in counter clockwise order.
func (QuadLiteral) Array ¶
func (ql QuadLiteral) Array() Array
Array returns the PDF representation of ql.
func (QuadLiteral) EnclosingRectangle ¶
func (ql QuadLiteral) EnclosingRectangle(f float64) *Rectangle
EnclosingRectangle calculates the rectangle enclosing ql's vertices at a distance f.
type QuadPoints ¶
type QuadPoints []QuadLiteral
QuadPoints is an array of 8 × n numbers specifying the coordinates of n quadrilaterals in default user space.
func (*QuadPoints) AddQuadLiteral ¶
func (qp *QuadPoints) AddQuadLiteral(ql QuadLiteral)
AddQuadLiteral adds a quadliteral to qp.
func (*QuadPoints) Array ¶
func (qp *QuadPoints) Array() Array
Array returns the PDF representation of qp.
type Rectangle ¶
Rectangle represents a rectangular region in userspace.
func NewRectangle ¶
NewRectangle returns a new rectangle for given corner coordinates.
func RectForDim ¶
RectForDim returns a new rectangle for given dimensions.
func RectForFormat ¶
RectForFormat returns a new rectangle for given format.
func RectForWidthAndHeight ¶
RectForWidthAndHeight returns a new rectangle for given dimensions.
func (Rectangle) AspectRatio ¶
AspectRatio returns the relation between width and height of a rectangle.
func (*Rectangle) ConvertToUnit ¶
func (r *Rectangle) ConvertToUnit(unit DisplayUnit) *Rectangle
ConvertToUnit converts r to unit.
func (Rectangle) CroppedCopy ¶
CroppedCopy returns a copy of r with applied margin..
func (Rectangle) Dimensions ¶
Dimensions returns r's dimensions.
func (Rectangle) FitsWithin ¶
FitsWithin returns true if rectangle r fits within rectangle r2.
func (Rectangle) Format ¶
func (r Rectangle) Format(unit DisplayUnit) string
Format returns r's details converted into unit.
func (Rectangle) ScaledHeight ¶
ScaledHeight returns the height for given width according to r's aspect ratio.
func (Rectangle) ScaledWidth ¶
ScaledWidth returns the width for given height according to r's aspect ratio.
func (Rectangle) ShortString ¶
ShortString returns a compact string representation for r.
func (Rectangle) ToCentimetres ¶
ToCentimetres converts r to centimetres.
func (Rectangle) ToMillimetres ¶
ToMillimetres converts r to millimetres.
type RelPosition ¶
type RelPosition int
RelPosition represents the relative position of a text field's label.
const ( RelPosLeft RelPosition = iota RelPosRight RelPosTop RelPosBottom )
These are the options for relative label positions.
func ParseRelPosition ¶
func ParseRelPosition(s string) (RelPosition, error)
type StreamDict ¶
type StreamDict struct { Dict StreamOffset int64 StreamLength *int64 StreamLengthObjNr *int FilterPipeline []PDFFilter Raw []byte // Encoded Content []byte // Decoded //DCTImage image.Image IsPageContent bool CSComponents int }
StreamDict represents a PDF stream dict object.
func NewStreamDict ¶
func NewStreamDict(d Dict, streamOffset int64, streamLength *int64, streamLengthObjNr *int, filterPipeline []PDFFilter) StreamDict
NewStreamDict creates a new PDFStreamDict for given PDFDict, stream offset and length.
func (*StreamDict) Decode ¶
func (sd *StreamDict) Decode() error
Decode applies sd's filter pipeline to sd.Raw in order to produce sd.Content.
func (*StreamDict) DecodeLength ¶
func (sd *StreamDict) DecodeLength(maxLen int64) ([]byte, error)
func (*StreamDict) Encode ¶
func (sd *StreamDict) Encode() error
Encode applies sd's filter pipeline to sd.Content in order to produce sd.Raw.
func (StreamDict) HasSoleFilterNamed ¶
func (sd StreamDict) HasSoleFilterNamed(filterName string) bool
HasSoleFilterNamed returns true if sd has a filterPipeline with 1 filter named filterName.
func (StreamDict) Image ¶
func (sd StreamDict) Image() bool
type StringLiteral ¶
type StringLiteral string
StringLiteral represents a PDF string literal object.
func (StringLiteral) Clone ¶
func (stringliteral StringLiteral) Clone() Object
Clone returns a clone of stringLiteral.
func (StringLiteral) PDFString ¶
func (stringliteral StringLiteral) PDFString() string
PDFString returns a string representation as found in and written to a PDF file.
func (StringLiteral) String ¶
func (stringliteral StringLiteral) String() string
func (StringLiteral) Value ¶
func (stringliteral StringLiteral) Value() string
Value returns a string value for this PDF object.
type StringSet ¶
StringSet is a set of strings.
func NewStringSet ¶
NewStringSet returns a new StringSet for slice.
type VAlignment ¶
type VAlignment int
VAlignment represents the vertical alignment of text.
const ( AlignBaseline VAlignment = iota AlignTop AlignMiddle AlignBottom )
These are the options for vertical aligned text.
type XRefStreamDict ¶
type XRefStreamDict struct { StreamDict Size int Objects []int W [3]int PreviousOffset *int64 }
XRefStreamDict represents a cross reference stream dictionary.