contentstream

package
v3.0.0-...-55e877b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package contentstream provides functionality for parsing and creating content streams for PDF files.

For processing and manipulating content streams, it allows parse the content stream into a list of operands that can then be processed further for rendering or extraction of information. The ContentStreamProcessor offers a basic engine for processing the content stream and can be used to render or modify the contents.

For creating content streams, see NewContentCreator. It allows adding multiple operands and then can be converted to a string for embedding in a PDF file.

The contentstream package uses the core and model packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOperand = _b.New("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064")
)

Functions

This section is empty.

Types

type ContentCreator

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

ContentCreator is a builder for PDF content streams.

func NewContentCreator

func NewContentCreator() *ContentCreator

NewContentCreator returns a new initialized ContentCreator.

func (*ContentCreator) AddOperand

AddOperand adds a specified operand.

func (*ContentCreator) Add_B

func (_agd *ContentCreator) Add_B() *ContentCreator

Add_B appends 'B' operand to the content stream: Fill and then stroke the path (nonzero winding number rule).

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_BMC

func (_ffa *ContentCreator) Add_BMC(tag _ed.PdfObjectName) *ContentCreator

Add_BMC appends 'BMC' operand to the content stream: Begins a marked-content sequence terminated by a balancing EMC operator. `tag` shall be a name object indicating the role or significance of the sequence.

See section 14.6 "Marked Content" and Table 320 (p. 561 PDF32000_2008).

func (*ContentCreator) Add_BT

func (_bfa *ContentCreator) Add_BT() *ContentCreator

Add_BT appends 'BT' operand to the content stream: Begin text.

See section 9.4 "Text Objects" and Table 107 (p. 256 PDF32000_2008).

func (*ContentCreator) Add_B_starred

func (_feg *ContentCreator) Add_B_starred() *ContentCreator

Add_B_starred appends 'B*' operand to the content stream: Fill and then stroke the path (even-odd rule).

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_CS

func (_edb *ContentCreator) Add_CS(name _ed.PdfObjectName) *ContentCreator

Add_CS appends 'CS' operand to the content stream: Set the current colorspace for stroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_Do

func (_aba *ContentCreator) Add_Do(name _ed.PdfObjectName) *ContentCreator

Add_Do adds 'Do' operation to the content stream: Displays an XObject (image or form) specified by `name`.

See section 8.8 "External Objects" and Table 87 (pp. 209-220 PDF32000_2008).

func (*ContentCreator) Add_EMC

func (_bad *ContentCreator) Add_EMC() *ContentCreator

Add_EMC appends 'EMC' operand to the content stream: Ends a marked-content sequence.

See section 14.6 "Marked Content" and Table 320 (p. 561 PDF32000_2008).

func (*ContentCreator) Add_ET

func (_abeb *ContentCreator) Add_ET() *ContentCreator

Add_ET appends 'ET' operand to the content stream: End text.

See section 9.4 "Text Objects" and Table 107 (p. 256 PDF32000_2008).

func (*ContentCreator) Add_G

func (_dcg *ContentCreator) Add_G(gray float64) *ContentCreator

Add_G appends 'G' operand to the content stream: Set the stroking colorspace to DeviceGray and sets the gray level (0-1).

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_J

func (_fab *ContentCreator) Add_J(lineCapStyle string) *ContentCreator

Add_J adds 'J' operand to the content stream: Set the line cap style (graphics state).

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_K

func (_ceg *ContentCreator) Add_K(c, m, y, k float64) *ContentCreator

Add_K appends 'K' operand to the content stream: Set the stroking colorspace to DeviceCMYK and sets the c,m,y,k color (0-1 each component).

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_M

func (_dgg *ContentCreator) Add_M(miterlimit float64) *ContentCreator

Add_M adds 'M' operand to the content stream: Set the miter limit (graphics state).

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_Q

func (_dba *ContentCreator) Add_Q() *ContentCreator

Add_Q adds 'Q' operand to the content stream: Pops the most recently stored state from the stack.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_RG

func (_gbd *ContentCreator) Add_RG(r, g, b float64) *ContentCreator

Add_RG appends 'RG' operand to the content stream: Set the stroking colorspace to DeviceRGB and sets the r,g,b colors (0-1 each).

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_S

func (_bdc *ContentCreator) Add_S() *ContentCreator

Add_S appends 'S' operand to the content stream: Stroke the path.

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_SC

func (_afb *ContentCreator) Add_SC(c ...float64) *ContentCreator

Add_SC appends 'SC' operand to the content stream: Set color for stroking operations. Input: c1, ..., cn.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_SCN

func (_bf *ContentCreator) Add_SCN(c ...float64) *ContentCreator

Add_SCN appends 'SCN' operand to the content stream: Same as SC but supports more colorspaces.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_SCN_pattern

func (_fbae *ContentCreator) Add_SCN_pattern(name _ed.PdfObjectName, c ...float64) *ContentCreator

Add_SCN_pattern appends 'SCN' operand to the content stream for pattern `name`: SCN with name attribute (for pattern). Syntax: c1 ... cn name SCN.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_TD

func (_gbdb *ContentCreator) Add_TD(tx, ty float64) *ContentCreator

Add_TD appends 'TD' operand to the content stream: Move to start of next line with offset (`tx`, `ty`).

See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).

func (*ContentCreator) Add_TJ

func (_aff *ContentCreator) Add_TJ(vals ..._ed.PdfObject) *ContentCreator

Add_TJ appends 'TJ' operand to the content stream: Show one or more text string. Array of numbers (displacement) and strings.

See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).

func (*ContentCreator) Add_TL

func (_ddag *ContentCreator) Add_TL(leading float64) *ContentCreator

Add_TL appends 'TL' operand to the content stream: Set leading.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Tc

func (_adf *ContentCreator) Add_Tc(charSpace float64) *ContentCreator

Add_Tc appends 'Tc' operand to the content stream: Set character spacing.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Td

func (_aed *ContentCreator) Add_Td(tx, ty float64) *ContentCreator

Add_Td appends 'Td' operand to the content stream: Move to start of next line with offset (`tx`, `ty`).

See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).

func (*ContentCreator) Add_Tf

func (_bdgg *ContentCreator) Add_Tf(fontName _ed.PdfObjectName, fontSize float64) *ContentCreator

Add_Tf appends 'Tf' operand to the content stream: Set font and font size specified by font resource `fontName` and `fontSize`.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Tj

func (_bcc *ContentCreator) Add_Tj(textstr _ed.PdfObjectString) *ContentCreator

Add_Tj appends 'Tj' operand to the content stream: Show a text string.

See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).

func (*ContentCreator) Add_Tm

func (_befg *ContentCreator) Add_Tm(a, b, c, d, e, f float64) *ContentCreator

Add_Tm appends 'Tm' operand to the content stream: Set the text line matrix.

See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).

func (*ContentCreator) Add_Tr

func (_gdb *ContentCreator) Add_Tr(render int64) *ContentCreator

Add_Tr appends 'Tr' operand to the content stream: Set text rendering mode.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Ts

func (_dcf *ContentCreator) Add_Ts(rise float64) *ContentCreator

Add_Ts appends 'Ts' operand to the content stream: Set text rise.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Tstar

func (_fece *ContentCreator) Add_Tstar() *ContentCreator

Add_Tstar appends 'T*' operand to the content stream: Move to the start of next line.

See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).

func (*ContentCreator) Add_Tw

func (_cecg *ContentCreator) Add_Tw(wordSpace float64) *ContentCreator

Add_Tw appends 'Tw' operand to the content stream: Set word spacing.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_Tz

func (_ccc *ContentCreator) Add_Tz(scale float64) *ContentCreator

Add_Tz appends 'Tz' operand to the content stream: Set horizontal scaling.

See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).

func (*ContentCreator) Add_W

func (_ffg *ContentCreator) Add_W() *ContentCreator

Add_W appends 'W' operand to the content stream: Modify the current clipping path by intersecting with the current path (nonzero winding rule).

See section 8.5.4 "Clipping Path Operators" and Table 61 (p. 146 PDF32000_2008).

func (*ContentCreator) Add_W_starred

func (_ffc *ContentCreator) Add_W_starred() *ContentCreator

Add_W_starred appends 'W*' operand to the content stream: Modify the current clipping path by intersecting with the current path (even odd rule).

See section 8.5.4 "Clipping Path Operators" and Table 61 (p. 146 PDF32000_2008).

func (*ContentCreator) Add_b

func (_dge *ContentCreator) Add_b() *ContentCreator

Add_b appends 'b' operand to the content stream: Close, fill and then stroke the path (nonzero winding number rule).

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_b_starred

func (_efg *ContentCreator) Add_b_starred() *ContentCreator

Add_b_starred appends 'b*' operand to the content stream: Close, fill and then stroke the path (even-odd winding number rule).

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_c

func (_ddg *ContentCreator) Add_c(x1, y1, x2, y2, x3, y3 float64) *ContentCreator

Add_c adds 'c' operand to the content stream: Append a Bezier curve to the current path from the current point to (x3,y3) with (x1,x1) and (x2,y2) as control points.

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_cm

func (_bef *ContentCreator) Add_cm(a, b, c, d, e, f float64) *ContentCreator

Add_cm adds 'cm' operation to the content stream: Modifies the current transformation matrix (ctm) of the graphics state.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_cs

func (_cff *ContentCreator) Add_cs(name _ed.PdfObjectName) *ContentCreator

Add_cs appends 'cs' operand to the content stream: Same as CS but for non-stroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_d

func (_ac *ContentCreator) Add_d(dashArray []int64, dashPhase int64) *ContentCreator

Add_d adds 'd' operand to the content stream: Set the line dash pattern.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_f

func (_dgfe *ContentCreator) Add_f() *ContentCreator

Add_f appends 'f' operand to the content stream: Fill the path using the nonzero winding number rule to determine fill region.

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_f_starred

func (_cad *ContentCreator) Add_f_starred() *ContentCreator

Add_f_starred appends 'f*' operand to the content stream. f*: Fill the path using the even-odd rule to determine fill region.

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_g

func (_ede *ContentCreator) Add_g(gray float64) *ContentCreator

Add_g appends 'g' operand to the content stream: Same as G but used for nonstroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_gs

func (_ge *ContentCreator) Add_gs(dictName _ed.PdfObjectName) *ContentCreator

Add_gs adds 'gs' operand to the content stream: Set the graphics state.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_h

func (_ace *ContentCreator) Add_h() *ContentCreator

Add_h appends 'h' operand to the content stream: Close the current subpath by adding a line between the current position and the starting position.

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_i

func (_gfg *ContentCreator) Add_i(flatness float64) *ContentCreator

Add_i adds 'i' operand to the content stream: Set the flatness tolerance in the graphics state.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_j

func (_fc *ContentCreator) Add_j(lineJoinStyle string) *ContentCreator

Add_j adds 'j' operand to the content stream: Set the line join style (graphics state).

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_k

func (_cgdb *ContentCreator) Add_k(c, m, y, k float64) *ContentCreator

Add_k appends 'k' operand to the content stream: Same as K but used for nonstroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_l

func (_gd *ContentCreator) Add_l(x, y float64) *ContentCreator

Add_l adds 'l' operand to the content stream: Append a straight line segment from the current point to (x,y).

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_m

func (_fec *ContentCreator) Add_m(x, y float64) *ContentCreator

Add_m adds 'm' operand to the content stream: Move the current point to (x,y).

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_n

func (_abf *ContentCreator) Add_n() *ContentCreator

Add_n appends 'n' operand to the content stream: End the path without filling or stroking.

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_q

func (_agf *ContentCreator) Add_q() *ContentCreator

Add_q adds 'q' operand to the content stream: Pushes the current graphics state on the stack.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_quote

func (_dcfg *ContentCreator) Add_quote(textstr _ed.PdfObjectString) *ContentCreator

Add_quote appends "'" operand to the content stream: Move to next line and show a string.

See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).

func (*ContentCreator) Add_quotes

func (_bg *ContentCreator) Add_quotes(textstr _ed.PdfObjectString, aw, ac float64) *ContentCreator

Add_quotes appends `"` operand to the content stream: Move to next line and show a string, using `aw` and `ac` as word and character spacing respectively.

See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).

func (*ContentCreator) Add_re

func (_gdd *ContentCreator) Add_re(x, y, width, height float64) *ContentCreator

Add_re appends 're' operand to the content stream: Append a rectangle to the current path as a complete subpath, with lower left corner (x,y).

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_rg

func (_adg *ContentCreator) Add_rg(r, g, b float64) *ContentCreator

Add_rg appends 'rg' operand to the content stream: Same as RG but used for nonstroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_ri

func (_fba *ContentCreator) Add_ri(intent _ed.PdfObjectName) *ContentCreator

Add_ri adds 'ri' operand to the content stream, which sets the color rendering intent.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_s

func (_afc *ContentCreator) Add_s() *ContentCreator

Add_s appends 's' operand to the content stream: Close and stroke the path.

See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).

func (*ContentCreator) Add_scn

func (_dec *ContentCreator) Add_scn(c ...float64) *ContentCreator

Add_scn appends 'scn' operand to the content stream: Same as SC but for nonstroking operations.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_scn_pattern

func (_bec *ContentCreator) Add_scn_pattern(name _ed.PdfObjectName, c ...float64) *ContentCreator

Add_scn_pattern appends 'scn' operand to the content stream for pattern `name`: scn with name attribute (for pattern). Syntax: c1 ... cn name scn.

See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).

func (*ContentCreator) Add_sh

func (_gbg *ContentCreator) Add_sh(name _ed.PdfObjectName) *ContentCreator

Add_sh appends 'sh' operand to the content stream: Paints the shape and colour shading described by a shading dictionary specified by `name`, subject to the current clipping path

See section 8.7.4 "Shading Patterns" and Table 77 (p. 190 PDF32000_2008).

func (*ContentCreator) Add_v

func (_fga *ContentCreator) Add_v(x2, y2, x3, y3 float64) *ContentCreator

Add_v appends 'v' operand to the content stream: Append a Bezier curve to the current path from the current point to (x3,y3) with the current point and (x2,y2) as control points.

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Add_w

func (_eeb *ContentCreator) Add_w(lineWidth float64) *ContentCreator

Add_w adds 'w' operand to the content stream, which sets the line width.

See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).

func (*ContentCreator) Add_y

func (_egb *ContentCreator) Add_y(x1, y1, x3, y3 float64) *ContentCreator

Add_y appends 'y' operand to the content stream: Append a Bezier curve to the current path from the current point to (x3,y3) with (x1, y1) and (x3,y3) as control points.

See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).

func (*ContentCreator) Bytes

func (_egf *ContentCreator) Bytes() []byte

Bytes converts the content stream operations to a content stream byte presentation, i.e. the kind that can be stored as a PDF stream or string format.

func (*ContentCreator) Operations

func (_ccf *ContentCreator) Operations() *ContentStreamOperations

Operations returns the list of operations.

func (*ContentCreator) RotateDeg

func (_faa *ContentCreator) RotateDeg(angle float64) *ContentCreator

RotateDeg applies a rotation to the transformation matrix.

func (*ContentCreator) Scale

func (_cce *ContentCreator) Scale(sx, sy float64) *ContentCreator

Scale applies x-y scaling to the transformation matrix.

func (*ContentCreator) SetNonStrokingColor

func (_cdd *ContentCreator) SetNonStrokingColor(color _ca.PdfColor) *ContentCreator

SetNonStrokingColor sets the non-stroking `color` where color can be one of PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK.

func (*ContentCreator) SetStrokingColor

func (_eggf *ContentCreator) SetStrokingColor(color _ca.PdfColor) *ContentCreator

SetStrokingColor sets the stroking `color` where color can be one of PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK.

func (*ContentCreator) String

func (_ec *ContentCreator) String() string

String is same as Bytes() except returns as a string for convenience.

func (*ContentCreator) Translate

func (_df *ContentCreator) Translate(tx, ty float64) *ContentCreator

Translate applies a simple x-y translation to the transformation matrix.

func (*ContentCreator) Wrap

func (_edf *ContentCreator) Wrap()

Wrap ensures that the contentstream is wrapped within a balanced q ... Q expression.

type ContentStreamInlineImage

type ContentStreamInlineImage struct {
	BitsPerComponent _ed.PdfObject
	ColorSpace       _ed.PdfObject
	Decode           _ed.PdfObject
	DecodeParms      _ed.PdfObject
	Filter           _ed.PdfObject
	Height           _ed.PdfObject
	ImageMask        _ed.PdfObject
	Intent           _ed.PdfObject
	Interpolate      _ed.PdfObject
	Width            _ed.PdfObject
	// contains filtered or unexported fields
}

ContentStreamInlineImage is a representation of an inline image in a Content stream. Everything between the BI and EI operands. ContentStreamInlineImage implements the core.PdfObject interface although strictly it is not a PDF object.

func NewInlineImageFromImage

func NewInlineImageFromImage(img _ca.Image, encoder _ed.StreamEncoder) (*ContentStreamInlineImage, error)

NewInlineImageFromImage makes a new content stream inline image object from an image.

func (*ContentStreamInlineImage) GetColorSpace

func (_fdcg *ContentStreamInlineImage) GetColorSpace(resources *_ca.PdfPageResources) (_ca.PdfColorspace, error)

GetColorSpace returns the colorspace of the inline image.

func (*ContentStreamInlineImage) GetEncoder

func (_bafc *ContentStreamInlineImage) GetEncoder() (_ed.StreamEncoder, error)

GetEncoder returns the encoder of the inline image.

func (*ContentStreamInlineImage) IsMask

func (_edd *ContentStreamInlineImage) IsMask() (bool, error)

IsMask checks if an image is a mask. The image mask entry in the image dictionary specifies that the image data shall be used as a stencil mask for painting in the current color. The mask data is 1bpc, grayscale.

func (*ContentStreamInlineImage) String

func (_ffd *ContentStreamInlineImage) String() string

func (*ContentStreamInlineImage) ToImage

func (_agbd *ContentStreamInlineImage) ToImage(resources *_ca.PdfPageResources) (*_ca.Image, error)

ToImage exports the inline image to Image which can be transformed or exported easily. Page resources are needed to look up colorspace information.

func (*ContentStreamInlineImage) WriteString

func (_bac *ContentStreamInlineImage) WriteString() string

WriteString outputs the object as it is to be written to file.

type ContentStreamOperation

type ContentStreamOperation struct {
	Params  []_ed.PdfObject
	Operand string
}

ContentStreamOperation represents an operation in PDF contentstream which consists of an operand and parameters.

type ContentStreamOperations

type ContentStreamOperations []*ContentStreamOperation

ContentStreamOperations is a slice of ContentStreamOperations.

func (*ContentStreamOperations) Bytes

func (_fa *ContentStreamOperations) Bytes() []byte

Bytes converts a set of content stream operations to a content stream byte presentation, i.e. the kind that can be stored as a PDF stream or string format.

func (*ContentStreamOperations) String

func (_egd *ContentStreamOperations) String() string

String returns `ops.Bytes()` as a string.

func (*ContentStreamOperations) WrapIfNeeded

func (_ga *ContentStreamOperations) WrapIfNeeded() *ContentStreamOperations

WrapIfNeeded wraps the entire contents within q ... Q. If unbalanced, then adds extra Qs at the end. Only does if needed. Ensures that when adding new content, one start with all states in the default condition.

type ContentStreamParser

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

ContentStreamParser represents a content stream parser for parsing content streams in PDFs.

func NewContentStreamParser

func NewContentStreamParser(contentStr string) *ContentStreamParser

NewContentStreamParser creates a new instance of the content stream parser from an input content stream string.

func (*ContentStreamParser) ExtractText deprecated

func (_bdg *ContentStreamParser) ExtractText() (string, error)

ExtractText parses and extracts all text data in content streams and returns as a string. Does not take into account Encoding table, the output is simply the character codes.

Deprecated: More advanced text extraction is offered in package extractor with character encoding support.

func (*ContentStreamParser) Parse

Parse parses all commands in content stream, returning a list of operation data.

func (*ContentStreamParser) ParseInlineImage

func (_fge *ContentStreamParser) ParseInlineImage() (*ContentStreamInlineImage, error)

ParseInlineImage parses an inline image from a content stream, both reading its properties and binary data. When called, "BI" has already been read from the stream. This function finishes reading through "EI" and then returns the ContentStreamInlineImage.

type ContentStreamProcessor

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

ContentStreamProcessor defines a data structure and methods for processing a content stream, keeping track of the current graphics state, and allowing external handlers to define their own functions as a part of the processing, for example rendering or extracting certain information.

func NewContentStreamProcessor

func NewContentStreamProcessor(ops []*ContentStreamOperation) *ContentStreamProcessor

NewContentStreamProcessor returns a new ContentStreamProcessor for operations `ops`.

func (*ContentStreamProcessor) AddHandler

func (_dbf *ContentStreamProcessor) AddHandler(condition HandlerConditionEnum, operand string, handler HandlerFunc)

AddHandler adds a new ContentStreamProcessor `handler` of type `condition` for `operand`.

func (*ContentStreamProcessor) Process

func (_dedg *ContentStreamProcessor) Process(resources *_ca.PdfPageResources) error

Process processes the entire list of operations. Maintains the graphics state that is passed to any handlers that are triggered during processing (either on specific operators or all).

type GraphicStateStack

type GraphicStateStack []GraphicsState

GraphicStateStack represents a stack of GraphicsState.

func (*GraphicStateStack) Pop

func (_ecee *GraphicStateStack) Pop() GraphicsState

Pop pops and returns the topmost GraphicsState off the `gsStack`.

func (*GraphicStateStack) Push

func (_bdcf *GraphicStateStack) Push(gs GraphicsState)

Push pushes `gs` on the `gsStack`.

type GraphicsState

type GraphicsState struct {
	ColorspaceStroking    _ca.PdfColorspace
	ColorspaceNonStroking _ca.PdfColorspace
	ColorStroking         _ca.PdfColor
	ColorNonStroking      _ca.PdfColor
	CTM                   _gc.Matrix
}

GraphicsState is a basic graphics state implementation for PDF processing. Initially only implementing and tracking a portion of the information specified. Easy to add more.

func (*GraphicsState) Transform

func (_acge *GraphicsState) Transform(x, y float64) (float64, float64)

Transform returns coordinates x, y transformed by the CTM.

type HandlerConditionEnum

type HandlerConditionEnum int

HandlerConditionEnum represents the type of operand content stream processor (handler). The handler may process a single specific named operand or all operands.

const (
	HandlerConditionEnumOperand HandlerConditionEnum = iota
	HandlerConditionEnumAllOperands
)

func (HandlerConditionEnum) All

func (_beca HandlerConditionEnum) All() bool

All returns true if `hce` is equivalent to HandlerConditionEnumAllOperands.

func (HandlerConditionEnum) Operand

func (_cdeg HandlerConditionEnum) Operand() bool

Operand returns true if `hce` is equivalent to HandlerConditionEnumOperand.

type HandlerFunc

type HandlerFunc func(_cab *ContentStreamOperation, _fbe GraphicsState, _aaeab *_ca.PdfPageResources) error

HandlerFunc is the function syntax that the ContentStreamProcessor handler must implement.

Directories

Path Synopsis
Package draw has handy features for defining paths which can be used to draw content on a PDF page.
Package draw has handy features for defining paths which can be used to draw content on a PDF page.

Jump to

Keyboard shortcuts

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