giopdf

package module
v0.0.0-...-aad9a09 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderPage

func RenderPage(ops *op.Ops, page pdf.Page) error

RenderPage draws the contents of a PDF page to ops. The caller should do the appropriate transformation and scaling to ensure that the content is not rendered upside down. (The PDF coordinate system starts in the lower left, not in the upper left like Gio's.)

Types

type Canvas

type Canvas struct {
	PathBuilder
	// contains filtered or unexported fields
}

A Canvas implements the PDF imaging model, drawing to a Gio operations list. Most of its methods correspond directly to PDF page description operators.

func NewCanvas

func NewCanvas(ops *op.Ops) *Canvas

func (*Canvas) BeginText

func (c *Canvas) BeginText()

BeginText starts a text object, setting the text matrix and text line matrix to the identity matrix.

func (*Canvas) Clip

func (c *Canvas) Clip()

Clip causes the current path to be added to the clipping path after it is painted.

func (*Canvas) CloseAndStroke

func (c *Canvas) CloseAndStroke()

CloseAndStroke closes the current path before stroking it it.

func (*Canvas) CloseFillAndStroke

func (c *Canvas) CloseFillAndStroke()

CloseFillAndStroke closes the current path before filling and stroking it.

func (*Canvas) EndText

func (c *Canvas) EndText()

EndText ends a text object.

func (*Canvas) Fill

func (c *Canvas) Fill()

Fill fills the current path.

func (*Canvas) FillAndStroke

func (c *Canvas) FillAndStroke()

FillAndStroke fills the current path and then strokes (outlines) it.

func (*Canvas) Image

func (c *Canvas) Image(img image.Image)

Image draws an image. The image is placed in the unit square of the user coordinate system.

func (*Canvas) Kern

func (c *Canvas) Kern(amount float32)

Kern moves the next text character to the left the specified amount. The distance is in units of 1/1000 of an em.

func (*Canvas) NoOpPaint

func (c *Canvas) NoOpPaint()

NoOpPaint finishes the current path without filling or stroking it. It is normally used to apply a clipping path after calling Clip.

func (*Canvas) Restore

func (c *Canvas) Restore()

Restore restores the graphics state, popping it off the stack.

func (*Canvas) Save

func (c *Canvas) Save()

Save pushes a copy of the current graphics state onto the state stack.

func (*Canvas) SetDash

func (s *Canvas) SetDash(lengths []float32, phase float32)

SetDash sets the dash pattern for stroking paths.

func (*Canvas) SetFillAlpha

func (s *Canvas) SetFillAlpha(alpha float32)

SetFillAlpha sets the opacity for filling paths.

func (*Canvas) SetFillGray

func (s *Canvas) SetFillGray(g float32)

SetFillGray sets the fill color to a gray in the range from 0 (black) to 1 (white).

func (*Canvas) SetFont

func (s *Canvas) SetFont(f Font, size float32)

SetFont sets the font and size for text.

func (*Canvas) SetHScale

func (s *Canvas) SetHScale(scale float32)

SetHScale sets the horizontal scaling percent for text.

func (*Canvas) SetLineCap

func (s *Canvas) SetLineCap(c int)

SetLineCap sets the style for the caps at the end of lines: 0 (butt cap), 1 (round cap), or 2 (square cap).

func (*Canvas) SetLineJoin

func (s *Canvas) SetLineJoin(j int)

SetLineJoin sets the style for the joins at corners of stroked paths: 0 (miter join), 1 (round join), or 2 (bevel join).

func (*Canvas) SetLineWidth

func (s *Canvas) SetLineWidth(w float32)

SetLineWidth sets the width of the lines to use for stroking (outlining) shapes.

func (*Canvas) SetMiterLimit

func (s *Canvas) SetMiterLimit(m float32)

SetMiterLimit sets the limit for the length of a mitered join.

func (*Canvas) SetRGBFillColor

func (s *Canvas) SetRGBFillColor(r, g, b float32)

SetRGBStrokeColor sets the color to be used for filling shapes. The RGB values must be in the range from 0 to 1.

func (*Canvas) SetRGBStrokeColor

func (s *Canvas) SetRGBStrokeColor(r, g, b float32)

SetRGBStrokeColor sets the color to be used for stroking (outlining) shapes. The RGB values must be in the range from 0 to 1.

func (*Canvas) SetStrokeAlpha

func (s *Canvas) SetStrokeAlpha(alpha float32)

SetStrokeAlpha sets the opacity for stroking paths.

func (*Canvas) SetStrokeGray

func (s *Canvas) SetStrokeGray(g float32)

SetStrokeGray sets the stroke color to a gray in the range from 0 (black) to 1 (white).

func (*Canvas) SetTextMatrix

func (s *Canvas) SetTextMatrix(a, b, c, d, e, f float32)

SetTextMatrix sets the text matrix and the text line matrix.

func (*Canvas) SetTextRendering

func (s *Canvas) SetTextRendering(mode int)

SetTextRendering sets the text rendering mode.

func (*Canvas) ShowText

func (c *Canvas) ShowText(s string)

ShowText displays a string of text.

func (*Canvas) Stroke

func (c *Canvas) Stroke()

Stroke strokes (outlines) the current path.

func (*Canvas) TextMove

func (s *Canvas) TextMove(x, y float32)

TextMove starts a new line of text offset by x and y from the start of the current line.

func (*Canvas) Transform

func (ca *Canvas) Transform(a, b, c, d, e, f float32)

Transform changes the coordinate system according to the transformation matrix specified.

type Font

type Font interface {
	ToGlyphs(s string) []Glyph
}

A Font converts text strings to slices of Glyphs, so that they can be displayed.

type Glyph

type Glyph struct {
	Outlines []PathElement
	Width    float32
}

A Glyph represents a character from a font. It uses a coordinate system where the origin is at the left end of the baseline of the glyph, y increases vertically, and the font size is one unit.

type PathBuilder

type PathBuilder struct {
	Path []PathElement
	// contains filtered or unexported fields
}

func (*PathBuilder) ClosePath

func (p *PathBuilder) ClosePath()

ClosePath closes the path, ensuring that it ends at the same point where it began.

func (*PathBuilder) CurveTo

func (p *PathBuilder) CurveTo(x1, y1, x2, y2, x3, y3 float32)

CurveTo adds a cubic Bezier curve to the path. It ends at (x3, y3) and has (x1, y1) and (x2, y2) for control points.

func (*PathBuilder) CurveV

func (p *PathBuilder) CurveV(x2, y2, x3, y3 float32)

CurveV adds a cubic Bezier curve to the path. It ends at (x3, y3) and has the current point and (x2, y2) for control points.

func (*PathBuilder) CurveY

func (p *PathBuilder) CurveY(x1, y1, x3, y3 float32)

CurveY adds a cubic Bezier curve to the path. It ends at (x3, y3) and has (x1, y1) and (x3, y3) for control points.

func (*PathBuilder) LineTo

func (p *PathBuilder) LineTo(x, y float32)

LineTo adds a line segment to the path, ending at (x, y).

func (*PathBuilder) MoveTo

func (p *PathBuilder) MoveTo(x, y float32)

MoveTo starts a new subpath at (x, y).

func (*PathBuilder) QuadraticCurveTo

func (p *PathBuilder) QuadraticCurveTo(x1, y1, x2, y2 float32)

QuadraticCurveTo adds a quadratic Bezier curve to the path. It ends at (x2, y2) and has (x1, y1) for its control point.

func (*PathBuilder) Rectangle

func (p *PathBuilder) Rectangle(x, y, width, height float32)

Rectangle creates a new subpath containing a rectangle of the specified dimensions.

type PathElement

type PathElement struct {
	// Op is the PDF path construction operator corresponding to this
	// PathElement. Possible values are:
	//
	//     m moveto
	//     l lineto
	//     c curveto
	//     h closepath
	Op byte

	// CP1 and CP2 are the control points for a bezier curve segment ('c').
	CP1, CP2 f32.Point
	End      f32.Point
}

A PathElement represents a segement of a path.

type SimpleFont

type SimpleFont struct {
	Glyphs [256]Glyph
}

A SimpleFont is a font with a simple 8-bit encoding.

func SimpleFontFromCFF

func SimpleFontFromCFF(data []byte, enc simpleencodings.Encoding) (*SimpleFont, error)

SimpleFontFromCFF converts a CFF font to a SimpleFont, using the encoding provided.

func SimpleFontFromSFNT

func SimpleFontFromSFNT(data []byte, enc simpleencodings.Encoding) (*SimpleFont, error)

SimpleFontFromSFNT converts an SFNT (TrueType or OpenType) font to a SimpleFont with the specified encoding.

func SimpleFontFromType1

func SimpleFontFromType1(data []byte, enc simpleencodings.Encoding) (*SimpleFont, error)

SimpleFontFromType1 converts a Type 1 font to a SimpleFont, using the encoding provided.

func (*SimpleFont) ToGlyphs

func (f *SimpleFont) ToGlyphs(s string) []Glyph

Directories

Path Synopsis
Package cff provides a parser for the CFF font format defined at https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5176.CFF.pdf.
Package cff provides a parser for the CFF font format defined at https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5176.CFF.pdf.
Package pdf implements reading of PDF files.
Package pdf implements reading of PDF files.

Jump to

Keyboard shortcuts

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