gofpdf

package module
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 31 Imported by: 0

README

gopdf

gopdf is a simple library for generating PDF document written in Go lang.

Features
  • Unicode subfont embedding. (Chinese, Japanese, Korean, etc.)
  • Draw line, oval, rect, curve
  • Draw image ( jpg, png )
  • Password protection
  • Font kerning

Installation

go get -u github.com/signintech/gopdf
Print text
  
package main
import (
	"log"
	"github.com/signintech/gopdf"
)

func main() {

	pdf := gopdf.GoPdf{}
	pdf.Start(gopdf.Config{ PageSize: gopdf.PageSizeA4 })  
	pdf.AddPage()
	err := pdf.AddTTFFont("wts11", "../ttf/wts11.ttf")
	if err != nil {
		log.Print(err.Error())
		return
	}

	err = pdf.SetFont("wts11", "", 14)
	if err != nil {
		log.Print(err.Error())
		return
	}
	pdf.Cell(nil, "您好")
	pdf.WritePdf("hello.pdf")

}

Image

package main
import (
	"log"
	"github.com/signintech/gopdf"
)

func main() {
	pdf := gopdf.GoPdf{}
	pdf.Start(gopdf.Config{PageSize: gopdf.PageSizeA4 })  
	pdf.AddPage()
	var err error
	err = pdf.AddTTFFont("loma", "../ttf/Loma.ttf")
	if err != nil {
		log.Print(err.Error())
		return
	}
	
	pdf.Image("../imgs/gopher.jpg", 200, 50, nil) //print image
	err = pdf.SetFont("loma", "", 14)
	if err != nil {
		log.Print(err.Error())
		return
	}
	pdf.SetX(250) //move current location
	pdf.SetY(200)
	pdf.Cell(nil, "gopher and gopher") //print text

	pdf.WritePdf("image.pdf")
}
  

package main

import (
	"log"
	"github.com/signintech/gopdf"
)

func main()  {
	pdf := gopdf.GoPdf{}
	pdf.Start(gopdf.Config{ PageSize: gopdf.PageSizeA4 }) //595.28, 841.89 = A4
	pdf.AddPage()
	err := pdf.AddTTFFont("times", "./test/res/times.ttf")
	if err != nil {
		log.Print(err.Error())
		return
	}

	err = pdf.SetFont("times", "", 14)
	if err != nil {
		log.Print(err.Error())
		return
	}

	pdf.SetX(30)
	pdf.SetY(40)
	pdf.Text("Link to example.com")
	pdf.AddExternalLink("http://example.com/", 27.5, 28, 125, 15)

	pdf.SetX(30)
	pdf.SetY(70)
	pdf.Text("Link to second page")
	pdf.AddInternalLink("anchor", 27.5, 58, 120, 15)

	pdf.AddPage()
	pdf.SetX(30)
	pdf.SetY(100)
	pdf.SetAnchor("anchor")
	pdf.Text("Anchor position")

	pdf.WritePdf("hello.tmp.pdf")

}
Draw line
pdf.SetLineWidth(2)
pdf.SetLineType("dashed")
pdf.Line(10, 30, 585, 30)
Draw oval
pdf.SetLineWidth(1)
pdf.Oval(100, 200, 500, 500)
Rotation text or image
pdf.SetX(100)
pdf.SetY(100)
pdf.Rotate(270.0, 100.0, 100.0)
pdf.Text("Hello...")
pdf.RotateReset() //reset
Password protection
package main

import (
	"log"

	"github.com/signintech/gopdf"
)


func main() {

	pdf := gopdf.GoPdf{}
	pdf.Start(gopdf.Config{
		PageSize: gopdf.PageSizeA4, //595.28, 841.89 = A4
		Protection: gopdf.PDFProtectionConfig{
			UseProtection: true,
			Permissions: gopdf.PermissionsPrint | gopdf.PermissionsCopy | gopdf.PermissionsModify,
			OwnerPass:   []byte("123456"),
			UserPass:    []byte("123456789")},
	})

	pdf.AddPage()
	pdf.AddTTFFont("loma", "../ttf/loma.ttf")
	pdf.Cell(nil,"Hi")
	pdf.WritePdf("protect.pdf")
}

visit https://github.com/oneplus1000/gopdfsample for more samples.

Documentation

Index

Constants

View Source
const (
	//Regular - font style regular
	Regular = 0 //000000
	//Italic - font style italic
	Italic = 1 //000001
	//Bold - font style bold
	Bold = 2 //000010
	//Underline - font style underline
	Underline = 4 //000100
)
View Source
const (
	CapStyleDefault = iota
	CapStyleRound
	CapStyleSquare
)
View Source
const (
	JoinStyleRound   = 1
	JoinStyleBevel   = 2
	JoinStyleDefault = 0
)
View Source
const (
	PageBoundaryCrop = iota
	PageBoundaryMedia
	PageBoundaryBleed
	PageBoundaryTrim
	PageBoundaryArt
)

Page boundary types

View Source
const (
	//PermissionsPrint setProtection print
	PermissionsPrint = 4
	//PermissionsModify setProtection modify
	PermissionsModify = 8
	//PermissionsCopy setProtection copy
	PermissionsCopy = 16
	//PermissionsAnnotForms setProtection  annot-forms
	PermissionsAnnotForms = 32
)
View Source
const (
	Unit_Unset = iota // No units were set, when conversion is called on nothing will happen
	Unit_PT           // Points
	Unit_MM           // Millimeters
	Unit_CM           // centimeters
	Unit_IN           // inches

)

The units that can be used in the document

View Source
const ARG_1_AND_2_ARE_WORDS = 1
View Source
const Bottom = 1 //000001

Bottom bottom

View Source
const Center = 16 //010000

Center center

View Source
const ContentTypeCell = 0

ContentTypeCell cell

View Source
const ContentTypeText = 1

ContentTypeText text

View Source
const Left = 8 //001000

Left left

View Source
const MORE_COMPONENTS = 32
View Source
const Middle = 32 //100000

Middle middle

View Source
const Right = 2 //000010

Right right

View Source
const Top = 4 //000100

Top top

View Source
const WE_HAVE_AN_X_AND_Y_SCALE = 64
View Source
const WE_HAVE_A_SCALE = 8
View Source
const WE_HAVE_A_TWO_BY_TWO = 128

Variables

View Source
var EntrySelectors = []int{
	0, 0, 1, 1, 2, 2,
	2, 2, 3, 3, 3, 3,
	3, 3, 3, 3, 4, 4,
	4, 4, 4, 4, 4, 4,
	4, 4, 4, 4, 4, 4, 4,
}

EntrySelectors entry selectors

View Source
var ErrCharNotFound = errors.New("char not found")

ErrCharNotFound char not found

View Source
var ErrNotSupportShortIndexYet = errors.New("not suport none short index yet")

ErrNotSupportShortIndexYet not suport none short index yet

View Source
var PageSize10x14 = Rect{W: 720, H: 1008, /* contains filtered or unexported fields */}
View Source
var PageSizeA0 = Rect{W: 2384, H: 3371, /* contains filtered or unexported fields */}
View Source
var PageSizeA1 = Rect{W: 1685, H: 2384, /* contains filtered or unexported fields */}
View Source
var PageSizeA2 = Rect{W: 1190, H: 1684, /* contains filtered or unexported fields */}
View Source
var PageSizeA3 = Rect{W: 842, H: 1190, /* contains filtered or unexported fields */}
View Source
var PageSizeA4 = Rect{W: 595, H: 842, /* contains filtered or unexported fields */}
View Source
var PageSizeA4Small = Rect{W: 595, H: 842, /* contains filtered or unexported fields */}
View Source
var PageSizeA5 = Rect{W: 420, H: 595, /* contains filtered or unexported fields */}
View Source
var PageSizeB4 = Rect{W: 729, H: 1032, /* contains filtered or unexported fields */}
View Source
var PageSizeB5 = Rect{W: 516, H: 729, /* contains filtered or unexported fields */}
View Source
var PageSizeExecutive = Rect{W: 540, H: 720, /* contains filtered or unexported fields */}
View Source
var PageSizeFolio = Rect{W: 612, H: 936, /* contains filtered or unexported fields */}
View Source
var PageSizeLedger = Rect{W: 1224, H: 792, /* contains filtered or unexported fields */}
View Source
var PageSizeLegal = Rect{W: 612, H: 1008, /* contains filtered or unexported fields */}
View Source
var PageSizeLetter = Rect{W: 612, H: 792, /* contains filtered or unexported fields */}
View Source
var PageSizeLetterSmall = Rect{W: 612, H: 792, /* contains filtered or unexported fields */}
View Source
var PageSizeQuarto = Rect{W: 610, H: 780, /* contains filtered or unexported fields */}
View Source
var PageSizeStatement = Rect{W: 396, H: 612, /* contains filtered or unexported fields */}
View Source
var PageSizeTabloid = Rect{W: 792, H: 1224, /* contains filtered or unexported fields */}

Functions

func CheckSum

func CheckSum(data []byte) uint

CheckSum check sum

func Chr

func Chr(n int) byte

func Coefficients added in v0.0.8

func Coefficients(p0, p1, p2, p3 float64) (C1, C2, C3, C4 float64)

func CreateEmbeddedFontSubsetName

func CreateEmbeddedFontSubsetName(name string) string

CreateEmbeddedFontSubsetName create Embedded font (subset font) name

func CurveLength added in v0.0.8

func CurveLength(bc BezierCurve) float64

func DebugSubType

func DebugSubType(b []byte)

func DesignUnitsToPdf

func DesignUnitsToPdf(val int, unitsPerEm uint) int

DesignUnitsToPdf convert unit

func Distance added in v0.0.8

func Distance(p0, p1 Point) float64

func FontConvertHelper_Cw2Str

func FontConvertHelper_Cw2Str(cw FontCw) string

func GetConvertedStyle

func GetConvertedStyle(fontStyle string) int

func ImgReactagleToWH

func ImgReactagleToWH(imageRect image.Rectangle) (float64, float64)

ImgReactagleToWH Rectangle to W and H

func PageBoundaryType added in v0.1.11

func PageBoundaryType(t int) string

func PointsToUnits

func PointsToUnits(t int, u float64) float64

PointsToUnits converts points to the provided units

func PointsToUnitsVar

func PointsToUnitsVar(t int, u ...*float64)

PointsToUnitsVar converts points to the provided units for all variables supplied

func ReadShortFromByte

func ReadShortFromByte(data []byte, offset int) (int64, int)

ReadShortFromByte read short from byte array

func ReadUShortFromByte

func ReadUShortFromByte(data []byte, offset int) (uint64, int)

ReadUShortFromByte read ushort from byte array

func StrHelperGetStringWidth

func StrHelperGetStringWidth(str string, fontSize int, ifont IFont) float64

StrHelperGetStringWidth get string width

func ToByte

func ToByte(chr string) byte

func UnitsToPoints

func UnitsToPoints(t int, u float64) float64

UnitsToPoints converts units of the provided type to points

func UnitsToPointsVar

func UnitsToPointsVar(t int, u ...*float64)

UnitsToPointsVar converts units of the provided type to points for all variables supplied

func WriteBytes

func WriteBytes(w io.Writer, data []byte, offset int, count int) error

WriteBytes writes []byte value to w io.Writer

func WriteTag

func WriteTag(w io.Writer, tag string) error

WriteTag writes string value to w io.Writer

func WriteUInt16

func WriteUInt16(w io.Writer, v uint) error

WriteUInt16 writes a 16-bit unsigned integer value to w io.Writer

func WriteUInt32

func WriteUInt32(w io.Writer, v uint) error

WriteUInt32 writes a 32-bit unsigned integer value to w io.Writer

Types

type BezierCurve added in v0.0.8

type BezierCurve struct {
	Cx1, Cx2, Cx3, Cx4, Cy1, Cy2, Cy3, Cy4, Length float64
}

func NewBezierCurve added in v0.0.8

func NewBezierCurve(x0, y0, cx0, cy0, cx1, cy1, x1, y1 float64) BezierCurve

func (BezierCurve) At added in v0.0.8

func (bc BezierCurve) At(t float64) Point

func (BezierCurve) Curve added in v0.0.8

func (bc BezierCurve) Curve(p []Point) []Point

func (BezierCurve) Dx added in v0.0.8

func (bc BezierCurve) Dx(t float64) float64

func (BezierCurve) Dy added in v0.0.8

func (bc BezierCurve) Dy(t float64) float64

func (BezierCurve) NormalDegrees added in v0.0.8

func (bc BezierCurve) NormalDegrees(t float64) float64

func (BezierCurve) SampleByArcLength added in v0.0.8

func (bc BezierCurve) SampleByArcLength(sample []float64) []float64

func (BezierCurve) Tangent added in v0.0.8

func (bc BezierCurve) Tangent(t float64) Point

type BezierPoint added in v0.0.8

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

type BezierSpline added in v0.0.8

type BezierSpline []BezierCurve

func NewBezierSpline added in v0.0.8

func NewBezierSpline(cp []Point) BezierSpline

func (BezierSpline) Length added in v0.0.8

func (bs BezierSpline) Length() float64

func (BezierSpline) SampleByArcLength added in v0.0.8

func (bs BezierSpline) SampleByArcLength(n int) BezierSplineSample

type BezierSplineSample added in v0.0.8

type BezierSplineSample [][]float64

func (BezierSplineSample) At added in v0.0.8

func (bss BezierSplineSample) At(k int) (int, float64)

type Buff

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

Buff for pdf content

func (*Buff) Bytes

func (b *Buff) Bytes() []byte

Bytes : get bytes

func (*Buff) Len

func (b *Buff) Len() int

Len : len of buffer

func (*Buff) Position

func (b *Buff) Position() int

Position : get current postion

func (*Buff) SetPosition

func (b *Buff) SetPosition(pos int)

SetPosition : set current postion

func (*Buff) Write

func (b *Buff) Write(p []byte) (int, error)

Write : write []byte to buffer

type CIDFontObj

type CIDFontObj struct {
	PtrToSubsetFontObj *SubsetFontObj
	// contains filtered or unexported fields
}

func (*CIDFontObj) SetIndexObjSubfontDescriptor

func (ci *CIDFontObj) SetIndexObjSubfontDescriptor(index int)

SetIndexObjSubfontDescriptor set indexObjSubfontDescriptor

func (*CIDFontObj) SetPtrToSubsetFontObj

func (ci *CIDFontObj) SetPtrToSubsetFontObj(ptr *SubsetFontObj)

SetPtrToSubsetFontObj set PtrToSubsetFontObj

type CacheContent

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

CacheContent Export cacheContent

func (*CacheContent) Setup

func (c *CacheContent) Setup(rectangle *Rect,
	textColor Rgb,
	grayFill float64,
	fontObjId string,
	fontSize float64,
	fontStyle int,
	setXCount int,
	x, y float64,
	fontSubset *SubsetFontObj,
	pageheight float64,
	contentType int,
	cellOpt CellOption,
	lineWidth float64,
)

Setup setup all infomation for cacheContent

func (*CacheContent) WriteTextToContent

func (c *CacheContent) WriteTextToContent(text string)

WriteTextToContent write text to content

type CatalogObj

type CatalogObj struct {
}

CatalogObj : catalog dictionary

type CellOption

type CellOption struct {
	Align  int //Allows to align the text. Possible values are: Left,Center,Right,Top,Bottom,Middle
	Border int //Indicates if borders must be drawn around the cell. Possible values are: Left, Top, Right, Bottom, ALL
	Float  int //Indicates where the current position should go after the call. Possible values are: Right, Bottom
}

CellOption cell option

type ContentObj

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

ContentObj content object

func (*ContentObj) AppendStreamArcTo

func (c *ContentObj) AppendStreamArcTo(x, y, rx, ry, degRotate, degStart, degEnd float64, styleStr string, path bool)

AppendStreamArcTo : appends an arc to

func (*ContentObj) AppendStreamClipBegin

func (c *ContentObj) AppendStreamClipBegin()

AppendStreamClipBegin starts a new clip in the content

func (*ContentObj) AppendStreamClipEllipse

func (c *ContentObj) AppendStreamClipEllipse(x, y, rx, ry float64, style string)

AppendStreamClipClipEllipse creates an Elliptical clipping path

func (*ContentObj) AppendStreamClipEnd

func (c *ContentObj) AppendStreamClipEnd()

AppendStreamClipEnd ends a clipping path in the content

func (*ContentObj) AppendStreamClipPolygon

func (c *ContentObj) AppendStreamClipPolygon(points []Point, style string)

AppendStreamClipClipEllipse creates an Elliptical clipping path

func (*ContentObj) AppendStreamClipRect

func (c *ContentObj) AppendStreamClipRect(x, y, w, h float64, style string)

AppendStreamClipRect starts a rectangle clipping path

func (*ContentObj) AppendStreamClipRoundedRect

func (c *ContentObj) AppendStreamClipRoundedRect(x, y, w, h, r float64, style string)

AppendStreamClipRoundedRect creates a rounded rectangle clipping path

func (*ContentObj) AppendStreamClipText

func (c *ContentObj) AppendStreamClipText(x, y float64, txtStr string, style int)

AppendStreamClipText creates a clipping path using the text

func (*ContentObj) AppendStreamClosePath

func (c *ContentObj) AppendStreamClosePath()

AppendStreamClosePath : appends a path closing

func (*ContentObj) AppendStreamCurve

func (c *ContentObj) AppendStreamCurve(cx, cy, x, y float64)

AppendStreamCurve : appends a curve

func (*ContentObj) AppendStreamCurveBezierCubic

func (c *ContentObj) AppendStreamCurveBezierCubic(cx0, cy0, cx1, cy1, x, y float64)

AppendStreamCurveBezierCubic : draw a curve from the current spot to the x and y position

func (*ContentObj) AppendStreamDrawPath

func (c *ContentObj) AppendStreamDrawPath(styleStr string)

AppendStreamDrawPath : appends a draw path with style string

func (*ContentObj) AppendStreamImage

func (c *ContentObj) AppendStreamImage(id string, x float64, y float64, rect Rect)

AppendStreamImage append image

func (*ContentObj) AppendStreamLine

func (c *ContentObj) AppendStreamLine(x1 float64, y1 float64, x2 float64, y2 float64)

AppendStreamLine append line

func (*ContentObj) AppendStreamLineTo

func (c *ContentObj) AppendStreamLineTo(x, y float64)

AppendStreamLineTo appends a line to

func (*ContentObj) AppendStreamOval

func (c *ContentObj) AppendStreamOval(x1 float64, y1 float64, x2 float64, y2 float64)

AppendStreamOval append oval

func (*ContentObj) AppendStreamPoint

func (c *ContentObj) AppendStreamPoint(x, y float64)

AppendStreamPoint appends a point

func (*ContentObj) AppendStreamRectangle

func (c *ContentObj) AppendStreamRectangle(x float64, y float64, wdth float64, hght float64, style string)

AppendStreamRectangle : draw rectangle from lower-left corner (x, y) with specif width/height

func (*ContentObj) AppendStreamSetCMYKColorFill

func (c *ContentObj) AppendStreamSetCMYKColorFill(cy uint8, m uint8, y uint8, k uint8)

AppendStreamSetCMYKColorFill set the color fill using CMYK

func (*ContentObj) AppendStreamSetCMYKColorStroke

func (c *ContentObj) AppendStreamSetCMYKColorStroke(cy uint8, m uint8, y uint8, k uint8)

AppendStreamSetCMYKColorStroke set the color stroke using CMYK

func (*ContentObj) AppendStreamSetCapStyle

func (c *ContentObj) AppendStreamSetCapStyle(t int)

AppendStreamSetLineType set the line type

func (*ContentObj) AppendStreamSetGrayFill

func (c *ContentObj) AppendStreamSetGrayFill(w float64)

AppendStreamSetGrayFill set the grayscale fills

func (*ContentObj) AppendStreamSetGrayStroke

func (c *ContentObj) AppendStreamSetGrayStroke(w float64)

AppendStreamSetGrayStroke set the grayscale stroke

func (*ContentObj) AppendStreamSetJoinStyle

func (c *ContentObj) AppendStreamSetJoinStyle(t int)

AppendStreamSetJoinType set the line type

func (*ContentObj) AppendStreamSetLineType

func (c *ContentObj) AppendStreamSetLineType(t string)

AppendStreamSetLineType : Set linetype [solid, dashed, dotted]

func (*ContentObj) AppendStreamSetLineWidth

func (c *ContentObj) AppendStreamSetLineWidth(w float64)

AppendStreamSetLineWidth : set line width

func (*ContentObj) AppendStreamSetRGBColorFill

func (c *ContentObj) AppendStreamSetRGBColorFill(r uint8, g uint8, b uint8)

AppendStreamSetRGBColorFill set the color fill using RB

func (*ContentObj) AppendStreamSetRGBColorStroke

func (c *ContentObj) AppendStreamSetRGBColorStroke(r uint8, g uint8, b uint8)

AppendStreamSetRGBColorStroke set the color stroke using RGB

func (*ContentObj) AppendStreamSubsetFont

func (c *ContentObj) AppendStreamSubsetFont(rectangle Rect, text string, cellOpt CellOption) error

AppendStreamSubsetFont add stream of text

func (*ContentObj) AppendStreamText

func (c *ContentObj) AppendStreamText(text string) error

AppendStreamText append text

func (*ContentObj) AppendStreamTransform

func (c *ContentObj) AppendStreamTransform(matrix TransformMatrix)

AppendStreamTransform applies the transformation matrix to the current content

func (*ContentObj) AppendStreamTransformBegin

func (c *ContentObj) AppendStreamTransformBegin()

AppendStreamTransformBegin starts a transformation in the current content

func (*ContentObj) AppendStreamTransformEnd

func (c *ContentObj) AppendStreamTransformEnd()

AppendStreamTransformEnd stops a transformation in the current content

func (*ContentObj) AppendStreamUseTemplate

func (c *ContentObj) AppendStreamUseTemplate(id string, x, y, h, sx, sy float64)

AppendStreamUseTemplate append a use template

type Current

type Current struct {
	X float64
	Y float64

	//font
	IndexOfFontObj int
	CountOfFont    int
	CountOfL       int

	Font_Size      float64
	Font_Style     int // Regular|Bold|Italic|Underline
	Font_FontCount int
	Font_Type      int // CURRENT_FONT_TYPE_IFONT or  CURRENT_FONT_TYPE_SUBSET

	Font_ISubset *SubsetFontObj // Font_Type == CURRENT_FONT_TYPE_SUBSET

	//page
	IndexOfPageObj int

	//img
	CountOfImg int
	// contains filtered or unexported fields
}

Current current state

type DeviceRGBObj

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

DeviceRGBObj DeviceRGB

type EmbedFontObj

type EmbedFontObj struct {
	Data string
	// contains filtered or unexported fields
}

func (*EmbedFontObj) SetFont

func (e *EmbedFontObj) SetFont(font IFont, zfontpath string)

type EncodingObj

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

func (*EncodingObj) GetFont

func (e *EncodingObj) GetFont() IFont

func (*EncodingObj) SetFont

func (e *EncodingObj) SetFont(font IFont)

type EncryptionObj

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

EncryptionObj encryption object res

type FontCw

type FontCw map[byte]int

type FontDescItem

type FontDescItem struct {
	Key string
	Val string
}

type FontDescriptorObj

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

func (*FontDescriptorObj) GetFont

func (f *FontDescriptorObj) GetFont() IFont

func (*FontDescriptorObj) SetFont

func (f *FontDescriptorObj) SetFont(font IFont)

func (*FontDescriptorObj) SetFontFileObjRelate

func (f *FontDescriptorObj) SetFontFileObjRelate(relate string)

type Fpdf

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

Fpdf : A simple library for generating PDF written in Go lang

func New

func New(opts ...PdfOption) (*Fpdf, error)

New creates a new Fpdf Object

func (gp *Fpdf) AddExternalLink(url string, x, y, w, h float64)

AddLink

func (gp *Fpdf) AddInternalLink(anchor string, x, y, w, h float64)

func (*Fpdf) AddPage

func (gp *Fpdf) AddPage()

AddPage : add new page

func (*Fpdf) AddPageWithOption

func (gp *Fpdf) AddPageWithOption(opt PageOption)

AddPageWithOption : add new page with option

func (*Fpdf) AddTTFFont

func (gp *Fpdf) AddTTFFont(family string, ttfpath string) error

AddTTFFont : add font file

func (*Fpdf) AddTTFFontByReader

func (gp *Fpdf) AddTTFFontByReader(family string, rd io.Reader) error

AddTTFFontByReader add font file

func (*Fpdf) AddTTFFontByReaderWithOption

func (gp *Fpdf) AddTTFFontByReaderWithOption(family string, rd io.Reader, option TtfOption) error

AddTTFFontByReaderWithOption add font file

func (*Fpdf) AddTTFFontBySubsetFont

func (gp *Fpdf) AddTTFFontBySubsetFont(family string, subsetFont *SubsetFontObj) error

func (*Fpdf) AddTTFFontWithOption

func (gp *Fpdf) AddTTFFontWithOption(family string, ttfpath string, option TtfOption) error

AddTTFFontWithOption : add font file

func (*Fpdf) Arc

func (gp *Fpdf) Arc(x, y, rx, ry, degRotate, degStart, degEnd float64, styleStr string)

Arc draws an elliptical arc centered at point (x, y). rx and ry specify its horizontal and vertical radii.

degRotate specifies the angle that the arc will be rotated. degStart and degEnd specify the starting and ending angle of the arc. All angles are specified in degrees and measured counter-clockwise from the 3 o'clock position.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color, line width, and cap style centered on the arc's path. Filling uses the current fill color.

The Circle() example demonstrates this method.

func (*Fpdf) ArcTo

func (gp *Fpdf) ArcTo(x, y, rx, ry, degRotate, degStart, degEnd float64)

ArcTo draws an elliptical arc centered at point (x, y). rx and ry specify its horizontal and vertical radii. If the start of the arc is not at the current position, a connecting line will be drawn.

degRotate specifies the angle that the arc will be rotated. degStart and degEnd specify the starting and ending angle of the arc. All angles are specified in degrees and measured counter-clockwise from the 3 o'clock position.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color, line width, and cap style centered on the arc's path. Filling uses the current fill color.

The MoveTo() example demonstrates this method.

func (*Fpdf) Beziergon

func (gp *Fpdf) Beziergon(pts Points, styleStr string) error

Beziergon draws a closed figure defined by a series of cubic Bézier curve segments. The first point in the slice defines the starting point of the figure. Each three following points p1, p2, p3 represent a curve segment to the point p3 using p1 and p2 as the Bézier control points.

The x and y fields of the points use the units established in New().

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color and line width centered on the ellipse's perimeter. Filling uses the current fill color.

func (*Fpdf) Beziertext added in v0.0.8

func (gp *Fpdf) Beziertext(pts Points, startBracket, endBracket float64, text string, opt CellOption) error

Beziertext writes text along a path defined by a series of cubic Bézier curve segments. Font size is reduced if the text exceeds avaiable arc length.

func (*Fpdf) Cell

func (gp *Fpdf) Cell(w, h float64, text string) error

Cell : create cell of text ( use current x,y is upper-left corner of cell) Note that this has no effect on Rect.H pdf (now). Fix later :-)

func (*Fpdf) CellWithOption

func (gp *Fpdf) CellWithOption(w, h float64, text string, opt CellOption) error

CellWithOption create cell of text ( use current x,y is upper-left corner of cell)

func (*Fpdf) Cellf

func (gp *Fpdf) Cellf(w, h float64, text string, args ...interface{}) error

Cellf : same as cell but using go's Sprintf format

func (*Fpdf) Circle

func (gp *Fpdf) Circle(x, y, r float64, styleStr string)

Circle draws a circle centered on point (x, y) with radius r.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color and line width centered on the circle's perimeter. Filling uses the current fill color.

func (*Fpdf) ClipCircle

func (gp *Fpdf) ClipCircle(x, y, r float64, outline bool)

ClipCircle begins a circular clipping operation. The circle is centered at (x, y) and has radius r. outline is true to draw a border with the current draw color and line width centered on the circle's perimeter. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped by the specified circle. Call ClipEnd() to restore unclipped operations.

The ClipText() example demonstrates this method.

func (*Fpdf) ClipEllipse

func (gp *Fpdf) ClipEllipse(x, y, rx, ry float64, outline bool)

ClipEllipse begins an elliptical clipping operation. The ellipse is centered at (x, y). Its horizontal and vertical radii are specified by rx and ry. outline is true to draw a border with the current draw color and line width centered on the ellipse's perimeter. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped by the specified ellipse. Call ClipEnd() to restore unclipped operations.

This ClipText() example demonstrates this method.

func (*Fpdf) ClipEnd

func (gp *Fpdf) ClipEnd()

ClipEnd ends a clipping operation that was started with a call to ClipRect(), ClipRoundedRect(), ClipText(), ClipEllipse(), ClipCircle() or ClipPolygon(). Clipping operations can be nested. The document cannot be successfully output while a clipping operation is active.

The ClipText() example demonstrates this method.

func (*Fpdf) ClipPolygon

func (gp *Fpdf) ClipPolygon(points []Point, outline bool)

ClipPolygon begins a clipping operation within a polygon. The figure is defined by a series of vertices specified by points. The x and y fields of the points use the units established in New(). The last point in the slice will be implicitly joined to the first to close the polygon. outline is true to draw a border with the current draw color and line width centered on the polygon's perimeter. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped by the specified polygon. Call ClipEnd() to restore unclipped operations.

The ClipText() example demonstrates this method.

func (*Fpdf) ClipRect

func (gp *Fpdf) ClipRect(x, y, w, h float64, outline bool)

ClipRect begins a rectangular clipping operation. The rectangle is of width w and height h. Its upper left corner is positioned at point (x, y). outline is true to draw a border with the current draw color and line width centered on the rectangle's perimeter. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped by the specified rectangle. Call ClipEnd() to restore unclipped operations.

This ClipText() example demonstrates this method.

func (*Fpdf) ClipRoundedRect

func (gp *Fpdf) ClipRoundedRect(x, y, w, h, r float64, outline bool)

ClipRoundedRect begins a rectangular clipping operation. The rectangle is of width w and height h. Its upper left corner is positioned at point (x, y). The rounded corners of the rectangle are specified by radius r. outline is true to draw a border with the current draw color and line width centered on the rectangle's perimeter. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped by the specified rectangle. Call ClipEnd() to restore unclipped operations.

This ClipText() example demonstrates this method.

func (*Fpdf) ClipText

func (gp *Fpdf) ClipText(x, y float64, txtStr string, outline bool)

ClipText begins a clipping operation in which rendering is confined to the character string specified by txtStr. The origin (x, y) is on the left of the first character at the baseline. The current font is used. outline is true to draw a border with the current draw color and line width centered on the perimeters of the text characters. Only the outer half of the border will be shown. After calling this method, all rendering operations (for example, Image(), LinearGradient(), etc) will be clipped. Call ClipEnd() to restore unclipped operations.

func (*Fpdf) Close

func (gp *Fpdf) Close() error

Close closes the pdf buffer

func (*Fpdf) ClosePath

func (gp *Fpdf) ClosePath()

ClosePath creates a line from the current location to the last MoveTo point (if not the same) and mark the path as closed so the first and last lines join nicely.

The MoveTo() example demonstrates this method.

func (*Fpdf) CreateTemplate

func (gp *Fpdf) CreateTemplate(fn TplFunc) (Template, error)

CreateTemplate defines a new template using the current page size.

func (*Fpdf) CreateTemplateCustom

func (gp *Fpdf) CreateTemplateCustom(corner Point, fn TplFunc, opts ...PdfOption) (Template, error)

CreateTemplateCustom starts a template, using the given bounds.

func (*Fpdf) Curve

func (gp *Fpdf) Curve(x0, y0, cx, cy, x1, y1 float64, styleStr string)

Curve draws a single-segment quadratic Bézier curve. The curve starts at the point (x0, y0) and ends at the point (x1, y1). The control point (cx, cy) specifies the curvature. At the start point, the curve is tangent to the straight line between the start point and the control point. At the end point, the curve is tangent to the straight line between the end point and the control point.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color, line width, and cap style centered on the curve's path. Filling uses the current fill color.

The Circle() example demonstrates this method.

func (*Fpdf) CurveBezierCubic

func (gp *Fpdf) CurveBezierCubic(x0, y0, cx0, cy0, cx1, cy1, x1, y1 float64, styleStr string)

CurveBezierCubic draws a single-segment cubic Bézier curve. The curve starts at the point (x0, y0) and ends at the point (x1, y1). The control points (cx0, cy0) and (cx1, cy1) specify the curvature. At the start point, the curve is tangent to the straight line between the start point and the control point (cx0, cy0). At the end point, the curve is tangent to the straight line between the end point and the control point (cx1, cy1).

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color, line width, and cap style centered on the curve's path. Filling uses the current fill color.

This routine performs the same function as CurveCubic() but uses standard argument order.

The Circle() example demonstrates this method.

func (*Fpdf) CurveBezierCubicTo

func (gp *Fpdf) CurveBezierCubicTo(cx0, cy0, cx1, cy1, x, y float64)

CurveBezierCubicTo creates a single-segment cubic Bézier curve. The curve starts at the current stylus location and ends at the point (x, y). The control points (cx0, cy0) and (cx1, cy1) specify the curvature. At the current stylus, the curve is tangent to the straight line between the current stylus location and the control point (cx0, cy0). At the end point, the curve is tangent to the straight line between the end point and the control point (cx1, cy1).

The MoveTo() example demonstrates this method.

func (*Fpdf) CurveCubic

func (gp *Fpdf) CurveCubic(x0, y0, cx0, cy0, x1, y1, cx1, cy1 float64, styleStr string)

CurveCubic draws a single-segment cubic Bézier curve. This routine performs the same function as CurveBezierCubic() but has a nonstandard argument order. It is retained to preserve backward compatibility.

func (*Fpdf) CurveTo

func (gp *Fpdf) CurveTo(cx, cy, x, y float64)

CurveTo : marks a curve from the x, y position to the new x, y position

func (*Fpdf) DrawPath

func (gp *Fpdf) DrawPath(styleStr string)

DrawPath actually draws the path on the page.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Path-painting operators as defined in the PDF specification are also allowed: "S" (Stroke the path), "s" (Close and stroke the path), "f" (fill the path, using the nonzero winding number), "f*" (Fill the path, using the even-odd rule), "B" (Fill and then stroke the path, using the nonzero winding number rule), "B*" (Fill and then stroke the path, using the even-odd rule), "b" (Close, fill, and then stroke the path, using the nonzero winding number rule) and "b*" (Close, fill, and then stroke the path, using the even-odd rule). Drawing uses the current draw color, line width, and cap style centered on the path. Filling uses the current fill color.

The MoveTo() example demonstrates this method.

func (*Fpdf) Ellipse

func (gp *Fpdf) Ellipse(x, y, rx, ry, degRotate float64, styleStr string)

Ellipse draws an ellipse centered at point (x, y). rx and ry specify its horizontal and vertical radii.

degRotate specifies the counter-clockwise angle in degrees that the ellipse will be rotated.

styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and filled. An empty string will be replaced with "D". Drawing uses the current draw color and line width centered on the ellipse's perimeter. Filling uses the current fill color.

The Circle() example demonstrates this method.

func (*Fpdf) GetBoundaryHeight

func (gp *Fpdf) GetBoundaryHeight(t int) float64

func (*Fpdf) GetBoundaryPosition

func (gp *Fpdf) GetBoundaryPosition(t int) (p Point)

func (*Fpdf) GetBoundarySize

func (gp *Fpdf) GetBoundarySize(t int) (rec Rect)

func (*Fpdf) GetBoundaryWidth

func (gp *Fpdf) GetBoundaryWidth(t int) float64

func (*Fpdf) GetBoundaryX

func (gp *Fpdf) GetBoundaryX(t int) float64

func (*Fpdf) GetBoundaryY

func (gp *Fpdf) GetBoundaryY(t int) float64

func (*Fpdf) GetBytesPdf

func (gp *Fpdf) GetBytesPdf() []byte

GetBytesPdf : get bytes of pdf file

func (*Fpdf) GetBytesPdfReturnErr

func (gp *Fpdf) GetBytesPdfReturnErr() ([]byte, error)

GetBytesPdfReturnErr : get bytes of pdf file

func (*Fpdf) GetInfo

func (gp *Fpdf) GetInfo() *PdfInfo

GetInfo get Document Information Dictionary

func (*Fpdf) GetPageBoundary

func (gp *Fpdf) GetPageBoundary(t int) *PageBoundary

func (*Fpdf) Image

func (gp *Fpdf) Image(picPath string, x float64, y float64, rect Rect) error

Image : draw image

func (*Fpdf) ImageByHolder

func (gp *Fpdf) ImageByHolder(img ImageHolder, x float64, y float64, rect Rect) error

ImageByHolder : draw image by ImageHolder

func (*Fpdf) ImageByObj added in v0.1.1

func (gp *Fpdf) ImageByObj(img *ImageObj, x float64, y float64, rect Rect) error

func (*Fpdf) ImageByReader

func (gp *Fpdf) ImageByReader(r io.Reader, x float64, y float64, rect Rect) error

ImageByReader adds an image to the pdf with a reader

func (*Fpdf) ImageByURL

func (gp *Fpdf) ImageByURL(url string, x float64, y float64, rect Rect) error

ImageByURL adds an image to the pdf using the given url

func (*Fpdf) KernOverride

func (gp *Fpdf) KernOverride(family string, fn FuncKernOverride) error

KernOverride override kern value

func (*Fpdf) Line

func (gp *Fpdf) Line(x1 float64, y1 float64, x2 float64, y2 float64)

Line : draw line

func (*Fpdf) LineTo

func (gp *Fpdf) LineTo(x, y float64)

LineTo creates a line from the current stylus location to (x, y), which becomes the new stylus location. Note that this only creates the line in the path; it does not actually draw the line on the page.

The MoveTo() example demonstrates this method.

func (*Fpdf) Ln

func (gp *Fpdf) Ln(h float64)

Ln performs a line break. The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter. This method is demonstrated in the example for MultiCell.

func (*Fpdf) MarginBottom

func (gp *Fpdf) MarginBottom() float64

MarginBottom returns the bottom margin

func (*Fpdf) MarginLeft

func (gp *Fpdf) MarginLeft() float64

MarginLeft returns the left margin

func (*Fpdf) MarginRight

func (gp *Fpdf) MarginRight() float64

MarginRight returns the right margin

func (*Fpdf) MarginTop

func (gp *Fpdf) MarginTop() float64

MarginTop returns the top margin

func (*Fpdf) Margins

func (gp *Fpdf) Margins() (float64, float64, float64, float64)

Margins gets the current margins, The margins will be converted back to the documents units. Returned values will be in the following order Left, Top, Right, Bottom

func (*Fpdf) MeasureTextWidth

func (gp *Fpdf) MeasureTextWidth(text string) (float64, error)

MeasureTextWidth : measure Width of text (use current font)

func (*Fpdf) MoveTo

func (gp *Fpdf) MoveTo(x, y float64)

MoveTo moves the stylus to (x, y) without drawing the path from the previous point. Paths must start with a MoveTo to set the original stylus location or the result is undefined.

Create a "path" by moving a virtual stylus around the page (with MoveTo, LineTo, CurveTo, CurveBezierCubicTo, ArcTo & ClosePath) then draw it or fill it in (with DrawPath). The main advantage of using the path drawing routines rather than multiple Fpdf.Line is that PDF creates nice line joins at the angles, rather than just overlaying the lines.

func (*Fpdf) MultiCell

func (gp *Fpdf) MultiCell(w, h float64, txtStr string) error

MultiCell supports printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other.

Text can be aligned, centered or justified. The cell block can be framed and the background painted. See CellFormat() for more details.

The current position after calling MultiCell() is the beginning of the next line, equivalent to calling CellFormat with ln equal to 1.

w is the width of the cells. A value of zero indicates cells that reach to the right margin.

h indicates the line height of each cell in the unit of measure specified in New().

func (*Fpdf) MultiCellOpts

func (gp *Fpdf) MultiCellOpts(w, h float64, txtStr string, opts CellOption) error

MultiCell supports printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other.

Text can be aligned, centered or justified. The cell block can be framed and the background painted. See CellFormat() for more details.

The current position after calling MultiCell() is the beginning of the next line, equivalent to calling CellFormat with ln equal to 1.

w is the width of the cells. A value of zero indicates cells that reach to the right margin.

h indicates the line height of each cell in the unit of measure specified in New().

func (*Fpdf) NewArtPageBoundary

func (gp *Fpdf) NewArtPageBoundary(x, y, w, h float64) *PageBoundary

func (*Fpdf) NewBleedPageBoundary

func (gp *Fpdf) NewBleedPageBoundary(x, y, w, h float64) *PageBoundary

func (*Fpdf) NewCropPageBoundary

func (gp *Fpdf) NewCropPageBoundary(x, y, w, h float64) *PageBoundary

func (*Fpdf) NewPageBoundary

func (gp *Fpdf) NewPageBoundary(t int, x, y, w, h float64) (*PageBoundary, error)

func (*Fpdf) NewPageOption

func (gp *Fpdf) NewPageOption(w, h float64) *PageOption

func (*Fpdf) NewPageSizeBoundary

func (gp *Fpdf) NewPageSizeBoundary(w, h float64) *PageBoundary

func (*Fpdf) NewTrimPageBoundary

func (gp *Fpdf) NewTrimPageBoundary(x, y, w, h float64) *PageBoundary

func (*Fpdf) Oval

func (gp *Fpdf) Oval(x1 float64, y1 float64, x2 float64, y2 float64)

Oval : draw oval

func (*Fpdf) PointsToUnits

func (gp *Fpdf) PointsToUnits(u float64) float64

PointsToUnits converts the points to the documents unit type

func (*Fpdf) PointsToUnitsVar

func (gp *Fpdf) PointsToUnitsVar(u ...*float64)

PointsToUnits converts the points to the documents unit type for all variables passed in

func (*Fpdf) Read

func (gp *Fpdf) Read(p []byte) (int, error)

func (*Fpdf) RectFromLowerLeft

func (gp *Fpdf) RectFromLowerLeft(x float64, y float64, wdth float64, hght float64)

RectFromLowerLeft : draw rectangle from lower-left corner (x, y)

func (*Fpdf) RectFromLowerLeftWithStyle

func (gp *Fpdf) RectFromLowerLeftWithStyle(x float64, y float64, wdth float64, hght float64, style string)

RectFromLowerLeftWithStyle : draw rectangle from lower-left corner (x, y)

  • style: Style of rectangule (draw and/or fill: D, F, DF, FD) D or empty string: draw. This is the default value. F: fill DF or FD: draw and fill

func (*Fpdf) RectFromUpperLeft

func (gp *Fpdf) RectFromUpperLeft(x float64, y float64, wdth float64, hght float64)

RectFromUpperLeft : draw rectangle from upper-left corner (x, y)

func (*Fpdf) RectFromUpperLeftWithStyle

func (gp *Fpdf) RectFromUpperLeftWithStyle(x float64, y float64, wdth float64, hght float64, style string)

RectFromUpperLeftWithStyle : draw rectangle from upper-left corner (x, y)

  • style: Style of rectangule (draw and/or fill: D, F, DF, FD) D or empty string: draw. This is the default value. F: fill DF or FD: draw and fill

func (*Fpdf) Rotate

func (gp *Fpdf) Rotate(angle, x, y float64)

Rotate rotate text or image angle is angle in degrees. x, y is rotation center

func (*Fpdf) RotateReset

func (gp *Fpdf) RotateReset()

RotateReset reset rotate

func (*Fpdf) SetAnchor

func (gp *Fpdf) SetAnchor(name string)

func (*Fpdf) SetArtBox

func (gp *Fpdf) SetArtBox(x, y, w, h float64)

func (*Fpdf) SetAuthor

func (gp *Fpdf) SetAuthor(authorStr string)

SetAuthor defines the author of the document.

func (*Fpdf) SetBleedBox

func (gp *Fpdf) SetBleedBox(x, y, w, h float64)

func (*Fpdf) SetCMYKFillColor

func (gp *Fpdf) SetCMYKFillColor(c, m, y, k uint8)

SetCMYKFillColor set the color for the stroke

func (*Fpdf) SetCMYKStrokeColor

func (gp *Fpdf) SetCMYKStrokeColor(c, m, y, k uint8)

SetCMYKStrokeColor set the color for the stroke

func (*Fpdf) SetCompressLevel

func (gp *Fpdf) SetCompressLevel(level int)

SetCompressLevel : set compress Level for content streams Possible values for level:

-2 HuffmanOnly, -1 DefaultCompression (which is level 6)
 0 No compression,
 1 fastest compression, but not very good ratio
 9 best compression, but slowest

func (*Fpdf) SetCreator

func (gp *Fpdf) SetCreator(creatorStr string)

SetCreator defines the creator of the document.

func (*Fpdf) SetCropBox

func (gp *Fpdf) SetCropBox(x, y, w, h float64)

func (*Fpdf) SetFont

func (gp *Fpdf) SetFont(family string, style string, size float64) error

SetFont : set font style support "" or "U" for "B" and "I" should be loaded apropriate fonts with same styles defined

func (*Fpdf) SetFontWithStyle

func (gp *Fpdf) SetFontWithStyle(family string, style int, size float64) error

SetFontWithStyle : set font style support Regular or Underline for Bold|Italic should be loaded apropriate fonts with same styles defined

func (*Fpdf) SetGrayFill

func (gp *Fpdf) SetGrayFill(grayScale float64)

SetGrayFill set the grayscale for the fill, takes a float64 between 0.0 and 1.0

func (*Fpdf) SetGrayStroke

func (gp *Fpdf) SetGrayStroke(grayScale float64)

SetGrayStroke set the grayscale for the stroke, takes a float64 between 0.0 and 1.0

func (*Fpdf) SetInfo

func (gp *Fpdf) SetInfo(info PdfInfo)

SetInfo set Document Information Dictionary

func (*Fpdf) SetKeywords

func (gp *Fpdf) SetKeywords(keywordsStr string)

SetKeywords defines the keywords of the document. keywordStr is a space-delimited string, for example "invoice August".

func (*Fpdf) SetLineCapStyle

func (gp *Fpdf) SetLineCapStyle(style int)

SetLineCapStyle defines the line cap style. styleStr should be "butt", "round" or "square". A square style projects from the end of the line. The method can be called before the first page is created. The value is retained from page to page.

func (*Fpdf) SetLineJoinStyle

func (gp *Fpdf) SetLineJoinStyle(style int)

SetLineJoinStyle defines the line cap style. styleStr should be "miter", "round" or "bevel". The method can be called before the first page is created. The value is retained from page to page.

func (*Fpdf) SetLineType

func (gp *Fpdf) SetLineType(linetype string)

SetLineType : set line type ("dashed" ,"dotted")

Usage:
pdf.SetLineType("dashed")
pdf.Line(50, 200, 550, 200)
pdf.SetLineType("dotted")
pdf.Line(50, 400, 550, 400)

func (*Fpdf) SetLineWidth

func (gp *Fpdf) SetLineWidth(width float64)

SetLineWidth : set line width

func (*Fpdf) SetMarginBottom

func (gp *Fpdf) SetMarginBottom(margin float64)

SetMarginBottom set the bottom margin

func (*Fpdf) SetMarginLeft

func (gp *Fpdf) SetMarginLeft(margin float64)

SetMarginLeft sets the left margin

func (*Fpdf) SetMarginRight

func (gp *Fpdf) SetMarginRight(margin float64)

SetMarginRight sets the right margin

func (*Fpdf) SetMarginTop

func (gp *Fpdf) SetMarginTop(margin float64)

SetMarginTop sets the top margin

func (*Fpdf) SetMargins

func (gp *Fpdf) SetMargins(left, top, right, bottom float64)

SetMargins defines the left, top, right and bottom margins. By default, they equal 1 cm. Call this method to change them.

func (*Fpdf) SetNoCompression

func (gp *Fpdf) SetNoCompression()

SetNoCompression : compressLevel = 0

func (*Fpdf) SetPageBoundary

func (gp *Fpdf) SetPageBoundary(pb *PageBoundary)

Set a page boundary

func (*Fpdf) SetPageSize

func (gp *Fpdf) SetPageSize(w, h float64)

func (*Fpdf) SetProducer

func (gp *Fpdf) SetProducer(producerStr string)

SetProdcer defines the producer of the document.

func (*Fpdf) SetRGBFillColor

func (gp *Fpdf) SetRGBFillColor(r uint8, g uint8, b uint8)

SetRGBFillColor set the color for the stroke

func (*Fpdf) SetRGBStrokeColor

func (gp *Fpdf) SetRGBStrokeColor(r uint8, g uint8, b uint8)

SetRBStrokeColor set the color for the stroke

func (*Fpdf) SetSubject

func (gp *Fpdf) SetSubject(subjectStr string)

SetSubject defines the subject of the document.

func (*Fpdf) SetTextColor

func (gp *Fpdf) SetTextColor(r uint8, g uint8, b uint8)

SetTextColor : function sets the text color

func (*Fpdf) SetTitle

func (gp *Fpdf) SetTitle(titleStr string)

SetTitle defines the title of the document.

func (*Fpdf) SetTrimBox

func (gp *Fpdf) SetTrimBox(x, y, w, h float64)

func (*Fpdf) SetX

func (gp *Fpdf) SetX(x float64)

SetX : set current position X

func (*Fpdf) SetXY

func (gp *Fpdf) SetXY(x, y float64)

SetXY sets both x and y

func (*Fpdf) SetY

func (gp *Fpdf) SetY(y float64)

SetY : set current position y

func (*Fpdf) Template added in v0.0.4

func (gp *Fpdf) Template(corner Point) (*FpdfTpl, error)

func (*Fpdf) Text

func (gp *Fpdf) Text(x, y float64, text string) error

Text write text start at current x,y ( current y is the baseline of text )

func (*Fpdf) Transform

func (gp *Fpdf) Transform(tm TransformMatrix)

Transform generally transforms the following text, drawings and images according to the specified matrix. It is typically easier to use the various methods such as TransformRotate() and TransformMirrorVertical() instead.

func (*Fpdf) TransformBegin

func (gp *Fpdf) TransformBegin()

TransformBegin sets up a transformation context for subsequent text, drawings and images. The typical usage is to immediately follow a call to this method with a call to one or more of the transformation methods such as TransformScale(), TransformSkew(), etc. This is followed by text, drawing or image output and finally a call to TransformEnd(). All transformation contexts must be properly ended prior to outputting the document.

func (*Fpdf) TransformEnd

func (gp *Fpdf) TransformEnd()

TransformEnd applies a transformation that was begun with a call to TransformBegin().

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformMirrorHorizontal

func (gp *Fpdf) TransformMirrorHorizontal(x float64)

TransformMirrorHorizontal horizontally mirrors the following text, drawings and images. x is the axis of reflection.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformMirrorLine

func (gp *Fpdf) TransformMirrorLine(angle, x, y float64)

TransformMirrorLine symmetrically mirrors the following text, drawings and images on the line defined by angle and the point (x, y). angles is specified in degrees and measured counter-clockwise from the 3 o'clock position.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformMirrorPoint

func (gp *Fpdf) TransformMirrorPoint(x, y float64)

TransformMirrorPoint symmetrically mirrors the following text, drawings and images on the point specified by (x, y).

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformMirrorVertical

func (gp *Fpdf) TransformMirrorVertical(y float64)

TransformMirrorVertical vertically mirrors the following text, drawings and images. y is the axis of reflection.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformRotate

func (gp *Fpdf) TransformRotate(angle, x, y float64)

TransformRotate rotates the following text, drawings and images around the center point (x, y). angle is specified in degrees and measured counter-clockwise from the 3 o'clock position.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformScale

func (gp *Fpdf) TransformScale(scaleWd, scaleHt, x, y float64) error

TransformScale generally scales the following text, drawings and images. scaleWd and scaleHt are the percentage scaling factors for width and height. (x, y) is center of scaling.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformScaleX

func (gp *Fpdf) TransformScaleX(scaleWd, x, y float64)

TransformScaleX scales the width of the following text, drawings and images. scaleWd is the percentage scaling factor. (x, y) is center of scaling.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformScaleXY

func (gp *Fpdf) TransformScaleXY(s, x, y float64)

TransformScaleXY uniformly scales the width and height of the following text, drawings and images. s is the percentage scaling factor for both width and height. (x, y) is center of scaling.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformScaleY

func (gp *Fpdf) TransformScaleY(scaleHt, x, y float64)

TransformScaleY scales the height of the following text, drawings and images. scaleHt is the percentage scaling factor. (x, y) is center of scaling.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformSkew

func (gp *Fpdf) TransformSkew(angleX, angleY, x, y float64) error

TransformSkew generally skews the following text, drawings and images keeping the point (x, y) stationary. angleX ranges from -90 degrees (skew to the left) to 90 degrees (skew to the right). angleY ranges from -90 degrees (skew to the bottom) to 90 degrees (skew to the top).

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformSkewX

func (gp *Fpdf) TransformSkewX(angleX, x, y float64) error

TransformSkewX horizontally skews the following text, drawings and images keeping the point (x, y) stationary. angleX ranges from -90 degrees (skew to the left) to 90 degrees (skew to the right).

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformSkewY

func (gp *Fpdf) TransformSkewY(angleY, x, y float64) error

TransformSkewY vertically skews the following text, drawings and images keeping the point (x, y) stationary. angleY ranges from -90 degrees (skew to the bottom) to 90 degrees (skew to the top).

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformTranslate

func (gp *Fpdf) TransformTranslate(tx, ty float64)

TransformTranslate moves the following text, drawings and images horizontally and vertically by the amounts specified by tx and ty.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformTranslateX

func (gp *Fpdf) TransformTranslateX(tx float64)

TransformTranslateX moves the following text, drawings and images horizontally by the amount specified by tx.

The TransformBegin() example demonstrates this method.

func (*Fpdf) TransformTranslateY

func (gp *Fpdf) TransformTranslateY(ty float64)

TransformTranslateY moves the following text, drawings and images vertically by the amount specified by ty.

The TransformBegin() example demonstrates this method.

func (*Fpdf) UnitsToPoints

func (gp *Fpdf) UnitsToPoints(u float64) float64

UnitsToPoints converts the units to the documents unit type

func (*Fpdf) UnitsToPointsVar

func (gp *Fpdf) UnitsToPointsVar(u ...*float64)

UnitsToPointsVar converts the units to the documents unit type for all variables passed in

func (*Fpdf) UseTemplate

func (gp *Fpdf) UseTemplate(t Template) error

UseTemplate adds a template to the current page or another template, using the size and position at which it was originally written.

func (*Fpdf) UseTemplateScaled

func (gp *Fpdf) UseTemplateScaled(t Template, corner Point, size Rect) error

UseTemplateScaled adds a template to the current page or another template, using the given page coordinates.

func (*Fpdf) Write

func (gp *Fpdf) Write(w io.Writer) error

func (*Fpdf) WritePdf

func (gp *Fpdf) WritePdf(pdfPath string) error

WritePdf : wirte pdf file

func (*Fpdf) WriteText

func (gp *Fpdf) WriteText(h float64, txtStr string) error

WriteText prints text from the current position. When the right margin is reached (or the \n character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text.

It is possible to put a link on the text.

h indicates the line height in the unit of measure specified in New().

func (*Fpdf) WriteTextOpts

func (gp *Fpdf) WriteTextOpts(h float64, txtStr string, opts CellOption) error

WriteText prints text from the current position. When the right margin is reached (or the \n character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text.

It is possible to put a link on the text.

h indicates the line height in the unit of measure specified in New().

func (*Fpdf) WriteTextOptsf

func (gp *Fpdf) WriteTextOptsf(h float64, txtStr string, opts CellOption, v ...interface{}) error

WriteTextOptsf is the same as WriteText but it uses fmt.Sprintf

func (*Fpdf) WriteTextf

func (gp *Fpdf) WriteTextf(h float64, txtStr string, v ...interface{}) error

WriteTextf is the same as WriteText but it uses fmt.Sprintf

func (*Fpdf) X

func (gp *Fpdf) X() float64

X : get current position X

func (*Fpdf) XY

func (gp *Fpdf) XY() (float64, float64)

XY gets the current x and y position

func (*Fpdf) Y

func (gp *Fpdf) Y() float64

Y : get current position y

type FpdfTpl

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

FpdfTpl is a concrete implementation of the Template interface.

func (*FpdfTpl) Bytes

func (t *FpdfTpl) Bytes() []byte

Bytes returns the actual template data, not including resources

func (*FpdfTpl) Fonts

func (t *FpdfTpl) Fonts() []*SubsetFontObj

Fonts returns a list of the fonts used in the template

func (*FpdfTpl) FromPage

func (t *FpdfTpl) FromPage(page int) (Template, error)

FromPage creates a new template from a specific Page

func (*FpdfTpl) FromPages

func (t *FpdfTpl) FromPages() []Template

FromPages creates a template slice with all the pages within a template.

func (*FpdfTpl) GobDecode

func (t *FpdfTpl) GobDecode(buf []byte) error

GobDecode decodes the specified byte buffer into the receiving template.

func (*FpdfTpl) GobEncode

func (t *FpdfTpl) GobEncode() ([]byte, error)

GobEncode encodes the receiving template into a byte buffer. Use GobDecode to decode the byte buffer back to a template.

func (*FpdfTpl) ID

func (t *FpdfTpl) ID() string

ID returns the global template identifier

func (*FpdfTpl) Images

func (t *FpdfTpl) Images() []*ImageObj

Images returns a list of the images used in this template

func (*FpdfTpl) NumPages

func (t *FpdfTpl) NumPages() int

NumPages returns the number of available pages within the template. Look at FromPage and FromPages on access to that content.

func (*FpdfTpl) Serialize

func (t *FpdfTpl) Serialize() ([]byte, error)

Serialize turns a template into a byte string for later deserialization

func (*FpdfTpl) Size

func (t *FpdfTpl) Size() (corner Point, size Rect)

Size gives the bounding dimensions of this template

func (*FpdfTpl) Templates

func (t *FpdfTpl) Templates() []Template

Templates returns a list of templates used in this template

type FuncKernOverride

type FuncKernOverride func(
	leftRune rune,
	rightRune rune,
	leftPair uint,
	rightPair uint,
	pairVal int16,
) int16

FuncKernOverride return your custome pair value

type IFont

type IFont interface {
	Init()
	GetType() string
	GetName() string
	GetDesc() []FontDescItem
	GetUp() int
	GetUt() int
	GetCw() FontCw
	GetEnc() string
	GetDiff() string
	GetOriginalsize() int

	SetFamily(family string)
	GetFamily() string
}

type IObj

type IObj interface {
	// contains filtered or unexported methods
}

IObj inteface for all pdf object

type ImageHolder

type ImageHolder interface {
	ID() string
	io.Reader
}

ImageHolder hold image data

func ImageHolderByBytes

func ImageHolderByBytes(b []byte) (ImageHolder, error)

ImageHolderByBytes create ImageHolder by []byte

func ImageHolderByPath

func ImageHolderByPath(path string) (ImageHolder, error)

ImageHolderByPath create ImageHolder by image path

func ImageHolderByReader

func ImageHolderByReader(r io.Reader) (ImageHolder, error)

ImageHolderByReader create ImageHolder by io.Reader

type ImageObj

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

ImageObj image object

func DeserializeImage added in v0.1.2

func DeserializeImage(b []byte) (*ImageObj, error)

func NewImageObj

func NewImageObj(img ImageHolder) (*ImageObj, error)

func (*ImageObj) GetRect

func (i *ImageObj) GetRect() *Rect

GetRect get rect of img

func (*ImageObj) GobDecode

func (s *ImageObj) GobDecode(buf []byte) error

func (*ImageObj) GobEncode

func (s *ImageObj) GobEncode() ([]byte, error)

func (*ImageObj) Parse

func (i *ImageObj) Parse() error

Parse parse img

func (*ImageObj) Serialize added in v0.1.1

func (i *ImageObj) Serialize() ([]byte, error)

func (*ImageObj) SetImage

func (i *ImageObj) SetImage(r io.Reader) error

SetImage set image

func (*ImageObj) SetImagePath

func (i *ImageObj) SetImagePath(path string) error

SetImagePath set image path

type MapOfCharacterToGlyphIndex

type MapOfCharacterToGlyphIndex struct {
	Keys []rune
	Vals []uint
	// contains filtered or unexported fields
}

MapOfCharacterToGlyphIndex map of CharacterToGlyphIndex

func NewMapOfCharacterToGlyphIndex

func NewMapOfCharacterToGlyphIndex() *MapOfCharacterToGlyphIndex

NewMapOfCharacterToGlyphIndex new CharacterToGlyphIndex

func (*MapOfCharacterToGlyphIndex) AllKeys

func (m *MapOfCharacterToGlyphIndex) AllKeys() []rune

AllKeys get keys

func (*MapOfCharacterToGlyphIndex) AllKeysString

func (m *MapOfCharacterToGlyphIndex) AllKeysString() string

func (*MapOfCharacterToGlyphIndex) AllVals

func (m *MapOfCharacterToGlyphIndex) AllVals() []uint

AllVals get all values

func (*MapOfCharacterToGlyphIndex) GobDecode

func (s *MapOfCharacterToGlyphIndex) GobDecode(buf []byte) error

func (*MapOfCharacterToGlyphIndex) GobEncode

func (s *MapOfCharacterToGlyphIndex) GobEncode() ([]byte, error)

func (*MapOfCharacterToGlyphIndex) Index

func (m *MapOfCharacterToGlyphIndex) Index(k rune) (int, bool)

Index get index by key

func (*MapOfCharacterToGlyphIndex) KeyExists

func (m *MapOfCharacterToGlyphIndex) KeyExists(k rune) bool

KeyExists key is exists?

func (*MapOfCharacterToGlyphIndex) Set

func (m *MapOfCharacterToGlyphIndex) Set(k rune, v uint)

Set set key and value to map

func (*MapOfCharacterToGlyphIndex) Val

Val get value by Key

type Margins

type Margins struct {
	Left, Top, Right, Bottom float64
}

type PDFProtection

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

PDFProtection protection in pdf

func (*PDFProtection) EncryptionObj

func (p *PDFProtection) EncryptionObj() *EncryptionObj

EncryptionObj get Encryption Object

func (*PDFProtection) Objectkey

func (p *PDFProtection) Objectkey(objID int) []byte

Objectkey create object key from ObjID

func (*PDFProtection) SetProtection

func (p *PDFProtection) SetProtection(permissions int, userPass []byte, ownerPass []byte) error

SetProtection set protection infomation

type PDFProtectionConfig

type PDFProtectionConfig struct {
	UseProtection bool
	Permissions   int
	UserPass      []byte
	OwnerPass     []byte
}

PDFProtectionConfig config of pdf protection

type PageBoundary

type PageBoundary struct {
	Type     int
	Position Point
	Size     Rect
}

func NewArtPageBoundary

func NewArtPageBoundary(u int, x, y, w, h float64) *PageBoundary

func NewBleedPageBoundary

func NewBleedPageBoundary(u int, x, y, w, h float64) *PageBoundary

func NewCropPageBoundary

func NewCropPageBoundary(u int, x, y, w, h float64) *PageBoundary

func NewPageBoundary

func NewPageBoundary(u int, t int, x, y, w, h float64) (*PageBoundary, error)

func NewPageSizeBoundary

func NewPageSizeBoundary(u int, w, h float64) *PageBoundary

func NewTrimPageBoundary

func NewTrimPageBoundary(u int, x, y, w, h float64) *PageBoundary

type PageObj

type PageObj struct {
	ResourcesRelate string

	Links []linkOption
	// contains filtered or unexported fields
}

PageObj pdf page object

type PageOption

type PageOption struct {
	PageBoundaries [5]*PageBoundary
}

PageOption option of page

func NewPageOption

func NewPageOption(u int, w, h float64) (po *PageOption)

func (*PageOption) AddPageBoundary

func (po *PageOption) AddPageBoundary(pb *PageBoundary)

func (*PageOption) GetBoundary

func (po *PageOption) GetBoundary(t int) *PageBoundary

func (*PageOption) IsEmpty

func (po *PageOption) IsEmpty() bool

type PagesObj

type PagesObj struct {
	PageCount int
	Kids      string
	// contains filtered or unexported fields
}

PagesObj pdf pages object

type PdfDictionaryObj

type PdfDictionaryObj struct {
	PtrToSubsetFontObj *SubsetFontObj
	// contains filtered or unexported fields
}

PdfDictionaryObj pdf dictionary object

func (*PdfDictionaryObj) AddCompositeGlyphs

func (p *PdfDictionaryObj) AddCompositeGlyphs(glyphArray *[]int, glyph int)

AddCompositeGlyphs add composite glyph composite glyph is a Unicode entity that can be defined as a sequence of one or more other characters.

func (*PdfDictionaryObj) GetOffset

func (p *PdfDictionaryObj) GetOffset(glyph int) int

GetOffset get offset from glyf table

func (*PdfDictionaryObj) SetPtrToSubsetFontObj

func (p *PdfDictionaryObj) SetPtrToSubsetFontObj(ptr *SubsetFontObj)

SetPtrToSubsetFontObj set subsetFontObj pointer

type PdfInfo

type PdfInfo struct {
	Title    string //The document’s title
	Author   string //The name of the person who created the document.
	Subject  string //The subject of the document.
	Creator  string // If the document was converted to PDF from another format, the name of the application original document from which it was converted.
	Producer string //If the document was converted to PDF from another format, the name of the application (for example, Acrobat Distiller) that converted it to PDF.
	Keywords string // The keywords associated with the document
}

PdfInfo Document Information Dictionary

type PdfOption

type PdfOption interface {
	// contains filtered or unexported methods
}

A pdf option is passed into the New method to set up the initial state of the pdf being generated.

func PdfOptionArtBox

func PdfOptionArtBox(x, y, w, h float64) PdfOption

PdfOptionArtBox creates a PdfOption that sets the documents ArtBox

func PdfOptionAuthor

func PdfOptionAuthor(author string) PdfOption

PdfOptionAuthor creates a PdfOption that sets the author of the document

func PdfOptionBleedBox

func PdfOptionBleedBox(x, y, w, h float64) PdfOption

PdfOptionBleedBox creates a PdfOption that sets the documents BleedBox

func PdfOptionCompress

func PdfOptionCompress(level int) PdfOption

PdfOptionCompress creates a PdfOption that sets the compression level of the document

func PdfOptionCreator

func PdfOptionCreator(creator string) PdfOption

PdfOptionCreator creates a PdfOption that sets the creator of the document

func PdfOptionCropBox

func PdfOptionCropBox(x, y, w, h float64) PdfOption

PdfOptionCropBox creates a PdfOption that sets the documents CropBox

func PdfOptionKeywords

func PdfOptionKeywords(keywords string) PdfOption

PdfOptionKeywords creates a PdfOption that sets the keywords of the document

func PdfOptionMargin

func PdfOptionMargin(l, t, r, b float64) PdfOption

PdfOptionMargin creates a new PdfOption that sets the margins of the pdf

func PdfOptionMediaBox

func PdfOptionMediaBox(x, y, w, h float64) PdfOption

PdfOptionMediaBox creates a PdfOption that sets the documents MediaBox

func PdfOptionNoCompress

func PdfOptionNoCompress() PdfOption

PdfOptionNoCompress creates a PdfOption that sets the compression level to none.

func PdfOptionPageBoundary

func PdfOptionPageBoundary(t int, x, y, w, h float64) PdfOption

PdfOptionPageBoundary creates a PdfOption that sets a page boundary. Options that can be set are MediaBox, BleedBox, TrimBox, CropBox and ArtBox

func PdfOptionPageSize

func PdfOptionPageSize(w, h float64) PdfOption

PdfOptionPageSize creates a PdfOption that sets the size of the document. This also sets the size of the MediaBox

func PdfOptionProducer

func PdfOptionProducer(producer string) PdfOption

PdfOptionProducer creates a PdfOption that sets the producer of the document

func PdfOptionProtection

func PdfOptionProtection(permissions int, userpass string, ownerpass string) PdfOption

PdfOptionProtection creates a PdfOption that set the protection for the document

func PdfOptionSubject

func PdfOptionSubject(subject string) PdfOption

PdfOptionSubject creates a PdfOption that sets the subject of the document

func PdfOptionTitle

func PdfOptionTitle(title string) PdfOption

PdfOptionTitle creates a PdfOption that sets the title of the document

func PdfOptionTrimBox

func PdfOptionTrimBox(x, y, w, h float64) PdfOption

PdfOptionTrimBox creates a PdfOption that sets the documents TrimBox

func PdfOptionUnit

func PdfOptionUnit(unit int) PdfOption

PdfOptionUnit Creates an option that sets the pdf unit

type Point

type Point struct {
	X, Y float64
}

Point fields X and Y specify the horizontal and vertical coordinates of a point, typically used in drawing.

func ParsePoints added in v0.1.3

func ParsePoints(p string) ([]Point, error)

func (Point) ToPoints

func (p Point) ToPoints(t int) Point

ToPoints converts the Point, assumed to be in units, to points

func (Point) ToUnits

func (p Point) ToUnits(t int) Point

ToUnits will conver the point, assumed to be in pts, to the specified units

func (Point) XY

func (p Point) XY() (float64, float64)

XY gets the X and Y points

type Points

type Points []Point

An array of Point objects

func (Points) ToPoints

func (pts Points) ToPoints(t int) Points

ToPoints will convert the Points, assumed to be in units, to pts

func (Points) ToUnits

func (pts Points) ToUnits(t int) Points

ToUnits will convert the Points, assumed to be in pts, to Units

type ProcSetObj

type ProcSetObj struct {
	//Font
	Realtes     RelateFonts
	RealteXobjs RealteXobjects
	// contains filtered or unexported fields
}

ProcSetObj pdf procSet object

type ProcsetIObj

type ProcsetIObj interface {
	IObj
	// contains filtered or unexported methods
}

ProcsetIObj interface for all pdf objects that need to be registerd to the procset

type RealteXobject

type RealteXobject struct {
	IndexOfObj int
	// should start with I when image
	IdOfObj string
}

type RealteXobjects

type RealteXobjects []RealteXobject

type Rect

type Rect struct {
	W float64
	H float64
	// contains filtered or unexported fields
}

Rect is Basic 2d rectangle object for defining objects sizes

func (Rect) PointsToUnits

func (rect Rect) PointsToUnits(t int) (r Rect)

PointsToUnits converts the rectanlges width and height to Units. When this is called it is assumed the values of the rectangle are in Points

func (Rect) UnitsToPoints

func (rect Rect) UnitsToPoints(t int) (r Rect)

UnitsToPoints converts the rectanlges width and height to Points. When this is called it is assumed the values of the rectangle are in Units

type RelateFont

type RelateFont struct {
	Family string
	//etc /F1
	IdOfObj string
	//etc  5 0 R
	IndexOfObj int
	Style      int // Regular|Bold|Italic
}

type RelateFonts

type RelateFonts []RelateFont

func (RelateFonts) IsContainsFamily

func (re RelateFonts) IsContainsFamily(family string) bool

func (RelateFonts) IsContainsFamilyAndStyle

func (re RelateFonts) IsContainsFamilyAndStyle(family string, style int) bool

IsContainsFamilyAndStyle - checks if already exists font with same name and style

type Rgb

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

Rgb rgb color

func (*Rgb) SetB

func (rgb *Rgb) SetB(b uint8)

SetB set blue

func (*Rgb) SetG

func (rgb *Rgb) SetG(g uint8)

SetG set green

func (*Rgb) SetR

func (rgb *Rgb) SetR(r uint8)

SetR set red

type SMask

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

SMask smask

func (*SMask) GobDecode

func (s *SMask) GobDecode(buf []byte) error

func (SMask) GobEncode

func (s SMask) GobEncode() ([]byte, error)

type SubfontDescriptorObj

type SubfontDescriptorObj struct {
	PtrToSubsetFontObj *SubsetFontObj
	// contains filtered or unexported fields
}

SubfontDescriptorObj pdf subfont descriptorObj object

func (*SubfontDescriptorObj) SetIndexObjPdfDictionary

func (s *SubfontDescriptorObj) SetIndexObjPdfDictionary(index int)

SetIndexObjPdfDictionary set PdfDictionary pointer

func (*SubfontDescriptorObj) SetPtrToSubsetFontObj

func (s *SubfontDescriptorObj) SetPtrToSubsetFontObj(ptr *SubsetFontObj)

SetPtrToSubsetFontObj set SubsetFont pointer

type SubsetFontObj

type SubsetFontObj struct {
	Family                string
	CharacterToGlyphIndex *MapOfCharacterToGlyphIndex
	CountOfFont           int
	// contains filtered or unexported fields
}

SubsetFontObj pdf subsetFont object

func DeserializeSubsetFont added in v0.0.9

func DeserializeSubsetFont(b []byte) (*SubsetFontObj, error)

func SubsetFontByReader added in v0.0.9

func SubsetFontByReader(rd io.Reader) (*SubsetFontObj, error)

func SubsetFontByReaderWithOption added in v0.0.9

func SubsetFontByReaderWithOption(rd io.Reader, option TtfOption) (*SubsetFontObj, error)

func (*SubsetFontObj) AddChars

func (s *SubsetFontObj) AddChars(txt string) error

AddChars add char to map CharacterToGlyphIndex

func (*SubsetFontObj) CharCodeToGlyphIndex

func (s *SubsetFontObj) CharCodeToGlyphIndex(r rune) (uint, error)

CharCodeToGlyphIndex get glyph index from char code

func (*SubsetFontObj) CharIndex

func (s *SubsetFontObj) CharIndex(r rune) (uint, error)

CharIndex index of char in glyph table

func (*SubsetFontObj) CharWidth

func (s *SubsetFontObj) CharWidth(r rune) (uint, error)

CharWidth with of char

func (*SubsetFontObj) Copy added in v0.1.9

func (s *SubsetFontObj) Copy() *SubsetFontObj

func (*SubsetFontObj) GetFamily

func (s *SubsetFontObj) GetFamily() string

GetFamily get font family name

func (*SubsetFontObj) GetTTFParser

func (s *SubsetFontObj) GetTTFParser() *core.TTFParser

GetTTFParser get TTFParser

func (*SubsetFontObj) GetTtfFontOption

func (s *SubsetFontObj) GetTtfFontOption() TtfOption

GetTtfFontOption get TtfOption must set before SetTTFByPath

func (*SubsetFontObj) GetUp

func (s *SubsetFontObj) GetUp() int

GetUp underline postion

func (*SubsetFontObj) GetUt

func (s *SubsetFontObj) GetUt() int

GetUt underlineThickness

func (*SubsetFontObj) GlyphIndexToPdfWidth

func (s *SubsetFontObj) GlyphIndexToPdfWidth(glyphIndex uint) uint

GlyphIndexToPdfWidth get with from glyphIndex

func (*SubsetFontObj) GobDecode

func (s *SubsetFontObj) GobDecode(buf []byte) error

func (*SubsetFontObj) GobEncode

func (s *SubsetFontObj) GobEncode() ([]byte, error)

func (*SubsetFontObj) KernValueByLeft

func (s *SubsetFontObj) KernValueByLeft(left uint) (bool, *core.KernValue)

KernValueByLeft find kern value from kern table by left

func (*SubsetFontObj) Serialize added in v0.0.9

func (s *SubsetFontObj) Serialize() ([]byte, error)

func (*SubsetFontObj) SetFamily

func (s *SubsetFontObj) SetFamily(familyname string)

SetFamily set font family name

func (*SubsetFontObj) SetIndexObjCIDFont

func (s *SubsetFontObj) SetIndexObjCIDFont(index int)

SetIndexObjCIDFont set IndexObjCIDFont

func (*SubsetFontObj) SetIndexObjUnicodeMap

func (s *SubsetFontObj) SetIndexObjUnicodeMap(index int)

SetIndexObjUnicodeMap set IndexObjUnicodeMap

func (*SubsetFontObj) SetTTFByPath

func (s *SubsetFontObj) SetTTFByPath(ttfpath string) error

SetTTFByPath set ttf

func (*SubsetFontObj) SetTTFByReader

func (s *SubsetFontObj) SetTTFByReader(rd io.Reader) error

SetTTFByReader set ttf

func (*SubsetFontObj) SetTtfFontOption

func (s *SubsetFontObj) SetTtfFontOption(option TtfOption)

SetTtfFontOption set TtfOption must set before SetTTFByPath

func (*SubsetFontObj) ToTemplateFont

func (s *SubsetFontObj) ToTemplateFont() *TemplateFont

ToTemplateFont turns the subsetFontObject into a Template Font

type Template

type Template interface {
	ID() string
	Size() (Point, Rect)
	Bytes() []byte
	Images() []*ImageObj
	Fonts() []*SubsetFontObj
	Templates() []Template
	NumPages() int
	FromPage(int) (Template, error)
	FromPages() []Template
	Serialize() ([]byte, error)
	gob.GobDecoder
	gob.GobEncoder
}

Template is an object that can be written to, then used and re-used any number of times within a document.

func CreateTemplate

func CreateTemplate(corner Point, unit int, fn TplFunc, opts ...PdfOption) (Template, error)

CreateTemplate creates a template that is not attached to any document.

func DeserializeTemplate

func DeserializeTemplate(b []byte) (Template, error)

DeserializeTemplate creaties a template from a previously serialized template

type TemplateFont

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

func NewTemplateFont

func NewTemplateFont(sf *SubsetFontObj) *TemplateFont

func (*TemplateFont) GobDecode

func (t *TemplateFont) GobDecode(buf []byte) error

GobDecode decodes the specified byte buffer into the receiving template.

func (*TemplateFont) GobEncode

func (t *TemplateFont) GobEncode() ([]byte, error)

GobEncode encodes the receiving template into a byte buffer. Use GobDecode to decode the byte buffer back to a template.

type TemplateImage

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

func NewTemplateImage

func NewTemplateImage(img *ImageObj) *TemplateImage

func (*TemplateImage) GobDecode

func (t *TemplateImage) GobDecode(buf []byte) error

GobDecode decodes the specified byte buffer into the receiving template.

func (*TemplateImage) GobEncode

func (t *TemplateImage) GobEncode() ([]byte, error)

GobEncode encodes the receiving template into a byte buffer. Use GobDecode to decode the byte buffer back to a template.

type TemplateObj

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

TemplateObj Template object

func (*TemplateObj) ToTemplate

func (tpl *TemplateObj) ToTemplate() Template

type TplFunc

type TplFunc func(*Fpdf) error

type TransformMatrix

type TransformMatrix struct {
	A, B, C, D, E, F float64
}

TransformMatrix is used for generalized transformations of text, drawings and images.

type TtfOption

type TtfOption struct {
	UseKerning bool
	Style      int // Regular|Bold|Italic
}

TtfOption font option

type UnicodeMap

type UnicodeMap struct {
	PtrToSubsetFontObj *SubsetFontObj
	// contains filtered or unexported fields
}

UnicodeMap unicode map

func (*UnicodeMap) SetPtrToSubsetFontObj

func (u *UnicodeMap) SetPtrToSubsetFontObj(ptr *SubsetFontObj)

SetPtrToSubsetFontObj set pointer to SubsetFontObj

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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