Documentation ¶
Index ¶
- type Context
- type FillRule
- type Gradient
- type LineCap
- type LineJoin
- type Pattern
- type TextFont
- func (tf *TextFont) BytesToCharcodes(data []byte) []textencoding.CharCode
- func (tf *TextFont) CharcodesToUnicode(charcodes []textencoding.CharCode) []rune
- func (tf *TextFont) GetCharMetrics(code textencoding.CharCode) (float64, float64, bool)
- func (tf *TextFont) GetRuneMetrics(r rune) (float64, float64, bool)
- func (tf *TextFont) WithSize(size float64, originalFont *model.PdfFont) *TextFont
- type TextState
- func (ts *TextState) ProcDQ(data []byte, aw, ac float64, ctx Context)
- func (ts *TextState) ProcQ(data []byte, ctx Context)
- func (ts *TextState) ProcTD(tx, ty float64)
- func (ts *TextState) ProcTStar()
- func (ts *TextState) ProcTd(tx, ty float64)
- func (ts *TextState) ProcTf(font *TextFont)
- func (ts *TextState) ProcTj(data []byte, ctx Context)
- func (ts *TextState) ProcTm(a, b, c, d, e, f float64)
- func (ts *TextState) Reset()
- func (ts *TextState) Translate(tx, ty float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { // Push adds the current context state on the stack. Push() // Pop removes the most recent context state from the stack. Pop() // Matrix returns the current transformation matrix. Matrix() transform.Matrix // SetMatrix modifies the transformation matrix. SetMatrix(m transform.Matrix) // Translate updates the current matrix with a translation. Translate(x, y float64) // Scale updates the current matrix with a scaling factor. // Scaling occurs about the origin. Scale(x, y float64) // Rotate updates the current matrix with a anticlockwise rotation. // Rotation occurs about the origin. Angle is specified in radians. Rotate(angle float64) // MoveTo starts a new subpath within the current path starting at // the specified point. MoveTo(x, y float64) // LineTo adds a line segment to the current path starting at the current // point. LineTo(x, y float64) // CubicTo adds a cubic bezier curve to the current path starting at the // current point. CubicTo(x1, y1, x2, y2, x3, y3 float64) // QuadraticTo adds a quadratic bezier curve to the current path starting // at the current point. QuadraticTo(x1, y1, x2, y2 float64) // NewSubPath starts a new subpath within the current path. NewSubPath() // ClosePath adds a line segment from the current point to the beginning // of the current subpath. ClosePath() // ClearPath clears the current path. ClearPath() // Clip updates the clipping region by intersecting the current // clipping region with the current path as it would be filled by Fill(). // The path is cleared after this operation. Clip() // ClipPreserve updates the clipping region by intersecting the current // clipping region with the current path as it would be filled by Fill(). // The path is preserved after this operation. ClipPreserve() // ResetClip clears the clipping region. ResetClip() // LineWidth returns the current line width. LineWidth() float64 // SetLineWidth sets the line width. SetLineWidth(lineWidth float64) // SetLineCap sets the line cap style. SetLineCap(lineCap LineCap) // SetLineJoin sets the line join style. SetLineJoin(lineJoin LineJoin) // SetDash sets the line dash pattern. SetDash(dashes ...float64) // SetDashOffset sets the initial offset into the dash pattern to use when // stroking dashed paths. SetDashOffset(offset float64) // Fill fills the current path with the current color. Open subpaths // are implicity closed. Fill() // FillPreserve fills the current path with the current color. Open subpaths // are implicity closed. The path is preserved after this operation. FillPreserve() // Stroke strokes the current path with the current color, line width, // line cap, line join and dash settings. The path is cleared after this // operation. Stroke() // StrokePreserve strokes the current path with the current color, // line width, line cap, line join and dash settings. The path is preserved // after this operation. StrokePreserve() // SetRGBA sets the both the fill and stroke colors. // r, g, b, a values should be in range 0-1. SetRGBA(r, g, b, a float64) // SetRGBA sets the fill color. // r, g, b, a values should be in range 0-1. SetFillRGBA(r, g, b, a float64) // SetStrokeStyle sets current fill pattern. SetFillStyle(pattern Pattern) // SetFillRule sets the fill rule. SetFillRule(fillRule FillRule) // SetRGBA sets the stroke color. // r, g, b, a values should be in range 0-1. SetStrokeRGBA(r, g, b, a float64) // SetStrokeStyle sets current stroke pattern. SetStrokeStyle(pattern Pattern) // TextState returns the current text state. TextState() *TextState // DrawString renders the specified string and the specified position. DrawString(s string, x, y float64) // Measure string returns the width and height of the specified string. MeasureString(s string) (w, h float64) // DrawRectangle draws the specified rectangle. DrawRectangle(x, y, w, h float64) // DrawImage draws the specified image at the specified point. DrawImage(image image.Image, x, y int) // DrawImageAnchored draws the specified image at the specified anchor point. // The anchor point is x - w * ax, y - h * ay, where w, h is the size of the // image. Use ax=0.5, ay=0.5 to center the image at the specified point. DrawImageAnchored(image image.Image, x, y int, ax, ay float64) // Width returns the width of the rendering area. Height() int // Height returns the height of the rendering area. Width() int }
Context defines operations for rendering to a particular target.
type Gradient ¶
Gradient represents a gradient pattern which can be rendered by a context instance.
type LineJoin ¶
type LineJoin int
LineJoin represents the line join style used by a context instance.
type Pattern ¶
Pattern represents a pattern which can be rendered by a context instance.
type TextFont ¶
type TextFont struct { Font *model.PdfFont Face font.Face Size float64 // contains filtered or unexported fields }
TextFont represents a font used to draw text to a target, through a rendering context.
func NewTextFont ¶
NewTextFont returns a new text font instance based on the specified PDF font and the specified font size.
func NewTextFontFromPath ¶
NewTextFontFromPath returns a new text font instance based on the specified font file and the specified font size.
func (*TextFont) BytesToCharcodes ¶
func (tf *TextFont) BytesToCharcodes(data []byte) []textencoding.CharCode
BytesToCharcodes converts the specified byte data to character codes, using the encapsulated PDF font instance.
func (*TextFont) CharcodesToUnicode ¶
func (tf *TextFont) CharcodesToUnicode(charcodes []textencoding.CharCode) []rune
CharcodesToUnicode converts the specified character codes to a slice of runes, using the encapsulated PDF font instance.
func (*TextFont) GetCharMetrics ¶
GetCharMetrics returns the metrics of the specified character code. The character metrics are calculated by the internal PDF font.
func (*TextFont) GetRuneMetrics ¶
GetRuneMetrics returns the metrics of the specified rune. The character metrics are calculated by the internal PDF font.
type TextState ¶
type TextState struct { Tc float64 // Character spacing. Tw float64 // Word spacing. Th float64 // Horizontal scaling. Tl float64 // Leading. Tf *TextFont // Font Ts float64 // Text rise. Tm transform.Matrix // Text matrix. Tlm transform.Matrix // Text line matrix. }
TextState holds a representation of a PDF text state. The text state processes different text related operations which may occur in PDF content streams. It is used as a part of a renderding context in order to manipulate and display text.
func (*TextState) ProcDQ ¶
ProcDQ processes a `”` operation, which advances the text state to a new line and then displays a text string using aw and ac as word and character spacing.
See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).
func (*TextState) ProcQ ¶
ProcQ processes a `'` operation, which advances the text state to a new line and then displays a text string.
See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).
func (*TextState) ProcTD ¶
ProcTD processes a `TD` operation, which advances the text state to a new line with offsets `tx`,`ty`.
See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).
func (*TextState) ProcTStar ¶
func (ts *TextState) ProcTStar()
ProcTStar processes a `T*` operation, which advances the text state to a new line.
See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).
func (*TextState) ProcTd ¶
ProcTd processes a `Td` operation, which advances the text state to a new line with offsets `tx`,`ty`.
See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).
func (*TextState) ProcTf ¶
ProcTf processes a `Tf` operation which sets the font and its size.
See section 9.3 "Text State Parameters and Operators" and Table 105 (pp. 251-252 PDF32000_2008).
func (*TextState) ProcTj ¶
ProcTj processes a `Tj` operation, which displays a text string.
See section 9.4.3 "Text Showing Operators" and Table 209 (pp. 258-259 PDF32000_2008).
func (*TextState) ProcTm ¶
ProcTm processes a `Tm` operation, which sets the current text matrix.
See section 9.4.2 "Text Positioning Operators" and Table 108 (pp. 257-258 PDF32000_2008).