graf

package
v0.0.0-...-ba91185 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PdfOps = map[string]func(pd *PdfDrawerT){
	"B": func(pd *PdfDrawerT) {
		pd.Draw.FillAndStroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"B*": func(pd *PdfDrawerT) {
		pd.Draw.EOFillAndStroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"F": func(pd *PdfDrawerT) {
		pd.Draw.Fill()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"S": func(pd *PdfDrawerT) {
		pd.Draw.Stroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"b": func(pd *PdfDrawerT) {
		pd.Draw.ClosePath()
		pd.CurrentPoint = nil
		pd.Draw.FillAndStroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"b*": func(pd *PdfDrawerT) {
		pd.Draw.ClosePath()
		pd.CurrentPoint = nil
		pd.Draw.EOFillAndStroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"c": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(6)
		pd.Draw.CurveTo(a)
		pd.CurrentPoint = a[4:6]
	},
	"cm": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(6)
		pd.Draw.Concat(a)
		pd.CurrentPoint = a[4:6]
	},
	"f": func(pd *PdfDrawerT) {
		pd.Draw.Fill()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"f*": func(pd *PdfDrawerT) {
		pd.Draw.EOFill()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"h": func(pd *PdfDrawerT) {
		pd.Draw.ClosePath()
		pd.CurrentPoint = nil
	},
	"l": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(2)
		pd.Draw.LineTo(a)
		pd.CurrentPoint = a
	},
	"m": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(2)
		pd.Draw.MoveTo(a)
		pd.CurrentPoint = a
	},
	"n": func(pd *PdfDrawerT) {
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"re": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(4)
		pd.Draw.Rectangle(a)
		pd.CurrentPoint = nil
	},
	"s": func(pd *PdfDrawerT) {
		pd.Draw.ClosePath()
		pd.Draw.Stroke()
		pd.Draw.DropPath()
		pd.CurrentPoint = nil
	},
	"v": func(pd *PdfDrawerT) {
		c := pd.CurrentPoint
		a := pd.Stack.Drop(4)
		pd.Draw.CurveTo([][]byte{c[0], c[1], a[0], a[1], a[2], a[3]})
		pd.CurrentPoint = a[2:4]
	},
	"y": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(4)
		pd.Draw.CurveTo([][]byte{a[0], a[1], a[2], a[3], a[2], a[3]})
		pd.CurrentPoint = a[2:4]
	},
	"G": func(pd *PdfDrawerT) {
		pd.Config.SetGrayStroke(pd.Stack.Pop())
		pd.Ops["SC"] = pd.Ops["G"]
	},
	"J": func(pd *PdfDrawerT) {
		pd.Config.SetLineCap(pd.Stack.Pop())
	},
	"K": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(4)
		pd.Config.SetCMYKStroke(a)
		pd.Ops["SC"] = pd.Ops["K"]
	},
	"M": func(pd *PdfDrawerT) {
		pd.Config.SetMiterLimit(pd.Stack.Pop())
	},
	"RG": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(3)
		pd.Config.SetRGBStroke(a)
		pd.Ops["SC"] = pd.Ops["RG"]
	},
	"g": func(pd *PdfDrawerT) {
		pd.Config.SetGrayFill(pd.Stack.Pop())
		pd.Ops["sc"] = pd.Ops["g"]
	},
	"gs": func(pd *PdfDrawerT) {

		pd.Draw.SetIdentity()
		pd.Stack.Pop()
	},
	"i": func(pd *PdfDrawerT) {
		pd.Config.SetFlat(pd.Stack.Pop())
	},
	"j": func(pd *PdfDrawerT) {
		pd.Config.SetLineJoin(pd.Stack.Pop())
	},
	"k": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(4)
		pd.Config.SetCMYKFill(a)
		pd.Ops["sc"] = pd.Ops["k"]
	},
	"rg": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(3)
		pd.Config.SetRGBFill(a)
		pd.Ops["sc"] = pd.Ops["rg"]
	},
	"w": func(pd *PdfDrawerT) {
		pd.Config.SetLineWidth(pd.Stack.Pop())
	},
	"TL": func(pd *PdfDrawerT) {
		pd.TConf.SetLeading(pd.Stack.Pop())
	},
	"Tc": func(pd *PdfDrawerT) {
		pd.TConf.SetCharSpace(pd.Stack.Pop())
	},
	"Tf": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(2)
		pd.TConf.SetFontAndSize(a)
	},
	"Tr": func(pd *PdfDrawerT) {
		pd.TConf.SetRender(pd.Stack.Pop())
	},
	"Ts": func(pd *PdfDrawerT) {
		pd.TConf.SetRise(pd.Stack.Pop())
	},
	"Tw": func(pd *PdfDrawerT) {
		pd.TConf.SetWordSpace(pd.Stack.Pop())
	},
	"Tz": func(pd *PdfDrawerT) {
		pd.TConf.SetScale(pd.Stack.Pop())
	},
	"'": func(pd *PdfDrawerT) {
		pd.Text.TNextLine()
		pd.Text.TShow(pd.Stack.Pop())
	},
	"BT": func(pd *PdfDrawerT) {
		pd.Text.TSetMatrix(nil)
	},
	"ET": func(pd *PdfDrawerT) {
	},
	"T*": func(pd *PdfDrawerT) {
		pd.Text.TNextLine()
	},
	"TD": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(2)
		pd.TConf.SetLeading(util.Bytes(strm.Neg(string(a[1]))))
		pd.Text.TMoveTo(a)
	},
	"TJ": func(pd *PdfDrawerT) {
		pd.Text.TShow(pd.Stack.Pop())
	},
	"Td": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(2)
		pd.Text.TMoveTo(a)
	},
	"Tj": func(pd *PdfDrawerT) {
		pd.Text.TShow(pd.Stack.Pop())
	},
	"Tm": func(pd *PdfDrawerT) {
		a := pd.Stack.Drop(6)
		pd.Text.TSetMatrix(a)
	},
	"\"": func(pd *PdfDrawerT) {
		t := pd.Stack.Drop(3)
		pd.TConf.SetWordSpace(t[0])
		pd.TConf.SetCharSpace(t[1])
		pd.Text.TNextLine()
		pd.Text.TShow(t[3])
	},
	"BDC": func(pd *PdfDrawerT) {
		pd.Stack.Drop(2)
	},
	"BMC": func(pd *PdfDrawerT) {
		pd.Stack.Pop()
	},
	"DP": func(pd *PdfDrawerT) {
		pd.Stack.Drop(2)
	},
	"EMC": func(pd *PdfDrawerT) {
	},
	"MP": func(pd *PdfDrawerT) {
		pd.Stack.Pop()
	},
}

Functions

This section is empty.

Types

type DocumentMarker

type DocumentMarker interface {
}

type Drawer

type Drawer interface {
	CloseDrawing()
	ClosePath()
	Concat(s [][]byte)
	CurveTo(s [][]byte)
	DropPath()
	EOFill()
	EOFillAndStroke()
	Fill()
	FillAndStroke()
	LineTo(s [][]byte)
	MoveTo(s [][]byte)
	Rectangle(s [][]byte)
	SetIdentity()
	Stroke()
}

type DrawerColor

type DrawerColor interface {
	RGB(rgb [][]byte) string
	CMYK(cmyk [][]byte) string
	Gray(g []byte) string
}

type DrawerConfig

type DrawerConfig interface {
	SetCMYKFill(s [][]byte)
	SetCMYKStroke(s [][]byte)
	SetColors(DrawerColor)
	SetFlat(a []byte)
	SetGrayFill(a []byte)
	SetGrayStroke(a []byte)
	SetLineCap(a []byte)
	SetLineJoin(a []byte)
	SetLineWidth(a []byte)
	SetMiterLimit(a []byte)
	SetRGBFill(s [][]byte)
	SetRGBStroke(s [][]byte)
}

type DrawerConfigT

type DrawerConfigT struct {
	FillColor   string
	StrokeColor string
	LineWidth   string
	LineCap     string
	LineJoin    string
	MiterLimit  string
	Flat        string
	// contains filtered or unexported fields
}

func (*DrawerConfigT) SetCMYKFill

func (t *DrawerConfigT) SetCMYKFill(s [][]byte)

func (*DrawerConfigT) SetCMYKStroke

func (t *DrawerConfigT) SetCMYKStroke(s [][]byte)

func (*DrawerConfigT) SetColors

func (t *DrawerConfigT) SetColors(hook DrawerColor)

func (*DrawerConfigT) SetFlat

func (t *DrawerConfigT) SetFlat(a []byte)

func (*DrawerConfigT) SetGrayFill

func (t *DrawerConfigT) SetGrayFill(a []byte)

func (*DrawerConfigT) SetGrayStroke

func (t *DrawerConfigT) SetGrayStroke(a []byte)

func (*DrawerConfigT) SetLineCap

func (t *DrawerConfigT) SetLineCap(a []byte)

func (*DrawerConfigT) SetLineJoin

func (t *DrawerConfigT) SetLineJoin(a []byte)

func (*DrawerConfigT) SetLineWidth

func (t *DrawerConfigT) SetLineWidth(a []byte)

func (*DrawerConfigT) SetMiterLimit

func (t *DrawerConfigT) SetMiterLimit(a []byte)

func (*DrawerConfigT) SetRGBFill

func (t *DrawerConfigT) SetRGBFill(s [][]byte)

func (*DrawerConfigT) SetRGBStroke

func (t *DrawerConfigT) SetRGBStroke(s [][]byte)

type DrawerText

type DrawerText interface {
	TMoveTo(s [][]byte)
	TNextLine()
	TSetMatrix(s [][]byte)
	TShow(a []byte)
}

type PdfDrawerT

type PdfDrawerT struct {
	Stack        stacks.Stack
	Ops          map[string]func(pd *PdfDrawerT)
	CurrentPoint [][]byte
	ConfigD      *DrawerConfigT
	TConfD       *TextConfigT
	Write        *util.OutT
	Draw         Drawer
	Config       DrawerConfig
	TConf        TextConfig
	Text         DrawerText
	Marker       DocumentMarker
}

func NewPdfDrawer

func NewPdfDrawer() *PdfDrawerT

func (*PdfDrawerT) Interpret

func (pd *PdfDrawerT) Interpret(rdr fancy.Reader)

type TextConfig

type TextConfig interface {
	SetCharSpace(a []byte)
	SetFontAndSize(s [][]byte)
	SetLeading(a []byte)
	SetRender(a []byte)
	SetRise(a []byte)
	SetScale(a []byte)
	SetWordSpace(a []byte)
}

type TextConfigT

type TextConfigT struct {
	CharSpace string
	WordSpace string
	Scale     string
	Leading   string
	Render    string
	Rise      string
	Font      string
	FontSize  string
}

func (*TextConfigT) SetCharSpace

func (t *TextConfigT) SetCharSpace(a []byte)

func (*TextConfigT) SetFontAndSize

func (t *TextConfigT) SetFontAndSize(a [][]byte)

func (*TextConfigT) SetLeading

func (t *TextConfigT) SetLeading(a []byte)

func (*TextConfigT) SetRender

func (t *TextConfigT) SetRender(a []byte)

func (*TextConfigT) SetRise

func (t *TextConfigT) SetRise(a []byte)

func (*TextConfigT) SetScale

func (t *TextConfigT) SetScale(a []byte)

func (*TextConfigT) SetWordSpace

func (t *TextConfigT) SetWordSpace(a []byte)

func (*TextConfigT) TMoveTo

func (t *TextConfigT) TMoveTo(s [][]byte)

func (*TextConfigT) TNextLine

func (t *TextConfigT) TNextLine()

func (*TextConfigT) TSetMatrix

func (t *TextConfigT) TSetMatrix(s [][]byte)

func (*TextConfigT) TShow

func (t *TextConfigT) TShow(a []byte)

Jump to

Keyboard shortcuts

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