Documentation
¶
Overview ¶
filepath: c:\Users\Cesar\Packages\Internal\docpdf\pdfengine\pdfEngineExtra.go
Example (FormatFloatTrim) ¶
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10.0))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10.01))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10.001))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10.0001))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(10.00001))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(9.99999))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(9.9999))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(9.999))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(9.99))
fmt.Printf("/F1 %s Tf\n", formatFloatTrim(9.9))
Output: /F1 10 Tf /F1 10 Tf /F1 10.01 Tf /F1 10.001 Tf /F1 10 Tf /F1 10 Tf /F1 10 Tf /F1 10 Tf /F1 9.999 Tf /F1 9.99 Tf /F1 9.9 Tf
Index ¶
- Constants
- Variables
- func CheckSum(data []byte) uint
- func CreateContent(f *ttfSubsetObj, text string, fontSize float64, charSpacing float64, ...) (float64, float64, float64, error)
- func ImageHolderByBytes(b []byte) (imageHolder, error)
- type BreakOption
- type CellOption
- type Config
- type CropOptions
- type ICacheColorText
- type ICacheContent
- type ImageOptions
- type JustifiedText
- func (jt *JustifiedText) Draw(gp *PdfEngine, x, y float64) error
- func (jt *JustifiedText) GetOriginalString() string
- func (jt *JustifiedText) GetSpaces() []float64
- func (jt *JustifiedText) GetWidth() float64
- func (jt *JustifiedText) GetWords() []string
- func (jt *JustifiedText) SpaceCount() int
- func (jt *JustifiedText) WordCount() int
- type PageOption
- type PdfEngine
- func (gp *PdfEngine) AddExternalLink(url string, x, y, w, h float64)
- func (gp *PdfEngine) AddFontFamilyConfig(fontFamily config.FontFamily) error
- func (gp *PdfEngine) AddFooter(f func())
- func (gp *PdfEngine) AddHeader(f func())
- func (gp *PdfEngine) AddInternalLink(anchor string, x, y, w, h float64)
- func (gp *PdfEngine) AddOutline(title string)
- func (gp *PdfEngine) AddOutlineWithPosition(title string) *outlineObj
- func (gp *PdfEngine) AddPage()
- func (gp *PdfEngine) AddPageWithOption(opt PageOption)
- func (gp *PdfEngine) AddTTFFont(family string, ttfpath string) error
- func (gp *PdfEngine) AddTTFFontByReader(family string, rd Reader) error
- func (gp *PdfEngine) AddTTFFontByReaderWithOption(family string, rd Reader, option TtfOption) error
- func (gp *PdfEngine) AddTTFFontData(family string, fontData []byte) error
- func (gp *PdfEngine) AddTTFFontDataWithOption(family string, fontData []byte, option TtfOption) error
- func (gp *PdfEngine) AddTTFFontWithOption(family string, ttfpath string, option TtfOption) error
- func (gp *PdfEngine) AllMargins() (float64, float64, float64, float64)
- func (gp *PdfEngine) Br(h float64)
- func (gp *PdfEngine) Cell(rectangle *canvas.Rect, text string) error
- func (gp *PdfEngine) CellWithOption(rectangle *canvas.Rect, text string, opt CellOption) error
- func (gp *PdfEngine) ClearTransparency()
- func (gp *PdfEngine) Close() error
- func (gp *PdfEngine) CurrentPdf() *currentPdf
- func (gp *PdfEngine) Curve(x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64, ...)
- func (gp *PdfEngine) DrawImageByHolder(img imageHolder, x float64, y float64, rect *canvas.Rect) error
- func (gp *PdfEngine) DrawImageInPdf(imageContent []byte, x float64, y float64, rect *canvas.Rect) error
- func (gp *PdfEngine) FillInPlaceHoldText(placeHolderName string, text string, align config.Alignment) error
- func (gp *PdfEngine) GetAnchors() map[string]anchorOption
- func (gp *PdfEngine) GetBuf() *bytes.Buffer
- func (gp *PdfEngine) GetBytesPdf() []byte
- func (gp *PdfEngine) GetBytesPdfReturnErr() ([]byte, error)
- func (gp *PdfEngine) GetEncryptionObjID() int
- func (gp *PdfEngine) GetIndexEncodingObjFonts() []int
- func (gp *PdfEngine) GetIndexOfContent() int
- func (gp *PdfEngine) GetInfo() *PdfInfo
- func (gp *PdfEngine) GetNextObjectID() int
- func (gp *PdfEngine) GetNumberOfPages() int
- func (gp *PdfEngine) GetPageSize() *canvas.Rect
- func (gp *PdfEngine) GetPdfObjs() []iObj
- func (gp *PdfEngine) GetPdfProtection() *pdfProtection
- func (gp *PdfEngine) GetX() float64
- func (gp *PdfEngine) GetY() float64
- func (gp *PdfEngine) ImageByHolderWithOptions(img imageHolder, opts ImageOptions) error
- func (gp *PdfEngine) ImageFrom(img image.Image, x float64, y float64, rect *canvas.Rect) error
- func (gp *PdfEngine) ImageFromWithOption(img image.Image, opts imageFromOption) error
- func (gp *PdfEngine) ImportObjects(objs map[int]string, startObjID int)
- func (gp *PdfEngine) ImportPage(sourceFile string, pageno int, Box string) int
- func (gp *PdfEngine) ImportPageStream(sourceStream *io.ReadSeeker, pageno int, Box string) int
- func (gp *PdfEngine) ImportPagesFromSource(source any, Box string) error
- func (gp *PdfEngine) ImportTemplates(tpls map[string]int)
- func (gp *PdfEngine) Init(importer ...*importer)
- func (gp *PdfEngine) IsCurrFontContainGlyph(r rune) (bool, error)
- func (gp *PdfEngine) IsFitMultiCell(rectangle *canvas.Rect, text string) (bool, float64, error)
- func (gp *PdfEngine) IsFitMultiCellWithNewline(rectangle *canvas.Rect, text string) (bool, float64, error)
- func (gp *PdfEngine) KernOverride(family string, fn funcKernOverride) error
- func (gp *PdfEngine) Line(x1 float64, y1 float64, x2 float64, y2 float64)
- func (gp *PdfEngine) MarginBottom() float64
- func (gp *PdfEngine) MarginLeft() float64
- func (gp *PdfEngine) MarginRight() float64
- func (gp *PdfEngine) MarginTop() float64
- func (gp *PdfEngine) Margins() canvas.Margins
- func (gp *PdfEngine) MeasureCellHeightByText(text string) (float64, error)
- func (gp *PdfEngine) MeasureTextWidth(text string) (float64, error)
- func (gp *PdfEngine) MultiCell(rectangle *canvas.Rect, text string) error
- func (gp *PdfEngine) MultiCellJustified(rectangle *canvas.Rect, text string) error
- func (gp *PdfEngine) MultiCellWithOption(rectangle *canvas.Rect, text string, opt CellOption) error
- func (gp *PdfEngine) Oval(x1 float64, y1 float64, x2 float64, y2 float64)
- func (gp *PdfEngine) ParseTextForJustification(text string, width float64) (*JustifiedText, error)
- func (gp *PdfEngine) PlaceHolderText(placeHolderName string, placeHolderWidth float64) error
- func (gp *PdfEngine) PointsToUnitsVar(u ...*float64)
- func (gp *PdfEngine) Polygon(points []point, style string)
- func (gp *PdfEngine) Read(p []byte) (int, error)
- func (gp *PdfEngine) RectFromLowerLeft(x float64, y float64, wdth float64, hght float64)
- func (gp *PdfEngine) RectFromLowerLeftWithOpts(opts drawableRectOptions) error
- func (gp *PdfEngine) RectFromLowerLeftWithStyle(x float64, y float64, wdth float64, hght float64, style string)
- func (gp *PdfEngine) RectFromUpperLeft(x float64, y float64, wdth float64, hght float64)
- func (gp *PdfEngine) RectFromUpperLeftWithOpts(opts drawableRectOptions) error
- func (gp *PdfEngine) RectFromUpperLeftWithStyle(x float64, y float64, wdth float64, hght float64, style string)
- func (gp *PdfEngine) Rectangle(x0 float64, y0 float64, x1 float64, y1 float64, style string, radius float64, ...) error
- func (gp *PdfEngine) Rotate(angle, x, y float64)
- func (gp *PdfEngine) RotateReset()
- func (gp *PdfEngine) SetAnchor(name string)
- func (gp *PdfEngine) SetCharSpacing(charSpacing float64) error
- func (gp *PdfEngine) SetCompressLevel(level int)
- func (gp *PdfEngine) SetCustomLineType(dashArray []float64, dashPhase float64)
- func (gp *PdfEngine) SetFileWriter(writer env.FileWriter)
- func (gp *PdfEngine) SetFillColor(r uint8, g uint8, b uint8)
- func (gp *PdfEngine) SetFillColorCMYK(c, m, y, k uint8)
- func (gp *PdfEngine) SetFont(cfs config.FontStyle) error
- func (gp *PdfEngine) SetFontSize(fontSize float64) error
- func (gp *PdfEngine) SetFontWithStyle(updatedStyle config.FontStyle) error
- func (gp *PdfEngine) SetGrayFill(grayScale float64)
- func (gp *PdfEngine) SetGrayStroke(grayScale float64)
- func (gp *PdfEngine) SetIndexOfProcSet(index int)
- func (gp *PdfEngine) SetInfo(info PdfInfo)
- func (gp *PdfEngine) SetLeftMargin(margin float64)
- func (gp *PdfEngine) SetLineType(linetype string)
- func (gp *PdfEngine) SetLineWidth(width float64)
- func (gp *PdfEngine) SetMarginBottom(margin float64)
- func (gp *PdfEngine) SetMarginLeft(margin float64)
- func (gp *PdfEngine) SetMarginRight(margin float64)
- func (gp *PdfEngine) SetMarginTop(margin float64)
- func (gp *PdfEngine) SetMargins(left, top, right, bottom float64)
- func (gp *PdfEngine) SetNewXY(y float64, x, h float64)
- func (gp *PdfEngine) SetNewY(y float64, h float64)
- func (gp *PdfEngine) SetNewYIfNoOffset(y float64, h float64)
- func (gp *PdfEngine) SetNoCompression()
- func (gp *PdfEngine) SetPage(pageno int) error
- func (gp *PdfEngine) SetStrokeColor(r uint8, g uint8, b uint8)
- func (gp *PdfEngine) SetStrokeColorCMYK(c, m, y, k uint8)
- func (gp *PdfEngine) SetTextColor(r uint8, g uint8, b uint8)
- func (gp *PdfEngine) SetTextColorCMYK(c, m, y, k uint8)
- func (gp *PdfEngine) SetTopMargin(margin float64)
- func (gp *PdfEngine) SetTransparency(transparency transparency) error
- func (gp *PdfEngine) SetX(x float64)
- func (gp *PdfEngine) SetXY(x, y float64)
- func (gp *PdfEngine) SetY(y float64)
- func (gp *PdfEngine) SplitText(text string, width float64) ([]string, error)
- func (gp *PdfEngine) SplitTextWithOption(text string, width float64, opt *BreakOption) ([]string, error)
- func (gp *PdfEngine) SplitTextWithWordWrap(text string, width float64) ([]string, error)
- func (gp *PdfEngine) Start(Config Config)
- func (gp *PdfEngine) StartWithImporter(Config Config, importer *importer)
- func (gp *PdfEngine) Text(text string) error
- func (gp *PdfEngine) UnitsToPoints(u float64) float64
- func (gp *PdfEngine) UnitsToPointsVar(u ...*float64)
- func (gp *PdfEngine) UseImportedTemplate(tplid int, x float64, y float64, w float64, h float64)
- func (gp *PdfEngine) Write(w Writer) errordeprecated
- func (gp *PdfEngine) WritePdf(pdfPath string) error
- func (gp *PdfEngine) WriteTo(w Writer) (n int64, err error)
- type PdfInfo
- type PdfProtectionConfig
- type Reader
- type TtfOption
- type Writer
Examples ¶
Constants ¶
const ( // BreakModeStrict causes the text-line to break immediately in case the current character would not fit into // the processed text-line. The separator (if provided) will be attached accordingly as a line suffix // to stay within the defined width. BreakModeStrict breakMode = iota // BreakModeIndicatorSensitive will try to break the current line based on the last index of a provided // BreakIndicator. If no indicator sensitive break can be performed a strict break will be performed, // potentially working with the given separator as a suffix. BreakModeIndicatorSensitive )
const ( //PermissionsPrint setProtection print PermissionsPrint = 4 //PermissionsModify setProtection modify PermissionsModify = 8 //PermissionsCopy setProtection copy PermissionsCopy = 16 //PermissionsAnnotForms setProtection annot-forms PermissionsAnnotForms = 32 )
Variables ¶
var ( // DefaultBreakOption will cause the text to break mid-word without any separator suffixes. DefaultBreakOption = BreakOption{ Mode: BreakModeStrict, BreakIndicator: 0, Separator: "", } )
Functions ¶
func CreateContent ¶ added in v0.0.61
func ImageHolderByBytes ¶
ImageHolderByBytes create imageHolder by []byte
Types ¶
type BreakOption ¶
type BreakOption struct {
// Mode defines the mode which should be used
Mode breakMode
// BreakIndicator is taken into account when using indicator sensitive mode to avoid mid-word line breaks
BreakIndicator rune
// Separator will act as a suffix for mid-word breaks when using strict mode
Separator string
}
BreakOption allows to configure the behavior of splitting or breaking larger texts via SplitTextWithOption.
func (BreakOption) HasSeparator ¶
func (bo BreakOption) HasSeparator() bool
type CellOption ¶
type CellOption struct {
Align config.Alignment //Allows to align the text. Possible values are: config.Left,config.Center,config.Right,config.Top,config.Bottom,config.Middle
Border config.Alignment //Indicates if borders must be drawn around the cell. Possible values are: config.Left, config.Top, config.Right, config.Bottom, ALL
Float config.Alignment //Indicates where the current config.Alignment should go after the call. Possible values are: config.Right, config.Bottom
TruncateLines int // Si > 0, limita el texto a este número de líneas y añade puntos suspensivos si es necesario
CoefUnderlinePosition float64
CoefLineHeight float64
CoefUnderlineThickness float64
BreakOption *BreakOption
// contains filtered or unexported fields
}
CellOption cell option
type Config ¶
type Config struct {
// Unit specifies the unit type to use when composing the document (canvas.UnitPT, canvas.UnitMM, canvas.UnitCM, canvas.UnitIN, canvas.UnitPX)
Unit int
// ConversionForUnit is a value used to convert units to points.
// If this value is not 0, it will be used for unit conversion instead of the default constants.
// When this is set, the Unit field is ignored.
// Example: For 300 DPI, set this to 72.0/300.0
ConversionForUnit float64
// TrimBox defines the default trim canvas.Box for all pages in the document
TrimBox canvas.Box
// canvas.PageSize defines the default page size for all pages in the document
PageSize canvas.Rect
// K is a scaling factor (purpose not well-documented)
K float64
// Protection contains the settings for PDF document protection
Protection PdfProtectionConfig
}
Config defines the basic configuration for a PDF document. It includes settings for unit types, page size, protection, and more.
func (Config) GetConversionForUnit ¶
GetConversionForUnit returns the custom conversion factor from the configuration
type ICacheColorText ¶ added in v0.0.61
type ICacheColorText interface {
ICacheContent
Equal(obj ICacheColorText) bool
}
type ICacheContent ¶ added in v0.0.61
type ImageOptions ¶
type JustifiedText ¶
type JustifiedText struct {
// contains filtered or unexported fields
}
JustifiedText representa un texto justificado con sus espacios ajustados
func (*JustifiedText) Draw ¶
func (jt *JustifiedText) Draw(gp *PdfEngine, x, y float64) error
Draw dibuja el texto justificado en las coordenadas especificadas
func (*JustifiedText) GetOriginalString ¶
func (jt *JustifiedText) GetOriginalString() string
GetOriginalString retorna el texto original antes de ser justificado
func (*JustifiedText) GetSpaces ¶
func (jt *JustifiedText) GetSpaces() []float64
GetSpaces retorna los espacios entre palabras del texto justificado
func (*JustifiedText) GetWidth ¶
func (jt *JustifiedText) GetWidth() float64
GetWidth retorna el ancho total del texto justificado
func (*JustifiedText) GetWords ¶
func (jt *JustifiedText) GetWords() []string
GetWords retorna las palabras del texto justificado
func (*JustifiedText) SpaceCount ¶
func (jt *JustifiedText) SpaceCount() int
SpaceCount retorna el número de espacios del texto justificado
func (*JustifiedText) WordCount ¶
func (jt *JustifiedText) WordCount() int
WordCount retorna el número de palabras del texto justificado
type PageOption ¶
PageOption option of page
type PdfEngine ¶
type PdfEngine struct {
// FileWriter function for custom file writing logic
FileWriter env.FileWriter
Config Config
// Number of pages obj
NumOfPagesObj int
// Log function for debugging
Log func(...any)
// contains filtered or unexported fields
}
PdfEngine : core library for generating PDF
func (*PdfEngine) AddExternalLink ¶
AddExternalLink adds a new external link.
func (*PdfEngine) AddFontFamilyConfig ¶ added in v0.0.78
func (gp *PdfEngine) AddFontFamilyConfig(fontFamily config.FontFamily) error
AddFontFamilyConfig adds a font using config.FontFamily structure
func (*PdfEngine) AddFooter ¶
func (gp *PdfEngine) AddFooter(f func())
AddFooter - add a footer function, if present this will be automatically called by AddPage()
func (*PdfEngine) AddHeader ¶
func (gp *PdfEngine) AddHeader(f func())
AddHeader - add a header function, if present this will be automatically called by AddPage()
func (*PdfEngine) AddInternalLink ¶
AddInternalLink adds a new internal link.
func (*PdfEngine) AddOutline ¶
func (*PdfEngine) AddOutlineWithPosition ¶
AddOutlineWithPosition add an outline with config.Alignment
func (*PdfEngine) AddPageWithOption ¶
func (gp *PdfEngine) AddPageWithOption(opt PageOption)
AddPageWithOption : add new page with option
func (*PdfEngine) AddTTFFont ¶
AddTTFFont : add font file - Legacy method, preserved for compatibility
func (*PdfEngine) AddTTFFontByReader ¶
AddTTFFontByReader adds font file by reader.
func (*PdfEngine) AddTTFFontByReaderWithOption ¶
AddTTFFontByReaderWithOption adds font file by reader with option.
func (*PdfEngine) AddTTFFontData ¶
AddTTFFontByReader adds font data by reader.
func (*PdfEngine) AddTTFFontDataWithOption ¶
func (gp *PdfEngine) AddTTFFontDataWithOption(family string, fontData []byte, option TtfOption) error
AddTTFFontDataWithOption adds font data with option.
func (*PdfEngine) AddTTFFontWithOption ¶
AddTTFFontWithOption : add font file
func (*PdfEngine) AllMargins ¶ added in v0.0.61
AllMargins 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 (*PdfEngine) Cell ¶
Cell : create cell of text ( use current x,y is upper-left corner of cell) Note that this has no effect on canvas.Rect.H pdf (now). Fix later :-)
func (*PdfEngine) CellWithOption ¶
CellWithOption create cell of text ( use current x,y is upper-left corner of cell)
func (*PdfEngine) ClearTransparency ¶
func (gp *PdfEngine) ClearTransparency()
func (*PdfEngine) CurrentPdf ¶ added in v0.0.61
func (gp *PdfEngine) CurrentPdf() *currentPdf
metodo que retorna currentPdf
func (*PdfEngine) Curve ¶
func (gp *PdfEngine) 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 (*PdfEngine) DrawImageByHolder ¶
func (gp *PdfEngine) DrawImageByHolder(img imageHolder, x float64, y float64, rect *canvas.Rect) error
DrawImageByHolder : draw image by imageHolder
func (*PdfEngine) DrawImageInPdf ¶ added in v0.0.61
func (gp *PdfEngine) DrawImageInPdf(imageContent []byte, x float64, y float64, rect *canvas.Rect) error
DrawImageInPdf : draw image in pdf by image content
func (*PdfEngine) FillInPlaceHoldText ¶
func (gp *PdfEngine) FillInPlaceHoldText(placeHolderName string, text string, align config.Alignment) error
[experimental] fill in text that created by function PlaceHolderText align: config.Left,config.Right,config.Center
func (*PdfEngine) GetAnchors ¶
metodo que retorna anchors
func (*PdfEngine) GetBytesPdf ¶
GetBytesPdf : get bytes of pdf file
func (*PdfEngine) GetBytesPdfReturnErr ¶
GetBytesPdfReturnErr : get bytes of pdf file
func (*PdfEngine) GetEncryptionObjID ¶
GetEncryptionObjID returns the encryption object ID
func (*PdfEngine) GetIndexEncodingObjFonts ¶
GetIndexEncodingObjFonts returns the index encoding object fonts
func (*PdfEngine) GetIndexOfContent ¶
GetIndexOfContent returns the index of content
func (*PdfEngine) GetNextObjectID ¶
GetNextObjectID gets the next object ID so that gofpdi knows where to start the object IDs.
func (*PdfEngine) GetNumberOfPages ¶
GetNumberOfPages gets the number of pages from the PDF.
func (*PdfEngine) GetPageSize ¶ added in v0.0.74
metodo que obteine la estrucutua tamaño de la pagina
func (*PdfEngine) GetPdfProtection ¶
func (gp *PdfEngine) GetPdfProtection() *pdfProtection
metodo que retorna el objeto de proteccion
func (*PdfEngine) ImageByHolderWithOptions ¶
func (gp *PdfEngine) ImageByHolderWithOptions(img imageHolder, opts ImageOptions) error
func (*PdfEngine) ImageFromWithOption ¶
func (*PdfEngine) ImportObjects ¶
ImportObjects imports objects from gofpdi into current document.
func (*PdfEngine) ImportPage ¶
ImportPage imports a page and return template id. gofpdi code
func (*PdfEngine) ImportPageStream ¶
ImportPageStream imports page using a stream. Return template id after importing. gofpdi code
func (*PdfEngine) ImportPagesFromSource ¶
ImportPagesFromSource imports pages from a source pdf. The source can be a file path, byte slice, or (*)io.ReadSeeker.
func (*PdfEngine) ImportTemplates ¶
ImportTemplates names into procset dictionary.
func (*PdfEngine) IsCurrFontContainGlyph ¶
IsCurrFontContainGlyph defines is current font contains to a glyph r: any rune
func (*PdfEngine) IsFitMultiCell ¶
IsFitMultiCell : check whether the rectangle's area is big enough for the text
func (*PdfEngine) IsFitMultiCellWithNewline ¶
func (gp *PdfEngine) IsFitMultiCellWithNewline(rectangle *canvas.Rect, text string) (bool, float64, error)
IsFitMultiCellWithNewline : similar to IsFitMultiCell, but process char newline as Br
func (*PdfEngine) KernOverride ¶
KernOverride override kern value
func (*PdfEngine) Line ¶
Line : draw line
Usage:
pdf.SetTransparency(docpdf.transparency{Alpha: 0.5,blendModeType: docpdf.colorBurn})
pdf.SetLineType("dotted")
pdf.SetStrokeColor(255, 0, 0)
pdf.SetLineWidth(2)
pdf.Line(10, 30, 585, 30)
pdf.ClearTransparency()
func (*PdfEngine) MarginBottom ¶
MarginBottom returns the bottom margin.
func (*PdfEngine) MarginLeft ¶
MarginLeft returns the left margin.
func (*PdfEngine) MarginRight ¶
MarginRight returns the right margin.
func (*PdfEngine) MeasureCellHeightByText ¶
MeasureCellHeightByText : measure Height of cell by text (use current font)
func (*PdfEngine) MeasureTextWidth ¶
MeasureTextWidth : measure Width of text (use current font)
func (*PdfEngine) MultiCell ¶
MultiCell : create of text with line breaks (use current x,y is upper-left corner of cell)
func (*PdfEngine) MultiCellJustified ¶
MultiCellJustified dibuja texto justificado dentro de un rectángulo
func (*PdfEngine) MultiCellWithOption ¶
MultiCellWithOption create of text with line breaks (use current x,y is upper-left corner of cell)
func (*PdfEngine) ParseTextForJustification ¶
func (gp *PdfEngine) ParseTextForJustification(text string, width float64) (*JustifiedText, error)
ParseTextForJustification divide un texto en sus palabras y calcula los espacios necesarios
func (*PdfEngine) PlaceHolderText ¶
[experimental] PlaceHolderText Create a text placehold for fillin text later with function FillInPlaceHoldText.
func (*PdfEngine) PointsToUnitsVar ¶ added in v0.0.61
PointsToUnitsVar converts the points to the documents unit type for all variables passed in
func (*PdfEngine) Polygon ¶
Polygon : draw polygon
- style: Style of polygon (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
Usage:
pdf.SetStrokeColor(255, 0, 0)
pdf.SetLineWidth(2)
pdf.SetFillColor(0, 255, 0)
pdf.Polygon([]docpdf.point{{X: 10, Y: 30}, {X: 585, Y: 200}, {X: 585, Y: 250}}, "DF")
func (*PdfEngine) RectFromLowerLeft ¶
RectFromLowerLeft : draw rectangle from lower-left corner (x, y)
func (*PdfEngine) RectFromLowerLeftWithOpts ¶
func (*PdfEngine) RectFromLowerLeftWithStyle ¶
func (gp *PdfEngine) 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 (*PdfEngine) RectFromUpperLeft ¶
RectFromUpperLeft : draw rectangle from upper-left corner (x, y)
func (*PdfEngine) RectFromUpperLeftWithOpts ¶
func (*PdfEngine) RectFromUpperLeftWithStyle ¶
func (gp *PdfEngine) 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 (*PdfEngine) Rectangle ¶
func (gp *PdfEngine) Rectangle(x0 float64, y0 float64, x1 float64, y1 float64, style string, radius float64, radiusPointNum int) error
Rectangle : draw rectangle, and add radius input to make a round corner, it helps to calculate the round corner coordinates and use Polygon functions to draw rectangle
- style: Style of Rectangle (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
Usage:
pdf.SetStrokeColor(255, 0, 0) pdf.SetLineWidth(2) pdf.SetFillColor(0, 255, 0) pdf.Rectangle(196.6, 336.8, 398.3, 379.3, "DF", 3, 10)
func (*PdfEngine) Rotate ¶
Rotate rotate text or image angle is angle in degrees. x, y is rotation center
func (*PdfEngine) SetCharSpacing ¶
SetCharSpacing : set the character spacing of the currently active font
func (*PdfEngine) SetCompressLevel ¶
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 (*PdfEngine) SetCustomLineType ¶
SetCustomLineType : set custom line type
Usage:
pdf.SetCustomLineType([]float64{0.8, 0.8}, 0)
pdf.Line(50, 200, 550, 200)
func (*PdfEngine) SetFileWriter ¶
func (gp *PdfEngine) SetFileWriter(writer env.FileWriter)
SetFileWriter sets a custom function for writing PDF files
func (*PdfEngine) SetFillColor ¶
SetFillColor set the color for the stroke
func (*PdfEngine) SetFillColorCMYK ¶
SetFillColorCMYK set the color for the fill in CMYK color mode
func (*PdfEngine) SetFontSize ¶
SetFontSize : set the font size (and only the font size) of the currently active font
func (*PdfEngine) SetFontWithStyle ¶
SetFontWithStyle
func (*PdfEngine) SetGrayFill ¶
SetGrayFill set the grayscale for the fill, takes a float64 between 0.0 and 1.0
func (*PdfEngine) SetGrayStroke ¶
SetGrayStroke set the grayscale for the stroke, takes a float64 between 0.0 and 1.0
func (*PdfEngine) SetIndexOfProcSet ¶
metodo para setar IndexOfProcSet
func (*PdfEngine) SetLeftMargin ¶
SetLeftMargin sets left margin.
func (*PdfEngine) SetLineType ¶
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 (*PdfEngine) SetLineWidth ¶
SetLineWidth : set line width
func (*PdfEngine) SetMarginBottom ¶
SetMarginBottom set the bottom margin
func (*PdfEngine) SetMarginLeft ¶
SetMarginLeft sets the left margin
func (*PdfEngine) SetMarginRight ¶
SetMarginRight sets the right margin
func (*PdfEngine) SetMarginTop ¶
SetMarginTop sets the top margin
func (*PdfEngine) SetMargins ¶
SetMargins defines the left, top, right and bottom canvas.Margins. By default, they equal 1 cm. Call this method to change them.
func (*PdfEngine) SetNewXY ¶
SetNewXY : set current config.Alignment x and y, and modified y if add a new page. Example: For example, if the page height is set to 841px, MarginTop is 20px, MarginBottom is 10px, and the height of the element to be inserted is 25px, because 10<25, you need to add another page and set y to 20px. Because of AddPage(), X is set to MarginLeft, so you should specify X if needed, or make sure SetX() is after SetNewY().
func (*PdfEngine) SetNewY ¶
SetNewY : set current config.Alignment y, and modified y if add a new page. Example: For example, if the page height is set to 841px, MarginTop is 20px, MarginBottom is 10px, and the height of the element(such as text) to be inserted is 25px, because 10<25, you need to add another page and set y to 20px. Because of called AddPage(), X is set to MarginLeft, so you should specify X if needed, or make sure SetX() is after SetNewY(), or using SetNewXY(). SetNewYIfNoOffset is more suitable for scenarios where the offset does not change, such as pdf.Image().
func (*PdfEngine) SetNewYIfNoOffset ¶
SetNewYIfNoOffset : set current config.Alignment y, and modified y if add a new page. Example: For example, if the page height is set to 841px, MarginTop is 20px, MarginBottom is 10px, and the height of the element(such as image) to be inserted is 200px, because 10<200, you need to add another page and set y to 20px. Tips: gp.curr.X and gp.curr.Y do not change when pdf.Image() is called.
func (*PdfEngine) SetNoCompression ¶
func (gp *PdfEngine) SetNoCompression()
SetNoCompression : compressLevel = 0
func (*PdfEngine) SetStrokeColor ¶
SetStrokeColor set the color for the stroke
func (*PdfEngine) SetStrokeColorCMYK ¶
SetStrokeColorCMYK set the color for the stroke in CMYK color mode
func (*PdfEngine) SetTextColor ¶
SetTextColor : function sets the text color
func (*PdfEngine) SetTextColorCMYK ¶
func (*PdfEngine) SetTopMargin ¶
SetTopMargin sets top margin.
func (*PdfEngine) SetTransparency ¶
SetTransparency sets transparency. alpha: value from 0 (transparent) to 1 (opaque) blendMode: blend mode, one of the following:
Normal, multiply, screen, overlay, darken, lighten, colorDodge, colorBurn, hardLight, softLight, difference, exclusion, hue, saturation, Color, luminosity
func (*PdfEngine) SplitText ¶
SplitText splits text into multiple lines based on width performing potential mid-word breaks.
func (*PdfEngine) SplitTextWithOption ¶
func (gp *PdfEngine) SplitTextWithOption(text string, width float64, opt *BreakOption) ([]string, error)
SplitTextWithOption splits a text into multiple lines based on the current font size of the document. BreakOptions allow to define the behavior of the split (strict or sensitive). For more information see BreakOption.
func (*PdfEngine) SplitTextWithWordWrap ¶
SplitTextWithWordWrap behaves the same way SplitText does but performs a word-wrap considering spaces in case a text line split would split a word.
func (*PdfEngine) StartWithImporter ¶
func (*PdfEngine) UnitsToPoints ¶
UnitsToPoints converts the units to the documents unit type
func (*PdfEngine) UnitsToPointsVar ¶
UnitsToPointsVar converts the units to the documents unit type for all variables passed in
func (*PdfEngine) UseImportedTemplate ¶
UseImportedTemplate draws an imported PDF page.
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 which created the original document
Producer string // If the document was converted to PDF from another format, the name of the application that converted the original document to PDF
CreationDate time.Time // The date and time the document was created, in human-readable form
}
PdfInfo Document Information Dictionary
type PdfProtectionConfig ¶
type PdfProtectionConfig struct {
// UseProtection determines whether to apply protection to the PDF
UseProtection bool
// Permissions specifies the allowed operations on the PDF (PermissionsPrint, PermissionsCopy, etc.)
Permissions int
// UserPass is the password required for general users to open the PDF
UserPass []byte
// OwnerPass is the password required for owners to remove restrictions
OwnerPass []byte
}
PdfProtectionConfig defines the configuration for PDF document protection.
type TtfOption ¶
type TtfOption struct {
UseKerning bool
Style config.FontStyle //Regular|Bold|Italic
OnGlyphNotFound func(r rune) //Called when a glyph cannot be found, just for debugging
OnGlyphNotFoundSubstitute func(r rune) rune //Called when a glyph cannot be found, we can return a new rune to replace it.
}
TtfOption font option
Source Files
¶
- annot_obj.go
- buff.go
- cache.go
- cache_content_image.go
- cache_content_text.go
- cid_font_obj.go
- config.go
- content_obj.go
- currentpdf.go
- device_rgb_obj.go
- embedfont_obj.go
- encoding_obj.go
- encryption_obj.go
- ext_g_state_obj.go
- file.go
- geometricFigures.go
- helpers.go
- image.go
- image_obj.go
- image_obj_parse.go
- imported_obj.go
- justify.go
- list_cache_content.go
- margin.go
- models.go
- multicell.go
- outlines_obj.go
- page.go
- pdfEngine.go
- pdfEngineExtra.go
- pdf_dictionary_obj.go
- pdf_protection.go
- pdi_importer.go
- pdi_reader.go
- pdi_writer.go
- positions.go
- procset_obj.go
- smask_obj.go
- strhelper.go
- style.go
- transparency.go
- transparency_xobject_group.go
- ttf.go
- ttfSubsetObj.go
- ttf_descriptor.go
- ttf_font.go
- unicode_map.go