Documentation
¶
Overview ¶
Package core is part of the go-fastreport library, a pure Go port of FastReport .NET.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array is a PDF array object that holds an ordered list of PDF Objects.
PDF representation:
[ val1 val2 val3 ]
type Boolean ¶
type Boolean struct {
// Value is the Go boolean value.
Value bool
}
Boolean is a PDF boolean object.
PDF representation: true or false
func NewBoolean ¶
NewBoolean returns a Boolean with the given value.
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is a PDF dictionary object. Keys are PDF Name values (without the leading slash) and values are any PDF Object. Entries are iterated in insertion order, which ensures deterministic output.
PDF representation:
<< /Key1 Value1 /Key2 Value2 >>
func NewDictionary ¶
func NewDictionary() *Dictionary
NewDictionary returns an empty, ready-to-use Dictionary.
func (*Dictionary) Add ¶
func (d *Dictionary) Add(key string, value Object) *Dictionary
Add inserts or replaces the entry with the given key. The key must be supplied without a leading slash (e.g. "Type", not "/Type"). Add returns the receiver so calls can be chained.
func (*Dictionary) Get ¶
func (d *Dictionary) Get(key string) Object
Get returns the value for key, or nil if the key is not present.
func (*Dictionary) Len ¶
func (d *Dictionary) Len() int
Len returns the number of entries in the dictionary.
type IndirectObject ¶
type IndirectObject struct {
// Number is the 1-based object number assigned by the PDF writer.
Number int
// Generation is almost always 0 for newly created objects.
Generation int
// Value is the PDF object contained in this indirect wrapper.
Value Object
}
IndirectObject wraps an Object with a PDF object number and generation number, producing the "N G obj … endobj" block used in PDF cross-reference tables.
Example output for Number=3, Generation=0:
3 0 obj …value… endobj
func (*IndirectObject) Reference ¶
func (o *IndirectObject) Reference() string
Reference writes the indirect reference token "N G R" for this object. This is a convenience helper for callers that need to refer to the object from elsewhere in the PDF without embedding the full indirect-object block.
type Name ¶
type Name struct {
// Value is the name without the leading slash.
Value string
}
Name is a PDF name object. In PDF syntax a name is prefixed with a forward slash and non-alphanumeric characters are encoded as "#XX" where XX is the uppercase hexadecimal byte value.
PDF representation: /FlateDecode or /my#20name
type Numeric ¶
type Numeric struct {
// Value holds the numeric value for both integer and real cases.
Value float64
// IsInt selects integer output (no decimal point) when true.
IsInt bool
}
Numeric is a PDF numeric object. It can represent either an integer or a real (floating-point) number.
PDF representation:
42 (integer) 3.1400 (real, 4 decimal places)
type Object ¶
type Object interface {
io.WriterTo
// Type returns a string tag for the concrete type, useful for debugging.
Type() ObjectType
}
Object is the base interface implemented by every PDF primitive. WriteTo writes the PDF textual representation of the object to w and returns the number of bytes written together with any write error.
type ObjectType ¶
type ObjectType string
ObjectType is a string tag identifying the kind of PDF object.
const ( TypeIndirect ObjectType = "indirect" TypeDictionary ObjectType = "dictionary" TypeArray ObjectType = "array" TypeStream ObjectType = "stream" TypeString ObjectType = "string" TypeName ObjectType = "name" TypeNumeric ObjectType = "numeric" TypeBoolean ObjectType = "boolean" TypeNull ObjectType = "null" )
PDF object type constants used for debugging and type assertions.
const TypeRef ObjectType = "ref"
TypeRef is the ObjectType tag for an indirect-reference object.
type Ref ¶
type Ref struct {
// Value is the complete reference string, e.g. "5 0 R".
Value string
}
Ref is a PDF indirect-reference token, e.g. "5 0 R". Use NewRef(obj) to create one from an IndirectObject.
func NewRef ¶
func NewRef(obj *IndirectObject) *Ref
NewRef creates a Ref pointing at the given indirect object.
type Stream ¶
type Stream struct {
// Dict holds auxiliary dictionary entries (e.g. /Type, /Subtype).
// /Length and, when Compressed is true, /Filter are managed automatically.
Dict *Dictionary
// Data is the raw (uncompressed) stream content.
Data []byte
// Compressed controls whether the data is zlib-compressed on output.
Compressed bool
}
Stream is a PDF stream object: a Dictionary followed by a block of binary data delimited by "stream" and "endstream" keywords.
When Compressed is true the Data payload is deflated with zlib before writing and the /Filter /FlateDecode and /Length entries are set automatically. When Compressed is false the raw Data bytes are written and only /Length is set.
PDF representation (compressed):
<< /Filter /FlateDecode /Length N >> stream …compressed bytes… endstream
type String ¶
type String struct {
// Value is the Go string to be encoded.
Value string
// IsHex selects the hex representation when true; parenthesised otherwise.
IsHex bool
}
String is a PDF string object. It can be rendered either as a parenthesised literal string or as an angle-bracket hex string.
Literal representation: (Hello\nWorld) Hex representation: <FEFF00480065006C006C006F>
In both cases the string value is first converted to a big-endian UTF-16 sequence with a BOM (0xFEFF), matching the behaviour of the original C# implementation.