gopdf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

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 ARG_1_AND_2_ARE_WORDS = 1
View Source
const Bold = 2 //000010

Bold - font style bold

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 Italic = 1 //000001

Italic - font style italic

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 Regular = 0 //000000

Regular - font style regular

View Source
const Right = 2 //000010

Right right

View Source
const Top = 4 //000100

Top top

View Source
const Underline = 4 //000100

Underline - font style underline

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 FontKeyword = "TT"

FontKeyword has TT as default value, can be set to F if PDF file has different font keyword

Functions

func CheckSum

func CheckSum(data []byte) uint

CheckSum check sum

func Chr

func Chr(n int) byte

func ContentObj_CalTextHeight

func ContentObj_CalTextHeight(fontsize int) float64

ContentObj_CalTextHeight calculate height of text

func CreateEmbeddedFontSubsetName

func CreateEmbeddedFontSubsetName(name string) string

CreateEmbeddedFontSubsetName create Embedded font (subset font) name

func DebugSubType

func DebugSubType(b []byte)

func DesignUnitsToPdf

func DesignUnitsToPdf(val int, unitsPerEm uint) int

DesignUnitsToPdf convert unit

func FontConvertHelper_Cw2Str

func FontConvertHelper_Cw2Str(cw FontCw) string

func ImgReactagleToWH

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

ImgReactagleToWH Rectangle to W and H

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 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 BasicObj

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

BasicObj : basic object in pdf

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
}

CIDFontObj .

func (*CIDFontObj) Build

func (ci *CIDFontObj) Build(objID int) error

Build build buffer

func (*CIDFontObj) GetObjBuff

func (ci *CIDFontObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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,
	fontCountIndex int,
	fontSize int,
	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) ToStream

func (c *CacheContent) ToStream(protection *PDFProtection) (*bytes.Buffer, error)

ToStream create stream of content

func (*CacheContent) WriteTextToContent

func (c *CacheContent) WriteTextToContent(text string)

WriteTextToContent write text to content

type CatalogObj

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

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 Config

type Config struct {
	//pt , mm , cm , in
	Unit       string
	PageSize   Rect
	K          float64
	Protection PDFProtectionConfig
}

Config static config

type ContentObj

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

ContentObj content object

func (*ContentObj) AppendStreamCurve

func (c *ContentObj) AppendStreamCurve(x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64, x3 float64, y3 float64, style string)

AppendStreamCurve draw curve

  • x0, y0: Start point
  • x1, y1: Control point 1
  • x2, y2: Control point 2
  • x3, y3: End point
  • 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 (*ContentObj) AppendStreamImage

func (c *ContentObj) AppendStreamImage(index int, 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) AppendStreamOval

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

AppendStreamOval append oval

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) AppendStreamSetColorFill

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

AppendStreamSetColorFill set the color fill

func (*ContentObj) AppendStreamSetColorStroke

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

AppendStreamSetColorStroke set the color stroke

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) 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) 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

type Current

type Current struct {
	X float64
	Y float64

	//font
	IndexOfFontObj int
	CountOfFont    int
	CountOfL       int

	Font_Size      int
	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
	//cache of image in pdf file
	ImgCaches []ImageCache
	// 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

func (*EncryptionObj) Build

func (e *EncryptionObj) Build(objID int) error

Build build buffer

func (*EncryptionObj) GetObjBuff

func (e *EncryptionObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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 FontObj

type FontObj struct {
	Family string
	//Style string
	//Size int
	IsEmbedFont bool

	Font        IFont
	CountOfFont int
	// contains filtered or unexported fields
}

FontObj font obj

func (*FontObj) SetIndexObjEncoding

func (f *FontObj) SetIndexObjEncoding(index int)

func (*FontObj) SetIndexObjFontDescriptor

func (f *FontObj) SetIndexObjFontDescriptor(index int)

func (*FontObj) SetIndexObjWidth

func (f *FontObj) SetIndexObjWidth(index int)

type FuncKernOverride

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

FuncKernOverride return your custome pair value

type FuncTextriseOverride

type FuncTextriseOverride func(
	leftRune rune,
	rightRune rune,
	fontsize int,
	allText string,
	currTextIndex int,
) float32

FuncTextriseOverride override text rise

type GoPdf

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

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

func (*GoPdf) AddPage

func (gp *GoPdf) AddPage()

AddPage : add new page

func (*GoPdf) AddPageWithOption

func (gp *GoPdf) AddPageWithOption(opt PageOption)

AddPageWithOption : add new page with option

func (*GoPdf) AddTTFFont

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

AddTTFFont : add font file

func (*GoPdf) AddTTFFontByReader

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

AddTTFFontByReader add font file

func (*GoPdf) AddTTFFontByReaderWithOption

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

AddTTFFontByReaderWithOption add font file

func (*GoPdf) AddTTFFontWithOption

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

AddTTFFontWithOption : add font file

func (*GoPdf) Br

func (gp *GoPdf) Br(h float64)

Br : new line

func (*GoPdf) Cell

func (gp *GoPdf) Cell(rectangle *Rect, 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 (*GoPdf) CellWithOption

func (gp *GoPdf) CellWithOption(rectangle *Rect, text string, opt CellOption) error

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

func (*GoPdf) Close

func (gp *GoPdf) Close() error

func (*GoPdf) Curve

func (gp *GoPdf) Curve(x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64, x3 float64, y3 float64, style string)

Curve Draws a Bézier curve (the Bézier curve is tangent to the line between the control points at either end of the curve) Parameters: - x0, y0: Start point - x1, y1: Control point 1 - x2, y2: Control point 2 - x3, y3: End point - style: Style of rectangule (draw and/or fill: D, F, DF, FD)

func (*GoPdf) GetBytesPdf

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

GetBytesPdf : get bytes of pdf file

func (*GoPdf) GetBytesPdfReturnErr

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

GetBytesPdfReturnErr : get bytes of pdf file

func (*GoPdf) GetX

func (gp *GoPdf) GetX() float64

GetX : get current position X

func (*GoPdf) GetY

func (gp *GoPdf) GetY() float64

GetY : get current position y

func (*GoPdf) Image

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

Image : draw image

func (*GoPdf) ImageByHolder

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

ImageByHolder : draw image by ImageHolder

func (*GoPdf) KernOverride

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

KernOverride override kern value

func (*GoPdf) Line

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

Line : draw line

func (*GoPdf) MeasureTextWidth

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

MeasureTextWidth : measure Width of text (use current font)

func (*GoPdf) Oval

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

Oval : draw oval

func (*GoPdf) Read

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

func (*GoPdf) RectFromLowerLeft

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

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

func (*GoPdf) RectFromLowerLeftWithStyle

func (gp *GoPdf) 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 (*GoPdf) RectFromUpperLeft

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

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

func (*GoPdf) RectFromUpperLeftWithStyle

func (gp *GoPdf) 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 (*GoPdf) SetCompressLevel

func (gp *GoPdf) 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 (*GoPdf) SetFillColor

func (gp *GoPdf) SetFillColor(r uint8, g uint8, b uint8)

SetFillColor set the color for the stroke

func (*GoPdf) SetFont

func (gp *GoPdf) SetFont(family string, style string, size int) error

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

func (*GoPdf) SetFontWithStyle

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

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

func (*GoPdf) SetGrayFill

func (gp *GoPdf) SetGrayFill(grayScale float64)

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

func (*GoPdf) SetGrayStroke

func (gp *GoPdf) SetGrayStroke(grayScale float64)

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

func (*GoPdf) SetInfo

func (gp *GoPdf) SetInfo(info PdfInfo)

SetInfo set Document Information Dictionary

func (*GoPdf) SetLeftMargin

func (gp *GoPdf) SetLeftMargin(margin float64)

SetLeftMargin : set left margin

func (*GoPdf) SetLineType

func (gp *GoPdf) 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 (*GoPdf) SetLineWidth

func (gp *GoPdf) SetLineWidth(width float64)

SetLineWidth : set line width

func (*GoPdf) SetNoCompression

func (gp *GoPdf) SetNoCompression()

SetNoCompression : compressLevel = 0

func (*GoPdf) SetStrokeColor

func (gp *GoPdf) SetStrokeColor(r uint8, g uint8, b uint8)

SetStrokeColor set the color for the stroke

func (*GoPdf) SetTextColor

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

SetTextColor : function sets the text color

func (*GoPdf) SetTopMargin

func (gp *GoPdf) SetTopMargin(margin float64)

SetTopMargin : set top margin

func (*GoPdf) SetX

func (gp *GoPdf) SetX(x float64)

SetX : set current position X

func (*GoPdf) SetY

func (gp *GoPdf) SetY(y float64)

SetY : set current position y

func (*GoPdf) Start

func (gp *GoPdf) Start(config Config)

Start : init gopdf

func (*GoPdf) Text

func (gp *GoPdf) Text(text string) error

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

func (*GoPdf) WritePdf

func (gp *GoPdf) WritePdf(pdfPath string)

WritePdf : wirte pdf file

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 ImageCache

type ImageCache struct {
	Path  string //ID or Path
	Index int
	Rect  *Rect
}

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 (*ImageObj) Build

func (i *ImageObj) Build(objID int) error

Build build buffer

func (*ImageObj) GetObjBuff

func (i *ImageObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

func (*ImageObj) GetRect

func (i *ImageObj) GetRect() *Rect

GetRect get rect of img

func (*ImageObj) Parse

func (i *ImageObj) Parse() error

Parse parse img

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) AllVals

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

AllVals get all values

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 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 PageObj

type PageObj struct {
	Contents        string
	ResourcesRelate string
	// contains filtered or unexported fields
}

PageObj pdf page object

type PageOption

type PageOption struct {
	PageSize Rect
}

PageOption option of page

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) Build

func (p *PdfDictionaryObj) Build(objID int) error

Build build buffer

func (*PdfDictionaryObj) GetObjBuff

func (p *PdfDictionaryObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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.
	CreationDate time.Time //The date and time the document was created, in human-readable form
}

PdfInfo Document Information Dictionary

type ProcSetObj

type ProcSetObj struct {

	//Font
	Realtes     RelateFonts
	RealteXobjs RealteXobjects
	// contains filtered or unexported fields
}

ProcSetObj pdf procSet object

type RealteXobject

type RealteXobject struct {
	IndexOfObj int
}

type RealteXobjects

type RealteXobjects []RealteXobject

type Rect

type Rect struct {
	W float64
	H float64
}

type RelateFont

type RelateFont struct {
	Family string
	//etc /F1
	CountOfFont int
	//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

type SubfontDescriptorObj

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

SubfontDescriptorObj pdf subfont descriptorObj object

func (*SubfontDescriptorObj) Build

func (s *SubfontDescriptorObj) Build(objID int) error

Build build buffer

func (*SubfontDescriptorObj) GetObjBuff

func (s *SubfontDescriptorObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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 (*SubsetFontObj) AddChars

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

AddChars add char to map CharacterToGlyphIndex

func (*SubsetFontObj) Build

func (s *SubsetFontObj) Build(objID int) error

Build build buffer

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) GetFamily

func (s *SubsetFontObj) GetFamily() string

GetFamily get font family name

func (*SubsetFontObj) GetObjBuff

func (s *SubsetFontObj) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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) KernValueByLeft

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

KernValueByLeft find kern value from kern table by left

func (*SubsetFontObj) SetFamily

func (s *SubsetFontObj) SetFamily(familyname string)

SetFamily set font family name

func (*SubsetFontObj) SetFuncKernOverride

func (s *SubsetFontObj) SetFuncKernOverride(funcKernOverride FuncKernOverride)

func (*SubsetFontObj) SetFuncTextriseOverride

func (s *SubsetFontObj) SetFuncTextriseOverride(funcTextriseOverride FuncTextriseOverride)

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

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) Build

func (u *UnicodeMap) Build(objID int) error

Build build buffer

func (*UnicodeMap) GetObjBuff

func (u *UnicodeMap) GetObjBuff() *bytes.Buffer

GetObjBuff get buffer

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