package pdfjet
import pdfjet "github.com/edragoev1/pdfjet/v9/src"
Package encryption implements the AES encryption of PDF documents.
Package pdfjet is a library for creating PDF documents.
Index
- Constants
- func DrawXMark(page *Page, x, y, size float32)
- func GS1DigitalLink(domain, data string) string
- func IsArabic(ch rune) bool
- func JoinsBackward(ch rune) bool
- func JoinsForward(ch rune) bool
- func ReorderVisually(str string) string
- func ReorderVisuallyPart(str string, from, to int) string
-
type Arc
- func NewArc() *Arc
- func (arc *Arc) DrawOn(page *Page) [2]float32
- func (arc *Arc) ScaleBy(factor float32) *Arc
- func (arc *Arc) SetActualText(actualText string) *Arc
- func (arc *Arc) SetAltDescription(altDescription string) *Arc
- func (arc *Arc) SetFillColor(c int32) *Arc
- func (arc *Arc) SetFillColorRGB(rgbColor [3]float32) *Arc
- func (arc *Arc) SetLocation(cx, cy float32) Drawable
- func (arc *Arc) SetRadius(r float32) *Arc
- func (arc *Arc) SetRadiusX(rx float32) *Arc
- func (arc *Arc) SetRadiusY(ry float32) *Arc
- func (arc *Arc) SetRotation(degrees float32) *Arc
- func (arc *Arc) SetStartAngle(angle float32) *Arc
- func (arc *Arc) SetStartPointToEndOf(line *Line) *Arc
- func (arc *Arc) SetStrokeColor(c int32) *Arc
- func (arc *Arc) SetStrokeColorRGB(rgbColor [3]float32) *Arc
- func (arc *Arc) SetStrokeDashPattern(strokeDashPattern string) *Arc
- func (arc *Arc) SetStrokeWidth(width float32) *Arc
- func (arc *Arc) SetSweep(degrees float32) *Arc
-
type BarChart
- func NewBarChart(f1, f2 *Font) *BarChart
- func (chart *BarChart) AddSeries(name string, values []float32) *BarChart
- func (chart *BarChart) AddSeriesWithColor(name string, values []float32, color int32) *BarChart
- func (chart *BarChart) AddSeriesWithColors(name string, values []float32, colors []int32) *BarChart
- func (chart *BarChart) DrawOn(page *Page) [2]float32
- func (chart *BarChart) SetAltDescription(altDescription string) *BarChart
- func (chart *BarChart) SetAxisLineWidth(width float32) *BarChart
- func (chart *BarChart) SetBarGap(gap float32) *BarChart
- func (chart *BarChart) SetCategories(categories ...string) *BarChart
- func (chart *BarChart) SetChartBorderWidth(width float32) *BarChart
- func (chart *BarChart) SetDrawGridLines(drawGridLines bool) *BarChart
- func (chart *BarChart) SetDrawLegend(drawLegend bool) *BarChart
- func (chart *BarChart) SetDrawValueLabels(drawValueLabels bool) *BarChart
- func (chart *BarChart) SetGridLineColor(c int32) *BarChart
- func (chart *BarChart) SetGridLineDashPattern(pattern string) *BarChart
- func (chart *BarChart) SetGridLineWidth(width float32) *BarChart
- func (chart *BarChart) SetGroupGap(gap float32) *BarChart
- func (chart *BarChart) SetGroupingUsed(groupingUsed bool) *BarChart
- func (chart *BarChart) SetHorizontal(horizontal bool) *BarChart
- func (chart *BarChart) SetInnerBorderWidth(width float32) *BarChart
- func (chart *BarChart) SetLocation(x, y float32) Drawable
- func (chart *BarChart) SetMaximumFractionDigits(maxFractionDigits int) *BarChart
- func (chart *BarChart) SetMinimumFractionDigits(minFractionDigits int) *BarChart
- func (chart *BarChart) SetSize(w, h float32) *BarChart
- func (chart *BarChart) SetStacked(stacked bool) *BarChart
- func (chart *BarChart) SetSubtitle(subtitle string) *BarChart
- func (chart *BarChart) SetTitle(title string) *BarChart
- func (chart *BarChart) SetValueAxisMinMax(min, max float32, gridLines int) *BarChart
- func (chart *BarChart) SetValueLabelsInside(valueLabelsInside bool) *BarChart
- func (chart *BarChart) SetXAxisTitle(title string) *BarChart
- func (chart *BarChart) SetYAxisTitle(title string) *BarChart
-
type Barcode
- func NewBarcode(barcodeType int, text string) *Barcode
- func (barcode *Barcode) DrawOn(page *Page) [2]float32
- func (barcode *Barcode) GetHeight() float32
- func (barcode *Barcode) SetAltDescription(altDescription string) *Barcode
- func (barcode *Barcode) SetBarHeightFactor(barHeightFactor float32) *Barcode
- func (barcode *Barcode) SetDirection(direction direction.Direction) *Barcode
- func (barcode *Barcode) SetFont(font *Font) *Barcode
- func (barcode *Barcode) SetLocation(x1, y1 float32) Drawable
- func (barcode *Barcode) SetModuleLength(moduleLength float32) *Barcode
-
type BaseAnnotation
- func (b *BaseAnnotation) DrawOn(page *Page) [2]float32
- func (b *BaseAnnotation) SetContents(contents string) *BaseAnnotation
- func (b *BaseAnnotation) SetFillColor(c int32) *BaseAnnotation
- func (b *BaseAnnotation) SetFillColorRGB(fillColor [3]float32) *BaseAnnotation
- func (b *BaseAnnotation) SetLocation(x, y float32) Drawable
- func (b *BaseAnnotation) SetOpacity(opacity float32) *BaseAnnotation
- func (b *BaseAnnotation) SetSize(w, h float32) *BaseAnnotation
- func (b *BaseAnnotation) SetTitle(title string) *BaseAnnotation
- type BaselineDrawable
-
type BigTable
- func NewBigTable(pdf *PDF, f1 *Font, f2 *Font, pageSize pagesize.PageSize) *BigTable
- func (bt *BigTable) Complete() error
- func (bt *BigTable) GetPages() []*Page
- func (bt *BigTable) SetBorderColor(c int32) *BigTable
- func (bt *BigTable) SetBorderColorRGB(rgb [3]float32) *BigTable
- func (bt *BigTable) SetBottomMargin(bottomMargin float32) *BigTable
- func (bt *BigTable) SetColumnWidthsInPercent(percents ...float32) *BigTable
- func (bt *BigTable) SetColumns(columns ...int) *BigTable
- func (bt *BigTable) SetFirstPage(page *Page, y float32) *BigTable
- func (bt *BigTable) SetFooter(text string, font *Font) *BigTable
- func (bt *BigTable) SetLocation(x, y float32) *BigTable
- func (bt *BigTable) SetNumberOfColumns(numberOfColumns int) *BigTable
- func (bt *BigTable) SetPadding(padding float32) *BigTable
- func (bt *BigTable) SetShadingColor(c int32) *BigTable
- func (bt *BigTable) SetShadingColorRGB(rgb [3]float32) *BigTable
- func (bt *BigTable) SetTableData(fileName, delimiter string) (*BigTable, error)
- func (bt *BigTable) SetTableRows(header []string, rows iter.Seq[[]string]) *BigTable
- func (bt *BigTable) SetTextAlignment(column int, alignment alignment.Alignment) *BigTable
-
type Bookmark
- func NewBookmark(pdf *PDF) *Bookmark
- func NewBookmarkAt(page *Page, y float32, key, title string) *Bookmark
- func (bookmark *Bookmark) AddBookmark(page *Page, title *Title) *Bookmark
- func (bookmark *Bookmark) AutoNumber(textLine *TextLine) *Bookmark
- func (bookmark *Bookmark) GetDestinationName() string
- func (bookmark *Bookmark) GetParent() *Bookmark
- func (bookmark *Bookmark) GetTitle() string
-
type CalendarMonth
- func NewCalendarMonth(f1, f2 *Font, year, month int) *CalendarMonth
- func (calendarMonth *CalendarMonth) DrawOn(page *Page) [2]float32
- func (calendarMonth *CalendarMonth) SetBodyFont(font *Font) *CalendarMonth
- func (calendarMonth *CalendarMonth) SetCellHeight(height float32) *CalendarMonth
- func (calendarMonth *CalendarMonth) SetCellWidth(width float32) *CalendarMonth
- func (calendarMonth *CalendarMonth) SetFirstDayOfWeek(day time.Weekday) *CalendarMonth
- func (calendarMonth *CalendarMonth) SetHeadFont(font *Font) *CalendarMonth
- func (calendarMonth *CalendarMonth) SetLocation(x, y float32) Drawable
-
type Cell
- func NewCell(font *Font, text string) *Cell
- func NewEmptyCell(font *Font) *Cell
- func (cell *Cell) GetBackgroundColor() *[3]float32
- func (cell *Cell) GetBarcode() *Barcode
- func (cell *Cell) GetBorder(b uint32) bool
- func (cell *Cell) GetBorderColor() *[3]float32
- func (cell *Cell) GetBorderWidth() float32
- func (cell *Cell) GetBottomPadding() float32
- func (cell *Cell) GetColSpan() int
- func (cell *Cell) GetCompositeTextLine() *CompositeTextLine
- func (cell *Cell) GetDrawable() Drawable
- func (cell *Cell) GetFallbackFont() *Font
- func (cell *Cell) GetFont() *Font
- func (cell *Cell) GetHeight(width float32) float32
- func (cell *Cell) GetImage() *Image
- func (cell *Cell) GetLeftPadding() float32
- func (cell *Cell) GetMarker() *Point
- func (cell *Cell) GetRightPadding() float32
- func (cell *Cell) GetRowSpan() int
- func (cell *Cell) GetStrikeout() bool
- func (cell *Cell) GetText() string
- func (cell *Cell) GetTextAlignment() alignment.Alignment
- func (cell *Cell) GetTextBlock() *TextBlock
- func (cell *Cell) GetTextColor() [3]float32
- func (cell *Cell) GetTextColumn() *TextColumn
- func (cell *Cell) GetTopPadding() float32
- func (cell *Cell) GetUnderline() bool
- func (cell *Cell) GetVerticalAlignment() alignment.Alignment
- func (cell *Cell) GetWidth() float32
- func (cell *Cell) SetBackgroundColor(c int32) *Cell
- func (cell *Cell) SetBackgroundColorRGB(rgbColor [3]float32) *Cell
- func (cell *Cell) SetBarcode(barcode *Barcode) *Cell
- func (cell *Cell) SetBorder(b uint32, visible bool) *Cell
- func (cell *Cell) SetBorderColor(c int32) *Cell
- func (cell *Cell) SetBorderColorRGB(rgbColor [3]float32) *Cell
- func (cell *Cell) SetBorderWidth(borderWidth float32) *Cell
- func (cell *Cell) SetBorders(visible bool) *Cell
- func (cell *Cell) SetBottomPadding(padding float32) *Cell
- func (cell *Cell) SetColSpan(colspan int) *Cell
- func (cell *Cell) SetCompositeTextLine(compositeTextLine *CompositeTextLine) *Cell
- func (cell *Cell) SetDrawable(drawable Drawable) *Cell
- func (cell *Cell) SetFallbackFont(fallbackFont *Font) *Cell
- func (cell *Cell) SetFont(font *Font) *Cell
- func (cell *Cell) SetFontSize(fontSize float32) *Cell
- func (cell *Cell) SetImage(image *Image) *Cell
- func (cell *Cell) SetLeftPadding(padding float32) *Cell
- func (cell *Cell) SetMarker(point *Point, align alignment.Alignment) *Cell
- func (cell *Cell) SetPadding(padding float32) *Cell
- func (cell *Cell) SetRightPadding(padding float32) *Cell
- func (cell *Cell) SetRowSpan(rowspan int) *Cell
- func (cell *Cell) SetStrikeout(strikeout bool) *Cell
- func (cell *Cell) SetText(text string) *Cell
- func (cell *Cell) SetTextAlignment(textAlignment alignment.Alignment) *Cell
- func (cell *Cell) SetTextBlock(textBlock *TextBlock) *Cell
- func (cell *Cell) SetTextColor(c int32) *Cell
- func (cell *Cell) SetTextColorRGB(textColor [3]float32) *Cell
- func (cell *Cell) SetTextColumn(textColumn *TextColumn) *Cell
- func (cell *Cell) SetTopPadding(padding float32) *Cell
- func (cell *Cell) SetURIAction(uri string) *Cell
- func (cell *Cell) SetUnderline(underline bool) *Cell
- func (cell *Cell) SetVerticalAlignment(valign alignment.Alignment) *Cell
- func (cell *Cell) SetWidth(width float32) *Cell
-
type Chart
- func NewChart(f1, f2 *Font) *Chart
- func (chart *Chart) AddSeries(name string) *Series
- func (chart *Chart) DrawOn(page *Page) [2]float32
- func (chart *Chart) SetAltDescription(altDescription string) *Chart
- func (chart *Chart) SetAxisLineWidth(width float32) *Chart
- func (chart *Chart) SetChartBorderWidth(width float32) *Chart
- func (chart *Chart) SetDrawHorizontalGridLines(drawHorizontalGridLines bool) *Chart
- func (chart *Chart) SetDrawLegend(drawLegend bool) *Chart
- func (chart *Chart) SetDrawVerticalGridLines(drawVerticalGridLines bool) *Chart
- func (chart *Chart) SetDrawXAxisLabels(drawXAxisLabels bool) *Chart
- func (chart *Chart) SetDrawYAxisLabels(drawYAxisLabels bool) *Chart
- func (chart *Chart) SetGridLineColor(c int32) *Chart
- func (chart *Chart) SetHorizontalGridLineDashPattern(pattern string) *Chart
- func (chart *Chart) SetHorizontalGridLineWidth(width float32) *Chart
- func (chart *Chart) SetInnerBorderWidth(width float32) *Chart
- func (chart *Chart) SetLocation(x, y float32) Drawable
- func (chart *Chart) SetMaximumFractionDigits(maxFractionDigits int) *Chart
- func (chart *Chart) SetMinimumFractionDigits(minFractionDigits int) *Chart
- func (chart *Chart) SetSize(w, h float32) *Chart
- func (chart *Chart) SetSubtitle(subtitle string) *Chart
- func (chart *Chart) SetTitle(title string) *Chart
- func (chart *Chart) SetVerticalGridLineDashPattern(pattern string) *Chart
- func (chart *Chart) SetVerticalGridLineWidth(width float32) *Chart
- func (chart *Chart) SetXAxisMinMax(xMin, xMax float32, xAxisGridLines int) *Chart
- func (chart *Chart) SetXAxisTitle(title string) *Chart
- func (chart *Chart) SetYAxisMinMax(yMin, yMax float32, yAxisGridLines int) *Chart
- func (chart *Chart) SetYAxisTitle(title string) *Chart
-
type CheckBox
- func NewCheckBox(font *Font, label string) *CheckBox
- func (checkBox *CheckBox) Check(checkMark mark.Mark) *CheckBox
- func (checkBox *CheckBox) DrawOn(page *Page) [2]float32
- func (checkBox *CheckBox) GetHeight() float32
- func (checkBox *CheckBox) GetWidth() float32
- func (checkBox *CheckBox) SetActualText(actualText string) *CheckBox
- func (checkBox *CheckBox) SetAltDescription(altDescription string) *CheckBox
- func (checkBox *CheckBox) SetBorderColor(borderColor int32) *CheckBox
- func (checkBox *CheckBox) SetBorderColorRGB(rgbColor [3]float32) *CheckBox
- func (checkBox *CheckBox) SetCheckmarkColor(checkmarkColor int32) *CheckBox
- func (checkBox *CheckBox) SetCheckmarkColorRGB(rgbColor [3]float32) *CheckBox
- func (checkBox *CheckBox) SetFontSize(fontSize float32) *CheckBox
- func (checkBox *CheckBox) SetLocation(x, y float32) Drawable
- func (checkBox *CheckBox) SetURIAction(uri string) *CheckBox
- type CircleAnnotation
-
type CompositeTextLine
- func NewCompositeTextLine(x, y float32) *CompositeTextLine
- func (composite *CompositeTextLine) AddComponent(textLine *TextLine) *CompositeTextLine
- func (composite *CompositeTextLine) AddFormula(font *Font, formula string) *CompositeTextLine
- func (composite *CompositeTextLine) DrawOn(page *Page) [2]float32
- func (composite *CompositeTextLine) GetAscent() float32
- func (composite *CompositeTextLine) GetDescent() float32
- func (composite *CompositeTextLine) GetFontSize() float32
- func (composite *CompositeTextLine) GetHeight() float32
- func (composite *CompositeTextLine) GetLocation() [2]float32
- func (composite *CompositeTextLine) GetMinMaxY() [2]float32
- func (composite *CompositeTextLine) GetNumberOfTextLines() int
- func (composite *CompositeTextLine) GetSubscriptFactor() float32
- func (composite *CompositeTextLine) GetSubscriptPosition() float32
- func (composite *CompositeTextLine) GetSuperscriptFactor() float32
- func (composite *CompositeTextLine) GetSuperscriptPosition() float32
- func (composite *CompositeTextLine) GetTextLine(index int) *TextLine
- func (composite *CompositeTextLine) GetWidth() float32
- func (composite *CompositeTextLine) SetFontSize(fontSize float32) *CompositeTextLine
- func (composite *CompositeTextLine) SetLocation(x, y float32) Drawable
- func (composite *CompositeTextLine) SetSubscriptFactor(subscript float32) *CompositeTextLine
- func (composite *CompositeTextLine) SetSubscriptPosition(subscriptPosition float32) *CompositeTextLine
- func (composite *CompositeTextLine) SetSuperscriptFactor(superscript float32) *CompositeTextLine
- func (composite *CompositeTextLine) SetSuperscriptPosition(superscriptPosition float32) *CompositeTextLine
-
type Container
- func NewContainer(width, height float32) *Container
- func (c *Container) Add(element Drawable) *Container
- func (c *Container) DrawOn(page *Page) [2]float32
- func (c *Container) GetRotationCenter() [2]float32
- func (c *Container) ScaleBy(factor float32) *Container
- func (c *Container) ScaleByWidthAndHeight(sx, sy float32) *Container
- func (c *Container) SetBorderColor(borderColor int32) *Container
- func (c *Container) SetBorderColorRGB(rgbColor [3]float32) *Container
- func (c *Container) SetLocation(x, y float32) Drawable
- func (c *Container) SetRotation(degrees float64) *Container
- type Destination
- type Dimension
-
type DonutChart
- func NewDonutChart(f1, f2 *Font) *DonutChart
- func (dc *DonutChart) AddSlice(slice *Slice) *DonutChart
- func (dc *DonutChart) DrawOn(page *Page) [2]float32
- func (dc *DonutChart) SetAltDescription(altDescription string) *DonutChart
- func (dc *DonutChart) SetLocation(x, y float32) Drawable
- func (dc *DonutChart) SetRadii(outerRadius, innerRadius float32) *DonutChart
- type Drawable
- type Ellipse
-
type EmbeddedFile
- func NewEmbeddedFile(pdf *PDF, fileName string, reader io.Reader, compress bool) *EmbeddedFile
- func NewEmbeddedFileAtPath(pdf *PDF, filePath string, compress bool) *EmbeddedFile
- func NewEmbeddedFileWithRelationship(pdf *PDF, fileName string, reader io.Reader, compress bool, mediaType string, ...) *EmbeddedFile
- func (file *EmbeddedFile) GetFileName() string
- type Encryption
- type Field
-
type FileAttachment
- func NewFileAttachment(embeddedFile *EmbeddedFile) *FileAttachment
- func (attachment *FileAttachment) DrawOn(page *Page) [2]float32
- func (attachment *FileAttachment) SetContents(contents string) *FileAttachment
- func (attachment *FileAttachment) SetIconPaperclip() *FileAttachment
- func (attachment *FileAttachment) SetIconPushPin() *FileAttachment
- func (attachment *FileAttachment) SetIconSize(height float32) *FileAttachment
- func (attachment *FileAttachment) SetLocation(x, y float32) Drawable
- func (attachment *FileAttachment) SetTitle(title string) *FileAttachment
-
type Font
- func NewCJKFont(pdf *PDF, cjkFont cjkfont.Font) *Font
- func NewCoreFont(pdf *PDF, coreFont *corefont.CoreFont) *Font
- func NewFont(pdf *PDF, reader io.Reader) *Font
- func NewFontForObjects(objects *[]*PDFobj, reader io.Reader) *Font
- func NewFontFromFile(pdf *PDF, filePath string) *Font
- func (font *Font) GetAscent(fontSize float32) float32
- func (font *Font) GetBodyHeight(fontSize float32) float32
- func (font *Font) GetDescent(fontSize float32) float32
- func (font *Font) GetFitChars(text string, width float32) int
- func (font *Font) GetLineGap(fontSize float32) float32
- func (font *Font) GetName() string
- func (font *Font) GetSize() float32
- func (font *Font) GetUnderlinePosition(fontSize float32) float32
- func (font *Font) GetUnderlineThickness(fontSize float32) float32
- func (font *Font) SetItalic(skew15 bool) *Font
- func (font *Font) SetKernPairs(kernPairs bool) *Font
- func (font *Font) SetSize(fontSize float32) *Font
- func (font *Font) SetSubset(subset bool) *Font
- func (font *Font) StringWidth(fontSize float32, str string) float32
- func (font *Font) StringWidthUsingFallbackFont(fallbackFont *Font, fontSize float32, text string) float32
-
type Form
- func NewForm(fields []*Field) *Form
- func (form *Form) DrawOn(page *Page) [2]float32
- func (form *Form) SetLabelColor(labelColor int32) *Form
- func (form *Form) SetLabelColorRGB(color [3]float32) *Form
- func (form *Form) SetLabelFont(f1 *Font) *Form
- func (form *Form) SetLabelFontSize(labelFontSize float32) *Form
- func (form *Form) SetLocation(x, y float32) Drawable
- func (form *Form) SetStrokeWidth(strokeWidth float32) *Form
- func (form *Form) SetValueColor(valueColor int32) *Form
- func (form *Form) SetValueColorRGB(color [3]float32) *Form
- func (form *Form) SetValueFont(f2 *Font) *Form
- func (form *Form) SetValueFontSize(valueFontSize float32) *Form
- func (form *Form) SetWidth(width float32) *Form
-
type GraphicsState
- func NewGraphicsState() *GraphicsState
- func (state *GraphicsState) GetAlphaNonStroking() float32
- func (state *GraphicsState) GetAlphaStroking() float32
- func (state *GraphicsState) SetAlphaNonStroking(nonStrokingAlpha float32) *GraphicsState
- func (state *GraphicsState) SetAlphaStroking(strokingAlpha float32) *GraphicsState
-
type Image
- func NewImage(pdf *PDF, reader io.Reader) *Image
- func NewImageForObjects(objects *[]*PDFobj, reader io.Reader) *Image
- func NewImageFromFile(pdf *PDF, filePath string) *Image
- func NewImageFromPDFobj(pdf *PDF, obj *PDFobj) *Image
- func (image *Image) DrawOn(page *Page) [2]float32
- func (image *Image) GetHeight() float32
- func (image *Image) GetWidth() float32
- func (image *Image) ResizeHeight(height float32) *Image
- func (image *Image) ResizeToFit(page *Page, keepAspectRatio bool)
- func (image *Image) ResizeWidth(width float32) *Image
- func (image *Image) ScaleBy(factor float32) *Image
- func (image *Image) ScaleByWidthAndHeight(widthFactor, heightFactor float32) *Image
- func (image *Image) SetActualText(actualText string) *Image
- func (image *Image) SetAltDescription(altDescription string) *Image
- func (image *Image) SetFlipUpsideDown(flipUpsideDown bool) *Image
- func (image *Image) SetGoToAction(key string) *Image
- func (image *Image) SetLanguage(language string) *Image
- func (image *Image) SetLocation(x, y float32) Drawable
- func (image *Image) SetRotation(degrees int) *Image
- func (image *Image) SetURIAction(uri string) *Image
- type ImageSize
-
type Line
- func NewLine(x1, y1, x2, y2 float32) *Line
- func (line *Line) DrawOn(page *Page) [2]float32
- func (line *Line) GetEndPoint() *Point
- func (line *Line) GetLineCapStyle() capstyle.CapStyle
- func (line *Line) GetStartPoint() *Point
- func (line *Line) ScaleBy(factor float32) *Line
- func (line *Line) SetActualText(actualText string) *Line
- func (line *Line) SetAltDescription(altDescription string) *Line
- func (line *Line) SetEndPoint(x, y float32) *Line
- func (line *Line) SetLineCapStyle(style capstyle.CapStyle) *Line
- func (line *Line) SetLocation(x, y float32) Drawable
- func (line *Line) SetStartPoint(x, y float32) *Line
- func (line *Line) SetStrokeColor(c int32) *Line
- func (line *Line) SetStrokeColorRGB(rgbColor [3]float32) *Line
- func (line *Line) SetStrokeDashPattern(pattern string) *Line
- func (line *Line) SetStrokeWidth(width float32) *Line
-
type Markdown
- func NewMarkdown(regular, bold, italic, boldItalic, code *Font) *Markdown
- func (markdown *Markdown) DrawOnPages(pdf *PDF, text string, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
- func (markdown *Markdown) SetCheckColor(checkColor int32) *Markdown
- func (markdown *Markdown) SetHeadingColor(headingColor int32) *Markdown
- func (markdown *Markdown) SetHeadingFont(font *Font) *Markdown
- func (markdown *Markdown) SetImageDirectory(directory string) *Markdown
- func (markdown *Markdown) SetLinkColor(linkColor int32) *Markdown
- func (markdown *Markdown) SetMargins(left, top, right, bottom float32) *Markdown
-
type Markup
- func NewMarkup(regular, bold, italic, boldItalic, code *Font) *Markup
- func (markup *Markup) Paragraph(text string) *Paragraph
- func (markup *Markup) Paragraphs(text string) []*Paragraph
- func (markup *Markup) SetLinkColor(linkColor int32) *Markup
- func (markup *Markup) SetLinkUnderline(underline bool) *Markup
-
type OptionalContentGroup
- func NewOptionalContentGroup(pdf *PDF, name string) *OptionalContentGroup
- func (ocg *OptionalContentGroup) Add(drawable Drawable) *OptionalContentGroup
- func (ocg *OptionalContentGroup) Clear() *OptionalContentGroup
- func (ocg *OptionalContentGroup) DrawOn(page *Page) [2]float32
- func (ocg *OptionalContentGroup) GetComponents() []Drawable
- func (ocg *OptionalContentGroup) GetName() string
- func (ocg *OptionalContentGroup) SetExportable(exportable bool) *OptionalContentGroup
- func (ocg *OptionalContentGroup) SetPrintable(printable bool) *OptionalContentGroup
- func (ocg *OptionalContentGroup) SetVisible(visible bool) *OptionalContentGroup
-
type PDF
- func NewPDF(w *bufio.Writer) *PDF
- func NewPDFFile(filePath string) (*PDF, error)
- func NewPDFReader() *PDF
- func (pdf *PDF) AddAssociatedFile(file *EmbeddedFile) *PDF
- func (pdf *PDF) AddMetadata(rdfDescription string) *PDF
- func (pdf *PDF) AddObjects(objects []*PDFobj) error
- func (pdf *PDF) AddPage(page *Page)
- func (pdf *PDF) AddPages(pages []*Page)
- func (pdf *PDF) AddResourceObjects(objects []*PDFobj)
- func (pdf *PDF) Complete() error
- func (pdf *PDF) GetCompliance() compliance.Compliance
- func (pdf *PDF) GetPageObjects(objects []*PDFobj) []*PDFobj
- func (pdf *PDF) Merge(objects []*PDFobj) error
- func (pdf *PDF) MergePages(objects []*PDFobj, pageNumbers ...int) error
- func (pdf *PDF) Read(buf []byte) ([]*PDFobj, error)
- func (pdf *PDF) ReadWithPassword(buf []byte, password string) (objects []*PDFobj, err error)
- func (pdf *PDF) SetAuthor(author string) *PDF
- func (pdf *PDF) SetCompliance(level compliance.Compliance) *PDF
- func (pdf *PDF) SetCreator(creator string) *PDF
- func (pdf *PDF) SetEncryption(encryption *Encryption) *PDF
- func (pdf *PDF) SetKeywords(keywords string) *PDF
- func (pdf *PDF) SetLanguage(language string) *PDF
- func (pdf *PDF) SetPageLayout(pageLayout pagelayout.PageLayout) *PDF
- func (pdf *PDF) SetPageMode(pageMode pagemode.PageMode) *PDF
- func (pdf *PDF) SetSubject(subject string) *PDF
- func (pdf *PDF) SetTitle(title string) *PDF
-
type PDFobj
- func (obj *PDFobj) AddContent(content []byte, objects *[]*PDFobj)
- func (obj *PDFobj) AddCoreFontResource(coreFont *corefont.CoreFont, objects *[]*PDFobj) *Font
- func (obj *PDFobj) AddFontResource(font *Font, objects *[]*PDFobj)
- func (obj *PDFobj) AddImageResource(image *Image, objects *[]*PDFobj)
- func (obj *PDFobj) AddPrefixContent(content []byte, objects *[]*PDFobj)
- func (obj *PDFobj) GetContentObject(objects []*PDFobj) *PDFobj
- func (obj *PDFobj) GetData() []byte
- func (obj *PDFobj) GetDict() []string
- func (obj *PDFobj) GetNumber() int
- func (obj *PDFobj) GetPageSize() pagesize.PageSize
- func (obj *PDFobj) GetResourcesObject(objects []*PDFobj) *PDFobj
- func (obj *PDFobj) GetValue(key string) string
- func (obj *PDFobj) SetGraphicsState(gs *GraphicsState, objects *[]*PDFobj) *PDFobj
-
type Page
- func NewPage(pdf *PDF, pageSize pagesize.PageSize) *Page
- func NewPageDetached(pdf *PDF, pageSize pagesize.PageSize) *Page
- func NewPageFromObject(pdf *PDF, pageObj *PDFobj) *Page
- func (page *Page) AddArcToPath(x, y, rx, ry, startAngle, sweepDegrees float32) []float32
- func (page *Page) AddArtifactBMC()
- func (page *Page) AddBDC(structure structelem.StructElem, language, actualText, altDescription string)
- func (page *Page) AddCircularArcToPath(x, y, r, startAngle, sweepDegrees float32) []float32
- func (page *Page) AddCoreFontResource(coreFont *corefont.CoreFont, objects *[]*PDFobj) *Font
- func (page *Page) AddDestination(name string, yPosition float32) *Destination
- func (page *Page) AddDestinationAt(name string, xPosition, yPosition float32) *Destination
- func (page *Page) AddEMC()
- func (page *Page) AddFontResource(font *Font, objects *[]*PDFobj)
- func (page *Page) AddFooter(textLine *TextLine) [2]float32
- func (page *Page) AddFooterOffsetBy(textLine *TextLine, offset float32) [2]float32
- func (page *Page) AddHeader(textLine *TextLine) [2]float32
- func (page *Page) AddHeaderOffsetBy(textLine *TextLine, offset float32) [2]float32
- func (page *Page) AddImageResource(image *Image, objects *[]*PDFobj)
- func (page *Page) AddWatermark(font *Font, text string)
- func (page *Page) BeginStructElement(structure structelem.StructElem)
- func (page *Page) BezierCurveTo(p1, p2, p3 *Point)
- func (page *Page) ClipPath()
- func (page *Page) ClipRect(x, y, w, h float32)
- func (page *Page) ClosePath()
- func (page *Page) Complete(objects *[]*PDFobj)
- func (page *Page) CurveTo(x1, y1, x2, y2, x3, y3 float32)
- func (page *Page) DrawCircle(x, y, r float32)
- func (page *Page) DrawContents(content []byte, h float32, x float32, y float32, xScale float32, ...)
- func (page *Page) DrawEllipse(x, y, r1, r2 float32)
- func (page *Page) DrawLine(x1, y1, x2, y2 float32)
- func (page *Page) DrawPath(path []*Point, pathOperator pathoperator.PathOperator)
- func (page *Page) DrawPoint(p *Point)
- func (page *Page) DrawRect(x, y, w, h float32)
- func (page *Page) DrawRoundedRect(x, y, w, h, r1, r2 float32)
- func (page *Page) DrawString(font, fallbackFont *Font, fontSize float32, text string, x, y float32)
- func (page *Page) DrawStringUsingFontSize(font *Font, fontSize float32, text string, x, y float32)
- func (page *Page) DrawStringUsingSpacing(font *Font, fontSize float32, text string, x, y, dx float32)
- func (page *Page) EndStructElement()
- func (page *Page) FillCircle(x, y, r float32)
- func (page *Page) FillEllipse(x, y, r1, r2 float32)
- func (page *Page) FillPath()
- func (page *Page) FillRect(x, y, w, h float32)
- func (page *Page) FillRoundedRect(x, y, w, h, r1, r2 float32)
- func (page *Page) GetBrushColor() [3]float32
- func (page *Page) GetContent() []byte
- func (page *Page) GetHeight() float32
- func (page *Page) GetPenColor() [3]float32
- func (page *Page) GetPenWidth() float32
- func (page *Page) GetWidth() float32
- func (page *Page) InvertYAxis()
- func (page *Page) LineTo(x, y float32)
- func (page *Page) MoveTo(x, y float32)
- func (page *Page) RestoreGraphicsState()
- func (page *Page) SaveGraphicsState()
- func (page *Page) SetArtBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
- func (page *Page) SetBleedBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
- func (page *Page) SetBrushColor(c int32) *Page
- func (page *Page) SetBrushColorCMYK(c, m, y, k float32) *Page
- func (page *Page) SetBrushColorRGB(rgbColor [3]float32) *Page
- func (page *Page) SetCropBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
- func (page *Page) SetDefaultPenWidth() *Page
- func (page *Page) SetDefaultStrokeDashPattern() *Page
- func (page *Page) SetFigureBoundingBox(x, y, w, h float32)
- func (page *Page) SetGraphicsState(gs *GraphicsState) *Page
- func (page *Page) SetLineCapStyle(style capstyle.CapStyle) *Page
- func (page *Page) SetLineJoinStyle(style joinstyle.JoinStyle) *Page
- func (page *Page) SetPenColor(c int32) *Page
- func (page *Page) SetPenColorCMYK(c, m, y, k float32) *Page
- func (page *Page) SetPenColorRGB(rgbColor [3]float32) *Page
- func (page *Page) SetPenWidth(width float32) *Page
- func (page *Page) SetRotation(degrees int) *Page
- func (page *Page) SetStrokeDashPattern(strokeDashPattern string) *Page
- func (page *Page) SetTextRenderingMode(mode int) (*Page, error)
- func (page *Page) SetTextRotation(degrees int) *Page
- func (page *Page) SetTrimBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
- func (page *Page) StrokePath()
- func (page *Page) Transform(values []float32)
-
type Paragraph
- func NewParagraph() *Paragraph
- func ParagraphsFromFile(f1 *Font, filePath string) []*Paragraph
- func (paragraph *Paragraph) Add(text *TextLine) *Paragraph
- func (paragraph *Paragraph) AddJoined(text *TextLine) *Paragraph
- func (paragraph *Paragraph) GetTextLines() []*TextLine
- func (paragraph *Paragraph) GetTextX() float32
- func (paragraph *Paragraph) GetTextY() float32
- func (paragraph *Paragraph) GetX1() float32
- func (paragraph *Paragraph) GetX2() float32
- func (paragraph *Paragraph) GetY1() float32
- func (paragraph *Paragraph) GetY2() float32
- func (paragraph *Paragraph) SetHighlightColors(colorMap map[string]int32) *Paragraph
- func (paragraph *Paragraph) SetListLabel(label *TextLine, indent float32) *Paragraph
- func (paragraph *Paragraph) SetStructureType(structureType structelem.StructElem) *Paragraph
- func (paragraph *Paragraph) SetTextAlignment(textAlignment alignment.Alignment) *Paragraph
- func (paragraph *Paragraph) SetTextColor(c int32) *Paragraph
- func (paragraph *Paragraph) SetTextColorRGB(rgbColor [3]float32) *Paragraph
- func (paragraph *Paragraph) StartsWith(token string) bool
-
type Path
- func NewPath() *Path
- func (path *Path) Add(point *Point) *Path
- func (path *Path) DrawOn(page *Page) [2]float32
- func (path *Path) GetLineCapStyle() capstyle.CapStyle
- func (path *Path) GetLineJoinStyle() joinstyle.JoinStyle
- func (path *Path) ScaleBy(factor float32) *Path
- func (path *Path) SetClosed(closed bool) *Path
- func (path *Path) SetFillShape(fillShape bool) *Path
- func (path *Path) SetLineCapStyle(style capstyle.CapStyle) *Path
- func (path *Path) SetLineJoinStyle(style joinstyle.JoinStyle) *Path
- func (path *Path) SetLocation(x, y float32) Drawable
- func (path *Path) SetStrokeColor(c int32) *Path
- func (path *Path) SetStrokeColorRGB(rgbColor [3]float32) *Path
- func (path *Path) SetStrokeDashPattern(pattern string) *Path
- func (path *Path) SetStrokeWidth(width float32) *Path
-
type Point
- func NewControlPointC(x, y float32) *Point
- func NewControlPointV(x, y float32) *Point
- func NewControlPointY(x, y float32) *Point
- func NewPoint(x, y float32) *Point
- func (point *Point) DrawOn(page *Page) [2]float32
- func (point *Point) GetAltDescription() string
- func (point *Point) GetFillColor() [3]float32
- func (point *Point) GetRadius() float32
- func (point *Point) GetShape() shape.Shape
- func (point *Point) GetStrokeColor() [3]float32
- func (point *Point) GetStrokeWidth() float32
- func (point *Point) GetURIAction() string
- func (point *Point) GetX() float32
- func (point *Point) GetY() float32
- func (point *Point) SetAltDescription(altDescription string) *Point
- func (point *Point) SetFillColor(fillColor int32) *Point
- func (point *Point) SetFillColorRGB(rgbColor [3]float32) *Point
- func (point *Point) SetLocation(x, y float32) Drawable
- func (point *Point) SetRadius(r float32) *Point
- func (point *Point) SetShape(pointShape shape.Shape) *Point
- func (point *Point) SetStrokeColor(strokeColor int32) *Point
- func (point *Point) SetStrokeColorRGB(rgbColor [3]float32) *Point
- func (point *Point) SetStrokeWidth(strokeWidth float32) *Point
- func (point *Point) SetURIAction(uri string) *Point
- func (point *Point) SetX(x float32) *Point
- func (point *Point) SetY(y float32) *Point
- type PolygonAnnotation
-
type RadioButton
- func NewRadioButton(font *Font, label string) *RadioButton
- func (radioButton *RadioButton) DrawOn(page *Page) [2]float32
- func (radioButton *RadioButton) Select(selected bool) *RadioButton
- func (radioButton *RadioButton) SetActualText(actualText string) *RadioButton
- func (radioButton *RadioButton) SetAltDescription(altDescription string) *RadioButton
- func (radioButton *RadioButton) SetFontSize(fontSize float32) *RadioButton
- func (radioButton *RadioButton) SetLocation(x, y float32) Drawable
- func (radioButton *RadioButton) SetURIAction(uri string) *RadioButton
-
type Rect
- func NewRect(x, y, w, h float32) *Rect
- func (rect *Rect) DrawOn(page *Page) [2]float32
- func (rect *Rect) ScaleBy(factor float32) *Rect
- func (rect *Rect) SetActualText(actualText string) *Rect
- func (rect *Rect) SetAltDescription(altDescription string) *Rect
- func (rect *Rect) SetBorderColor(borderColor int32) *Rect
- func (rect *Rect) SetBorderColorRGB(borderColor [3]float32) *Rect
- func (rect *Rect) SetBorderDashPattern(borderPattern string) *Rect
- func (rect *Rect) SetBorderWidth(borderWidth float32) *Rect
- func (rect *Rect) SetCornerRadius(cornerRadius float32) *Rect
- func (rect *Rect) SetFillColor(fillColor int32) *Rect
- func (rect *Rect) SetFillColorRGB(fillColor [3]float32) *Rect
- func (rect *Rect) SetGoToAction(key string) *Rect
- func (rect *Rect) SetLanguage(language string) *Rect
- func (rect *Rect) SetLocation(x, y float32) Drawable
- func (rect *Rect) SetSize(w, h float32) *Rect
- func (rect *Rect) SetURIAction(uri string) *Rect
-
type SVGImage
- func NewSVGImage(reader io.Reader) (*SVGImage, error)
- func NewSVGImageFromFile(filePath string) (*SVGImage, error)
- func (image *SVGImage) DrawOn(page *Page) [2]float32
- func (image *SVGImage) GetHeight() float32
- func (image *SVGImage) GetWidth() float32
- func (image *SVGImage) ScaleBy(factor float32) *SVGImage
- func (image *SVGImage) SetActualText(actualText string) *SVGImage
- func (image *SVGImage) SetAltDescription(altDescription string) *SVGImage
- func (image *SVGImage) SetGoToAction(key string) *SVGImage
- func (image *SVGImage) SetLanguage(language string) *SVGImage
- func (image *SVGImage) SetLocation(x, y float32) Drawable
- func (image *SVGImage) SetURIAction(uri string) *SVGImage
-
type Series
- func (series *Series) AddPoint(x, y float32) *Series
- func (series *Series) AddPointWithMarker(point *Point) *Series
- func (series *Series) SetDrawPath(drawPath bool) *Series
- func (series *Series) SetRadius(radius float32) *Series
- func (series *Series) SetShape(markerShape shape.Shape) *Series
- func (series *Series) SetStrokeColor(c int32) *Series
- func (series *Series) SetStrokeDashPattern(strokeDashPattern string) *Series
- func (series *Series) SetStrokeWidth(strokeWidth float32) *Series
- type Slice
- type SquareAnnotation
-
type Stamp
- func NewStamp(pdf *PDF) *Stamp
- func (s *Stamp) AddFont(font *Font) *Stamp
- func (s *Stamp) CloseFillAndStrokePath() *Stamp
- func (s *Stamp) ClosePath() *Stamp
- func (s *Stamp) Complete()
- func (s *Stamp) CurveTo(x1, y1, x2, y2, x3, y3 float32) *Stamp
- func (s *Stamp) DrawOn(page *Page) [2]float32
- func (s *Stamp) DrawPath(path []*Point, pathOperator pathoperator.PathOperator)
- func (s *Stamp) DrawRect(x, y, w, h float32) *Stamp
- func (s *Stamp) DrawText(font *Font, fontSize, x, y float32, text string) *Stamp
- func (s *Stamp) DrawTextUsingParams(params *TextParameters) *Stamp
- func (s *Stamp) FillPath() *Stamp
- func (s *Stamp) FillRect(x, y, w, h float32) *Stamp
- func (s *Stamp) LineTo(x, y float32) *Stamp
- func (s *Stamp) MoveTo(x, y float32) *Stamp
- func (s *Stamp) ScaleBy(factor float32) *Stamp
- func (s *Stamp) ScaleByWidthAndHeight(sx, sy float32) *Stamp
- func (s *Stamp) SetActualText(actualText string) *Stamp
- func (s *Stamp) SetAltDescription(altDescription string) *Stamp
- func (s *Stamp) SetFillColor(c int32) *Stamp
- func (s *Stamp) SetFillColorRGB(rgbColor [3]float32) *Stamp
- func (s *Stamp) SetLanguage(language string) *Stamp
- func (s *Stamp) SetLocation(x, y float32) Drawable
- func (s *Stamp) SetRotation(degrees float64) *Stamp
- func (s *Stamp) SetSize(width, height float32) *Stamp
- func (s *Stamp) SetStrokeColor(c int32) *Stamp
- func (s *Stamp) SetStrokeColorRGB(rgbColor [3]float32) *Stamp
- func (s *Stamp) SetStrokeWidth(width float32) *Stamp
- func (s *Stamp) StrokePath() *Stamp
-
type Table
- func NewTable() *Table
- func NewTableFromFile(f1, f2 *Font, fileName string) *Table
- func ReadTableFromFile(f1, f2 *Font, fileName string) (table *Table, err error)
- func (table *Table) AutoAdjustColumnWidths() *Table
- func (table *Table) DrawOn(page *Page) [2]float32
- func (table *Table) DrawOnPages(pdf *PDF, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
- func (table *Table) DrawOnPagesFrom(pdf *PDF, first *Page, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
- func (table *Table) FitToWidth(width float32) *Table
- func (table *Table) GetCellAt(rowIndex, colIndex int) *Cell
- func (table *Table) GetColumn(index int) []*Cell
- func (table *Table) GetColumnWidth(index int) float32
- func (table *Table) GetRow(index int) []*Cell
- func (table *Table) GetRowsRendered() int
- func (table *Table) GetWidth() float32
- func (table *Table) KeepRowWithNext(index int) *Table
- func (table *Table) RemoveLineBetweenRows(index1, index2 int) *Table
- func (table *Table) RightAlignNumbers() *Table
- func (table *Table) SetAlternateRowColor(c int32) *Table
- func (table *Table) SetAlternateRowColorRGB(rgbColor [3]float32) *Table
- func (table *Table) SetBottomMargin(bottomMargin float32) *Table
- func (table *Table) SetBroughtForwardSum(row, column, decimals int) *Table
- func (table *Table) SetCellBorderColor(c int32) *Table
- func (table *Table) SetCellBorderColorRGB(rgbColor [3]float32) *Table
- func (table *Table) SetCellBorderWidth(width float32) *Table
- func (table *Table) SetCellBorders(borders bool) *Table
- func (table *Table) SetCellPadding(side, vertical float32) *Table
- func (table *Table) SetColumnWidth(index int, width float32) *Table
- func (table *Table) SetColumnWidthsInPercent(percents ...float32) *Table
- func (table *Table) SetFirstPageTopMargin(firstPageTopMargin float32) *Table
- func (table *Table) SetFontInColumn(index int, font *Font) *Table
- func (table *Table) SetFontInRow(index int, font *Font) *Table
- func (table *Table) SetFooterRowStyle(font *Font, textColor, backgroundColor int32) *Table
- func (table *Table) SetHeaderRowStyle(font *Font, textColor, backgroundColor int32) *Table
- func (table *Table) SetLocation(x, y float32) Drawable
- func (table *Table) SetNumberOfFooterRows(numOfFooterRows int) *Table
- func (table *Table) SetPageSum(row, column, decimals int) *Table
- func (table *Table) SetRunningSum(row, column, decimals int) *Table
- func (table *Table) SetTableData(tableData [][]*Cell, numOfHeaderRows int) *Table
- func (table *Table) SetTextAlignmentInColumn(index int, textAlignment alignment.Alignment) *Table
- func (table *Table) SetTextColorInColumn(index int, color int32) *Table
- func (table *Table) SetTextColorInRow(index int, color int32) *Table
- func (table *Table) SetVisibleColumns(visible ...int) *Table
- func (table *Table) SetWidth(width float32) *Table
- type TextAnnotation
-
type TextBlock
- func NewTextBlock(font *Font, textContent string) *TextBlock
- func (textBlock *TextBlock) DrawOn(page *Page) [2]float32
- func (textBlock *TextBlock) GetBackgroundColor() *[3]float32
- func (textBlock *TextBlock) GetBorderColor() *[3]float32
- func (textBlock *TextBlock) GetBorderWidth() float32
- func (textBlock *TextBlock) GetFont() *Font
- func (textBlock *TextBlock) GetHeight() float32
- func (textBlock *TextBlock) GetLocation() [2]float32
- func (textBlock *TextBlock) GetPadding() float32
- func (textBlock *TextBlock) GetStrikeout() bool
- func (textBlock *TextBlock) GetText() string
- func (textBlock *TextBlock) GetTextAlignment() alignment.Alignment
- func (textBlock *TextBlock) GetTextColor() [3]float32
- func (textBlock *TextBlock) GetUnderline() bool
- func (textBlock *TextBlock) GetVerticalAlignment() alignment.Alignment
- func (textBlock *TextBlock) GetWidth() float32
- func (textBlock *TextBlock) SetBackgroundColor(c int32) *TextBlock
- func (textBlock *TextBlock) SetBackgroundColorRGB(fillColor [3]float32) *TextBlock
- func (textBlock *TextBlock) SetBorderColor(c int32) *TextBlock
- func (textBlock *TextBlock) SetBorderColorRGB(borderColor [3]float32) *TextBlock
- func (textBlock *TextBlock) SetBorderWidth(borderWidth float32) *TextBlock
- func (textBlock *TextBlock) SetCornerRadius(borderCornerRadius float32) *TextBlock
- func (textBlock *TextBlock) SetFallbackFont(fallbackFont *Font) *TextBlock
- func (textBlock *TextBlock) SetFallbackFontSize(size float32) *TextBlock
- func (textBlock *TextBlock) SetFont(font *Font) *TextBlock
- func (textBlock *TextBlock) SetFontSize(size float32) *TextBlock
- func (textBlock *TextBlock) SetHeight(h float32) *TextBlock
- func (textBlock *TextBlock) SetHighlightColors(keywordHighlightColors map[string]int32) *TextBlock
- func (textBlock *TextBlock) SetLanguage(language string) *TextBlock
- func (textBlock *TextBlock) SetLineSpacing(lineSpacing float32) *TextBlock
- func (textBlock *TextBlock) SetLocation(x, y float32) Drawable
- func (textBlock *TextBlock) SetPadding(padding float32) *TextBlock
- func (textBlock *TextBlock) SetRightToLeft(rightToLeft bool) *TextBlock
- func (textBlock *TextBlock) SetSize(w, h float32) *TextBlock
- func (textBlock *TextBlock) SetStrikeout(strikeout bool) *TextBlock
- func (textBlock *TextBlock) SetStructureType(structureType structelem.StructElem) *TextBlock
- func (textBlock *TextBlock) SetText(text string) *TextBlock
- func (textBlock *TextBlock) SetTextAlignment(textAlignment alignment.Alignment) *TextBlock
- func (textBlock *TextBlock) SetTextColor(c int32) *TextBlock
- func (textBlock *TextBlock) SetTextColorRGB(textColor [3]float32) *TextBlock
- func (textBlock *TextBlock) SetURIAction(uri string) *TextBlock
- func (textBlock *TextBlock) SetUnderline(underline bool) *TextBlock
- func (textBlock *TextBlock) SetVerticalAlignment(verticalAlignment alignment.Alignment) *TextBlock
- func (textBlock *TextBlock) SetWidth(w float32) *TextBlock
-
type TextColumn
- func NewTextColumn() *TextColumn
- func (textColumn *TextColumn) AddCJKParagraph(font *Font, text string) *TextColumn
- func (textColumn *TextColumn) AddCJKParagraphWithLanguage(font *Font, text, language string) *TextColumn
- func (textColumn *TextColumn) AddParagraph(paragraph *Paragraph) *TextColumn
- func (textColumn *TextColumn) DrawOn(page *Page) [2]float32
- func (textColumn *TextColumn) GetHeight() float32
- func (textColumn *TextColumn) GetSize() *Dimension
- func (textColumn *TextColumn) GetWidth() float32
- func (textColumn *TextColumn) RemoveLastParagraph() *TextColumn
- func (textColumn *TextColumn) SetHeight(h float32) *TextColumn
- func (textColumn *TextColumn) SetLineBetweenParagraphs(lineBetweenParagraphs bool) *TextColumn
- func (textColumn *TextColumn) SetLineSpacing(lineSpacing float32) *TextColumn
- func (textColumn *TextColumn) SetLocation(x, y float32) Drawable
- func (textColumn *TextColumn) SetParagraphSpacing(paragraphSpacing float32) *TextColumn
- func (textColumn *TextColumn) SetTextAlignment(textAlignment alignment.Alignment) *TextColumn
- func (textColumn *TextColumn) SetWidth(w float32) *TextColumn
-
type TextFrame
- func NewTextFrame(f1 *Font, inputList []string) *TextFrame
- func NewTextFrameFromParagraphs(paragraphs []*Paragraph) *TextFrame
- func (tf *TextFrame) DrawOn(page *Page) [2]float32
- func (tf *TextFrame) DrawOnPages(pdf *PDF, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
- func (tf *TextFrame) GetHeight() float32
- func (tf *TextFrame) GetWidth() float32
- func (tf *TextFrame) HasMoreText() bool
- func (tf *TextFrame) SetBorderColor(c int32) *TextFrame
- func (tf *TextFrame) SetBorderColorRGB(borderColor [3]float32) *TextFrame
- func (tf *TextFrame) SetBorderDashPattern(borderPattern string) *TextFrame
- func (tf *TextFrame) SetBorderWidth(borderWidth float32) *TextFrame
- func (tf *TextFrame) SetBorders(border bool) *TextFrame
- func (tf *TextFrame) SetHeight(h float32) *TextFrame
- func (tf *TextFrame) SetLocation(x, y float32) Drawable
- func (tf *TextFrame) SetParagraphGap(paragraphGap float32) *TextFrame
- func (tf *TextFrame) SetWidth(w float32) *TextFrame
-
type TextLine
- func NewEmptyTextLine(font *Font) *TextLine
- func NewTextLine(font *Font, text string) *TextLine
- func (textLine *TextLine) DrawOn(page *Page) [2]float32
- func (textLine *TextLine) GetAltDescription() string
- func (textLine *TextLine) GetAscent() float32
- func (textLine *TextLine) GetDecorationColor() [3]float32
- func (textLine *TextLine) GetDescent() float32
- func (textLine *TextLine) GetDestination() string
- func (textLine *TextLine) GetFallbackFont() *Font
- func (textLine *TextLine) GetFont() *Font
- func (textLine *TextLine) GetFontSize() float32
- func (textLine *TextLine) GetGoToAction() string
- func (textLine *TextLine) GetHeight() float32
- func (textLine *TextLine) GetHighlightColors() map[string]int32
- func (textLine *TextLine) GetLanguage() string
- func (textLine *TextLine) GetLocation() [2]float32
- func (textLine *TextLine) GetScriptPosition() scriptposition.ScriptPosition
- func (textLine *TextLine) GetStrikeout() bool
- func (textLine *TextLine) GetText() string
- func (textLine *TextLine) GetTextColor() [3]float32
- func (textLine *TextLine) GetTextRotation() int
- func (textLine *TextLine) GetURIAction() string
- func (textLine *TextLine) GetURIActualText() string
- func (textLine *TextLine) GetURIAltDescription() string
- func (textLine *TextLine) GetURILanguage() string
- func (textLine *TextLine) GetUnderline() bool
- func (textLine *TextLine) GetVerticalOffset() float32
- func (textLine *TextLine) GetWidth() float32
- func (textLine *TextLine) SetAltDescription(altDescription string) *TextLine
- func (textLine *TextLine) SetDecorationColor(c int32) *TextLine
- func (textLine *TextLine) SetDecorationColorRGB(c [3]float32) *TextLine
- func (textLine *TextLine) SetDestination(name string) *TextLine
- func (textLine *TextLine) SetFallbackFont(fallbackFont *Font) *TextLine
- func (textLine *TextLine) SetFont(font *Font) *TextLine
- func (textLine *TextLine) SetFontSize(fontSize float32) *TextLine
- func (textLine *TextLine) SetGoToAction(key string) *TextLine
- func (textLine *TextLine) SetHighlightColors(colorMap map[string]int32) *TextLine
- func (textLine *TextLine) SetLanguage(language string) *TextLine
- func (textLine *TextLine) SetLocation(x, y float32) Drawable
- func (textLine *TextLine) SetScriptPosition(scriptPosition scriptposition.ScriptPosition) *TextLine
- func (textLine *TextLine) SetStrikeout(strikeout bool) *TextLine
- func (textLine *TextLine) SetStructureType(structureType structelem.StructElem) *TextLine
- func (textLine *TextLine) SetText(text string) *TextLine
- func (textLine *TextLine) SetTextColor(c int32) *TextLine
- func (textLine *TextLine) SetTextColorRGB(c [3]float32) *TextLine
- func (textLine *TextLine) SetTextRotation(degrees int) *TextLine
- func (textLine *TextLine) SetURIAction(uri string) *TextLine
- func (textLine *TextLine) SetURIActualText(uriActualText string) *TextLine
- func (textLine *TextLine) SetURIAltDescription(uriAltDescription string) *TextLine
- func (textLine *TextLine) SetURILanguage(uriLanguage string) *TextLine
- func (textLine *TextLine) SetUnderline(underline bool) *TextLine
- func (textLine *TextLine) SetVerticalOffset(verticalOffset float32) *TextLine
-
type TextParameters
- func NewTextParameters() *TextParameters
- func (tp *TextParameters) SetFont(font *Font) *TextParameters
- func (tp *TextParameters) SetFontSize(fontSize float32) *TextParameters
- func (tp *TextParameters) SetLocation(x, y float32) *TextParameters
- func (tp *TextParameters) SetText(text string) *TextParameters
-
type Title
- func NewTitle(font *Font, text string, x, y float32) *Title
- func (title *Title) DrawOn(page *Page) [2]float32
- func (title *Title) GetPrefix() *TextLine
- func (title *Title) GetTextLine() *TextLine
- func (title *Title) SetLocation(x, y float32) Drawable
- func (title *Title) SetOffset(offset float32) *Title
- func (title *Title) SetPrefix(text string) *Title
Constants
const ( EAN_13 = iota UPC_A CODE_128 CODE_39 GS1_128 ITF_14 )
Constants for the barcode type.
const ( MScaleX = iota // Index of the horizontal scale. MSkewX // Index of the horizontal skew. MTransX // Index of the horizontal translation. MSkewY // Index of the vertical skew. MScaleY // Index of the vertical scale. MTransY // Index of the vertical translation. )
Indices in an Android Matrix value array, for Transform.
Functions
func DrawXMark
func DrawXMark(page *Page, x, y, size float32)
DrawXMark draws a blue X mark of the specified size at x, y.
func GS1DigitalLink
func GS1DigitalLink(domain, data string) string
GS1DigitalLink returns the GS1 Digital Link of the GS1 data, the web address an ordinary QR code carries, at the domain: a brand's own, or GS1's resolver, https://id.gs1.org. The data is written as people read it, each Application Identifier in parentheses and its data after it:
GS1DigitalLink("https://id.gs1.org", "(01)09506000134352(10)ABC123(17)261231")
is "https://id.gs1.org/01/09506000134352/10/ABC123?17=261231". The primary key, such as a GTIN (01), an SSCC (00) or a GLN (414), is first in the path, then its qualifiers in the order of the standard, such as (22), the batch (10) and the serial (21) of a GTIN, and the other fields are in the query, in their order. A value is percent-encoded where a web address needs it. It panics if the domain does not start with https:// or http://; if the data is not GS1, as for Barcode.GS1_128; or if it has no primary key or two, or both (254) and (7040) of a GLN.
func IsArabic
func IsArabic(ch rune) bool
IsArabic reports whether the code point is in the Arabic block (U+0600..U+06FF).
func JoinsBackward
func JoinsBackward(ch rune) bool
JoinsBackward reports whether the Arabic character joins the character before it.
func JoinsForward
func JoinsForward(ch rune) bool
JoinsForward reports whether the Arabic character joins the character that follows it.
func ReorderVisually
func ReorderVisually(str string) string
ReorderVisually reorders the string so that Arabic and Hebrew text flows from right to left while numbers and Latin text flows from left to right. The string is laid out as a right to left line with left to right text nested in it one level deep. Spaces, punctuation and brackets take their direction from the text around them, as in the Unicode Bidirectional Algorithm. Brackets in right to left text are replaced with their mirror images, each after a right-to-left mark (U+200F). Page does not draw the mark, and gives the bracket after it the bracket it stands for as actual text, so the text copied from the page has the brackets that were typed.
Please see Example_04.
func ReorderVisuallyPart
func ReorderVisuallyPart(str string, from, to int) string
ReorderVisuallyPart reorders the string like ReorderVisually, and returns the part of the result that comes from the bytes of the string from the byte index from, inclusive, to the byte index to, exclusive. The letters are shaped in the context of the whole string, so a word that is broken between two lines keeps its joined forms at the break when each line is made this way.
- str: the input string.
- from: the byte index of the first character to return.
- to: the byte index after the last character to return.
Returns the reordered part of the string.
Types
type Arc
type Arc struct { // contains filtered or unexported fields }
Arc is used to create arc objects.
func NewArc
func NewArc() *Arc
NewArc creates an Arc with a solid stroke dash pattern, as the other three ports do in their Arc field initializers.
func (*Arc) DrawOn
func (arc *Arc) DrawOn(page *Page) [2]float32
DrawOn draws this arc on the specified page.
func (*Arc) ScaleBy
func (arc *Arc) ScaleBy(factor float32) *Arc
ScaleBy scales both radii of this arc by the specified factor.
func (*Arc) SetActualText
func (arc *Arc) SetActualText(actualText string) *Arc
SetActualText sets the actual text of this arc, used for accessibility.
func (*Arc) SetAltDescription
func (arc *Arc) SetAltDescription(altDescription string) *Arc
SetAltDescription sets the alternate description of this arc, used for accessibility.
func (*Arc) SetFillColor
func (arc *Arc) SetFillColor(c int32) *Arc
SetFillColor sets the fill color as a 0xRRGGBB value, for example color.Blue. color.Transparent leaves it unchanged.
func (*Arc) SetFillColorRGB
func (arc *Arc) SetFillColorRGB(rgbColor [3]float32) *Arc
SetFillColorRGB sets the fill color from the red, green and blue components, from 0.0 to 1.0.
func (*Arc) SetLocation
func (arc *Arc) SetLocation(cx, cy float32) Drawable
SetLocation sets the center of this arc.
func (*Arc) SetRadius
func (arc *Arc) SetRadius(r float32) *Arc
SetRadius sets both radii of this arc to the same value, making it circular.
func (*Arc) SetRadiusX
func (arc *Arc) SetRadiusX(rx float32) *Arc
SetRadiusX sets the horizontal radius of this arc.
func (*Arc) SetRadiusY
func (arc *Arc) SetRadiusY(ry float32) *Arc
SetRadiusY sets the vertical radius of this arc.
func (*Arc) SetRotation
func (arc *Arc) SetRotation(degrees float32) *Arc
SetRotation rotates this arc by the specified degrees, clockwise, as every rotation in PDFjet turns.
func (*Arc) SetStartAngle
func (arc *Arc) SetStartAngle(angle float32) *Arc
SetStartAngle sets the angle in degrees where this arc starts, clockwise from the 3 o'clock direction, as every angle in PDFjet turns.
func (*Arc) SetStartPointToEndOf
func (arc *Arc) SetStartPointToEndOf(line *Line) *Arc
SetStartPointToEndOf starts this arc at the end point of the specified line.
func (*Arc) SetStrokeColor
func (arc *Arc) SetStrokeColor(c int32) *Arc
SetStrokeColor sets the stroke color as a 0xRRGGBB value, for example color.Blue. color.Transparent leaves it unchanged.
func (*Arc) SetStrokeColorRGB
func (arc *Arc) SetStrokeColorRGB(rgbColor [3]float32) *Arc
SetStrokeColorRGB sets the stroke color from the red, green and blue components, from 0.0 to 1.0.
func (*Arc) SetStrokeDashPattern
func (arc *Arc) SetStrokeDashPattern(strokeDashPattern string) *Arc
SetStrokeDashPattern sets the line dash pattern, for example "[3 5] 6".
func (*Arc) SetStrokeWidth
func (arc *Arc) SetStrokeWidth(width float32) *Arc
SetStrokeWidth sets the width of the arc outline.
func (*Arc) SetSweep
func (arc *Arc) SetSweep(degrees float32) *Arc
SetSweep sets how far this arc sweeps from its start angle, in degrees: clockwise for a positive angle, as every angle in PDFjet turns, and counterclockwise for a negative angle.
type BarChart
type BarChart struct { // contains filtered or unexported fields }
BarChart is a bar chart renderer for PDF pages: one slot per category, the bars of the series grouped inside each slot. See Example_27, of horizontal and vertical bars.
func NewBarChart
func NewBarChart(f1, f2 *Font) *BarChart
NewBarChart creates a bar chart.
- f1: the font for the chart title.
- f2: the font for the axis titles, the labels and the legend.
func (*BarChart) AddSeries
func (chart *BarChart) AddSeries(name string, values []float32) *BarChart
AddSeries adds a series drawn in the next color of the default palette. A value that is NaN or infinite has no bar.
- name: the series name, shown in the legend; empty for none.
- values: one value per category.
func (*BarChart) AddSeriesWithColor
func (chart *BarChart) AddSeriesWithColor(name string, values []float32, color int32) *BarChart
AddSeriesWithColor adds a series drawn in the specified color.
- name: the series name, shown in the legend; empty for none.
- values: one value per category.
- color: the bar color as a 0xRRGGBB value, for example color.Blue.
func (*BarChart) AddSeriesWithColors
func (chart *BarChart) AddSeriesWithColors(name string, values []float32, colors []int32) *BarChart
AddSeriesWithColors adds a series with a color per category, for a chart whose bars each have their own color. A bar past the end of the colors has the next color of the default palette.
- name: the series name, shown in the legend; empty for none.
- values: one value per category.
- colors: one 0xRRGGBB color per category.
func (*BarChart) DrawOn
func (chart *BarChart) DrawOn(page *Page) [2]float32
DrawOn draws this chart on the specified page and returns the bottom right corner coordinates.
func (*BarChart) SetAltDescription
func (chart *BarChart) SetAltDescription(altDescription string) *BarChart
SetAltDescription sets the alternate description of the chart, which a screen reader reads in a PDF/UA document, where the chart is a figure. The default is the title, or "Bar chart" without one. Describe what the chart shows.
func (*BarChart) SetAxisLineWidth
func (chart *BarChart) SetAxisLineWidth(width float32) *BarChart
SetAxisLineWidth sets the width of the axis lines. The default is 0.5; 0 hides them.
func (*BarChart) SetBarGap
func (chart *BarChart) SetBarGap(gap float32) *BarChart
SetBarGap sets the gap between the bars of a group as a fraction of the bar width. The default is 0.0, so the bars of a group touch.
func (*BarChart) SetCategories
func (chart *BarChart) SetCategories(categories ...string) *BarChart
SetCategories sets the categories, one per group of bars, in the order they are drawn: left to right in a vertical chart, top to bottom in a horizontal one.
func (*BarChart) SetChartBorderWidth
func (chart *BarChart) SetChartBorderWidth(width float32) *BarChart
SetChartBorderWidth sets the width of the outer chart border. A width of 0, the default, hides it.
func (*BarChart) SetDrawGridLines
func (chart *BarChart) SetDrawGridLines(drawGridLines bool) *BarChart
SetDrawGridLines sets whether the grid lines of the value axis are drawn.
func (*BarChart) SetDrawLegend
func (chart *BarChart) SetDrawLegend(drawLegend bool) *BarChart
SetDrawLegend sets whether the legend is drawn. The legend lists the series that have a name, under the title.
func (*BarChart) SetDrawValueLabels
func (chart *BarChart) SetDrawValueLabels(drawValueLabels bool) *BarChart
SetDrawValueLabels sets whether the value of each bar is written at its end, or, in a stacked chart, inside each segment that has room for it.
func (*BarChart) SetGridLineColor
func (chart *BarChart) SetGridLineColor(c int32) *BarChart
SetGridLineColor sets the color of the grid lines. The default is black.
- color: the color as a 0xRRGGBB value, for example color.LightGray.
color.Transparent leaves it unchanged.
func (*BarChart) SetGridLineDashPattern
func (chart *BarChart) SetGridLineDashPattern(pattern string) *BarChart
SetGridLineDashPattern sets the dash pattern of the grid lines, for example "[1 1] 0".
func (*BarChart) SetGridLineWidth
func (chart *BarChart) SetGridLineWidth(width float32) *BarChart
SetGridLineWidth sets the width of the grid lines. A width of 0 draws the thinnest line a viewer shows; SetDrawGridLines(false) hides them.
func (*BarChart) SetGroupGap
func (chart *BarChart) SetGroupGap(gap float32) *BarChart
SetGroupGap sets the gap between the groups of bars as a fraction of the category slot, from 0.0 to below 1.0. The default is 0.3.
func (*BarChart) SetGroupingUsed
func (chart *BarChart) SetGroupingUsed(groupingUsed bool) *BarChart
SetGroupingUsed sets whether the labels group the digits in thousands with a comma, as in 6,650. The default is false.
func (*BarChart) SetHorizontal
func (chart *BarChart) SetHorizontal(horizontal bool) *BarChart
SetHorizontal sets whether the bars are horizontal. The default is vertical bars.
func (*BarChart) SetInnerBorderWidth
func (chart *BarChart) SetInnerBorderWidth(width float32) *BarChart
SetInnerBorderWidth sets the width of the plot area border. A width of 0, the default, hides it.
func (*BarChart) SetLocation
func (chart *BarChart) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this chart. It returns the chart as a Drawable, so in a chain of setter calls SetLocation goes last, right before DrawOn.
func (*BarChart) SetMaximumFractionDigits
func (chart *BarChart) SetMaximumFractionDigits(maxFractionDigits int) *BarChart
SetMaximumFractionDigits sets the maximum number of decimal places in the value labels. The default is 2.
func (*BarChart) SetMinimumFractionDigits
func (chart *BarChart) SetMinimumFractionDigits(minFractionDigits int) *BarChart
SetMinimumFractionDigits sets the minimum number of decimal places in the value labels. The axis labels have at least the decimal places of the axis step. The default is 0.
func (*BarChart) SetSize
func (chart *BarChart) SetSize(w, h float32) *BarChart
SetSize sets the size of this chart.
func (*BarChart) SetStacked
func (chart *BarChart) SetStacked(stacked bool) *BarChart
SetStacked sets whether the series are stacked: one bar per category, with the value of each series as a segment of it. The values above 0 stack up from 0 and the values below 0 stack down. The default is grouped bars.
func (*BarChart) SetSubtitle
func (chart *BarChart) SetSubtitle(subtitle string) *BarChart
SetSubtitle sets the subtitle, written in gray under the title in the second font.
func (*BarChart) SetTitle
func (chart *BarChart) SetTitle(title string) *BarChart
SetTitle sets the chart title.
func (*BarChart) SetValueAxisMinMax
func (chart *BarChart) SetValueAxisMinMax(min, max float32, gridLines int) *BarChart
SetValueAxisMinMax sets the range and the number of grid lines of the value axis. Without it the range is computed from the data and always includes 0.
- min: the value at the start of the axis.
- max: the value at the end of the axis.
- gridLines: the number of grid lines, at least 1.
func (*BarChart) SetValueLabelsInside
func (chart *BarChart) SetValueLabelsInside(valueLabelsInside bool) *BarChart
SetValueLabelsInside sets whether the value labels are written inside the bars, in white at the end of each bar, instead of next to the bar ends. A bar too short for its label gets it next to its end. The default is false.
func (*BarChart) SetXAxisTitle
func (chart *BarChart) SetXAxisTitle(title string) *BarChart
SetXAxisTitle sets the X axis title.
func (*BarChart) SetYAxisTitle
func (chart *BarChart) SetYAxisTitle(title string) *BarChart
SetYAxisTitle sets the Y axis title.
type Barcode
type Barcode struct { // contains filtered or unexported fields }
Barcode describes one dimensional barcodes - EAN-13, UPC-A, Code 39, Code 128, GS1-128 and ITF-14. The text of an ITF-14 barcode is the 13 digits of a GTIN without its check digit, which is added, as for UPC-A and EAN-13. The text of a GS1-128 barcode is GS1 data written as people read it, each Application Identifier in parentheses and its data after it, such as "(01)09506000134352(10)ABC123", and is drawn so under its bars. Please see Example_36.
func NewBarcode
func NewBarcode(barcodeType int, text string) *Barcode
NewBarcode constructs barcode objects.
- barcodeType: the type of the barcode.
- text: the content string of the barcode.
func (*Barcode) DrawOn
func (barcode *Barcode) DrawOn(page *Page) [2]float32
DrawOn draws this barcode on the specified page.
func (*Barcode) GetHeight
func (barcode *Barcode) GetHeight() float32
GetHeight returns the height of this barcode as it is drawn: from its location to the bottom of the bars, or of the text under them, in the direction the barcode is drawn, so a barcode drawn top to bottom or bottom to top is as tall as it is long.
func (*Barcode) SetAltDescription
func (barcode *Barcode) SetAltDescription(altDescription string) *Barcode
SetAltDescription sets what the barcode says, such as its digits or the web address of a QR code, for a screen reader: a tagged document, PDF/UA or a PDF/A of level A, then has the barcode as one figure of that description. Without one, its bars are decoration, which a screen reader skips, and the text under them, if any, is read as text.
func (*Barcode) SetBarHeightFactor
func (barcode *Barcode) SetBarHeightFactor(barHeightFactor float32) *Barcode
SetBarHeightFactor sets the bar height factor. The height of the bars is the moduleLength * barHeightFactor The default value is 50.0f
func (*Barcode) SetDirection
func (barcode *Barcode) SetDirection(direction direction.Direction) *Barcode
SetDirection sets the direction in which this barcode is drawn.
- direction: the specified direction.
func (*Barcode) SetFont
func (barcode *Barcode) SetFont(font *Font) *Barcode
SetFont sets the font to be used with this barcode.
- font: the specified font.
func (*Barcode) SetLocation
func (barcode *Barcode) SetLocation(x1, y1 float32) Drawable
SetLocation sets the location where this barcode will be drawn on the page.
- x1: the x coordinate of the top left corner of the barcode.
- y1: the y coordinate of the top left corner of the barcode.
func (*Barcode) SetModuleLength
func (barcode *Barcode) SetModuleLength(moduleLength float32) *Barcode
SetModuleLength sets the module length of this barcode. The default value is 0.75
type BaseAnnotation
type BaseAnnotation struct { // contains filtered or unexported fields }
BaseAnnotation represents a base annotation in a PDF document.
func (*BaseAnnotation) DrawOn
func (b *BaseAnnotation) DrawOn(page *Page) [2]float32
DrawOn draws the annotation on the specified page.
func (*BaseAnnotation) SetContents
func (b *BaseAnnotation) SetContents(contents string) *BaseAnnotation
SetContents sets the contents of the annotation.
func (*BaseAnnotation) SetFillColor
func (b *BaseAnnotation) SetFillColor(c int32) *BaseAnnotation
SetFillColor sets the fill color as a 0xRRGGBB value, for example color.Blue. color.Transparent leaves it unchanged.
func (*BaseAnnotation) SetFillColorRGB
func (b *BaseAnnotation) SetFillColorRGB(fillColor [3]float32) *BaseAnnotation
SetFillColorRGB sets the fill color from the red, green and blue components, from 0.0 to 1.0.
func (*BaseAnnotation) SetLocation
func (b *BaseAnnotation) SetLocation(x, y float32) Drawable
SetLocation sets the first point of the annotation.
func (*BaseAnnotation) SetOpacity
func (b *BaseAnnotation) SetOpacity(opacity float32) *BaseAnnotation
SetOpacity sets the opacity, from 0.0 (invisible) to 1.0 (opaque, the default). PDF/A-1 has no transparency, so a document of PDF_A_1A or PDF_A_1B ignores the opacity and draws the annotation opaque.
func (*BaseAnnotation) SetSize
func (b *BaseAnnotation) SetSize(w, h float32) *BaseAnnotation
SetSize sets the size of the annotation: its second point is w to the right of its first point and h below it, whether SetLocation is called before or after.
func (*BaseAnnotation) SetTitle
func (b *BaseAnnotation) SetTitle(title string) *BaseAnnotation
SetTitle sets the title of the annotation.
type BaselineDrawable
type BaselineDrawable interface { Drawable // GetAscent returns how far above its baseline this drawable reaches, in points. GetAscent() float32 // GetDescent returns how far below its baseline this drawable reaches, in points. GetDescent() float32 // GetWidth returns the width of this drawable, in points. GetWidth() float32 }
BaselineDrawable is the interface of a drawable whose location is the baseline of its text, not the top left corner of a box: a line of text, such as TextLine and CompositeTextLine.
A Cell draws such a drawable where it draws its own text, on the baseline that its vertical alignment asks for, and makes room for the ascent and the descent below. A drawable that is not one of these is placed by its top left corner, at the padding of the cell.
type BigTable
type BigTable struct { // contains filtered or unexported fields }
BigTable is a table for large amounts of data, read row by row from a delimited text file or from an iterator. Each page is written as soon as it is full, so the memory stays flat however many rows there are. A PDF/UA document holds no more than that either: the table is tagged as a table, and the structure elements of a page are written with it. What is left is one cross-reference entry for each of them, which every object of a PDF has.
func NewBigTable
func NewBigTable(pdf *PDF, f1 *Font, f2 *Font, pageSize pagesize.PageSize) *BigTable
NewBigTable creates a new BigTable instance
func (*BigTable) Complete
func (bt *BigTable) Complete() error
Complete draws the rows, then the vertical lines, with the footer on every page. The pages are added to the PDF as they are drawn, so the document does not hold them all. It returns an error if the data file cannot be read. A table without data draws nothing.
func (*BigTable) GetPages
func (bt *BigTable) GetPages() []*Page
GetPages returns the pages, which Complete has already added to the PDF.
func (*BigTable) SetBorderColor
func (bt *BigTable) SetBorderColor(c int32) *BigTable
SetBorderColor sets the color of the lines between the rows and the columns and around the table, as a 0xRRGGBB value. color.Transparent leaves the lines out.
func (*BigTable) SetBorderColorRGB
func (bt *BigTable) SetBorderColorRGB(rgb [3]float32) *BigTable
SetBorderColorRGB sets the color of the lines between the rows and the columns and around the table from its red, green and blue values from 0 to 1.
func (*BigTable) SetBottomMargin
func (bt *BigTable) SetBottomMargin(bottomMargin float32) *BigTable
SetBottomMargin sets the bottom margin
func (*BigTable) SetColumnWidthsInPercent
func (bt *BigTable) SetColumnWidthsInPercent(percents ...float32) *BigTable
SetColumnWidthsInPercent gives the columns, in the order SetColumns draws them, their percentages of the width of the table, the width of the page less the margin of SetLocation on each side, as Table's SetColumnWidthsInPercent does; percentages that do not add up to 100 are shares of it. A field wider than its column is cut to fit it, its text ending in " ...". Without them each column is as wide as its widest field. Call it after SetColumns or SetNumberOfColumns: percentages that are not one for each column, or one that is negative or not a number, are recorded on the PDF as misuse, and the widths are left as they were.
func (*BigTable) SetColumns
func (bt *BigTable) SetColumns(columns ...int) *BigTable
SetColumns sets the fields of every row that the table draws, by their index from 0, in the order they are drawn, so SetColumns(3, 0, 11) draws the fourth field, then the first, then the twelfth. The indexes pick the header fields the same way. A row without a field for every index is skipped. Call it before SetTableData; SetTextAlignment counts the columns as they are drawn. A negative index is recorded on the PDF as misuse, and the columns are left as they were.
func (*BigTable) SetFirstPage
func (bt *BigTable) SetFirstPage(page *Page, y float32) *BigTable
SetFirstPage starts the table on a page of the PDF that has other content above it, such as a heading, at y on that page. The next pages are new, and the table starts on them at the y of its location. The page is one that NewPage has added to the PDF, and nothing is drawn on it after the table. When the header and the first row do not fit on the page above its bottom margin, the table starts on a new page instead, and draws nothing on it.
func (*BigTable) SetFooter
func (bt *BigTable) SetFooter(text string, font *Font) *BigTable
SetFooter sets the footer drawn at the bottom of every page, centered. In the text, {page} stands for the number of the page and {pages} for the number of pages. The footer is "Page {page} of {pages}" in the header font by default. An empty text leaves the footer out, and a nil font is the header font.
func (*BigTable) SetLocation
func (bt *BigTable) SetLocation(x, y float32) *BigTable
SetLocation sets the table location
func (*BigTable) SetNumberOfColumns
func (bt *BigTable) SetNumberOfColumns(numberOfColumns int) *BigTable
SetNumberOfColumns sets the number of columns in this table: the first fields of every row, in their order. It is the same as SetColumns(0, 1, ... numberOfColumns - 1).
func (*BigTable) SetPadding
func (bt *BigTable) SetPadding(padding float32) *BigTable
SetPadding sets the space between the text of a column and the lines on its left and right. It is 2 points by default. A negative padding is recorded on the PDF as misuse, and the padding is left as it was.
func (*BigTable) SetShadingColor
func (bt *BigTable) SetShadingColor(c int32) *BigTable
SetShadingColor sets the color of every other row, starting with the header, as a 0xRRGGBB value. color.Transparent turns the shading off.
func (*BigTable) SetShadingColorRGB
func (bt *BigTable) SetShadingColorRGB(rgb [3]float32) *BigTable
SetShadingColorRGB sets the color of every other row, starting with the header, from its red, green and blue values from 0 to 1.
func (*BigTable) SetTableData
func (bt *BigTable) SetTableData(fileName, delimiter string) (*BigTable, error)
SetTableData sets the table data from the file, which is read as UTF-8. Its first line with a field for every column is the header, and the lines after it are the rows. A quoted field is read as RFC 4180 reads it, so a delimiter inside one is text, and a line break inside one goes on to the next line of the file and is drawn as a space. It returns the table, or an error if the file cannot be read.
func (*BigTable) SetTableRows
func (bt *BigTable) SetTableRows(header []string, rows iter.Seq[[]string]) *BigTable
SetTableRows sets the table data from rows that are not in a file: the results of a query, or a slice of objects. The rows are iterated twice, once here to measure the columns and once by Complete to draw them, and neither keeps them, so an iterator that runs the query again, or maps the objects to fields as it goes, keeps the memory flat. A row without a field for every column is skipped, as a short line of a file is, and a line break in a field is drawn as a space. A header without a field for every column is recorded on the PDF as misuse, and the table is left without data.
func (*BigTable) SetTextAlignment
func (bt *BigTable) SetTextAlignment(column int, alignment alignment.Alignment) *BigTable
SetTextAlignment sets the text alignment of the column, which is one of the columns of the table. Call it after SetTableData, which makes the columns: a column that the table does not have is recorded on the PDF as misuse, and the alignment is left as it was.
type Bookmark
type Bookmark struct { // contains filtered or unexported fields }
Bookmark please see Example_41
func NewBookmark
func NewBookmark(pdf *PDF) *Bookmark
NewBookmark creates new bookmark.
func NewBookmarkAt
func NewBookmarkAt(page *Page, y float32, key, title string) *Bookmark
NewBookmarkAt creates new bookmark at the specified y coordinate.
func (*Bookmark) AddBookmark
func (bookmark *Bookmark) AddBookmark(page *Page, title *Title) *Bookmark
AddBookmark adds bookmark to the page.
func (*Bookmark) AutoNumber
func (bookmark *Bookmark) AutoNumber(textLine *TextLine) *Bookmark
AutoNumber auto numbers the bookmark.
func (*Bookmark) GetDestinationName
func (bookmark *Bookmark) GetDestinationName() string
GetDestinationName returns the name of the destination of this bookmark.
func (*Bookmark) GetParent
func (bookmark *Bookmark) GetParent() *Bookmark
GetParent returns the parent bookmark.
func (*Bookmark) GetTitle
func (bookmark *Bookmark) GetTitle() string
GetTitle returns the title of the bookmark.
type CalendarMonth
type CalendarMonth struct { // contains filtered or unexported fields }
CalendarMonth draws a calendar for one month: the names of the days in the header font, a line under them, and the dates in the body font, each in a blue circle, in up to six weeks. The week starts on Sunday unless SetFirstDayOfWeek sets another day.
func NewCalendarMonth
func NewCalendarMonth(f1, f2 *Font, year, month int) *CalendarMonth
NewCalendarMonth creates a calendar for the specified month.
- f1: the header font.
- f2: the body font.
- year: the year.
- month: the month, from 1 to 12.
func (*CalendarMonth) DrawOn
func (calendarMonth *CalendarMonth) DrawOn(page *Page) [2]float32
DrawOn draws the calendar on the page and returns the x and y coordinates of its bottom right corner. The line and the circles are drawn as an artifact, and the pen of the page is left as it was.
func (*CalendarMonth) SetBodyFont
func (calendarMonth *CalendarMonth) SetBodyFont(font *Font) *CalendarMonth
SetBodyFont sets the font of the calendar body.
func (*CalendarMonth) SetCellHeight
func (calendarMonth *CalendarMonth) SetCellHeight(height float32) *CalendarMonth
SetCellHeight sets the height of the day cells.
func (*CalendarMonth) SetCellWidth
func (calendarMonth *CalendarMonth) SetCellWidth(width float32) *CalendarMonth
SetCellWidth sets the width of the day cells.
func (*CalendarMonth) SetFirstDayOfWeek
func (calendarMonth *CalendarMonth) SetFirstDayOfWeek(day time.Weekday) *CalendarMonth
SetFirstDayOfWeek sets the day the weeks start on, in the first column. The default is Sunday; many countries start the week on Monday.
func (*CalendarMonth) SetHeadFont
func (calendarMonth *CalendarMonth) SetHeadFont(font *Font) *CalendarMonth
SetHeadFont sets the font of the calendar header.
func (*CalendarMonth) SetLocation
func (calendarMonth *CalendarMonth) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of the calendar.
type Cell
type Cell struct { // contains filtered or unexported fields }
Cell is used to create table cell objects. See the Table class for more information.
The four paddings of a cell, top, bottom, left and right, are kept in one 32-bit integer, a byte each, 4 bytes for every cell where four floats would take 16:
bits 31-24 23-16 15-8 7-0 byte right left bottom top
A byte holds its padding in quarters of a point, 0 to 255, so a padding is 0 to 63.75 points in steps of 0.25, more than the text of a cell needs. A padding that is set is kept to the nearest quarter, a half up: 2.1 is kept as 2.0 and 2.13 as 2.25. One below 0, or not a number, is 0, and one above 63.75 is 63.75. A cell has a padding of 2 points on every side until it is set; SetPadding sets the four at once, and SetTopPadding and the others one each. A top of 2, a bottom of 3.5, a left of 1.25 and a right of 0 are the bytes 8, 14, 5 and 0, the integer 0x00050E08.
The fields are in the order of their size, so that a cell takes no bytes for the padding between them that it does not have to.
func NewCell
func NewCell(font *Font, text string) *Cell
NewCell creates a cell object and sets the font and the cell text. The font is also the fallback font until SetFallbackFont changes it.
- font: the font.
- text: the text.
func NewEmptyCell
func NewEmptyCell(font *Font) *Cell
NewEmptyCell creates a cell without text, like Cell(font) in the other ports. It is 0 tall until it gets text, an image or a barcode.
func (*Cell) GetBackgroundColor
func (cell *Cell) GetBackgroundColor() *[3]float32
GetBackgroundColor returns a copy of the background color of this cell, or nil if it has none.
func (*Cell) GetBarcode
func (cell *Cell) GetBarcode() *Barcode
GetBarcode returns the barcode drawn in this cell, or nil when the cell holds none.
func (*Cell) GetBorder
func (cell *Cell) GetBorder(b uint32) bool
GetBorder returns true if any of the specified borders is drawn.
- b: the borders, for example border.Top.
func (*Cell) GetBorderColor
func (cell *Cell) GetBorderColor() *[3]float32
GetBorderColor returns a copy of the color of the cell borders, or nil if none was set.
func (*Cell) GetBorderWidth
func (cell *Cell) GetBorderWidth() float32
GetBorderWidth returns the width of the cell borders. Returns the width of the cell borders.
func (*Cell) GetBottomPadding
func (cell *Cell) GetBottomPadding() float32
GetBottomPadding returns the bottom padding of this cell.
func (*Cell) GetColSpan
func (cell *Cell) GetColSpan() int
GetColSpan returns the number of columns this cell spans. Returns the column span value.
func (*Cell) GetCompositeTextLine
func (cell *Cell) GetCompositeTextLine() *CompositeTextLine
GetCompositeTextLine returns the composite text line that this cell holds.
func (*Cell) GetDrawable
func (cell *Cell) GetDrawable() Drawable
GetDrawable returns the drawable inside this cell, or nil.
func (*Cell) GetFallbackFont
func (cell *Cell) GetFallbackFont() *Font
GetFallbackFont returns the fallback font used by this cell. Returns the fallback font.
func (*Cell) GetFont
func (cell *Cell) GetFont() *Font
GetFont returns the font used by this cell. Returns the font.
func (*Cell) GetHeight
func (cell *Cell) GetHeight(width float32) float32
GetHeight returns the cell height. Returns the cell height.
func (*Cell) GetImage
func (cell *Cell) GetImage() *Image
GetImage returns the cell image, or nil when the cell holds none.
func (*Cell) GetLeftPadding
func (cell *Cell) GetLeftPadding() float32
GetLeftPadding returns the left padding of this cell.
func (*Cell) GetMarker
func (cell *Cell) GetMarker() *Point
GetMarker returns the marker drawn in this cell.
func (*Cell) GetRightPadding
func (cell *Cell) GetRightPadding() float32
GetRightPadding returns the right padding of this cell.
func (*Cell) GetRowSpan
func (cell *Cell) GetRowSpan() int
GetRowSpan returns the number of rows this cell spans.
func (*Cell) GetStrikeout
func (cell *Cell) GetStrikeout() bool
GetStrikeout returns the strikeout text parameter. Returns the strikeout text parameter.
func (*Cell) GetText
func (cell *Cell) GetText() string
GetText returns the cell text.
func (*Cell) GetTextAlignment
func (cell *Cell) GetTextAlignment() alignment.Alignment
GetTextAlignment returns the text alignment. Returns the text horizontal alignment code.
func (*Cell) GetTextBlock
func (cell *Cell) GetTextBlock() *TextBlock
GetTextBlock returns the text block drawn in this cell, or nil when it holds none.
func (*Cell) GetTextColor
func (cell *Cell) GetTextColor() [3]float32
GetTextColor returns the text color.
func (*Cell) GetTextColumn
func (cell *Cell) GetTextColumn() *TextColumn
GetTextColumn returns the text column that this cell holds, or nil when it holds none.
func (*Cell) GetTopPadding
func (cell *Cell) GetTopPadding() float32
GetTopPadding returns the top padding of this cell.
func (*Cell) GetUnderline
func (cell *Cell) GetUnderline() bool
GetUnderline returns the underline text parameter. Returns the underline text parameter.
func (*Cell) GetVerticalAlignment
func (cell *Cell) GetVerticalAlignment() alignment.Alignment
GetVerticalAlignment returns the cell text vertical alignment. Returns the vertical alignment code.
func (*Cell) GetWidth
func (cell *Cell) GetWidth() float32
GetWidth returns the cell width. Returns the cell width.
func (*Cell) SetBackgroundColor
func (cell *Cell) SetBackgroundColor(c int32) *Cell
SetBackgroundColor sets the background color of this cell as a 0xRRGGBB value. color.Transparent removes the background.
func (*Cell) SetBackgroundColorRGB
func (cell *Cell) SetBackgroundColorRGB(rgbColor [3]float32) *Cell
SetBackgroundColorRGB sets the background color from red, green and blue values. The cell keeps each component to the nearest of 256 steps.
func (*Cell) SetBarcode
func (cell *Cell) SetBarcode(barcode *Barcode) *Cell
SetBarcode sets the barcode inside this cell and clears the cell text.
func (*Cell) SetBorder
func (cell *Cell) SetBorder(b uint32, visible bool) *Cell
SetBorder sets whether the specified borders are drawn.
- b: the borders, for example border.Top | border.Bottom.
- visible: true to draw the borders.
func (*Cell) SetBorderColor
func (cell *Cell) SetBorderColor(c int32) *Cell
SetBorderColor sets the color of the cell borders. color.Transparent draws them black, as a cell does when no color is set.
- c: the color specified as 0xRRGGBB integer.
func (*Cell) SetBorderColorRGB
func (cell *Cell) SetBorderColorRGB(rgbColor [3]float32) *Cell
SetBorderColorRGB sets the color of the cell borders from red, green and blue values. The cell keeps each component to the nearest of 256 steps.
func (*Cell) SetBorderWidth
func (cell *Cell) SetBorderWidth(borderWidth float32) *Cell
SetBorderWidth sets the width of the cell borders.
- borderWidth: the width of the cell borders.
Returns this Cell object.
func (*Cell) SetBorders
func (cell *Cell) SetBorders(visible bool) *Cell
SetBorders sets whether all four borders of this cell are drawn.
func (*Cell) SetBottomPadding
func (cell *Cell) SetBottomPadding(padding float32) *Cell
SetBottomPadding sets the bottom padding of this cell.
- padding: the bottom padding.
func (*Cell) SetColSpan
func (cell *Cell) SetColSpan(colspan int) *Cell
SetColSpan sets the number of columns this cell spans, counted from this one. A column span of less than 1 is 1, and one past the end of its row spans the columns the row has left.
- colspan: the specified column span value, from 1.
func (*Cell) SetCompositeTextLine
func (cell *Cell) SetCompositeTextLine(compositeTextLine *CompositeTextLine) *Cell
SetCompositeTextLine sets the composite text line that this cell holds.
func (*Cell) SetDrawable
func (cell *Cell) SetDrawable(drawable Drawable) *Cell
SetDrawable sets the drawable inside this cell and clears the cell text. A cell holds one drawable, so this replaces the image, barcode, text block or text column set before. The drawable is placed by its top left corner, at the padding, and aligned in the cell as the text is; it is measured with DrawOn(nil). A text block gets the width of the cell.
- drawable: the drawable, for example a QRCode, an SVGImage or a Table.
func (*Cell) SetFallbackFont
func (cell *Cell) SetFallbackFont(fallbackFont *Font) *Cell
SetFallbackFont sets the fallback font for this cell.
- fallbackFont: the fallback font.
func (*Cell) SetFont
func (cell *Cell) SetFont(font *Font) *Cell
SetFont sets the font for this cell. The font size does not change; set it with SetFontSize. The fallback font changes with the font, unless a different fallback font was set.
- font: the font.
func (*Cell) SetFontSize
func (cell *Cell) SetFontSize(fontSize float32) *Cell
SetFontSize sets the font size of the cell text.
func (*Cell) SetImage
func (cell *Cell) SetImage(image *Image) *Cell
SetImage sets the image inside this cell and clears the cell text.
func (*Cell) SetLeftPadding
func (cell *Cell) SetLeftPadding(padding float32) *Cell
SetLeftPadding sets the left padding of this cell.
- padding: the left padding.
func (*Cell) SetMarker
func (cell *Cell) SetMarker(point *Point, align alignment.Alignment) *Cell
SetMarker sets the marker drawn in this cell: a Point, placed at the left or the right of the cell and centered vertically. See the Point class and Example_26 for more information.
- point: the point.
- align: alignment.Left or alignment.Right.
func (*Cell) SetPadding
func (cell *Cell) SetPadding(padding float32) *Cell
SetPadding sets the top, bottom, left and right paddings of this cell.
- padding: the right padding.
func (*Cell) SetRightPadding
func (cell *Cell) SetRightPadding(padding float32) *Cell
SetRightPadding sets the right padding of this cell.
- padding: the right padding.
func (*Cell) SetRowSpan
func (cell *Cell) SetRowSpan(rowspan int) *Cell
SetRowSpan sets the number of rows this cell spans, counted from this one, so that a row span of 2 covers this row and the one under it. The cells the span covers are not drawn: this cell draws its text, its background and its borders once over all of them, and a page break moves the whole of it to the next page. The table keeps its shape, so the rows under this one still hold a cell at this column, which is left empty. A row span of 1, the default, spans nothing. Please see Example_21.
- rowspan: the number of rows, from 1.
func (*Cell) SetStrikeout
func (cell *Cell) SetStrikeout(strikeout bool) *Cell
SetStrikeout sets the strikeout text parameter.
- strikeout: the strikeout text parameter.
func (*Cell) SetText
func (cell *Cell) SetText(text string) *Cell
SetText sets the cell text.
- text: the cell text.
func (*Cell) SetTextAlignment
func (cell *Cell) SetTextAlignment(textAlignment alignment.Alignment) *Cell
SetTextAlignment sets the cell text alignment.
- alignment: the alignment code.
Supported values: alignment.Left, alignment.Right, alignment.Center and alignment.Justify, which draws the single line of cell text left aligned.
func (*Cell) SetTextBlock
func (cell *Cell) SetTextBlock(textBlock *TextBlock) *Cell
SetTextBlock sets the text block drawn in this cell and clears the cell text.
func (*Cell) SetTextColor
func (cell *Cell) SetTextColor(c int32) *Cell
SetTextColor sets the text color. color.Transparent leaves the text color unchanged.
- c: the color specified as 0xRRGGBB integer.
func (*Cell) SetTextColorRGB
func (cell *Cell) SetTextColorRGB(textColor [3]float32) *Cell
SetTextColorRGB sets the text color from red, green and blue values. The cell keeps each component to the nearest of 256 steps.
func (*Cell) SetTextColumn
func (cell *Cell) SetTextColumn(textColumn *TextColumn) *Cell
SetTextColumn sets the text column drawn in this cell, widens the cell to fit it and clears the cell text.
func (*Cell) SetTopPadding
func (cell *Cell) SetTopPadding(padding float32) *Cell
SetTopPadding sets the top padding of this cell.
- padding: the top padding.
func (*Cell) SetURIAction
func (cell *Cell) SetURIAction(uri string) *Cell
SetURIAction sets the URI action.
func (*Cell) SetUnderline
func (cell *Cell) SetUnderline(underline bool) *Cell
SetUnderline sets the underline text parameter. If the value of the underline variable is 'true' - the text is underlined.
- underline: the underline text parameter.
func (*Cell) SetVerticalAlignment
func (cell *Cell) SetVerticalAlignment(valign alignment.Alignment) *Cell
SetVerticalAlignment sets the cell text vertical alignment.
- alignment: the alignment code.
Supported values: alignment.Top, alignment.Center and alignment.Bottom.
func (*Cell) SetWidth
func (cell *Cell) SetWidth(width float32) *Cell
SetWidth sets the width of this cell.
- width: the specified width.
type Chart
type Chart struct { // contains filtered or unexported fields }
Chart is used to create XY chart objects and draw them on a page. Please see Example_26.
func NewChart
func NewChart(f1, f2 *Font) *Chart
NewChart creates XY chart objects.
- f1: the font used for the chart title.
- f2: the font used for the X and Y axis titles.
func (*Chart) AddSeries
func (chart *Chart) AddSeries(name string) *Series
AddSeries adds a series and returns it, to add its points and set its line and marker. A series without a stroke color has the next color of the palette. The legend lists the series that have a name.
- name: the series name, shown in the legend; empty for none.
func (*Chart) DrawOn
func (chart *Chart) DrawOn(page *Page) [2]float32
DrawOn draws chart on the specified page.
- page: the page to draw chart on.
func (*Chart) SetAltDescription
func (chart *Chart) SetAltDescription(altDescription string) *Chart
SetAltDescription sets the alternate description of the chart, which a screen reader reads in a PDF/UA document, where the chart is a figure. The default is the title, or "Chart" without one. Describe what the chart shows.
func (*Chart) SetAxisLineWidth
func (chart *Chart) SetAxisLineWidth(width float32) *Chart
SetAxisLineWidth sets the width of the axis lines, along the left and the bottom sides of the plot area. The default is 0.5; 0 hides them.
func (*Chart) SetChartBorderWidth
func (chart *Chart) SetChartBorderWidth(width float32) *Chart
SetChartBorderWidth sets the width of the outer chart border. A width of 0, the default, hides it.
func (*Chart) SetDrawHorizontalGridLines
func (chart *Chart) SetDrawHorizontalGridLines(drawHorizontalGridLines bool) *Chart
SetDrawHorizontalGridLines sets whether to draw horizontal grid lines on the chart.
func (*Chart) SetDrawLegend
func (chart *Chart) SetDrawLegend(drawLegend bool) *Chart
SetDrawLegend sets whether the legend is drawn. The legend lists the series that have a name, under the title, each with its line or its marker.
func (*Chart) SetDrawVerticalGridLines
func (chart *Chart) SetDrawVerticalGridLines(drawVerticalGridLines bool) *Chart
SetDrawVerticalGridLines sets whether to draw vertical grid lines on the chart.
func (*Chart) SetDrawXAxisLabels
func (chart *Chart) SetDrawXAxisLabels(drawXAxisLabels bool) *Chart
SetDrawXAxisLabels sets whether to draw X axis labels on the chart.
func (*Chart) SetDrawYAxisLabels
func (chart *Chart) SetDrawYAxisLabels(drawYAxisLabels bool) *Chart
SetDrawYAxisLabels sets whether to draw Y axis labels on the chart.
func (*Chart) SetGridLineColor
func (chart *Chart) SetGridLineColor(c int32) *Chart
SetGridLineColor sets the color of the grid lines as a 0xRRGGBB value. The default is black. color.Transparent leaves it unchanged.
func (*Chart) SetHorizontalGridLineDashPattern
func (chart *Chart) SetHorizontalGridLineDashPattern(pattern string) *Chart
SetHorizontalGridLineDashPattern sets the horizontal grid line dash pattern, e.g. "[1 1] 0".
func (*Chart) SetHorizontalGridLineWidth
func (chart *Chart) SetHorizontalGridLineWidth(width float32) *Chart
SetHorizontalGridLineWidth sets the width of the horizontal grid lines.
func (*Chart) SetInnerBorderWidth
func (chart *Chart) SetInnerBorderWidth(width float32) *Chart
SetInnerBorderWidth sets the width of the plot area border. A width of 0, the default, hides it.
func (*Chart) SetLocation
func (chart *Chart) SetLocation(x, y float32) Drawable
SetLocation sets the location of chart on the page.
func (*Chart) SetMaximumFractionDigits
func (chart *Chart) SetMaximumFractionDigits(maxFractionDigits int) *Chart
SetMaximumFractionDigits sets the maximum number of decimal places in the axis labels. The default is 2.
func (*Chart) SetMinimumFractionDigits
func (chart *Chart) SetMinimumFractionDigits(minFractionDigits int) *Chart
SetMinimumFractionDigits sets the minimum number of decimal places in the axis labels. The labels of an axis have at least the decimal places of its step, so an axis with a whole number step has whole number labels. The default is 0.
func (*Chart) SetSize
func (chart *Chart) SetSize(w, h float32) *Chart
SetSize sets the size of chart.
func (*Chart) SetSubtitle
func (chart *Chart) SetSubtitle(subtitle string) *Chart
SetSubtitle sets the subtitle, written in gray under the title in the second font.
func (*Chart) SetTitle
func (chart *Chart) SetTitle(title string) *Chart
SetTitle sets the title of the chart.
func (*Chart) SetVerticalGridLineDashPattern
func (chart *Chart) SetVerticalGridLineDashPattern(pattern string) *Chart
SetVerticalGridLineDashPattern sets the vertical grid line dash pattern, e.g. "[1 1] 0".
func (*Chart) SetVerticalGridLineWidth
func (chart *Chart) SetVerticalGridLineWidth(width float32) *Chart
SetVerticalGridLineWidth sets the width of the vertical grid lines.
func (*Chart) SetXAxisMinMax
func (chart *Chart) SetXAxisMinMax(xMin, xMax float32, xAxisGridLines int) *Chart
SetXAxisMinMax sets the X axis range and its number of grid lines. With 0 grid lines, the default, the range is the range of the data rounded to "nice" values, and xMin and xMax are not used; a negative number is taken as 0.
func (*Chart) SetXAxisTitle
func (chart *Chart) SetXAxisTitle(title string) *Chart
SetXAxisTitle sets the title for the X axis.
func (*Chart) SetYAxisMinMax
func (chart *Chart) SetYAxisMinMax(yMin, yMax float32, yAxisGridLines int) *Chart
SetYAxisMinMax sets the Y axis range and its number of grid lines. With 0 grid lines, the default, the range is the range of the data rounded to "nice" values, and yMin and yMax are not used; a negative number is taken as 0.
func (*Chart) SetYAxisTitle
func (chart *Chart) SetYAxisTitle(title string) *Chart
SetYAxisTitle sets the title for the Y axis.
type CheckBox
type CheckBox struct { // contains filtered or unexported fields }
CheckBox creates a CheckBox, which can be set checked or unchecked. By default, the checkbox is unchecked.
func NewCheckBox
func NewCheckBox(font *Font, label string) *CheckBox
NewCheckBox creates a CheckBox with black check mark.
func (*CheckBox) Check
func (checkBox *CheckBox) Check(checkMark mark.Mark) *CheckBox
Check checks or unchecks this check box. See the mark package for the options.
func (*CheckBox) DrawOn
func (checkBox *CheckBox) DrawOn(page *Page) [2]float32
DrawOn draws the CheckBox on the specified Page.
- page: the Page where the CheckBox is to be drawn.
func (*CheckBox) GetHeight
func (checkBox *CheckBox) GetHeight() float32
GetHeight gets the height of the CheckBox.
func (*CheckBox) GetWidth
func (checkBox *CheckBox) GetWidth() float32
GetWidth gets the width of the CheckBox.
func (*CheckBox) SetActualText
func (checkBox *CheckBox) SetActualText(actualText string) *CheckBox
SetActualText sets the actual text for checkBox check box.
- actualText: the actual text for the checkbox.
Returns the CheckBox.
func (*CheckBox) SetAltDescription
func (checkBox *CheckBox) SetAltDescription(altDescription string) *CheckBox
SetAltDescription sets the alternate description of checkBox check box.
- altDescription: the alternate description of the checkbox.
Returns the Checkbox.
func (*CheckBox) SetBorderColor
func (checkBox *CheckBox) SetBorderColor(borderColor int32) *CheckBox
SetBorderColor sets the color of the checkbox.
- borderColor: the checkbox color specified as an 0xRRGGBB integer.
Returns the CheckBox. color.Transparent leaves it unchanged.
func (*CheckBox) SetBorderColorRGB
func (checkBox *CheckBox) SetBorderColorRGB(rgbColor [3]float32) *CheckBox
SetBorderColorRGB sets the color of the box from red, green and blue values.
func (*CheckBox) SetCheckmarkColor
func (checkBox *CheckBox) SetCheckmarkColor(checkmarkColor int32) *CheckBox
SetCheckmarkColor sets the color of the check mark.
- checkmarkColor: the check mark color specified as an 0xRRGGBB integer.
Returns the CheckBox. color.Transparent leaves it unchanged.
func (*CheckBox) SetCheckmarkColorRGB
func (checkBox *CheckBox) SetCheckmarkColorRGB(rgbColor [3]float32) *CheckBox
SetCheckmarkColorRGB sets the color of the check mark from red, green and blue values.
func (*CheckBox) SetFontSize
func (checkBox *CheckBox) SetFontSize(fontSize float32) *CheckBox
SetFontSize sets the font size to use for checkBox text line.
- fontSize: the fontSize to use.
Returns the CheckBox.
func (*CheckBox) SetLocation
func (checkBox *CheckBox) SetLocation(x, y float32) Drawable
SetLocation sets the x,y location on the Page.
- x: the x coordinate on the Page.
- y: the y coordinate on the Page.
Returns the CheckBox.
func (*CheckBox) SetURIAction
func (checkBox *CheckBox) SetURIAction(uri string) *CheckBox
SetURIAction sets the URI for the "click text line" action.
- uri: the URI.
Returns the CheckBox.
type CircleAnnotation
type CircleAnnotation struct { BaseAnnotation }
CircleAnnotation extends BaseAnnotation to represent a circle.
func NewCircleAnnotation
func NewCircleAnnotation() *CircleAnnotation
NewCircleAnnotation acts as the constructor.
type CompositeTextLine
type CompositeTextLine struct { // contains filtered or unexported fields }
CompositeTextLine constructs composite text line objects. This class was designed and implemented by Jon T. Swanson, Ph.D. Refactored and integrated into the project by Evgeni Dragoev - 1st of June 2020.
func NewCompositeTextLine
func NewCompositeTextLine(x, y float32) *CompositeTextLine
NewCompositeTextLine constructs new composite text line object.
func (*CompositeTextLine) AddComponent
func (composite *CompositeTextLine) AddComponent(textLine *TextLine) *CompositeTextLine
AddComponent adds a new text line. Find the current font, current size and effects (normal, super or subscript) Set the position of the component to the starting stored as current position Set the size and offset based on effects Set the new current position
- component: the component.
func (*CompositeTextLine) AddFormula
func (composite *CompositeTextLine) AddFormula(font *Font, formula string) *CompositeTextLine
AddFormula adds the components of a chemical formula, in the specified font.
The digits that follow an element or a closing bracket are subscripts, as the 2 of H2O and the 6, 12 and 6 of C6H12O6; a run of digits and signs after a circumflex is a superscript, as the charge of Ca^2+ and SO4^2-; and everything else is drawn on the baseline, including a digit that begins the formula, as the 2 of 2H2O.
- font: the font of the formula.
- formula: the formula, for example "C6H12O6" or "SO4^2-".
func (*CompositeTextLine) DrawOn
func (composite *CompositeTextLine) DrawOn(page *Page) [2]float32
DrawOn draws this line on the specified page.
- page: the page to draw this line on.
Returns x and y coordinates of the bottom right corner of this component.
func (*CompositeTextLine) GetAscent
func (composite *CompositeTextLine) GetAscent() float32
GetHeight returns the height of this CompositeTextLine. GetAscent returns how far above its baseline this composite text line reaches: the ascent of the component that reaches highest, a superscript included.
func (*CompositeTextLine) GetDescent
func (composite *CompositeTextLine) GetDescent() float32
GetDescent returns how far below its baseline this composite text line reaches: the descent of the component that reaches lowest, a subscript included.
func (*CompositeTextLine) GetFontSize
func (composite *CompositeTextLine) GetFontSize() float32
GetFontSize gets the font size.
func (*CompositeTextLine) GetHeight
func (composite *CompositeTextLine) GetHeight() float32
func (*CompositeTextLine) GetLocation
func (composite *CompositeTextLine) GetLocation() [2]float32
GetLocation return the position of this composite text line.
func (*CompositeTextLine) GetMinMaxY
func (composite *CompositeTextLine) GetMinMaxY() [2]float32
GetMinMaxY returns the vertical coordinates of the top left and bottom right corners of the bounding box of this composite text line. Returns the array containing the vertical coordinates.
func (*CompositeTextLine) GetNumberOfTextLines
func (composite *CompositeTextLine) GetNumberOfTextLines() int
GetNumberOfTextLines returns the number of text lines.
func (*CompositeTextLine) GetSubscriptFactor
func (composite *CompositeTextLine) GetSubscriptFactor() float32
GetSubscriptFactor gets the subscript factor for this text line. Returns subscript the subscript size factor.
func (*CompositeTextLine) GetSubscriptPosition
func (composite *CompositeTextLine) GetSubscriptPosition() float32
GetSubscriptPosition gets the subscript position for this text line. Returns subscriptPosition the subscript position.
func (*CompositeTextLine) GetSuperscriptFactor
func (composite *CompositeTextLine) GetSuperscriptFactor() float32
GetSuperscriptFactor gets the superscript factor for this text line. Returns superscript the superscript size factor.
func (*CompositeTextLine) GetSuperscriptPosition
func (composite *CompositeTextLine) GetSuperscriptPosition() float32
GetSuperscriptPosition gets the superscript position for this text line.
func (*CompositeTextLine) GetTextLine
func (composite *CompositeTextLine) GetTextLine(index int) *TextLine
GetTextLine return the nth entry in the TextLine array.
- index: the index of the nth element.
func (*CompositeTextLine) GetWidth
func (composite *CompositeTextLine) GetWidth() float32
GetWidth returns the width of this CompositeTextLine.
func (*CompositeTextLine) SetFontSize
func (composite *CompositeTextLine) SetFontSize(fontSize float32) *CompositeTextLine
SetFontSize sets the font size.
func (*CompositeTextLine) SetLocation
func (composite *CompositeTextLine) SetLocation(x, y float32) Drawable
SetLocation loops through all the text lines and reset their location based on the new location set here.
- x: the x coordinate.
- y: the y coordinate.
func (*CompositeTextLine) SetSubscriptFactor
func (composite *CompositeTextLine) SetSubscriptFactor(subscript float32) *CompositeTextLine
*
- Sets the subscript factor for this composite text line. *
- - subscript: the subscript size factor.
func (*CompositeTextLine) SetSubscriptPosition
func (composite *CompositeTextLine) SetSubscriptPosition(subscriptPosition float32) *CompositeTextLine
SetSubscriptPosition sets the subscript position for this composite text line.
- subscriptPosition: the subscript position.
func (*CompositeTextLine) SetSuperscriptFactor
func (composite *CompositeTextLine) SetSuperscriptFactor(superscript float32) *CompositeTextLine
SetSuperscriptFactor sets the superscript factor for this composite text line.
- superscript: the superscript size factor.
func (*CompositeTextLine) SetSuperscriptPosition
func (composite *CompositeTextLine) SetSuperscriptPosition(superscriptPosition float32) *CompositeTextLine
SetSuperscriptPosition sets the superscript position for this composite text line.
- superscriptPosition: the superscript position.
type Container
type Container struct { // contains filtered or unexported fields }
Container is a group of drawable elements that are moved, rotated and scaled together: shapes, text, images, annotations, stamps and nested containers.
What a container is good at: it takes anything that implements Drawable, so a group can hold an Image, a Table, a chart, a barcode, a link or another annotation, and each element keeps everything it can do. Each element also tags itself in a PDF/UA document, so a TextLine in a container is a paragraph of its own and an Image is a figure with its alternate description. Laying a group out once and placing it, rotated or scaled, is what it is for; elements that have no rotation of their own get one this way.
What it costs: the elements are drawn into the page on every DrawOn, so a container on 100 pages writes its drawing 100 times over.
Use a Stamp instead for content that repeats on many pages -- a header, a footer, a logo, a watermark -- which is written once as a form XObject and placed with a few bytes. Of a 200 by 50 point box with two lines of text, a container writes 367 bytes into every page and a stamp 83, so the stamp is the smaller of the two from the fourth page on: over 100 pages it saves 12,855 bytes of a 104,530 byte file, and over 500 pages 66,052 of 275,553. On one page the stamp is the larger, since its XObject costs about 300 bytes of its own, and it draws only paths and text in an embedded font.
Please see Example_42 and Example_31.
func NewContainer
func NewContainer(width, height float32) *Container
NewContainer creates a new container with the specified width and height.
The container is initialized with:
- Rotation set to 0 degrees
- Scaling factors set to 1.0 for both axes
- An empty slice of drawable elements
func (*Container) Add
func (c *Container) Add(element Drawable) *Container
Add adds a drawable element to this container.
element is the Drawable object to add.
func (*Container) DrawOn
func (c *Container) DrawOn(page *Page) [2]float32
DrawOn draws the container and all child elements onto the given page.
The transformations applied are:
- Translate container to its final position on the page
- Move origin to the center of the container
- Rotate around the container center
- Scale around the container center
- Move origin back for child drawing
Returns a slice containing the bottom-right position of the container. Returns an error if drawing fails.
func (*Container) GetRotationCenter
func (c *Container) GetRotationCenter() [2]float32
GetRotationCenter returns the center of this container, which it rotates around.
func (*Container) ScaleBy
func (c *Container) ScaleBy(factor float32) *Container
ScaleBy sets a uniform scaling factor for both X and Y axes.
factor specifies the scaling factor to apply.
func (*Container) ScaleByWidthAndHeight
func (c *Container) ScaleByWidthAndHeight(sx, sy float32) *Container
ScaleByWidthAndHeight sets non-uniform scaling factors for the X and Y axes.
sx specifies the scaling factor along the X-axis. sy specifies the scaling factor along the Y-axis.
func (*Container) SetBorderColor
func (c *Container) SetBorderColor(borderColor int32) *Container
SetBorderColor sets the 0xRRGGBB color of the border around this container. color.Transparent leaves it unchanged.
func (*Container) SetBorderColorRGB
func (c *Container) SetBorderColorRGB(rgbColor [3]float32) *Container
SetBorderColorRGB sets the color of the border around this container from red, green and blue values.
func (*Container) SetLocation
func (c *Container) SetLocation(x, y float32) Drawable
SetLocation sets the location of the container on the page.
x is the horizontal coordinate and y is the vertical coordinate.
func (*Container) SetRotation
func (c *Container) SetRotation(degrees float64) *Container
SetRotation rotates this container around its center: clockwise for a positive angle, as every rotation in PDFjet turns, and counterclockwise for a negative angle.
type Destination
type Destination struct { // contains filtered or unexported fields }
Destination is a destination on a page, made by Page.AddDestination.
type Dimension
type Dimension struct { // contains filtered or unexported fields }
Dimension encapsulates the width and height of a component.
func NewDimension
func NewDimension(width, height float32) *Dimension
NewDimension Constructor for creating dimension objects.
- width: the width.
- height: the height.
func (*Dimension) GetHeight
func (dimension *Dimension) GetHeight() float32
GetHeight gets the height of the component.
func (*Dimension) GetWidth
func (dimension *Dimension) GetWidth() float32
GetWidth gets the width of the component.
type DonutChart
type DonutChart struct { // contains filtered or unexported fields }
DonutChart is a donut or pie chart: each slice is its value's share of the sum of the values, with a label next to it and its percentage inside it. A chart with an inner radius of 0 is a pie chart. See Example_28.
func NewDonutChart
func NewDonutChart(f1, f2 *Font) *DonutChart
NewDonutChart creates a donut chart with f1 as the font for the slice labels and f2 as the font for the percentages drawn inside the slices. With an inner radius of 0 it is a pie chart.
func (*DonutChart) AddSlice
func (dc *DonutChart) AddSlice(slice *Slice) *DonutChart
AddSlice adds a slice to this chart.
func (*DonutChart) DrawOn
func (dc *DonutChart) DrawOn(page *Page) [2]float32
DrawOn draws this chart on the specified page. It returns the x and y coordinates of the bottom right corner of the outer circle of this chart. The slice labels can extend past it.
func (*DonutChart) SetAltDescription
func (dc *DonutChart) SetAltDescription(altDescription string) *DonutChart
SetAltDescription sets the alternate description of the chart, which a screen reader reads in a PDF/UA document, where the chart is a figure. The default lists the label and the percentage of each slice.
func (*DonutChart) SetLocation
func (dc *DonutChart) SetLocation(x, y float32) Drawable
SetLocation sets the top left corner of the outer circle of this chart. The center is one outer radius to the right of it and one below. The slice labels can extend past the circle. It returns the chart as a Drawable, so in a chain of setter calls SetLocation goes last, right before DrawOn.
func (*DonutChart) SetRadii
func (dc *DonutChart) SetRadii(outerRadius, innerRadius float32) *DonutChart
SetRadii sets the outer and inner radius of this chart; an inner radius of 0 makes a pie chart.
type Drawable
type Drawable interface { // DrawOn draws the component implementing this interface on the PDF page. // - page: the page to draw on. // Returns x and y coordinates of the bottom right corner of this component. DrawOn(page *Page) [2]float32 // SetLocation sets the location of the component on the page. // It returns the component as a Drawable, so in a chain of setter calls // SetLocation goes last, right before DrawOn. // - x: the x coordinate of the top left corner of the component. // - y: the y coordinate of the top left corner of the component. // Returns this component. SetLocation(x, y float32) Drawable }
Drawable is the interface of the components that can be drawn on a page, which a Container or an OptionalContentGroup can hold. @author Mark Paxton, Evgeni Dragoev
type Ellipse
type Ellipse struct { Arc // Embedding enables inheriting Arc's methods }
Ellipse represents an ellipse shape, implemented as a full circle arc.
func NewEllipse
func NewEllipse() *Ellipse
NewEllipse creates a new Ellipse instance with default values (a complete 360-degree arc representing an ellipse/circle).
type EmbeddedFile
type EmbeddedFile struct { // contains filtered or unexported fields }
EmbeddedFile is used to embed file objects in the PDF. The file objects must be added to the PDF before drawing on the first page.
func NewEmbeddedFile
func NewEmbeddedFile(pdf *PDF, fileName string, reader io.Reader, compress bool) *EmbeddedFile
NewEmbeddedFile is the constructor.
func NewEmbeddedFileAtPath
func NewEmbeddedFileAtPath(pdf *PDF, filePath string, compress bool) *EmbeddedFile
NewEmbeddedFileAtPath embeds the file at the specified path into the PDF, compressing it with Flate when compress is true. It panics if the file cannot be opened.
func NewEmbeddedFileWithRelationship
func NewEmbeddedFileWithRelationship(pdf *PDF, fileName string, reader io.Reader, compress bool, mediaType string, relation relationship.Relationship, description string) *EmbeddedFile
NewEmbeddedFileWithRelationship embeds the file and says what it holds and how it relates to the document. A document of PDF/A-3 needs all three of them for each file it carries, and so does a document that carries the XML of an invoice. PDF.AddAssociatedFile adds the embedded file to the document. The media type is what the file holds, such as "text/xml", the relation is how the file relates to the document and the description is what the file is, in the words of a person; each of them may be empty.
func (*EmbeddedFile) GetFileName
func (file *EmbeddedFile) GetFileName() string
GetFileName returns the file name.
type Encryption
type Encryption struct { // contains filtered or unexported fields }
Encryption handles PDF encryption functionality
func NewEncryption
func NewEncryption(pdf *PDF, passwords *encryption.Passwords, permissions *encryption.Permissions) (*Encryption, error)
NewEncryption creates a new encryption dictionary and adds it to the PDF
type Field
type Field struct { // contains filtered or unexported fields }
Field describes field object that is used from the Form class. Please see Example_44
func NewField
func NewField(x float32, label, value string) *Field
NewField constructs field object.
type FileAttachment
type FileAttachment struct { // contains filtered or unexported fields }
FileAttachment describes file attachment object.
func NewFileAttachment
func NewFileAttachment(embeddedFile *EmbeddedFile) *FileAttachment
NewFileAttachment constructs file attachment objects.
func (*FileAttachment) DrawOn
func (attachment *FileAttachment) DrawOn(page *Page) [2]float32
DrawOn draws this component on the page.
func (*FileAttachment) SetContents
func (attachment *FileAttachment) SetContents(contents string) *FileAttachment
SetContents sets the contents of this attachment, the text a viewer shows for it.
func (*FileAttachment) SetIconPaperclip
func (attachment *FileAttachment) SetIconPaperclip() *FileAttachment
SetIconPaperclip sets the "Paperclip" icon.
func (*FileAttachment) SetIconPushPin
func (attachment *FileAttachment) SetIconPushPin() *FileAttachment
SetIconPushPin sets the "PushPin" icon.
func (*FileAttachment) SetIconSize
func (attachment *FileAttachment) SetIconSize(height float32) *FileAttachment
SetIconSize sets the icon size.
func (*FileAttachment) SetLocation
func (attachment *FileAttachment) SetLocation(x, y float32) Drawable
SetLocation sets the location.
func (*FileAttachment) SetTitle
func (attachment *FileAttachment) SetTitle(title string) *FileAttachment
SetTitle sets the title.
type Font
type Font struct { // contains filtered or unexported fields }
Font is used to create font objects. The font objects must be added to the PDF before they can be used to draw text.
func NewCJKFont
func NewCJKFont(pdf *PDF, cjkFont cjkfont.Font) *Font
NewCJKFont is the constructor for CJK - Chinese, Japanese and Korean fonts. The font is not embedded: the PDF names it and the viewer supplies it, so a document in it is a few kilobytes, where an embedded CJK font adds hundreds. The viewer needs the Adobe Asian font pack, or a font of its own in its place, and the text takes the shapes of the font it finds; Latin letters and spaces are drawn full width; and a PDF with it cannot be PDF/A or PDF/UA. See Example_05. To ship the glyphs with the document, use an embedded font, such as IBMPlexSansJP, KR, SC or TC: see Example_02 and Example_03.
- pdf: the PDF to add this font to.
- cjkFont: the font.
func NewCoreFont
func NewCoreFont(pdf *PDF, coreFont *corefont.CoreFont) *Font
NewCoreFont is the constructor for the 14 standard fonts. Creates a font object and adds it to the PDF.
Examples:
font1 := pdfjet.NewCoreFont(pdf, corefont.Helvetica()) font2 := pdfjet.NewCoreFont(pdf, corefont.TimesItalic()) font3 := pdfjet.NewCoreFont(pdf, corefont.ZapfDingbats()) - pdf: the PDF to add this font to. - coreFont: the core font, for example corefont.Helvetica().
func NewFont
func NewFont(pdf *PDF, reader io.Reader) *Font
NewFont constructs a font from an OpenType or TrueType font, a .otf or a .ttf, and adds it to the PDF.
func NewFontForObjects
func NewFontForObjects(objects *[]*PDFobj, reader io.Reader) *Font
NewFontForObjects constructs a font from an OpenType or TrueType font, a .otf or a .ttf, and adds it to the objects of an existing PDF. It is embedded as a subset of the glyphs drawn, when the objects are added to the PDF, unless SetSubset(false) keeps it whole.
func NewFontFromFile
func NewFontFromFile(pdf *PDF, filePath string) *Font
NewFontFromFile creates a font from the .otf or .ttf file at the path and adds it to the PDF. It panics if the file cannot be opened.
func (*Font) GetAscent
func (font *Font) GetAscent(fontSize float32) float32
GetAscent returns the ascent of this font at the font size.
func (*Font) GetBodyHeight
func (font *Font) GetBodyHeight(fontSize float32) float32
GetBodyHeight returns the height of the body of the font at the font size.
func (*Font) GetDescent
func (font *Font) GetDescent(fontSize float32) float32
GetDescent returns the descent of this font at the font size.
func (*Font) GetFitChars
func (font *Font) GetFitChars(text string, width float32) int
GetFitChars returns the number of characters from the specified text string that will fit within the specified width. They are counted in runes, not in bytes, so that string([]rune(text)[:n]) is the text that fits; Java and C# count UTF-16 chars, where a character outside the Basic Multilingual Plane is two.
func (*Font) GetLineGap
func (font *Font) GetLineGap(fontSize float32) float32
GetLineGap returns the line gap at the font size: the space the font puts between the descent of a line and the ascent of the next one. It is 0 for most fonts, which leave that space in their ascent and descent, and 1 em for the Japanese and Chinese IBM Plex fonts, whose ascent and descent add up to 1 em.
func (*Font) GetName
func (font *Font) GetName() string
GetName returns the name of this font.
func (*Font) GetSize
func (font *Font) GetSize() float32
GetSize returns the current font size.
func (*Font) GetUnderlinePosition
func (font *Font) GetUnderlinePosition(fontSize float32) float32
GetUnderlinePosition returns the underline position at the font size.
func (*Font) GetUnderlineThickness
func (font *Font) GetUnderlineThickness(fontSize float32) float32
GetUnderlineThickness returns the underline thickness at the font size.
func (*Font) SetItalic
func (font *Font) SetItalic(skew15 bool) *Font
SetItalic sets the skew15 private variable. When the variable is set to 'true' all glyphs in the font are skewed on 15 degrees. This makes a regular font look like an italic type font. Use this method when you don't have real italic font in the font family, or when you want to generate smaller PDF files. For example, you could embed only the Regular and Bold fonts and synthesize the RegularItalic and BoldItalic.
func (*Font) SetKernPairs
func (font *Font) SetKernPairs(kernPairs bool) *Font
SetKernPairs sets the kerning for the selected font to 'true' or 'false' depending on the passed value of kernPairs parameter. The kerning is implemented only for the 14 standard fonts.
func (*Font) SetSize
func (font *Font) SetSize(fontSize float32) *Font
SetSize sets the size of this font.
func (*Font) SetSubset
func (font *Font) SetSubset(subset bool) *Font
SetSubset sets whether this font is embedded as a subset, the outlines of the glyphs the document does not draw left out, which is the default for a .ttf or a .otf. A font whose license does not allow subsetting, by the fsType of its OS/2 table, is embedded whole. Fonts read from one file are one font program in the PDF: kept whole for one, the program is whole for all of them. It must be called before Complete, and for a font added to the objects of an existing PDF, before the objects are added to the PDF.
func (*Font) StringWidth
func (font *Font) StringWidth(fontSize float32, str string) float32
StringWidth returns the width of the specified string when drawn on the page with this font using the current font size.
func (*Font) StringWidthUsingFallbackFont
func (font *Font) StringWidthUsingFallbackFont(fallbackFont *Font, fontSize float32, text string) float32
StringWidthUsingFallbackFont returns the width of text string drawn using main and fallback fonts.
type Form
type Form struct { // contains filtered or unexported fields }
Form describes form object. Please see Example_44
func NewForm
func NewForm(fields []*Field) *Form
NewForm constructs new form object.
func (*Form) DrawOn
func (form *Form) DrawOn(page *Page) [2]float32
DrawOn draws the form on the specified page.
- page: the page to draw form on.
Returns x and y coordinates of the bottom right corner of form component.
func (*Form) SetLabelColor
func (form *Form) SetLabelColor(labelColor int32) *Form
SetLabelColor sets the color for the label. color.Transparent leaves it unchanged.
func (*Form) SetLabelColorRGB
func (form *Form) SetLabelColorRGB(color [3]float32) *Form
SetLabelColorRGB sets the color for the label using RGB float values (0.0-1.0).
func (*Form) SetLabelFont
func (form *Form) SetLabelFont(f1 *Font) *Form
SetLabelFont sets the font for the label text.
func (*Form) SetLabelFontSize
func (form *Form) SetLabelFontSize(labelFontSize float32) *Form
SetLabelFontSize sets the font size for the label text.
func (*Form) SetLocation
func (form *Form) SetLocation(x, y float32) Drawable
SetLocation sets location x and y.
func (*Form) SetStrokeWidth
func (form *Form) SetStrokeWidth(strokeWidth float32) *Form
SetStrokeWidth sets the stroke width.
func (*Form) SetValueColor
func (form *Form) SetValueColor(valueColor int32) *Form
SetValueColor sets the color for the value string. color.Transparent leaves it unchanged.
func (*Form) SetValueColorRGB
func (form *Form) SetValueColorRGB(color [3]float32) *Form
SetValueColorRGB sets the color for the value string using RGB float values (0.0-1.0).
func (*Form) SetValueFont
func (form *Form) SetValueFont(f2 *Font) *Form
SetValueFont sets the font for the value text.
func (*Form) SetValueFontSize
func (form *Form) SetValueFontSize(valueFontSize float32) *Form
SetValueFontSize sets the font size for value text.
func (*Form) SetWidth
func (form *Form) SetWidth(width float32) *Form
SetWidth sets the width of this form.
type GraphicsState
type GraphicsState struct { // contains filtered or unexported fields }
GraphicsState is used to create graphics state objects.
func NewGraphicsState
func NewGraphicsState() *GraphicsState
NewGraphicsState is the constructor.
func (*GraphicsState) GetAlphaNonStroking
func (state *GraphicsState) GetAlphaNonStroking() float32
GetAlphaNonStroking returns the non stroking alpha.
func (*GraphicsState) GetAlphaStroking
func (state *GraphicsState) GetAlphaStroking() float32
GetAlphaStroking returns the stroking alpha.
func (*GraphicsState) SetAlphaNonStroking
func (state *GraphicsState) SetAlphaNonStroking(nonStrokingAlpha float32) *GraphicsState
SetAlphaNonStroking sets the non stroking alpha.
func (*GraphicsState) SetAlphaStroking
func (state *GraphicsState) SetAlphaStroking(strokingAlpha float32) *GraphicsState
SetAlphaStroking sets the stroking alpha.
type Image
type Image struct { // contains filtered or unexported fields }
Image describes an image object. The image type can be one of the following:
imagetype.JPG, imagetype.PNG or imagetype.BMP
Please see Example_32 and Example_14.
func NewImage
func NewImage(pdf *PDF, reader io.Reader) *Image
NewImage the main constructor for the Image class.
- pdf: the PDF to which we add this image.
- inputStream: the input stream to read the image from.
func NewImageForObjects
func NewImageForObjects(objects *[]*PDFobj, reader io.Reader) *Image
NewImageForObjects adds this image to the existing PDF objects.
- objects: the map to which we add this image.
- inputStream: the input stream to read the image from.
func NewImageFromFile
func NewImageFromFile(pdf *PDF, filePath string) *Image
NewImageFromFile creates an image from the PNG, BMP or JPEG file at the specified path. It panics if the extension is not supported or the file cannot be opened.
func NewImageFromPDFobj
func NewImageFromPDFobj(pdf *PDF, obj *PDFobj) *Image
NewImageFromPDFobj constructs new image from an existing PDF object.
func (*Image) DrawOn
func (image *Image) DrawOn(page *Page) [2]float32
DrawOn draws this image on the specified page.
- page: the page to draw this image on.
Returns x and y coordinates of the bottom right corner of this component.
func (*Image) GetHeight
func (image *Image) GetHeight() float32
GetHeight returns the height of this image when drawn on the page, its width before it is turned when it is turned a quarter of the way. The scaling is taken into account. Returns h - the height of this image.
func (*Image) GetWidth
func (image *Image) GetWidth() float32
GetWidth returns the width of this image when drawn on the page, its height before it is turned when it is turned a quarter of the way. The scaling is taken into account. Returns w - the width of this image.
func (*Image) ResizeHeight
func (image *Image) ResizeHeight(height float32) *Image
ResizeHeight resizes the image to the specified height.
func (*Image) ResizeToFit
func (image *Image) ResizeToFit(page *Page, keepAspectRatio bool)
ResizeToFit resizes an image so it would fit on a page.
func (*Image) ResizeWidth
func (image *Image) ResizeWidth(width float32) *Image
ResizeWidth resizes the image to the specified width.
func (*Image) ScaleBy
func (image *Image) ScaleBy(factor float32) *Image
ScaleBy scales this image by the specified factor.
- factor: the factor used to scale the image.
func (*Image) ScaleByWidthAndHeight
func (image *Image) ScaleByWidthAndHeight(widthFactor, heightFactor float32) *Image
ScaleByWidthAndHeight scales this image by the specified width and height factor.
Author: Pieter Libin, pieter@emweb.be
- widthFactor: the factor used to scale the width of the image
- heightFactor: the factor used to scale the height of the image
func (*Image) SetActualText
func (image *Image) SetActualText(actualText string) *Image
SetActualText sets the actual text for this image.
- actualText: the actual text for the image.
Returns this Image.
func (*Image) SetAltDescription
func (image *Image) SetAltDescription(altDescription string) *Image
SetAltDescription sets the alternate description of this image.
- altDescription: the alternate description of the image.
Returns this Image.
func (*Image) SetFlipUpsideDown
func (image *Image) SetFlipUpsideDown(flipUpsideDown bool) *Image
SetFlipUpsideDown sets whether this image is drawn upside down.
func (*Image) SetGoToAction
func (image *Image) SetGoToAction(key string) *Image
SetGoToAction sets the destination key for the action.
- key: the destination name.
func (*Image) SetLanguage
func (image *Image) SetLanguage(language string) *Image
SetLanguage sets the language of this image, for example "en-US".
func (*Image) SetLocation
func (image *Image) SetLocation(x, y float32) Drawable
SetLocation sets the location of this image on the page to (x, y).
- x: the x coordinate of the top left corner of the image.
- y: the y coordinate of the top left corner of the image.
func (*Image) SetRotation
func (image *Image) SetRotation(degrees int) *Image
SetRotation rotates this image clockwise by 0, 90, 180 or 270 degrees, as every rotation in PDFjet turns. It panics on any other angle.
func (*Image) SetURIAction
func (image *Image) SetURIAction(uri string) *Image
SetURIAction sets the URI for the "click box" action.
- uri: the URI
type ImageSize
type ImageSize struct { // contains filtered or unexported fields }
ImageSize is the size an image is drawn at, and its pixels, read from the header of its file alone, without its image data in memory: the size of a page laid out before its images are drawn, and an image refused early, for its size or for a header that NewImage refuses, before a byte of its image data is decoded (9 October 2026).
The size is the one NewImage gives the image: its pixels, or the physical size the file asks for, the pHYs chunk of a PNG, the JFIF density of a JPEG or the pixels per metre of a BMP; a JPEG turned a quarter of the way by its Exif orientation is its height by its width. What only the image data shows, a JPEG cut short or the rows of a PNG, is NewImage's to refuse.
func ReadImageSize
func ReadImageSize(reader io.Reader) (*ImageSize, error)
ReadImageSize reads the size of the PNG, JPEG or BMP image of the reader from its header, or returns why NewImage would refuse the image, as far as its header shows. A JPEG is read to its frame header, a BMP to its pixels per metre, and a PNG to its end, a chunk at a time, its image data checked and passed over, as a pHYs chunk may come after it.
func ReadImageSizeFromFile
func ReadImageSizeFromFile(filePath string) (*ImageSize, error)
ReadImageSizeFromFile reads the size of the PNG, JPEG or BMP file at the path, as ReadImageSize does.
func (*ImageSize) GetHeight
func (size *ImageSize) GetHeight() float32
GetHeight returns the height the image is drawn at, in points, as Image's GetHeight before it is scaled.
func (*ImageSize) GetPixelHeight
func (size *ImageSize) GetPixelHeight() int
GetPixelHeight returns the height of the image in pixels, as stored.
func (*ImageSize) GetPixelWidth
func (size *ImageSize) GetPixelWidth() int
GetPixelWidth returns the width of the image in pixels, as stored.
func (*ImageSize) GetWidth
func (size *ImageSize) GetWidth() float32
GetWidth returns the width the image is drawn at, in points, as Image's GetWidth before it is scaled.
type Line
type Line struct { // contains filtered or unexported fields }
Line is used to create line objects. Please see Example_08 and Example_35.
func NewLine
func NewLine(x1, y1, x2, y2 float32) *Line
NewLine creates a line object.
- x1: the x coordinate of the start point.
- y1: the y coordinate of the start point.
- x2: the x coordinate of the end point.
- y2: the y coordinate of the end point.
func (*Line) DrawOn
func (line *Line) DrawOn(page *Page) [2]float32
DrawOn draws this line on the specified page.
- page: the page to draw this line on.
Returns x and y coordinates of the bottom right corner of this component.
func (*Line) GetEndPoint
func (line *Line) GetEndPoint() *Point
GetEndPoint returns the end point of this line. Returns Point the point.
func (*Line) GetLineCapStyle
func (line *Line) GetLineCapStyle() capstyle.CapStyle
GetLineCapStyle returns the line cap style. Returns the cap style.
func (*Line) GetStartPoint
func (line *Line) GetStartPoint() *Point
GetStartPoint returns the start point of this line. Returns Point the point.
func (*Line) ScaleBy
func (line *Line) ScaleBy(factor float32) *Line
ScaleBy scales this line by the specified factor.
- factor: the factor used to scale the line.
Returns this Line object.
func (*Line) SetActualText
func (line *Line) SetActualText(actualText string) *Line
SetActualText sets the actual text for this line.
- actualText: the actual text for the line.
Returns this Line.
func (*Line) SetAltDescription
func (line *Line) SetAltDescription(altDescription string) *Line
SetAltDescription sets the alternate description of this line.
- altDescription: the alternate description of the line.
Returns this Line.
func (*Line) SetEndPoint
func (line *Line) SetEndPoint(x, y float32) *Line
SetEndPoint sets the x and y coordinates of the end point.
- x: the x coordinate of the end point.
- y: the y coordinate of the end point.
Returns this Line object.
func (*Line) SetLineCapStyle
func (line *Line) SetLineCapStyle(style capstyle.CapStyle) *Line
SetLineCapStyle sets the line cap style.
- style: the cap style of the current line. Supported values: capstyle.Butt, capstyle.Round and capstyle.ProjectingSquare
Returns this Line object.
func (*Line) SetLocation
func (line *Line) SetLocation(x, y float32) Drawable
SetLocation moves this line so that it starts at the specified point. The end point moves with it.
- x: the x coordinate of the start point.
- y: the y coordinate of the start point.
Returns this Line object.
func (*Line) SetStartPoint
func (line *Line) SetStartPoint(x, y float32) *Line
SetStartPoint sets the x and y coordinates of the start point.
- x: the x coordinate of the start point.
- y: the y coordinate of the start point.
Returns this Line object.
func (*Line) SetStrokeColor
func (line *Line) SetStrokeColor(c int32) *Line
SetStrokeColor sets the stroke color of this line.
- color: the color specified as an integer.
Returns this Line object. color.Transparent leaves it unchanged.
func (*Line) SetStrokeColorRGB
func (line *Line) SetStrokeColorRGB(rgbColor [3]float32) *Line
SetStrokeColorRGB sets the color of this line from red, green and blue values.
func (*Line) SetStrokeDashPattern
func (line *Line) SetStrokeDashPattern(pattern string) *Line
SetStrokeDashPattern sets the line dash pattern that controls the pattern of dashes and gaps used to stroke paths. It is specified by a dash array and a dash phase. The elements of the dash array are positive numbers that specify the lengths of alternating dashes and gaps. The dash phase specifies the distance into the dash pattern at which to start the dash. The elements of both the dash array and the dash phase are expressed in user space units.
Examples of line dash patterns:
"[Array] Phase" Appearance Description _______________ _________________ ____________________________________ "[] 0" ----------------- Solid line "[3] 0" --- --- --- 3 units on, 3 units off, ... "[2] 1" - -- -- -- -- 1 on, 2 off, 2 on, 2 off, ... "[2 1] 0" -- -- -- -- -- -- 2 on, 1 off, 2 on, 1 off, ... "[3 5] 6" --- --- 2 off, 3 on, 5 off, 3 on, 5 off, ... "[2 3] 11" - -- -- -- 1 on, 3 off, 2 on, 3 off, 2 on, ... - pattern: the line dash pattern.
Returns this Line object.
func (*Line) SetStrokeWidth
func (line *Line) SetStrokeWidth(width float32) *Line
SetStrokeWidth sets the stroke width of this line.
- width: the width.
Returns this Line object.
type Markdown
type Markdown struct { // contains filtered or unexported fields }
Markdown draws a Markdown text on as many pages as it needs: headings of # and of underlines, paragraphs with the inline markup of Markup, bullet and numbered lists that nest, block quotes, fenced and indented code, thematic breaks, the tables and the task lists of GitHub's Markdown, - [ ] and - [x], drawn as boxes, and images alone in their paragraph. In a PDF/UA document the headings are H1 to H6, with no level skipped, the lists are lists, the boxes of the tasks their labels, read as ☐ and ☑, the quotes BlockQuotes, the code Code, the tables tables and the images figures, with their text as the alternate description.
It is not all of Markdown: HTML is drawn as the text it is, a line break is a space, links in a table cell are its text, and an image is drawn only when it is alone in its paragraph, from the directory that SetImageDirectory names; with none, its text is drawn instead, so that a text from anyone reads no file. Please see Example_19.
func NewMarkdown
func NewMarkdown(regular, bold, italic, boldItalic, code *Font) *Markdown
NewMarkdown creates the Markdown of text in the fonts, each at its size: the size of the regular font is the size of the text, which the headings are drawn larger than.
- regular: the font of the text.
- bold: the font of **bold** text, and of the headings unless SetHeadingFont sets another.
- italic: the font of *italic* text.
- boldItalic: the font of ***bold italic*** text.
- code: the font of code, usually a monospaced font.
func (*Markdown) DrawOnPages
func (markdown *Markdown) DrawOnPages(pdf *PDF, text string, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
DrawOnPages draws the text on as many new pages as it needs. The pages are created detached and added to the list, so that a footer or a page number can be drawn on each before they are added to the PDF. A text with no blocks needs no page. It returns the x and y coordinates of the bottom right corner of the text on the last page.
- pdf: the PDF document.
- text: the Markdown text.
- pages: the list that receives the new pages.
- pageSize: the page size, for example letter.Portrait().
func (*Markdown) SetCheckColor
func (markdown *Markdown) SetCheckColor(checkColor int32) *Markdown
SetCheckColor sets the color of the box of a task that is done, - [x] in the Markdown, as a 0xRRGGBB value, which has a white check mark in it. It is green, 0x1A7F37, unless it is set; color.Transparent leaves it as it is.
func (*Markdown) SetHeadingColor
func (markdown *Markdown) SetHeadingColor(headingColor int32) *Markdown
SetHeadingColor sets the color of the headings, as a 0xRRGGBB value. They are in the color of the text unless it is set.
func (*Markdown) SetHeadingFont
func (markdown *Markdown) SetHeadingFont(font *Font) *Markdown
SetHeadingFont sets the font of the headings, which is the bold font unless it is set.
func (*Markdown) SetImageDirectory
func (markdown *Markdown) SetImageDirectory(directory string) *Markdown
SetImageDirectory sets the directory that the images are read from: the source of an image in the Markdown is the file of that name in the directory, a JPEG, PNG, BMP or SVG file. A source that is an absolute path, a URL or has .. in it is not read, and neither is any image unless the directory is set: the image's text is drawn instead.
func (*Markdown) SetLinkColor
func (markdown *Markdown) SetLinkColor(linkColor int32) *Markdown
SetLinkColor sets the color of the text of links, as a 0xRRGGBB value. They are blue unless it is set.
func (*Markdown) SetMargins
func (markdown *Markdown) SetMargins(left, top, right, bottom float32) *Markdown
SetMargins sets the margins of the pages, in points. They are 72 points, an inch, unless they are set.
type Markup
type Markup struct { // contains filtered or unexported fields }
Markup makes paragraphs of text with the inline markup of Markdown: **bold**, *italic*, ***bold italic***, `code` and [links](https://pdfjet.com), in the fonts given for each, and as GitHub's Markdown has them, __bold__ and _italic_, ~~strikethrough~~ of two ~, one being text here, as in ~5, and links that are their address, <https://pdfjet.com> or https://pdfjet.com alone. An _ emphasizes only at the edge of a word, so that snake_case is text; an address alone ends before the punctuation at its end, as the period of a sentence, and before a ) that closes no ( of its own. A backslash before a punctuation character, as in \*, makes it plain text, and so is a mark that has no match, such as the * of 2 * 3. Emphasis can be inside a link, and neither inside code. A word keeps its punctuation next to it in another style, as in **bold**, with no space between them: the paragraph joins its text lines with Paragraph.AddJoined.
Headings, lists, block quotes and the rest of Markdown's blocks are not read: a line break is a space, and Paragraphs splits a text into paragraphs at its empty lines. The markup is read in time linear in the length of the text, so it can come from anyone. Please see Example_18.
The text is read as characters, as Java reads it, with the whitespace of Java's Character.isWhitespace. A byte of the text that is not valid UTF-8 is read as the character U+FFFD, one for each such byte, as a conversion of the string to []rune reads it.
func NewMarkup
func NewMarkup(regular, bold, italic, boldItalic, code *Font) *Markup
NewMarkup creates the markup of paragraphs in the fonts, each at its size.
- regular: the font of the text.
- bold: the font of **bold** text.
- italic: the font of *italic* text.
- boldItalic: the font of ***bold italic*** text.
- code: the font of `code`, usually a monospaced font.
func (*Markup) Paragraph
func (markup *Markup) Paragraph(text string) *Paragraph
Paragraph returns the text as one paragraph: a text line for each run of text in one style, each joined to the text before it.
func (*Markup) Paragraphs
func (markup *Markup) Paragraphs(text string) []*Paragraph
Paragraphs returns the paragraphs of the text, which empty lines separate: none for a text with no words.
func (*Markup) SetLinkColor
func (markup *Markup) SetLinkColor(linkColor int32) *Markup
SetLinkColor sets the color of the text of links, as a 0xRRGGBB value. The default is color.Blue. color.Transparent leaves it unchanged.
func (*Markup) SetLinkUnderline
func (markup *Markup) SetLinkUnderline(underline bool) *Markup
SetLinkUnderline sets whether the text of links is underlined, as it is by default.
type OptionalContentGroup
type OptionalContentGroup struct { // contains filtered or unexported fields }
OptionalContentGroup is container for drawable objects that can be drawn on a page as part of Optional Content Group. Please see the PDF specification and Example_47 for more details.
@author Mark Paxton
func NewOptionalContentGroup
func NewOptionalContentGroup(pdf *PDF, name string) *OptionalContentGroup
NewOptionalContentGroup constructs optional content group.
func (*OptionalContentGroup) Add
func (ocg *OptionalContentGroup) Add(drawable Drawable) *OptionalContentGroup
Add appends drawable component to this optional content group.
func (*OptionalContentGroup) Clear
func (ocg *OptionalContentGroup) Clear() *OptionalContentGroup
Clear removes all drawable components from this optional content group.
func (*OptionalContentGroup) DrawOn
func (ocg *OptionalContentGroup) DrawOn(page *Page) [2]float32
DrawOn draws the components in the optional content group on the page and returns the largest x and y coordinates of their bottom right corners.
func (*OptionalContentGroup) GetComponents
func (ocg *OptionalContentGroup) GetComponents() []Drawable
GetComponents returns a copy of the list of drawable components in this optional content group.
func (*OptionalContentGroup) GetName
func (ocg *OptionalContentGroup) GetName() string
GetName returns the name of this optional content group.
func (*OptionalContentGroup) SetExportable
func (ocg *OptionalContentGroup) SetExportable(exportable bool) *OptionalContentGroup
SetExportable sets the exportable components.
func (*OptionalContentGroup) SetPrintable
func (ocg *OptionalContentGroup) SetPrintable(printable bool) *OptionalContentGroup
SetPrintable sets whether this group is printed. In a PDF/UA or PDF/A document every group that is shown is printed: they have no setting for a group that is not, and the viewers print what they show.
func (*OptionalContentGroup) SetVisible
func (ocg *OptionalContentGroup) SetVisible(visible bool) *OptionalContentGroup
SetVisible sets the visibility of the group.
type PDF
type PDF struct { // contains filtered or unexported fields }
PDF is used to create PDF objects.
func NewPDF
func NewPDF(w *bufio.Writer) *PDF
NewPDF creates a PDF document that is written to the writer. Here is the layout of the PDF document:
Metadata Object Output Intent Object Fonts Images Resources Object Content1 Content2 ... ContentN Annot1 Annot2 ... AnnotN Page1 Page2 ... PageN Pages StructElem1 StructElem2 ... StructElemN StructTreeRoot Info Root xref table Trailer
SetCompliance makes it a PDF/UA or PDF/A document; PDF/A requires all fonts to be embedded.
func NewPDFFile
func NewPDFFile(filePath string) (*PDF, error)
NewPDFFile creates a PDF document that is written to the file at the specified path. Complete closes the file.
func NewPDFReader
func NewPDFReader() *PDF
NewPDFReader creates a PDF that only reads existing documents with Read and ReadWithPassword, like the PDF() constructor of the other ports. Use NewPDF or NewPDFFile to write a document.
func (*PDF) AddAssociatedFile
func (pdf *PDF) AddAssociatedFile(file *EmbeddedFile) *PDF
AddAssociatedFile adds a file that the document carries with it: a reader shows it beside the document, and a program that reads the document finds it by its name. This is how a document of PDF/A-3 carries the data behind what it shows, such as the XML of an invoice.
The file names what it holds, how it relates to the document and what it is, so it has to be made with NewEmbeddedFileWithRelationship.
func (*PDF) AddMetadata
func (pdf *PDF) AddMetadata(rdfDescription string) *PDF
AddMetadata adds a description to the metadata of the document: the rdf:Description element of a standard that asks for properties of its own, such as the invoice standards that say which of the files the document carries is the invoice. The text is written into the metadata as it is given, so it has to be XML, and the document has to be of PDF/A or PDF/UA, which are the documents that carry metadata.
func (*PDF) AddObjects
func (pdf *PDF) AddObjects(objects []*PDFobj) error
AddObjects adds the specified objects to the PDF. The objects keep their numbers and are written as they are, so they are added before any font, image or page of this document, and an encrypted PDF cannot take them. Their page tree is the page tree of this document, so it can have no pages of its own, before or after them, and it cannot be a PDF/UA or PDF/A document, as the pages were not made for its compliance. It records the mistake and returns it as an error, as it does when the objects have no root /Pages object.
func (*PDF) AddPage
func (pdf *PDF) AddPage(page *Page)
AddPage adds page to the PDF.
func (*PDF) AddPages
func (pdf *PDF) AddPages(pages []*Page)
AddPages adds the pages to this document.
func (*PDF) AddResourceObjects
func (pdf *PDF) AddResourceObjects(objects []*PDFobj)
AddResourceObjects adds the fonts, images and graphics states used by the pages to this document. The objects keep their numbers and are written as they are, so they are added before any font, image or page of this document, and an encrypted PDF cannot take them: the mistake is recorded, and Complete returns it.
func (*PDF) Complete
func (pdf *PDF) Complete() error
Complete writes the rest of the PDF, flushes the bufio.Writer and closes the file that NewPDFFile opened. It returns the first error writing the document.
func (*PDF) GetCompliance
func (pdf *PDF) GetCompliance() compliance.Compliance
GetCompliance returns the PDF/UA or PDF/A compliance of this document. See the compliance package.
func (*PDF) GetPageObjects
func (pdf *PDF) GetPageObjects(objects []*PDFobj) []*PDFobj
GetPageObjects returns the page objects, each holding the entries it inherits from the page tree: /Resources, /MediaBox, /CropBox and /Rotate, which a PDF can write once on a node above the pages rather than on every page. A page that has an entry of its own keeps it, and the entries are added to the page the first time it is returned, so that GetPageSize and GetResourcesObject read what the page is.
func (*PDF) Merge
func (pdf *PDF) Merge(objects []*PDFobj) error
Merge adds all the pages of a document that was read with Read after the pages of this document, in their order. A PDF can merge several documents and draw pages of its own before, between and after them.
The merged pages keep their content, resources, annotations and links. The parts of the read document that belong to the whole document are left out: its bookmarks, form fields, tagging, named destinations and optional content settings. The objects that the pages use are written at once, so the objects are not needed after the call.
A PDF/UA or PDF/A document cannot merge pages, which were not made for its compliance, and Merge cannot be used with AddObjects: Merge records the mistake and returns it as an error.
func (*PDF) MergePages
func (pdf *PDF) MergePages(objects []*PDFobj, pageNumbers ...int) error
MergePages adds the listed pages of a document that was read with Read after the pages of this document, in the order they are listed. A document is split by merging each part of it into a PDF of its own: the objects that Read returned can be merged into any number of PDFs.
The pages are merged as Merge merges all of them, and a link to a page that is not merged leads nowhere. A page number that the document does not have, or one that is listed twice, is refused: MergePages records the mistake and returns it as an error.
func (*PDF) Read
func (pdf *PDF) Read(buf []byte) ([]*PDFobj, error)
Read returns the objects of the PDF in buf. An encrypted PDF is decrypted when it opens without a password. It returns an error if the PDF needs a password or cannot be read.
func (*PDF) ReadWithPassword
func (pdf *PDF) ReadWithPassword(buf []byte, password string) (objects []*PDFobj, err error)
ReadWithPassword returns a list of objects of type PDFobj read from the bytes of a PDF that is encrypted with the standard security handler. The PDF is decrypted with the password, which is its user or its owner password. It returns an error if the password is not correct or the PDF cannot be read.
func (*PDF) SetAuthor
func (pdf *PDF) SetAuthor(author string) *PDF
SetAuthor sets the "Author" document property of the PDF file.
func (*PDF) SetCompliance
func (pdf *PDF) SetCompliance(level compliance.Compliance) *PDF
SetCompliance sets the PDF/UA or PDF/A compliance of this document. See the compliance package.
func (*PDF) SetCreator
func (pdf *PDF) SetCreator(creator string) *PDF
SetCreator sets the creator field of the PDF.
func (*PDF) SetEncryption
func (pdf *PDF) SetEncryption(encryption *Encryption) *PDF
SetEncryption sets the encryption applied to this document.
func (*PDF) SetKeywords
func (pdf *PDF) SetKeywords(keywords string) *PDF
SetKeywords sets the keywords.
func (*PDF) SetLanguage
func (pdf *PDF) SetLanguage(language string) *PDF
SetLanguage sets the "Language" document property of the PDF file.
func (*PDF) SetPageLayout
func (pdf *PDF) SetPageLayout(pageLayout pagelayout.PageLayout) *PDF
SetPageLayout sets the page layout. A value that is not one of pagelayout's is refused: it was written as it was, and "Single Page" broke the catalog (review of 12 October 2026, F18).
func (*PDF) SetPageMode
func (pdf *PDF) SetPageMode(pageMode pagemode.PageMode) *PDF
SetPageMode sets the page mode. A value that is not one of pagemode's is refused.
func (*PDF) SetSubject
func (pdf *PDF) SetSubject(subject string) *PDF
SetSubject sets the "Subject" document property of the PDF file.
func (*PDF) SetTitle
func (pdf *PDF) SetTitle(title string) *PDF
SetTitle sets the "Title" document property of the PDF file.
type PDFobj
type PDFobj struct { // contains filtered or unexported fields }
PDFobj is an object of a PDF that was read with PDF.Read, which holds the tokens of its dictionary and its stream. See Example_34, Example_48 and Example_50.
func (*PDFobj) AddContent
func (obj *PDFobj) AddContent(content []byte, objects *[]*PDFobj)
AddContent appends a content stream to the contents of this page.
func (*PDFobj) AddCoreFontResource
func (obj *PDFobj) AddCoreFontResource(coreFont *corefont.CoreFont, objects *[]*PDFobj) *Font
AddCoreFontResource adds a core font to the resources of this page and returns it.
func (*PDFobj) AddFontResource
func (obj *PDFobj) AddFontResource(font *Font, objects *[]*PDFobj)
AddFontResource adds font resource.
func (*PDFobj) AddImageResource
func (obj *PDFobj) AddImageResource(image *Image, objects *[]*PDFobj)
AddImageResource adds an image resource.
func (*PDFobj) AddPrefixContent
func (obj *PDFobj) AddPrefixContent(content []byte, objects *[]*PDFobj)
AddPrefixContent adds a content stream before the existing content streams of this page. The original code was provided by Stefan Ostermann author of ScribMaster and HandWrite Pro. Additional code to handle PDFs with indirect array of stream objects was written by EDragoev.
func (*PDFobj) GetContentObject
func (obj *PDFobj) GetContentObject(objects []*PDFobj) *PDFobj
GetContentObject returns the content object of the page, or nil if it has no contents. The content of a page can be split into several streams, listed in an array that is either in the page dictionary or an object of its own. Together they are one content stream, so they are returned joined in a new object, which is not in the objects list.
func (*PDFobj) GetData
func (obj *PDFobj) GetData() []byte
GetData returns the uncompressed stream data. A stream that is not a cross-reference or an object stream is decoded the first time its data is asked for, and the data is kept in the object: the first call changes the object, so two goroutines do not call it at once on the same object. The streams of one PDF that Read returns share a budget of 256 MiB of decoded data, maxDecodedTotal: a stream past what is left of it, or one that cannot be decoded, has no data, nil, as in the other ports.
func (*PDFobj) GetDict
func (obj *PDFobj) GetDict() []string
GetDict returns the object dictionary.
func (*PDFobj) GetNumber
func (obj *PDFobj) GetNumber() int
GetNumber returns the object number.
func (*PDFobj) GetPageSize
func (obj *PDFobj) GetPageSize() pagesize.PageSize
GetPageSize returns the width and height of the page, which its /MediaBox gives as the two corners of a rectangle, in either order. A page with no /MediaBox of its own, one that is not four numbers, or an empty one is letter size, as MuPDF and pdf.js draw it. PDF.GetPageObjects gives a page the box it inherits from the page tree, which a page of another program's PDF often does not carry itself, and the numbers of a box that is an object of its own or refers to them.
func (*PDFobj) GetResourcesObject
func (obj *PDFobj) GetResourcesObject(objects []*PDFobj) *PDFobj
GetResourcesObject returns the resources object of this page, or nil if it has none.
func (*PDFobj) GetValue
func (obj *PDFobj) GetValue(key string) string
GetValue returns the dictionary value for the specified key, or "" when the object has no such key. The key is an entry of the dictionary of the object, and not of a dictionary inside it: the /Type of a /Group before the /Type of a page is not the type of the page. A dictionary or an array that the PDF ends in the middle of is closed where it ends, since a PDF that was read can hold anything.
func (*PDFobj) SetGraphicsState
func (obj *PDFobj) SetGraphicsState(gs *GraphicsState, objects *[]*PDFobj) *PDFobj
SetGraphicsState sets the graphics state.
type Page
type Page struct { // contains filtered or unexported fields }
Page is used to create PDF page objects.
Please note:
- The coordinate (0.0, 0.0) is the top left corner of the page.
- Page sizes are in points; 1 point is 1/72 inch.
func NewPage
func NewPage(pdf *PDF, pageSize pagesize.PageSize) *Page
NewPage creates a page of the specified size and adds it to the PDF.
func NewPageDetached
func NewPageDetached(pdf *PDF, pageSize pagesize.PageSize) *Page
NewPageDetached creates a page of the specified size without adding it to the PDF.
func NewPageFromObject
func NewPageFromObject(pdf *PDF, pageObj *PDFobj) *Page
NewPageFromObject creates page object from PDFobj.
func (*Page) AddArcToPath
func (page *Page) AddArcToPath( x, y, rx, ry, startAngle, sweepDegrees float32) []float32
AddArcToPath adds an elliptical arc to the current path. It returns the control points and the end point of the last curve segment. A sweep of 0 adds nothing, one of more than a full turn is one full turn, and one that is not a number, or infinite, is refused.
func (*Page) AddArtifactBMC
func (page *Page) AddArtifactBMC()
AddArtifactBMC begins marked content for an artifact when the document is tagged: PDF/UA, or a PDF/A of level A.
func (*Page) AddBDC
func (page *Page) AddBDC(structure structelem.StructElem, language, actualText, altDescription string)
AddBDC begins marked content for a structure element with BDC, when the document is tagged: PDF/UA, or a PDF/A of level A.
func (*Page) AddCircularArcToPath
func (page *Page) AddCircularArcToPath( x, y, r, startAngle, sweepDegrees float32) []float32
AddCircularArcToPath adds a circular arc to the current path. It returns the control points and the end point of the last curve segment.
func (*Page) AddCoreFontResource
func (page *Page) AddCoreFontResource(coreFont *corefont.CoreFont, objects *[]*PDFobj) *Font
AddCoreFontResource adds core font to the PDF objects.
func (*Page) AddDestination
func (page *Page) AddDestination(name string, yPosition float32) *Destination
AddDestination adds destination to this page.
- name: The destination name.
- yPosition: The vertical position of the destination on this page.
func (*Page) AddDestinationAt
func (page *Page) AddDestinationAt(name string, xPosition, yPosition float32) *Destination
AddDestinationAt adds destination to this page.
- name: The destination name.
- xPosition: The horizontal position of the destination on this page.
- yPosition: The vertical position of the destination on this page.
func (*Page) AddEMC
func (page *Page) AddEMC()
AddEMC adds EMC to the page.
func (*Page) AddFontResource
func (page *Page) AddFontResource(font *Font, objects *[]*PDFobj)
AddFontResource adds font to the PDF objects.
func (*Page) AddFooter
func (page *Page) AddFooter(textLine *TextLine) [2]float32
AddFooter adds footer to this page.
func (*Page) AddFooterOffsetBy
func (page *Page) AddFooterOffsetBy(textLine *TextLine, offset float32) [2]float32
AddFooterOffsetBy adds footer to this page offset by the specified value.
func (*Page) AddHeader
func (page *Page) AddHeader(textLine *TextLine) [2]float32
AddHeader adds header to this page.
func (*Page) AddHeaderOffsetBy
func (page *Page) AddHeaderOffsetBy(textLine *TextLine, offset float32) [2]float32
AddHeaderOffsetBy adds header to this page offset by the specified value.
func (*Page) AddImageResource
func (page *Page) AddImageResource(image *Image, objects *[]*PDFobj)
AddImageResource adds an image to the PDF objects.
func (*Page) AddWatermark
func (page *Page) AddWatermark(font *Font, text string)
AddWatermark add watermark to the page.
func (*Page) BeginStructElement
func (page *Page) BeginStructElement(structure structelem.StructElem)
BeginStructElement begins a structure element of a tagged document, PDF/UA or a PDF/A of level A, that what is drawn until EndStructElement becomes the kids of, like the L of a list whose items are drawn one at a time. The calls nest, and every one needs its EndStructElement. In a document that is not tagged both do nothing.
A list of two items is:
page.BeginStructElement(structelem.L)
for i, item := range items {
page.BeginStructElement(structelem.LI)
pdfjet.NewTextLine(font, strconv.Itoa(i+1)+".").
SetStructureType(structelem.Lbl).SetLocation(70, y).DrawOn(page)
pdfjet.NewTextLine(font, item).
SetStructureType(structelem.LBody).SetLocation(90, y).DrawOn(page)
page.EndStructElement()
}
page.EndStructElement()
func (*Page) BezierCurveTo
func (page *Page) BezierCurveTo(p1, p2, p3 *Point)
BezierCurveTo draw a Bézier curve starting from the current point. Please note: You must call the fillPath, closePath or strokePath method after the last bezierCurveTo call.
Author: Pieter Libin, pieter@emweb.be
- p1: first control point
- p2: second control point
- p3: end point
func (*Page) ClipPath
func (page *Page) ClipPath()
ClipPath clips the path.
func (*Page) ClipRect
func (page *Page) ClipRect(x, y, w, h float32)
ClipRect sets the clipping path to the specified rectangle.
func (*Page) ClosePath
func (page *Page) ClosePath()
ClosePath closes the path and draws it using the current pen color.
func (*Page) Complete
func (page *Page) Complete(objects *[]*PDFobj)
Complete completes adding content to the existing PDF. The content of the page is drawn first, in a q and a Q of its own, so that what it leaves set, a scale or a text rendering mode, does not change what is drawn after it; and a page with no content gets this one (review of 12 October 2026, F2).
func (*Page) CurveTo
func (page *Page) CurveTo(x1, y1, x2, y2, x3, y3 float32)
CurveTo adds a cubic Bézier curve command to the page’s content stream. The coordinates (x1,y1) and (x2,y2) are the two control points, and (x3,y3) is the end point of the curve.
func (*Page) DrawCircle
func (page *Page) DrawCircle(x, y, r float32)
DrawCircle draws a circle on the page.
The outline of the circle is drawn using the current pen color.
- x: the x coordinate of the center of the circle to be drawn.
- y: the y coordinate of the center of the circle to be drawn.
- r: the radius of the circle to be drawn.
func (*Page) DrawContents
func (page *Page) DrawContents( content []byte, h float32, x float32, y float32, xScale float32, yScale float32)
DrawContents draws the contents on the page.
func (*Page) DrawEllipse
func (page *Page) DrawEllipse(x, y, r1, r2 float32)
DrawEllipse draws an ellipse on the page using the current pen color.
- x: the x coordinate of the center of the ellipse to be drawn.
- y: the y coordinate of the center of the ellipse to be drawn.
- r1: the horizontal radius of the ellipse to be drawn.
- r2: the vertical radius of the ellipse to be drawn.
func (*Page) DrawLine
func (page *Page) DrawLine(x1, y1, x2, y2 float32)
DrawLine draws a line on the page, using the current color, between the points (x1, y1) and (x2, y2).
func (*Page) DrawPath
func (page *Page) DrawPath(path []*Point, pathOperator pathoperator.PathOperator)
DrawPath draws a path consisting of multiple points using the specified path operator. The path can include both straight lines and Bézier curves defined by control points.
path: A slice of Points that defines the path. Fewer than two points paint nothing. pathOperator: The PDF path painting operator to apply, for example pathoperator.Stroke or pathoperator.Fill.
The method starts at the first point and processes subsequent points as either line segments or curve control points based on their controlPoint field. A path that ends on a control point, whose curve has no end, is refused and nothing of it is drawn.
func (*Page) DrawPoint
func (page *Page) DrawPoint(p *Point)
DrawPoint draws a point on the page using the current pen color.
- p: the point.
func (*Page) DrawRect
func (page *Page) DrawRect(x, y, w, h float32)
DrawRect draws the outline of the specified rectangle on the page. The left and right edges of the rectangle are at x and x + w. The top and bottom edges are at y and y + h. The rectangle is drawn using the current pen color.
- x: the x coordinate of the rectangle to be drawn.
- y: the y coordinate of the rectangle to be drawn.
- w: the width of the rectangle to be drawn.
- h: the height of the rectangle to be drawn.
func (*Page) DrawRoundedRect
func (page *Page) DrawRoundedRect(x, y, w, h, r1, r2 float32)
DrawRoundedRect draws the outline of a rectangle with rounded corners using the current pen color.
- x: the x coordinate of the top left corner.
- y: the y coordinate of the top left corner.
- w: the width.
- h: the height.
- r1: the horizontal radius of the corners.
- r2: the vertical radius of the corners.
func (*Page) DrawString
func (page *Page) DrawString(font, fallbackFont *Font, fontSize float32, text string, x, y float32)
DrawString draws the string in black at the x, y location. The fallback font is used for the characters the main font does not have.
func (*Page) DrawStringUsingFontSize
func (page *Page) DrawStringUsingFontSize( font *Font, fontSize float32, text string, x, y float32)
DrawStringUsingFontSize draws a string using the specified font and font size at the x, y location. The baseline of the leftmost character is at (x, y).
func (*Page) DrawStringUsingSpacing
func (page *Page) DrawStringUsingSpacing(font *Font, fontSize float32, text string, x, y, dx float32)
DrawStringUsingSpacing draws the characters of the string dx apart, the first one at (x, y).
func (*Page) EndStructElement
func (page *Page) EndStructElement()
EndStructElement ends the structure element that BeginStructElement began.
func (*Page) FillCircle
func (page *Page) FillCircle(x, y, r float32)
FillCircle fills a circle on the page using the current brush color.
- x: the x coordinate of the center of the circle to be filled.
- y: the y coordinate of the center of the circle to be filled.
- r: the radius of the circle to be filled.
func (*Page) FillEllipse
func (page *Page) FillEllipse(x, y, r1, r2 float32)
FillEllipse fills an ellipse on the page using the current brush color.
- x: the x coordinate of the center of the ellipse to be drawn.
- y: the y coordinate of the center of the ellipse to be drawn.
- r1: the horizontal radius of the ellipse to be drawn.
- r2: the vertical radius of the ellipse to be drawn.
func (*Page) FillPath
func (page *Page) FillPath()
FillPath closes and fills the path with the current brush color.
func (*Page) FillRect
func (page *Page) FillRect(x, y, w, h float32)
FillRect fills the specified rectangle on the page. The left and right edges of the rectangle are at x and x + w. The top and bottom edges are at y and y + h. The rectangle is drawn using the current brush color.
- x: the x coordinate of the rectangle to be drawn.
- y: the y coordinate of the rectangle to be drawn.
- w: the width of the rectangle to be drawn.
- h: the height of the rectangle to be drawn.
func (*Page) FillRoundedRect
func (page *Page) FillRoundedRect(x, y, w, h, r1, r2 float32)
FillRoundedRect fills a rectangle with rounded corners using the current brush color.
- x: the x coordinate of the top left corner.
- y: the y coordinate of the top left corner.
- w: the width.
- h: the height.
- r1: the horizontal radius of the corners.
- r2: the vertical radius of the corners.
func (*Page) GetBrushColor
func (page *Page) GetBrushColor() [3]float32
GetBrushColor returns the current brush color as an RGB float32 array. The returned array contains three float32 values representing the red, green, and blue components of the brush color, each in the range [0.0, 1.0].
Returns a [3]float32 array with the brush color in RGB format.
The array contains values in the range [0.0, 1.0] corresponding to the red, green, and blue color components.
func (*Page) GetContent
func (page *Page) GetContent() []byte
GetContent returns a copy of the content stream of this page.
func (*Page) GetHeight
func (page *Page) GetHeight() float32
GetHeight returns the height of this page.
func (*Page) GetPenColor
func (page *Page) GetPenColor() [3]float32
GetPenColor returns the current pen color as an RGB float32 array. The returned array contains three float32 values representing the red, green, and blue components of the pen color, each in the range [0.0, 1.0].
Returns a [3]float32 array with the pen color in RGB format.
The array contains values in the range [0.0, 1.0] corresponding to the red, green, and blue color components.
func (*Page) GetPenWidth
func (page *Page) GetPenWidth() float32
GetPenWidth returns the current pen width.
func (*Page) GetWidth
func (page *Page) GetWidth() float32
GetWidth returns the width of this page.
func (*Page) InvertYAxis
func (page *Page) InvertYAxis()
InvertYAxis inverts the Y axis.
func (*Page) LineTo
func (page *Page) LineTo(x, y float32)
LineTo draws a line from the current pen position to the point with coordinates (x, y), using the current pen width and stroke color. Make sure you call strokePath(), closePath() or fillPath() after the last call to this method.
func (*Page) MoveTo
func (page *Page) MoveTo(x, y float32)
MoveTo moves the pen to the point with coordinates (x, y) on the page.
- x: the x coordinate of new pen position.
- y: the y coordinate of new pen position.
func (*Page) RestoreGraphicsState
func (page *Page) RestoreGraphicsState()
RestoreGraphicsState restores the last saved graphics state. Please see Example_30.
func (*Page) SaveGraphicsState
func (page *Page) SaveGraphicsState()
SaveGraphicsState saves the current graphics state. Please see Example_30.
func (*Page) SetArtBox
func (page *Page) SetArtBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
SetArtBox sets the page ArtBox. See page 77 of the PDF32000_2008.pdf specification.
- upperLeftX: the top left X coordinate of the ArtBox.
- upperLeftY: the top left Y coordinate of the ArtBox.
- lowerRightX: the bottom right X coordinate of the ArtBox.
- lowerRightY: the bottom right Y coordinate of the ArtBox.
func (*Page) SetBleedBox
func (page *Page) SetBleedBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
SetBleedBox sets the page BleedBox. See page 77 of the PDF32000_2008.pdf specification.
- upperLeftX: the top left X coordinate of the BleedBox.
- upperLeftY: the top left Y coordinate of the BleedBox.
- lowerRightX: the bottom right X coordinate of the BleedBox.
- lowerRightY: the bottom right Y coordinate of the BleedBox.
func (*Page) SetBrushColor
func (page *Page) SetBrushColor(c int32) *Page
SetBrushColor sets the brush color using a packed RGB color integer. The color should be provided in the 0x00RRGGBB format (hexadecimal), where RR, GG, and BB represent the red, green, and blue components of the color, respectively, each in the range 00 to FF (0-255).
Parameters:
color: A 32-bit integer representing the color in the format 0x00RRGGBB.
The method converts this integer into RGB float values between 0.0 and 1.0,
and sets the brush color accordingly.
Notes:
- The color components are extracted by bit-shifting and masking the integer to separate the red, green, and blue channels. Each component is then scaled to a float value between 0.0 and 1.0 (by dividing by 255).
- The method calls SetBrushColorRGB internally to apply the color using float32 values.
color.Transparent leaves it unchanged.
func (*Page) SetBrushColorCMYK
func (page *Page) SetBrushColorCMYK(c, m, y, k float32) *Page
SetBrushColorCMYK sets the color for brush operations using CMYK. This is the color used when drawing regular text and filling shapes.
- c: the cyan component is float value from 0.0 to 1.0.
- m: the magenta component is float value from 0.0 to 1.0.
- y: the yellow component is float value from 0.0 to 1.0.
- k: the black component is float value from 0.0 to 1.0.
func (*Page) SetBrushColorRGB
func (page *Page) SetBrushColorRGB(rgbColor [3]float32) *Page
SetBrushColorRGB sets the brush color using an RGB color array. Each element in the array represents the red, green, and blue components of the color as floating-point values between 0.0 and 1.0.
Parameters:
rgbColor: A fixed-size array of 3 float32 values representing the red, green, and blue color components respectively. Each value should be between 0.0 (no intensity) and 1.0 (full intensity).
Notes:
- The method performs a range check to ensure that each color component is within the valid range [0.0, 1.0]. If any component is out of range, the method prints a warning and exits early without modifying the color.
- The method then sets the brushColor and appends the color values to the appropriate output stream (e.g., for a PDF or graphics context).
func (*Page) SetCropBox
func (page *Page) SetCropBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
SetCropBox sets the page CropBox. See page 77 of the PDF32000_2008.pdf specification.
- upperLeftX: the top left X coordinate of the CropBox.
- upperLeftY: the top left Y coordinate of the CropBox.
- lowerRightX: the bottom right X coordinate of the CropBox.
- lowerRightY: the bottom right Y coordinate of the CropBox.
func (*Page) SetDefaultPenWidth
func (page *Page) SetDefaultPenWidth() *Page
SetDefaultPenWidth sets the line width to the default. The default is the finest line width.
func (*Page) SetDefaultStrokeDashPattern
func (page *Page) SetDefaultStrokeDashPattern() *Page
SetDefaultStrokeDashPattern sets the default line dash pattern - solid line.
func (*Page) SetFigureBoundingBox
func (page *Page) SetFigureBoundingBox(x, y, w, h float32)
SetFigureBoundingBox sets the bounding box of the figure that AddBDC began last: the box it is drawn in, x and y its top left corner, w wide and h tall. PDF/UA asks for the bounding box of every figure, which a screen reader or a program that reflows the page uses to find it. The figures of the library, images, SVG images, charts, barcodes and QR codes, set it themselves; a figure drawn with AddBDC and AddEMC around other drawing needs it set before AddEMC. It does nothing in a document that is not tagged.
func (*Page) SetGraphicsState
func (page *Page) SetGraphicsState(gs *GraphicsState) *Page
SetGraphicsState sets the graphics state. Please see Example_30.
- gs: the graphics state to use.
func (*Page) SetLineCapStyle
func (page *Page) SetLineCapStyle(style capstyle.CapStyle) *Page
SetLineCapStyle sets the current line cap style. Supported values: capstyle.Butt, capstyle.Round and capstyle.ProjectingSquare
func (*Page) SetLineJoinStyle
func (page *Page) SetLineJoinStyle(style joinstyle.JoinStyle) *Page
SetLineJoinStyle sets the line join style. Supported values: joinstyle.Miter, joinstyle.Round and joinstyle.Bevel
func (*Page) SetPenColor
func (page *Page) SetPenColor(c int32) *Page
SetPenColor sets the pen color using a packed RGB color integer. The color should be provided in the 0x00RRGGBB format (hexadecimal), where RR, GG, and BB represent the red, green, and blue components of the color, respectively, each in the range 00 to FF (0-255).
Parameters:
color: A 32-bit integer representing the color in the format 0x00RRGGBB.
The method converts this integer into RGB float values between 0.0 and 1.0,
and sets the pen color accordingly.
Notes:
- The color components are extracted by bit-shifting and masking the integer to separate the red, green, and blue channels. Each component is then scaled to a float value between 0.0 and 1.0 (by dividing by 255).
- The method calls SetPenColorRGB internally to apply the color using float32 values.
color.Transparent leaves it unchanged.
func (*Page) SetPenColorCMYK
func (page *Page) SetPenColorCMYK(c, m, y, k float32) *Page
SetPenColorCMYK sets the color for stroking operations using CMYK. The pen color is used when drawing lines and splines.
- c: the cyan component is float value from 0.0 to 1.0.
- m: the magenta component is float value from 0.0 to 1.0.
- y: the yellow component is float value from 0.0 to 1.0.
- k: the black component is float value from 0.0 to 1.0.
func (*Page) SetPenColorRGB
func (page *Page) SetPenColorRGB(rgbColor [3]float32) *Page
SetPenColorRGB sets the pen color using an RGB color array. Each element in the array represents the red, green, and blue components of the color as floating-point values between 0.0 and 1.0.
Parameters:
rgbColor: A fixed-size array of 3 float32 values representing the red, green, and blue color components respectively. Each value should be between 0.0 (no intensity) and 1.0 (full intensity).
Notes:
- The method performs a range check to ensure that each color component is within the valid range [0.0, 1.0]. If any component is out of range, the method prints a warning and exits early without modifying the color.
- The method then sets the penColor and appends the color values to the appropriate output stream (e.g., for a PDF or graphics context).
func (*Page) SetPenWidth
func (page *Page) SetPenWidth(width float32) *Page
SetPenWidth sets the pen width that will be used to draw lines and splines on this page.
func (*Page) SetRotation
func (page *Page) SetRotation(degrees int) *Page
SetRotation rotates this page clockwise when it is displayed, by 0, 90, 180 or 270 degrees, as every rotation in PDFjet turns and as /Rotate does. Other angles are ignored.
func (*Page) SetStrokeDashPattern
func (page *Page) SetStrokeDashPattern(strokeDashPattern string) *Page
SetStrokeDashPattern the stroke dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by a dash array and a dash phase. The elements of the dash array are positive numbers that specify the lengths of alternating dashes and gaps. The dash phase specifies the distance into the dash pattern at which to start the dash. The elements of both the dash array and the dash phase are expressed in user space units.
Examples of line dash patterns:
"[Array] Phase" Appearance Description _______________ _________________ ____________________________________ "[] 0" ----------------- Solid line "[3] 0" --- --- --- 3 units on, 3 units off, ... "[2] 1" - -- -- -- -- 1 on, 2 off, 2 on, 2 off, ... "[2 1] 0" -- -- -- -- -- -- 2 on, 1 off, 2 on, 1 off, ... "[3 5] 6" --- --- 2 off, 3 on, 5 off, 3 on, 5 off, ... "[2 3] 11" - -- -- -- 1 on, 3 off, 2 on, 3 off, 2 on, ... - strokeDashPattern: the line dash pattern.
func (*Page) SetTextRenderingMode
func (page *Page) SetTextRenderingMode(mode int) (*Page, error)
SetTextRenderingMode sets the text rendering mode for the page. The mode determines how text is rendered, and must be an integer value between 0 and 7 (inclusive).
Parameters:
mode (int): the text rendering mode to set (0 to 7)
Example usage:
page.SetTextRenderingMode(3)
It returns an error when the mode is not 0 to 7.
func (*Page) SetTextRotation
func (page *Page) SetTextRotation(degrees int) *Page
SetTextRotation sets the rotation, in degrees, of the text that is drawn next. A positive angle turns clockwise, as every rotation in PDFjet turns, and a negative angle counterclockwise.
Parameters:
degrees (int): the angle (in degrees) to set the text direction
Example usage:
page.SetTextRotation(90)
func (*Page) SetTrimBox
func (page *Page) SetTrimBox(upperLeftX, upperLeftY, lowerRightX, lowerRightY float32) *Page
SetTrimBox sets the page TrimBox. See page 77 of the PDF32000_2008.pdf specification.
- upperLeftX: the top left X coordinate of the TrimBox.
- upperLeftY: the top left Y coordinate of the TrimBox.
- lowerRightX: the bottom right X coordinate of the TrimBox.
- lowerRightY: the bottom right Y coordinate of the TrimBox.
func (*Page) StrokePath
func (page *Page) StrokePath()
StrokePath draws the path using the current pen color.
func (*Page) Transform
func (page *Page) Transform(values []float32)
Transform concatenates a transformation matrix to the current one. Save the graphics state before and restore it after. The values are the scale x, skew x, translate x, skew y, scale y and translate y at the MScaleX to MTransY indices, the first six values of an Android Matrix.getValues() array. The page height is divided by the vertical scale.
type Paragraph
type Paragraph struct { // contains filtered or unexported fields }
Paragraph is used to create paragraph objects. See the TextColumn class for more information.
func NewParagraph
func NewParagraph() *Paragraph
NewParagraph creates a paragraph.
func ParagraphsFromFile
func ParagraphsFromFile(f1 *Font, filePath string) []*Paragraph
ParagraphsFromFile reads a text file and returns its paragraphs. An empty line separates the paragraphs. It panics if the file cannot be read.
func (*Paragraph) Add
func (paragraph *Paragraph) Add(text *TextLine) *Paragraph
Add adds a text line to this paragraph.
func (*Paragraph) AddJoined
func (paragraph *Paragraph) AddJoined(text *TextLine) *Paragraph
AddJoined adds a text line that goes on from the text before it with no space between them, so that a word can change its font or its color partway through: a word in bold followed by a comma in the regular font, or a link that ends before the period after it. A row of text does not break between the two. When the text line starts with a space, or the text before it ends with one, the two are apart as they are with Add. Text in Chinese, Japanese or Korean is not joined.
func (*Paragraph) GetTextLines
func (paragraph *Paragraph) GetTextLines() []*TextLine
GetTextLines returns the text lines of this paragraph.
func (*Paragraph) GetTextX
func (paragraph *Paragraph) GetTextX() float32
GetTextX returns the x coordinate where the text of this paragraph starts.
func (*Paragraph) GetTextY
func (paragraph *Paragraph) GetTextY() float32
GetTextY returns the baseline y coordinate of the first line of this paragraph.
func (*Paragraph) GetX1
func (paragraph *Paragraph) GetX1() float32
GetX1 returns the x coordinate of the top left corner of this paragraph.
func (*Paragraph) GetX2
func (paragraph *Paragraph) GetX2() float32
GetX2 returns the x coordinate where the last line of this paragraph ends.
func (*Paragraph) GetY1
func (paragraph *Paragraph) GetY1() float32
GetY1 returns the y coordinate of the top left corner of this paragraph.
func (*Paragraph) GetY2
func (paragraph *Paragraph) GetY2() float32
GetY2 returns the y coordinate of the bottom of the last line of this paragraph.
func (*Paragraph) SetHighlightColors
func (paragraph *Paragraph) SetHighlightColors(colorMap map[string]int32) *Paragraph
SetHighlightColors sets the word highlight colors of all lines in this paragraph.
func (*Paragraph) SetListLabel
func (paragraph *Paragraph) SetListLabel(label *TextLine, indent float32) *Paragraph
SetListLabel makes this paragraph an item of a list, labelled by the text line, which is drawn indent points to the left of the text of the paragraph and on the baseline of its first line. A run of paragraphs that have a label is a list: in a PDF/UA document it is an L of an LI for each paragraph, each holding the Lbl of its label and the LBody of its text, so that a reader reads the label of an item before the item, however the two are drawn.
func (*Paragraph) SetStructureType
func (paragraph *Paragraph) SetStructureType( structureType structelem.StructElem) *Paragraph
SetStructureType sets the structure element type of this paragraph, for a PDF/UA document: structelem.H1 to structelem.H6 for a heading, and structelem.P, which it is, for a paragraph. The paragraph is one element however many lines and words it is drawn in.
func (*Paragraph) SetTextAlignment
func (paragraph *Paragraph) SetTextAlignment(textAlignment alignment.Alignment) *Paragraph
SetTextAlignment sets the alignment of the text in this paragraph: alignment.Left, alignment.Right, alignment.Center or alignment.Justify. A paragraph with no alignment set takes the alignment of the text column it is drawn in.
func (*Paragraph) SetTextColor
func (paragraph *Paragraph) SetTextColor(c int32) *Paragraph
SetTextColor sets the text color of all lines in this paragraph. color.Transparent leaves it unchanged.
func (*Paragraph) SetTextColorRGB
func (paragraph *Paragraph) SetTextColorRGB(rgbColor [3]float32) *Paragraph
SetTextColorRGB sets the text color of all lines in this paragraph from red, green and blue values.
func (*Paragraph) StartsWith
func (paragraph *Paragraph) StartsWith(token string) bool
StartsWith returns true if the first line of this paragraph starts with the specified token.
type Path
type Path struct { // contains filtered or unexported fields }
Path is used to create path objects. The path objects may consist of lines, splines or both. Please see Example_34 and Example_40.
func NewPath
func NewPath() *Path
NewPath creates an empty path.
func (*Path) Add
func (path *Path) Add(point *Point) *Path
Add adds a point to this path.
- point: the point to add.
Returns this Path object.
func (*Path) DrawOn
func (path *Path) DrawOn(page *Page) [2]float32
DrawOn draws this path on the specified page. If fillShape is set the shape is filled with the stroke color; otherwise the path is stroked with its width, dash pattern, cap style and join style.
- page: the page to draw this path on.
Returns x and y coordinates of the bottom right corner of this component.
func (*Path) GetLineCapStyle
func (path *Path) GetLineCapStyle() capstyle.CapStyle
GetLineCapStyle returns the line cap style for this path. Returns the line cap style for this path.
func (*Path) GetLineJoinStyle
func (path *Path) GetLineJoinStyle() joinstyle.JoinStyle
GetLineJoinStyle returns the line join style. Returns the line join style.
func (*Path) ScaleBy
func (path *Path) ScaleBy(factor float32) *Path
ScaleBy scales the points of this path by the specified factor.
- factor: the factor used to scale the path.
Returns this Path object.
func (*Path) SetClosed
func (path *Path) SetClosed(closed bool) *Path
SetClosed sets whether a line is drawn from the last point of this path back to the first.
- closed: true to close the path.
Returns this Path object.
func (*Path) SetFillShape
func (path *Path) SetFillShape(fillShape bool) *Path
SetFillShape sets whether the shape of this path is filled with the stroke color instead of stroked.
- fillShape: true to fill the shape.
Returns this Path object.
func (*Path) SetLineCapStyle
func (path *Path) SetLineCapStyle(style capstyle.CapStyle) *Path
SetLineCapStyle sets the line cap style.
- style: the cap style of this path. Supported values: capstyle.Butt, capstyle.Round and capstyle.ProjectingSquare
Returns this Path object.
func (*Path) SetLineJoinStyle
func (path *Path) SetLineJoinStyle(style joinstyle.JoinStyle) *Path
SetLineJoinStyle sets the line join style.
- style: the line join style. Supported values: joinstyle.Miter, joinstyle.Round and joinstyle.Bevel
Returns this Path object.
func (*Path) SetLocation
func (path *Path) SetLocation(x, y float32) Drawable
SetLocation sets the location of this path: its points are drawn offset by x and y.
- x: the x offset.
- y: the y offset.
Returns this Path object.
func (*Path) SetStrokeColor
func (path *Path) SetStrokeColor(c int32) *Path
SetStrokeColor sets the stroke color that will be used to draw this path.
- color: the color specified as an integer.
Returns this Path object. color.Transparent leaves it unchanged.
func (*Path) SetStrokeColorRGB
func (path *Path) SetStrokeColorRGB(rgbColor [3]float32) *Path
SetStrokeColorRGB sets the color of this path from red, green and blue values.
func (*Path) SetStrokeDashPattern
func (path *Path) SetStrokeDashPattern(pattern string) *Path
SetStrokeDashPattern sets the line dash pattern for this path.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by a dash array and a dash phase. The elements of the dash array are positive numbers that specify the lengths of alternating dashes and gaps. The dash phase specifies the distance into the dash pattern at which to start the dash. The elements of both the dash array and the dash phase are expressed in user space units.
Examples of line dash patterns:
"[Array] Phase" Appearance Description _______________ _________________ ____________________________________ "[] 0" ----------------- Solid line "[3] 0" --- --- --- 3 units on, 3 units off, ... "[2] 1" - -- -- -- -- 1 on, 2 off, 2 on, 2 off, ... "[2 1] 0" -- -- -- -- -- -- 2 on, 1 off, 2 on, 1 off, ... "[3 5] 6" --- --- 2 off, 3 on, 5 off, 3 on, 5 off, ... "[2 3] 11" - -- -- -- 1 on, 3 off, 2 on, 3 off, 2 on, ... - pattern: the line dash pattern.
Returns this Path object.
func (*Path) SetStrokeWidth
func (path *Path) SetStrokeWidth(width float32) *Path
SetStrokeWidth sets the stroke width that will be used to draw the lines and splines that are part of this path.
- width: the stroke width.
Returns this Path object.
type Point
type Point struct { // contains filtered or unexported fields }
Point is a point with a marker: a shape drawn around its (x, y) coordinates, which are the center of the marker. A point is drawn on a page on its own, as the marker of a table cell, or in a chart Series, and a slice of points is a path for Page.DrawPath. Please see Example_05.
func NewControlPointC
func NewControlPointC(x, y float32) *Point
NewControlPointC creates a "c" type control point for cubic Bézier curves.
- x: the x coordinate of this point.
- y: the y coordinate of this point.
func NewControlPointV
func NewControlPointV(x, y float32) *Point
NewControlPointV creates a "v" type control point for cubic Bézier curves.
- x: the x coordinate of this point.
- y: the y coordinate of this point.
func NewControlPointY
func NewControlPointY(x, y float32) *Point
NewControlPointY creates a "y" type control point for cubic Bézier curves.
- x: the x coordinate of this point.
- y: the y coordinate of this point.
func NewPoint
func NewPoint(x, y float32) *Point
NewPoint constructor for creating point objects.
- x: the x coordinate of this point when drawn on the page.
- y: the y coordinate of this point when drawn on the page.
func (*Point) DrawOn
func (point *Point) DrawOn(page *Page) [2]float32
DrawOn draws this point on the specified page.
- page: the page to draw this point on.
Returns x and y coordinates of the bottom right corner of this component.
func (*Point) GetAltDescription
func (point *Point) GetAltDescription() string
GetAltDescription returns what the point stands for, or "".
func (*Point) GetFillColor
func (point *Point) GetFillColor() [3]float32
GetFillColor returns the fill color as red, green and blue values.
func (*Point) GetRadius
func (point *Point) GetRadius() float32
GetRadius returns the radius of this point. Returns the radius of this point.
func (*Point) GetShape
func (point *Point) GetShape() shape.Shape
GetShape returns the shape of the marker drawn at this point.
func (*Point) GetStrokeColor
func (point *Point) GetStrokeColor() [3]float32
GetStrokeColor returns the stroke color as red, green and blue values.
func (*Point) GetStrokeWidth
func (point *Point) GetStrokeWidth() float32
GetStrokeWidth returns the width of the lines used to draw this point. Returns the stroke width.
func (*Point) GetURIAction
func (point *Point) GetURIAction() string
GetURIAction returns the URI of the link opened by a click on this point. Returns the URI, or "".
func (*Point) GetX
func (point *Point) GetX() float32
GetX returns the x coordinate of this point. Returns the x coordinate of this point.
func (*Point) GetY
func (point *Point) GetY() float32
GetY returns the y coordinate of this point. Returns the y coordinate of this point.
func (*Point) SetAltDescription
func (point *Point) SetAltDescription(altDescription string) *Point
SetAltDescription sets what a point that is a link stands for, like the country a point of a chart is, for a screen reader: in a tagged document, PDF/UA or a PDF/A of level A, a point of a chart that is a link is a figure of its own in the Link, described by it. Without one it is described by its URI.
- altDescription: what the point stands for.
func (*Point) SetFillColor
func (point *Point) SetFillColor(fillColor int32) *Point
SetFillColor sets the fill color as a 0xRRGGBB value. color.Transparent leaves it unchanged.
func (*Point) SetFillColorRGB
func (point *Point) SetFillColorRGB(rgbColor [3]float32) *Point
SetFillColorRGB sets the fill color from red, green and blue values.
func (*Point) SetLocation
func (point *Point) SetLocation(x, y float32) Drawable
SetLocation sets the location (x, y) of this point.
- x: the x coordinate of this point when drawn on the page.
- y: the y coordinate of this point when drawn on the page.
func (*Point) SetRadius
func (point *Point) SetRadius(r float32) *Point
SetRadius sets the radius of this point.
- r: the radius.
func (*Point) SetShape
func (point *Point) SetShape(pointShape shape.Shape) *Point
SetShape sets the shape of the marker drawn at this point, for example shape.Circle; shape.Invisible draws no marker.
func (*Point) SetStrokeColor
func (point *Point) SetStrokeColor(strokeColor int32) *Point
SetStrokeColor sets the stroke color as a 0xRRGGBB value. color.Transparent leaves it unchanged.
func (*Point) SetStrokeColorRGB
func (point *Point) SetStrokeColorRGB(rgbColor [3]float32) *Point
SetStrokeColorRGB sets the stroke color from red, green and blue values.
func (*Point) SetStrokeWidth
func (point *Point) SetStrokeWidth(strokeWidth float32) *Point
SetStrokeWidth sets the width of the lines used to draw this point.
func (*Point) SetURIAction
func (point *Point) SetURIAction(uri string) *Point
SetURIAction sets the URI of the link opened by a click on this point.
- uri: the URI.
func (*Point) SetX
func (point *Point) SetX(x float32) *Point
SetX sets the x coordinate of this point.
- x: the x coordinate of this point when drawn on the page.
func (*Point) SetY
func (point *Point) SetY(y float32) *Point
SetY sets the y coordinate of this point.
- y: the y coordinate of this point when drawn on the page.
type PolygonAnnotation
type PolygonAnnotation struct { BaseAnnotation }
PolygonAnnotation extends BaseAnnotation to represent a polygon.
func NewPolygonAnnotation
func NewPolygonAnnotation() *PolygonAnnotation
NewPolygonAnnotation acts as the constructor.
func (*PolygonAnnotation) SetVertices
func (p *PolygonAnnotation) SetVertices(vertices []float32) *PolygonAnnotation
SetVertices sets the vertices for the polygon.
type RadioButton
type RadioButton struct { // contains filtered or unexported fields }
RadioButton is used to create radio button, which can be set selected or unselected.
func NewRadioButton
func NewRadioButton(font *Font, label string) *RadioButton
NewRadioButton creates RadioButton that is not selected.
func (*RadioButton) DrawOn
func (radioButton *RadioButton) DrawOn(page *Page) [2]float32
DrawOn draws this RadioButton on the specified Page.
- page: the Page where the RadioButton is to be drawn.
Returns x and y coordinates of the bottom right corner of this component.
func (*RadioButton) Select
func (radioButton *RadioButton) Select(selected bool) *RadioButton
Select selects or deselects this radio button.
- selected: the selection flag.
Returns this RadioButton.
func (*RadioButton) SetActualText
func (radioButton *RadioButton) SetActualText(actualText string) *RadioButton
SetActualText sets the actual text for this radio button.
- actualText: the actual text for the radio button.
Returns this RadioButton.
func (*RadioButton) SetAltDescription
func (radioButton *RadioButton) SetAltDescription(altDescription string) *RadioButton
SetAltDescription sets the alternate description of this radio button.
- altDescription: the alternate description of the radio button.
Returns this RadioButton.
func (*RadioButton) SetFontSize
func (radioButton *RadioButton) SetFontSize(fontSize float32) *RadioButton
SetFontSize sets the size of the label text. The font keeps its own size.
func (*RadioButton) SetLocation
func (radioButton *RadioButton) SetLocation(x, y float32) Drawable
SetLocation sets the x,y location on the Page.
- x: the x coordinate on the Page.
- y: the y coordinate on the Page.
Returns this RadioButton.
func (*RadioButton) SetURIAction
func (radioButton *RadioButton) SetURIAction(uri string) *RadioButton
SetURIAction sets the URI for the "click text line" action.
- uri: the URI.
Returns this RadioButton.
type Rect
type Rect struct { // contains filtered or unexported fields }
Rect is used to create rectangular shapes on a page.
func NewRect
func NewRect(x, y, w, h float32) *Rect
NewRect creates new Rect object.
- x: the x coordinate of the top left corner of this rect when drawn on the page.
- y: the y coordinate of the top left corner of this rect when drawn on the page.
- w: the width of this rect.
- h: the height of this rect.
func (*Rect) DrawOn
func (rect *Rect) DrawOn(page *Page) [2]float32
DrawOn draws this rect on the specified page.
- page: the page to draw this rect on.
Returns x and y coordinates of the bottom right corner of this component.
func (*Rect) ScaleBy
func (rect *Rect) ScaleBy(factor float32) *Rect
ScaleBy scales the width, height and corner radius of this rect by the specified factor. The location does not change.
- factor: the factor used to scale the rect.
func (*Rect) SetActualText
func (rect *Rect) SetActualText(actualText string) *Rect
SetActualText sets the actual text for this rect.
- actualText: the actual text for the rect.
Returns this Rect.
func (*Rect) SetAltDescription
func (rect *Rect) SetAltDescription(altDescription string) *Rect
SetAltDescription sets the alternate description of this rect.
- altDescription: the alternate description of the rect.
Returns this Rect.
func (*Rect) SetBorderColor
func (rect *Rect) SetBorderColor(borderColor int32) *Rect
SetBorderColor sets the border color as a 0xRRGGBB value. color.Transparent removes the border.
func (*Rect) SetBorderColorRGB
func (rect *Rect) SetBorderColorRGB(borderColor [3]float32) *Rect
SetBorderColorRGB sets the border color from red, green and blue values.
func (*Rect) SetBorderDashPattern
func (rect *Rect) SetBorderDashPattern(borderPattern string) *Rect
SetBorderDashPattern sets the line dash pattern of the border.
func (*Rect) SetBorderWidth
func (rect *Rect) SetBorderWidth(borderWidth float32) *Rect
SetBorderWidth sets the border width.
func (*Rect) SetCornerRadius
func (rect *Rect) SetCornerRadius(cornerRadius float32) *Rect
SetCornerRadius sets the corner radius.
func (*Rect) SetFillColor
func (rect *Rect) SetFillColor(fillColor int32) *Rect
SetFillColor sets the fill color as a 0xRRGGBB value. color.Transparent leaves it unchanged.
func (*Rect) SetFillColorRGB
func (rect *Rect) SetFillColorRGB(fillColor [3]float32) *Rect
SetFillColorRGB sets the fill color from red, green and blue values.
func (*Rect) SetGoToAction
func (rect *Rect) SetGoToAction(key string) *Rect
SetGoToAction sets the destination key for the action.
- key: the destination name.
func (*Rect) SetLanguage
func (rect *Rect) SetLanguage(language string) *Rect
SetLanguage sets the language of this rect, used for accessibility. When it is not set, the language of the document is used.
- language: the language, for example "en-US".
func (*Rect) SetLocation
func (rect *Rect) SetLocation(x, y float32) Drawable
SetLocation sets the location of this rect on the page.
- x: the x coordinate of the top left corner of this rect when drawn on the page.
- y: the y coordinate of the top left corner of this rect when drawn on the page.
func (*Rect) SetSize
func (rect *Rect) SetSize(w, h float32) *Rect
SetSize sets the size of this rect.
- w: the width of this rect.
- h: the height of this rect.
func (*Rect) SetURIAction
func (rect *Rect) SetURIAction(uri string) *Rect
SetURIAction sets the URI for the "click rect" action.
- uri: the URI
type SVGImage
type SVGImage struct { // contains filtered or unexported fields }
SVGImage is used to draw svgParser images on a page.
func NewSVGImage
func NewSVGImage(reader io.Reader) (*SVGImage, error)
NewSVGImage parses an svgParser image from a reader, for embedding in a PDF document. It draws the <path>, <rect>, <circle>, <ellipse>, <line>, <polyline> and <polygon> elements, in groups or not, with their transforms, and the fill, stroke, stroke-width, fill-rule, stroke-linecap, stroke-linejoin, opacity, fill-opacity and stroke-opacity they have or inherit, as attributes, in a style attribute or in rules for their classes in a <style> element that comes before them. The width, height, viewBox and preserveAspectRatio of the <svg> element give the size of the image.
func NewSVGImageFromFile
func NewSVGImageFromFile(filePath string) (*SVGImage, error)
NewSVGImageFromFile reads and parses an svgParser image from a file. The file is fully read before parsing, so no file handle lifecycle is involved.
func (*SVGImage) DrawOn
func (image *SVGImage) DrawOn(page *Page) [2]float32
DrawOn draws this svgParser image on the specified page.
func (*SVGImage) GetHeight
func (image *SVGImage) GetHeight() float32
GetHeight returns the height of this svgParser image.
func (*SVGImage) GetWidth
func (image *SVGImage) GetWidth() float32
GetWidth returns the width of this svgParser image.
func (*SVGImage) ScaleBy
func (image *SVGImage) ScaleBy(factor float32) *SVGImage
ScaleBy scales this svgParser image by the specified factor.
func (*SVGImage) SetActualText
func (image *SVGImage) SetActualText(actualText string) *SVGImage
SetActualText sets the actual text of this image.
func (*SVGImage) SetAltDescription
func (image *SVGImage) SetAltDescription(altDescription string) *SVGImage
SetAltDescription sets the alternate description of this image.
func (*SVGImage) SetGoToAction
func (image *SVGImage) SetGoToAction(key string) *SVGImage
SetGoToAction sets the destination key for the action.
func (*SVGImage) SetLanguage
func (image *SVGImage) SetLanguage(language string) *SVGImage
SetLanguage sets the language of this image, for example "en-US".
func (*SVGImage) SetLocation
func (image *SVGImage) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this image on the page.
func (*SVGImage) SetURIAction
func (image *SVGImage) SetURIAction(uri string) *SVGImage
SetURIAction sets the URI for the "click box" action.
type Series
type Series struct { // contains filtered or unexported fields }
Series is one series of a Chart: its points, the line that connects them when it is drawn, and the marker of the points added by their coordinates. A series is created with Chart.AddSeries; its name is listed in the legend of the chart. See Example_26.
func (*Series) AddPoint
func (series *Series) AddPoint(x, y float32) *Series
AddPoint adds a point with the marker of this series.
- x: the x value.
- y: the y value.
func (*Series) AddPointWithMarker
func (series *Series) AddPointWithMarker(point *Point) *Series
AddPointWithMarker adds a point with its own marker: its shape, radius and colors. A point without a stroke color is drawn in the color of the series.
func (*Series) SetDrawPath
func (series *Series) SetDrawPath(drawPath bool) *Series
SetDrawPath sets whether the points are connected with a line, in the order they were added. The default is false: only the markers are drawn.
func (*Series) SetRadius
func (series *Series) SetRadius(radius float32) *Series
SetRadius sets the radius of the marker of the points added by their coordinates. The default is 2.
func (*Series) SetShape
func (series *Series) SetShape(markerShape shape.Shape) *Series
SetShape sets the shape of the marker of the points added by their coordinates. The default is shape.Circle; shape.Invisible draws no markers.
func (*Series) SetStrokeColor
func (series *Series) SetStrokeColor(c int32) *Series
SetStrokeColor sets the color of the line and of the markers that have no color of their own. Without it the series has the next color of the palette.
- color: the color as a 0xRRGGBB value, for example color.Blue.
color.Transparent leaves it unchanged.
func (*Series) SetStrokeDashPattern
func (series *Series) SetStrokeDashPattern(strokeDashPattern string) *Series
SetStrokeDashPattern sets the dash pattern of the line, for example "[3 3] 0". The default is a solid line.
func (*Series) SetStrokeWidth
func (series *Series) SetStrokeWidth(strokeWidth float32) *Series
SetStrokeWidth sets the width of the line. The default is 1.
type Slice
type Slice struct { // contains filtered or unexported fields }
Slice is a slice of a DonutChart: a value, a color and a label. The slice's share of the sum of the values of the chart sets its angle.
func NewSlice
func NewSlice(value float32, color int32, text string) *Slice
NewSlice creates a slice with its value, above 0, the 0xRRGGBB color and the label drawn next to it. The chart draws the value's share of the sum.
type SquareAnnotation
type SquareAnnotation struct { BaseAnnotation }
SquareAnnotation extends BaseAnnotation to represent a square.
func NewSquareAnnotation
func NewSquareAnnotation() *SquareAnnotation
NewSquareAnnotation acts as the constructor.
type Stamp
type Stamp struct { // contains filtered or unexported fields }
Stamp is content that is drawn once with the path and text methods of this type, written to the document as a PDF form XObject by Complete, and placed on pages with DrawOn, at a location, a rotation and a scale, as a Container is.
What a stamp is good at: the content is in the file once, and each placement is the q, the transform and the Do that name it -- 83 bytes for a 200 by 50 point box with two lines of text, against the 367 a Container writes into every page for the same drawing. From the fourth page on the stamp is the smaller of the two: over 100 pages it saves 12,855 bytes of a 104,530 byte file, and over 500 pages 66,052 of 275,553. The whole stamp is one structure element in a PDF/UA document, with the alternate description, the language and the actual text it is given, which is what a logo or a watermark wants.
What it costs: a stamp draws with the methods of this type -- MoveTo, LineTo, CurveTo, DrawRect, FillRect and DrawText -- and holds no drawable of its own, so it has no images, no annotations, no tables and no barcodes. Its text needs a font that is embedded in the document: a core font and a CJK font are refused, since a stamp has no map from their characters to their glyphs. It has to be completed before it is drawn, and completed once. On fewer than four pages it is the larger of the two, since its XObject costs about 300 bytes of its own.
Use a Container instead to group drawable elements -- Rect, TextLine, Image, Table, a chart, a barcode, an annotation -- that are moved, rotated and scaled together, and to lay a group out once for one page. A container can hold a stamp, so a header written once can be placed inside a group that is rotated with the rest of it.
Please see Example_31.
func NewStamp
func NewStamp(pdf *PDF) *Stamp
NewStamp creates a stamp for the specified document.
func (*Stamp) AddFont
func (s *Stamp) AddFont(font *Font) *Stamp
AddFont adds a font used by the text on this stamp.
func (*Stamp) CloseFillAndStrokePath
func (s *Stamp) CloseFillAndStrokePath() *Stamp
CloseFillAndStrokePath closes, fills and strokes the current path.
func (*Stamp) ClosePath
func (s *Stamp) ClosePath() *Stamp
ClosePath closes and strokes the current path.
func (*Stamp) Complete
func (s *Stamp) Complete()
Complete writes this stamp to the document as a form XObject. Call it once, after drawing the content and before DrawOn.
func (*Stamp) CurveTo
func (s *Stamp) CurveTo(x1, y1, x2, y2, x3, y3 float32) *Stamp
CurveTo adds a cubic Bézier curve from the current point to x3, y3, using x1, y1 and x2, y2 as control points.
func (*Stamp) DrawOn
func (s *Stamp) DrawOn(page *Page) [2]float32
DrawOn draws this stamp on the specified page and returns the x and y coordinates of its bottom right corner.
func (*Stamp) DrawPath
func (s *Stamp) DrawPath(path []*Point, pathOperator pathoperator.PathOperator)
DrawPath draws a path through the points. Control points define Bézier curves. Fewer than two points paint nothing. A path that ends on a control point, whose curve has no end, is refused and nothing of it is drawn.
func (*Stamp) DrawRect
func (s *Stamp) DrawRect(x, y, w, h float32) *Stamp
DrawRect draws the outline of a rectangle with its top left corner at x, y.
func (*Stamp) DrawText
func (s *Stamp) DrawText(font *Font, fontSize, x, y float32, text string) *Stamp
DrawText draws text on this stamp with an embedded font, which the stamp adds to its fonts.
func (*Stamp) DrawTextUsingParams
func (s *Stamp) DrawTextUsingParams(params *TextParameters) *Stamp
DrawTextUsingParams draws text using the font, font size, location and text in the parameters.
func (*Stamp) FillPath
func (s *Stamp) FillPath() *Stamp
FillPath fills the current path.
func (*Stamp) FillRect
func (s *Stamp) FillRect(x, y, w, h float32) *Stamp
FillRect draws a filled rectangle with its top left corner at x, y.
func (*Stamp) LineTo
func (s *Stamp) LineTo(x, y float32) *Stamp
LineTo adds a straight line from the current point to the specified point.
func (*Stamp) MoveTo
func (s *Stamp) MoveTo(x, y float32) *Stamp
MoveTo begins a new path at the specified point.
func (*Stamp) ScaleBy
func (s *Stamp) ScaleBy(factor float32) *Stamp
ScaleBy scales this stamp around its center when it is placed on a page; 1 is its size.
func (*Stamp) ScaleByWidthAndHeight
func (s *Stamp) ScaleByWidthAndHeight(sx, sy float32) *Stamp
ScaleByWidthAndHeight scales this stamp around its center when it is placed on a page.
func (*Stamp) SetActualText
func (s *Stamp) SetActualText(actualText string) *Stamp
SetActualText sets the actual text for this stamp.
func (*Stamp) SetAltDescription
func (s *Stamp) SetAltDescription(altDescription string) *Stamp
SetAltDescription sets the alternate description of this stamp.
func (*Stamp) SetFillColor
func (s *Stamp) SetFillColor(c int32) *Stamp
SetFillColor sets the fill color for the content drawn after it, as a 0xRRGGBB value, for example color.Blue. color.Transparent leaves it unchanged.
func (*Stamp) SetFillColorRGB
func (s *Stamp) SetFillColorRGB(rgbColor [3]float32) *Stamp
SetFillColorRGB sets the fill color for the content drawn after it, from the red, green and blue components, from 0.0 to 1.0.
func (*Stamp) SetLanguage
func (s *Stamp) SetLanguage(language string) *Stamp
SetLanguage sets the language of this stamp, used for accessibility, for example "en-US".
func (*Stamp) SetLocation
func (s *Stamp) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this stamp on the page. It returns the stamp as a Drawable, so in a chain of setter calls SetLocation goes last, right before DrawOn.
func (*Stamp) SetRotation
func (s *Stamp) SetRotation(degrees float64) *Stamp
SetRotation rotates this stamp around its center: clockwise for a positive angle, as every rotation in PDFjet turns, and counterclockwise for a negative angle.
func (*Stamp) SetSize
func (s *Stamp) SetSize(width, height float32) *Stamp
SetSize sets the size of this stamp, before anything is drawn on it: its y runs down from its top.
func (*Stamp) SetStrokeColor
func (s *Stamp) SetStrokeColor(c int32) *Stamp
SetStrokeColor sets the stroke color for the content drawn after it, as a 0xRRGGBB value, for example color.Blue. color.Transparent leaves it unchanged.
func (*Stamp) SetStrokeColorRGB
func (s *Stamp) SetStrokeColorRGB(rgbColor [3]float32) *Stamp
SetStrokeColorRGB sets the stroke color for the content drawn after it, from the red, green and blue components, from 0.0 to 1.0.
func (*Stamp) SetStrokeWidth
func (s *Stamp) SetStrokeWidth(width float32) *Stamp
SetStrokeWidth sets the stroke width for the content drawn after it.
func (*Stamp) StrokePath
func (s *Stamp) StrokePath() *Stamp
StrokePath strokes the current path.
type Table
type Table struct { // contains filtered or unexported fields }
Table is used to create table objects and draw them on a page. Please see Example_20.
func NewTable
func NewTable() *Table
NewTable creates table objects.
func NewTableFromFile
func NewTableFromFile(f1, f2 *Font, fileName string) *Table
NewTableFromFile creates a table from a text file with comma, pipe or tab separated values. The first line is the header row and uses f1; the other lines use f2. Every row gets as many cells as the first line has fields. A quoted field is read as RFC 4180 reads it, and a line break inside one goes on to the next line of the file and is drawn as a space. It panics if the file cannot be read, or has a quoted field that is not closed; use ReadTableFromFile to have the error returned.
func ReadTableFromFile
func ReadTableFromFile(f1, f2 *Font, fileName string) (table *Table, err error)
ReadTableFromFile creates a table from a text file as NewTableFromFile does, and returns the error, rather than panic, if the file cannot be read or has a quoted field that is not closed, as the other ports throw it.
func (*Table) AutoAdjustColumnWidths
func (table *Table) AutoAdjustColumnWidths() *Table
AutoAdjustColumnWidths adjusts the widths of all columns so that they are just wide enough to hold the text without truncation.
func (*Table) DrawOn
func (table *Table) DrawOn(page *Page) [2]float32
DrawOn draws this table on the specified page.
- page: the page to draw this table on.
Returns the x and y coordinates of the bottom right corner of the table.
func (*Table) DrawOnPages
func (table *Table) DrawOnPages(pdf *PDF, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
DrawOnPages draws this table on as many new pages as it needs. The pages are created detached and added to the list; add them to the PDF afterwards. It returns the x and y coordinates of the bottom right corner of the table on the last page.
func (*Table) DrawOnPagesFrom
func (table *Table) DrawOnPagesFrom(pdf *PDF, first *Page, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
DrawOnPagesFrom draws this table as DrawOnPages does, starting on first: a page that has other content above the table, such as a heading, which SetFirstPageTopMargin puts the table under. The next pages are new, and are added to the list; first is not.
func (*Table) FitToWidth
func (table *Table) FitToWidth(width float32) *Table
FitToWidth makes the table the width given, sharing it among the columns by the widths they have: after AutoAdjustColumnWidths, by the text each holds. Text wraps to the widths.
func (*Table) GetCellAt
func (table *Table) GetCellAt(rowIndex, colIndex int) *Cell
GetCellAt returns the cell at the specified row and column.
- row: the specified row.
- col: the specified column.
Returns the cell at the specified row and column.
func (*Table) GetColumn
func (table *Table) GetColumn(index int) []*Cell
GetColumn returns a list of cells for the specified column.
- index: the index of the specified column.
Returns the list of cells.
func (*Table) GetColumnWidth
func (table *Table) GetColumnWidth(index int) float32
GetColumnWidth returns the column width of the column at the specified index.
- index: the index of the column.
Returns the width of the column.
func (*Table) GetRow
func (table *Table) GetRow(index int) []*Cell
GetRow returns a list of cells for the specified row.
- index: the index of the specified row.
Returns the list of cells.
func (*Table) GetRowsRendered
func (table *Table) GetRowsRendered() int
GetRowsRendered returns the number of rows below the header rows that are drawn so far, counting each line of wrapped cell text as a row, or -1 when all rows are drawn.
func (*Table) GetWidth
func (table *Table) GetWidth() float32
GetWidth returns the width of the table when drawn on a page. Returns the width of the table.
func (*Table) KeepRowWithNext
func (table *Table) KeepRowWithNext(index int) *Table
KeepRowWithNext keeps the row with the specified index on the same page as the next row, as a heading row is kept with the rows under it: a page break does not fall between them, and moves both to the next page. Rows kept with the next one one after another are kept together, unless together they are taller than a page. Call it before the table is drawn.
func (*Table) RemoveLineBetweenRows
func (table *Table) RemoveLineBetweenRows(index1, index2 int) *Table
RemoveLineBetweenRows removes the horizontal lines between the rows from index1 to index2.
func (*Table) RightAlignNumbers
func (table *Table) RightAlignNumbers() *Table
RightAlignNumbers aligns to the right the cells whose text is a number, such as 1,234.50, (1,234.50), -5 or 1.5E+3. The periods, commas and apostrophes are ignored, and the number can be in parentheses.
func (*Table) SetAlternateRowColor
func (table *Table) SetAlternateRowColor(c int32) *Table
SetAlternateRowColor colors every other row of the body of the table, the second, the fourth and so on, counting the rows of the data and not those of each page, as BigTable.SetShadingColor shades its rows. The lines a row wraps into have its color, and a cell with a background of its own keeps it; the header and the footer rows are not striped. color.Transparent turns the stripes off.
func (*Table) SetAlternateRowColorRGB
func (table *Table) SetAlternateRowColorRGB(rgbColor [3]float32) *Table
SetAlternateRowColorRGB colors every other row of the body of the table, as SetAlternateRowColor does, with a color of red, green and blue values from 0 to 1.
func (*Table) SetBottomMargin
func (table *Table) SetBottomMargin(bottomMargin float32) *Table
SetBottomMargin sets the bottom margin for table.
- bottomMargin: the margin.
func (*Table) SetBroughtForwardSum
func (table *Table) SetBroughtForwardSum(row, column, decimals int) *Table
SetBroughtForwardSum makes the cell of a header row show the sum of its column over all the rows of the pages before: the total brought forward, which the cell that SetRunningSum marks shows at the end of the page before. A header row with such a cell is drawn from the second page on, under the header rows above it, and not on the first page, which has nothing to bring forward; in a PDF/UA document it is an artifact, as the header rows are on those pages. The numbers are read and the sum is written as SetPageSum reads and writes them. The row is the index of a header row, see SetTableData.
func (*Table) SetCellBorderColor
func (table *Table) SetCellBorderColor(c int32) *Table
SetCellBorderColor sets the color of the cell border lines.
- color: the color of the cell border lines.
color.Transparent leaves it unchanged.
func (*Table) SetCellBorderColorRGB
func (table *Table) SetCellBorderColorRGB(rgbColor [3]float32) *Table
SetCellBorderColorRGB sets the color of the cell border lines from red, green and blue values.
func (*Table) SetCellBorderWidth
func (table *Table) SetCellBorderWidth(width float32) *Table
SetCellBorderWidth sets the width of the cell border lines.
- width: the width of the border lines.
func (*Table) SetCellBorders
func (table *Table) SetCellBorders(borders bool) *Table
SetCellBorders sets all table cells borders to false or true.
func (*Table) SetCellPadding
func (table *Table) SetCellPadding(side, vertical float32) *Table
SetCellPadding sets the padding of every cell of the table, as SetCellBorders sets their borders: side at the left and the right of the text, vertical over and under it, in points. A table whose cells have borders reads better with more than NewCell's 2 points on every side, such as 4 at the sides and 3 over and under. A cell set afterwards keeps its own padding, and the rows a wrapped cell adds under it have the side padding of the cell, none over them and NewCell's under them, as with Cell's SetPadding.
- side: the padding at the left and the right of each cell.
- vertical: the padding over and under the text of each cell.
func (*Table) SetColumnWidth
func (table *Table) SetColumnWidth(index int, width float32) *Table
SetColumnWidth sets the width of the column with the specified index.
- index: the index of specified column.
- width: the specified width.
func (*Table) SetColumnWidthsInPercent
func (table *Table) SetColumnWidthsInPercent(percents ...float32) *Table
SetColumnWidthsInPercent gives the columns, from the first, their percentages of the width of the table that SetWidth sets, whichever of the two is called first. The columns that have none share what is left of 100 equally, and the widths are then made to add up to the width of the table, so percentages that do not add up to 100 are shares of it. Text wraps to the widths.
func (*Table) SetFirstPageTopMargin
func (table *Table) SetFirstPageTopMargin(firstPageTopMargin float32) *Table
SetFirstPageTopMargin sets the top margin on the first page when the table spans several pages.
func (*Table) SetFontInColumn
func (table *Table) SetFontInColumn(index int, font *Font) *Table
SetFontInColumn sets the font and the font size of the cells in the specified column.
- index: the column index.
- font: the font.
func (*Table) SetFontInRow
func (table *Table) SetFontInRow(index int, font *Font) *Table
SetFontInRow sets the font and the font size of the cells in the specified row.
- index: the row index.
- font: the font.
func (*Table) SetFooterRowStyle
func (table *Table) SetFooterRowStyle(font *Font, textColor, backgroundColor int32) *Table
SetFooterRowStyle sets the font, the text color and the background color of the footer rows, the rows SetNumberOfFooterRows names, as SetHeaderRowStyle sets those of the header rows. Call it after SetNumberOfFooterRows.
func (*Table) SetHeaderRowStyle
func (table *Table) SetHeaderRowStyle(font *Font, textColor, backgroundColor int32) *Table
SetHeaderRowStyle sets the font, the text color and the background color of the header rows, the rows SetTableData names, as SetFontInRow and SetTextColorInRow set them for one row. A nil font keeps the fonts of the cells, and color.Transparent keeps a color. Call it after SetTableData and before AutoAdjustColumnWidths, which measures the text in the font.
func (*Table) SetLocation
func (table *Table) SetLocation(x, y float32) Drawable
SetLocation sets the location (x, y) of the top left corner of table on the page.
- x: the x coordinate of the top left point of the table.
- y: the y coordinate of the top left point of the table.
func (*Table) SetNumberOfFooterRows
func (table *Table) SetNumberOfFooterRows(numOfFooterRows int) *Table
SetNumberOfFooterRows makes the last rows of the table data footer rows, which are drawn again at the end of the table on every page, under the last row the page holds, as the header rows are drawn again at the top. A page leaves room for them. In a PDF/UA document they are rows of the table once, where the table ends, and artifacts on the other pages.
func (*Table) SetPageSum
func (table *Table) SetPageSum(row, column, decimals int) *Table
SetPageSum makes the cell of a footer row show the sum of its column over the rows of each page: the page total. The numbers are read as RightAlignNumbers reads them, with commas and apostrophes between the thousands and a period before the decimals, and a cell that has no number is left out. The sum has the number of decimals, from 0 to 9, rounded half away from zero, and commas between the thousands. Until the table is drawn the cell has the sum of all the rows, so that AutoAdjustColumnWidths leaves room for it; its text is not wrapped. The row is the index of a footer row, see SetNumberOfFooterRows.
func (*Table) SetRunningSum
func (table *Table) SetRunningSum(row, column, decimals int) *Table
SetRunningSum makes the cell of a footer row show the sum of its column over all the rows up to the end of each page: the total carried forward, which is the total of the table on its last page. The numbers are read and the sum is written as SetPageSum reads and writes them.
func (*Table) SetTableData
func (table *Table) SetTableData(tableData [][]*Cell, numOfHeaderRows int) *Table
SetTableData sets the table data and specifies the number of header rows in table data. The header rows are drawn again at the top of every page.
func (*Table) SetTextAlignmentInColumn
func (table *Table) SetTextAlignmentInColumn(index int, textAlignment alignment.Alignment) *Table
SetTextAlignmentInColumn sets the text alignment in the specified column.
- index: the index of the specified column.
- alignment: the specified alignment.
Supported values: alignment.Left, alignment.Right, alignment.Center and alignment.Justify.
func (*Table) SetTextColorInColumn
func (table *Table) SetTextColorInColumn(index int, color int32) *Table
SetTextColorInColumn sets the color of the text in the specified column.
- index: the index of the specified column.
- color: the color specified as an integer.
func (*Table) SetTextColorInRow
func (table *Table) SetTextColorInRow(index int, color int32) *Table
SetTextColorInRow sets the color of the text in the specified row.
- index: the index of the specified row.
- color: the color specified as an integer.
func (*Table) SetVisibleColumns
func (table *Table) SetVisibleColumns(visible ...int) *Table
SetVisibleColumns keeps only the columns with the specified indexes.
func (*Table) SetWidth
func (table *Table) SetWidth(width float32) *Table
SetWidth sets the width of the table. The columns share it by the percentages SetColumnWidthsInPercent gives them, whichever of the two is called first; without them, by the widths they have, as FitToWidth shares it.
type TextAnnotation
type TextAnnotation struct { BaseAnnotation }
TextAnnotation extends BaseAnnotation to represent a text label.
func NewTextAnnotation
func NewTextAnnotation() *TextAnnotation
NewTextAnnotation acts as the constructor.
type TextBlock
type TextBlock struct { // contains filtered or unexported fields }
TextBlock is a block of text that wraps at its width, with an optional border, background and padding. Without a height the block is as tall as its text; with one the text that does not fit is cut, and the lines are aligned to the top, the center or the bottom of the block.
Use a TextBlock for one run of text in one font: a label, a note, a table cell or a paragraph in a box. It breaks words that do not fit on a line, wraps right to left and Thai text, highlights keywords and can be cut to a height. Use a TextColumn for paragraphs of TextLine objects that differ in font or color, for justified text or for a rotated column, and a TextFrame for text that flows from one frame to the next. See Example_01, 10 and 11.
func NewTextBlock
func NewTextBlock(font *Font, textContent string) *TextBlock
NewTextBlock creates a text block and sets the font and the text. The font is the fallback font too.
func (*TextBlock) DrawOn
func (textBlock *TextBlock) DrawOn(page *Page) [2]float32
DrawOn draws this text block on the specified page and returns the x and y coordinates of its bottom right corner.
func (*TextBlock) GetBackgroundColor
func (textBlock *TextBlock) GetBackgroundColor() *[3]float32
GetBackgroundColor returns a copy of the background color, or nil if none was set.
func (*TextBlock) GetBorderColor
func (textBlock *TextBlock) GetBorderColor() *[3]float32
GetBorderColor returns a copy of the border color, or nil if none was set.
func (*TextBlock) GetBorderWidth
func (textBlock *TextBlock) GetBorderWidth() float32
GetBorderWidth returns the border width.
func (*TextBlock) GetFont
func (textBlock *TextBlock) GetFont() *Font
GetFont returns the font of the text.
func (*TextBlock) GetHeight
func (textBlock *TextBlock) GetHeight() float32
GetHeight returns the height of this text block as it is drawn: the height set with SetHeight or SetSize, or the height of the text and padding without one.
func (*TextBlock) GetLocation
func (textBlock *TextBlock) GetLocation() [2]float32
GetLocation returns the x and y coordinates of the top left corner of this text block.
func (*TextBlock) GetPadding
func (textBlock *TextBlock) GetPadding() float32
GetPadding returns the padding between the text and the border.
func (*TextBlock) GetStrikeout
func (textBlock *TextBlock) GetStrikeout() bool
GetStrikeout returns whether the text is struck out.
func (*TextBlock) GetText
func (textBlock *TextBlock) GetText() string
GetText returns the text of this text block.
func (*TextBlock) GetTextAlignment
func (textBlock *TextBlock) GetTextAlignment() alignment.Alignment
GetTextAlignment returns the horizontal alignment of the text.
func (*TextBlock) GetTextColor
func (textBlock *TextBlock) GetTextColor() [3]float32
GetTextColor returns the text color as red, green and blue components, from 0.0 to 1.0.
func (*TextBlock) GetUnderline
func (textBlock *TextBlock) GetUnderline() bool
GetUnderline returns whether the text is underlined.
func (*TextBlock) GetVerticalAlignment
func (textBlock *TextBlock) GetVerticalAlignment() alignment.Alignment
GetVerticalAlignment returns the vertical alignment of the text.
func (*TextBlock) GetWidth
func (textBlock *TextBlock) GetWidth() float32
GetWidth returns the width of this text block.
func (*TextBlock) SetBackgroundColor
func (textBlock *TextBlock) SetBackgroundColor(c int32) *TextBlock
SetBackgroundColor sets the background color as a 0xRRGGBB value. color.Transparent removes the background.
func (*TextBlock) SetBackgroundColorRGB
func (textBlock *TextBlock) SetBackgroundColorRGB(fillColor [3]float32) *TextBlock
SetBackgroundColorRGB sets the background color from the red, green and blue components, from 0.0 to 1.0.
func (*TextBlock) SetBorderColor
func (textBlock *TextBlock) SetBorderColor(c int32) *TextBlock
SetBorderColor sets the border color as a 0xRRGGBB value. color.Transparent removes the border.
func (*TextBlock) SetBorderColorRGB
func (textBlock *TextBlock) SetBorderColorRGB(borderColor [3]float32) *TextBlock
SetBorderColorRGB sets the border color from the red, green and blue components, from 0.0 to 1.0.
func (*TextBlock) SetBorderWidth
func (textBlock *TextBlock) SetBorderWidth(borderWidth float32) *TextBlock
SetBorderWidth sets the border width.
func (*TextBlock) SetCornerRadius
func (textBlock *TextBlock) SetCornerRadius(borderCornerRadius float32) *TextBlock
SetCornerRadius sets the border corner radius.
func (*TextBlock) SetFallbackFont
func (textBlock *TextBlock) SetFallbackFont(fallbackFont *Font) *TextBlock
SetFallbackFont sets the fallback font.
func (*TextBlock) SetFallbackFontSize
func (textBlock *TextBlock) SetFallbackFontSize(size float32) *TextBlock
SetFallbackFontSize sets the size of the characters drawn in the fallback font. By default they are drawn at the font size.
func (*TextBlock) SetFont
func (textBlock *TextBlock) SetFont(font *Font) *TextBlock
SetFont sets the font of the text. The fallback font changes with it, unless a different fallback font was set.
func (*TextBlock) SetFontSize
func (textBlock *TextBlock) SetFontSize(size float32) *TextBlock
SetFontSize sets the font size of the text.
func (*TextBlock) SetHeight
func (textBlock *TextBlock) SetHeight(h float32) *TextBlock
SetHeight sets the height of this text block. With a height above 0 the block is that tall: the lines that do not fit are cut, the last line that fits ends with "...", and the lines are aligned by the vertical alignment. A height of 0 is the height of the text.
func (*TextBlock) SetHighlightColors
func (textBlock *TextBlock) SetHighlightColors(keywordHighlightColors map[string]int32) *TextBlock
SetHighlightColors sets the colors used to highlight keywords, matched ignoring case.
func (*TextBlock) SetLanguage
func (textBlock *TextBlock) SetLanguage(language string) *TextBlock
SetLanguage sets the language of the text, for example "he", "ar" or "fa", as a BCP 47 language tag. The text is marked with it, for screen readers and text extraction.
func (*TextBlock) SetLineSpacing
func (textBlock *TextBlock) SetLineSpacing(lineSpacing float32) *TextBlock
SetLineSpacing sets the line spacing as a multiple of the font's body height.
func (*TextBlock) SetLocation
func (textBlock *TextBlock) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this text block on the page.
func (*TextBlock) SetPadding
func (textBlock *TextBlock) SetPadding(padding float32) *TextBlock
SetPadding sets the padding between the text and the border.
func (*TextBlock) SetRightToLeft
func (textBlock *TextBlock) SetRightToLeft(rightToLeft bool) *TextBlock
SetRightToLeft sets whether the text is right to left, like Arabic and Hebrew text. Each paragraph is wrapped at the width in logical order, and each line is then reordered with Bidi reordering, which also shapes the Arabic letters, and aligned to the right, unless the text alignment is alignment.Center.
func (*TextBlock) SetSize
func (textBlock *TextBlock) SetSize(w, h float32) *TextBlock
SetSize sets the width and height of this text block. With a height above 0 the block is that tall: the lines that do not fit are cut, the last line that fits ends with "...", and the lines are aligned by the vertical alignment. A height of 0 is the height of the text.
func (*TextBlock) SetStrikeout
func (textBlock *TextBlock) SetStrikeout(strikeout bool) *TextBlock
SetStrikeout strikes out the text of this text block.
func (*TextBlock) SetStructureType
func (textBlock *TextBlock) SetStructureType(structureType structelem.StructElem) *TextBlock
SetStructureType sets the structure element type of this text block, for example structelem.P, the default, or structelem.H1 for a heading, as a tagged document, PDF/UA or a PDF/A of level A, tags it.
func (*TextBlock) SetText
func (textBlock *TextBlock) SetText(text string) *TextBlock
SetText sets the text of this text block.
func (*TextBlock) SetTextAlignment
func (textBlock *TextBlock) SetTextAlignment(textAlignment alignment.Alignment) *TextBlock
SetTextAlignment sets the horizontal alignment of the text.
func (*TextBlock) SetTextColor
func (textBlock *TextBlock) SetTextColor(c int32) *TextBlock
SetTextColor sets the text color as a 0xRRGGBB value. color.Transparent leaves the text color unchanged.
func (*TextBlock) SetTextColorRGB
func (textBlock *TextBlock) SetTextColorRGB(textColor [3]float32) *TextBlock
SetTextColorRGB sets the text color from the red, green and blue components, from 0.0 to 1.0.
func (*TextBlock) SetURIAction
func (textBlock *TextBlock) SetURIAction(uri string) *TextBlock
SetURIAction sets the URI opened when this text block is clicked.
func (*TextBlock) SetUnderline
func (textBlock *TextBlock) SetUnderline(underline bool) *TextBlock
SetUnderline underlines the text of this text block.
func (*TextBlock) SetVerticalAlignment
func (textBlock *TextBlock) SetVerticalAlignment(verticalAlignment alignment.Alignment) *TextBlock
SetVerticalAlignment sets the vertical alignment of the text in a block with a height: alignment.Top, the default, alignment.Center or alignment.Bottom.
func (*TextBlock) SetWidth
func (textBlock *TextBlock) SetWidth(w float32) *TextBlock
SetWidth sets the width of this text block. The height is adjusted automatically to fit the text.
type TextColumn
type TextColumn struct { // contains filtered or unexported fields }
TextColumn is a column of paragraphs, each a list of TextLine objects that can differ in font, size and color, aligned left, right, center or justified, with a line spacing, a paragraph spacing and an optional line between the paragraphs. It draws all of its paragraphs where it is placed, top down; to rotate a column, add it to a Container and rotate that.
Use a TextColumn for an article or a page of mixed text: bold or colored words in a paragraph, justified paragraphs, CJK paragraphs. Use a TextBlock for one run of text in one font, and a TextFrame when the text must continue from one frame to the next, across columns or pages. Please see Example_12, Example_22, Example_13 and Example_16.
func NewTextColumn
func NewTextColumn() *TextColumn
NewTextColumn creates a text column object.
func (*TextColumn) AddCJKParagraph
func (textColumn *TextColumn) AddCJKParagraph(font *Font, text string) *TextColumn
AddCJKParagraph adds a paragraph of Chinese, Japanese or Korean text, in the specified font, to this text column. The text is wrapped at any character to the width of the column.
func (*TextColumn) AddCJKParagraphWithLanguage
func (textColumn *TextColumn) AddCJKParagraphWithLanguage(font *Font, text, language string) *TextColumn
AddCJKParagraphWithLanguage adds a paragraph of Chinese, Japanese or Korean text, as AddCJKParagraph does, in the language given, for example "zh-Hans", "ja" or "ko", which a screen reader reads it in.
func (*TextColumn) AddParagraph
func (textColumn *TextColumn) AddParagraph(paragraph *Paragraph) *TextColumn
AddParagraph adds a new paragraph to this text column.
func (*TextColumn) DrawOn
func (textColumn *TextColumn) DrawOn(page *Page) [2]float32
DrawOn draws this text column on the specified page and returns the x and y coordinates of its bottom right corner. With no page nothing is drawn and the corner is computed.
func (*TextColumn) GetHeight
func (textColumn *TextColumn) GetHeight() float32
GetHeight returns the height of this text column.
func (*TextColumn) GetSize
func (textColumn *TextColumn) GetSize() *Dimension
GetSize returns dimension object containing the width and height of this component.
func (*TextColumn) GetWidth
func (textColumn *TextColumn) GetWidth() float32
GetWidth returns the width of this text column.
func (*TextColumn) RemoveLastParagraph
func (textColumn *TextColumn) RemoveLastParagraph() *TextColumn
RemoveLastParagraph removes the last paragraph added to this text column.
func (*TextColumn) SetHeight
func (textColumn *TextColumn) SetHeight(h float32) *TextColumn
SetHeight sets the height of this text column.
func (*TextColumn) SetLineBetweenParagraphs
func (textColumn *TextColumn) SetLineBetweenParagraphs(lineBetweenParagraphs bool) *TextColumn
SetLineBetweenParagraphs sets whether an empty line is inserted between the current and next paragraphs.
func (*TextColumn) SetLineSpacing
func (textColumn *TextColumn) SetLineSpacing(lineSpacing float32) *TextColumn
SetLineSpacing sets the space between the lines.
func (*TextColumn) SetLocation
func (textColumn *TextColumn) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this text column on the page.
func (*TextColumn) SetParagraphSpacing
func (textColumn *TextColumn) SetParagraphSpacing(paragraphSpacing float32) *TextColumn
SetParagraphSpacing sets the space between paragraphs.
func (*TextColumn) SetTextAlignment
func (textColumn *TextColumn) SetTextAlignment(textAlignment alignment.Alignment) *TextColumn
SetTextAlignment sets the text alignment: alignment.Left, alignment.Right, alignment.Center or alignment.Justify.
func (*TextColumn) SetWidth
func (textColumn *TextColumn) SetWidth(w float32) *TextColumn
SetWidth sets the desired width of this text column.
type TextFrame
type TextFrame struct { // contains filtered or unexported fields }
TextFrame is paragraphs of text lines, wrapped at the width of the frame, with an optional border. A frame with a height draws as much of the text as fits and keeps the rest for the next frame, so text flows from frame to frame. A frame without a height draws all of the text. Drawing consumes the text: a second DrawOn draws what is left, so build a new frame to draw the same text again.
Use a TextFrame for text that continues from one frame to the next: the columns of an article, or the pages of a long text. Use a TextColumn to draw paragraphs in one place, with justified text or a rotation, and a TextBlock for one run of text in one font. Please see Example_14 and Example_15.
func NewTextFrame
func NewTextFrame(f1 *Font, inputList []string) *TextFrame
NewTextFrame creates a text frame from strings, one paragraph each, in the font at its size. An empty line separates the paragraphs.
func NewTextFrameFromParagraphs
func NewTextFrameFromParagraphs(paragraphs []*Paragraph) *TextFrame
NewTextFrameFromParagraphs creates a text frame from paragraphs of text lines. An empty line separates the paragraphs unless SetParagraphGap sets another gap.
func (*TextFrame) DrawOn
func (tf *TextFrame) DrawOn(page *Page) [2]float32
DrawOn draws the text on the page: all of it when this frame has no height, or as much as fits in the height, keeping the rest for the next frame. The first line of a frame is drawn even when it does not fit, so the text always flows, and a word wider than the frame is broken. With no page nothing is drawn, the paragraphs get their coordinates and the text is kept. It returns the x and y coordinates of the bottom right corner of this frame, or of the text when the frame has no height.
func (*TextFrame) DrawOnPages
func (tf *TextFrame) DrawOnPages(pdf *PDF, pages *[]*Page, pageSize pagesize.PageSize) [2]float32
DrawOnPages draws the text on as many new pages as it needs, at the location and the width of this frame on each: a whole book, page after page. The height of the frame is the height of the text on each page; a frame without one reaches down to the margin its location leaves at the top, so text at 72, 72 keeps 72 points free at the bottom too. The pages are created detached and added to the list, so that a footer or a page number can be drawn on each before they are added to the PDF. A frame with no text left needs no page. It returns the x and y coordinates of the bottom right corner of this frame on the last page.
func (*TextFrame) GetHeight
func (tf *TextFrame) GetHeight() float32
GetHeight returns the height of this text frame.
func (*TextFrame) GetWidth
func (tf *TextFrame) GetWidth() float32
GetWidth returns the width of this text frame.
func (*TextFrame) HasMoreText
func (tf *TextFrame) HasMoreText() bool
HasMoreText returns true if some of the text has not been drawn yet.
func (*TextFrame) SetBorderColor
func (tf *TextFrame) SetBorderColor(c int32) *TextFrame
SetBorderColor sets the border color as a 0xRRGGBB value and draws a border around this text frame. color.Transparent removes the border.
func (*TextFrame) SetBorderColorRGB
func (tf *TextFrame) SetBorderColorRGB(borderColor [3]float32) *TextFrame
SetBorderColorRGB sets the border color from red, green and blue values and draws a border around this text frame.
func (*TextFrame) SetBorderDashPattern
func (tf *TextFrame) SetBorderDashPattern(borderPattern string) *TextFrame
SetBorderDashPattern sets the dash pattern of the border, for example "[3] 0".
func (*TextFrame) SetBorderWidth
func (tf *TextFrame) SetBorderWidth(borderWidth float32) *TextFrame
SetBorderWidth sets the border width.
func (*TextFrame) SetBorders
func (tf *TextFrame) SetBorders(border bool) *TextFrame
SetBorders sets whether a border is drawn around this text frame.
func (*TextFrame) SetHeight
func (tf *TextFrame) SetHeight(h float32) *TextFrame
SetHeight sets the height of this text frame. With a height of 0, the default, the frame draws all of its text.
func (*TextFrame) SetLocation
func (tf *TextFrame) SetLocation(x, y float32) Drawable
SetLocation sets the location of the top left corner of this text frame.
func (*TextFrame) SetParagraphGap
func (tf *TextFrame) SetParagraphGap(paragraphGap float32) *TextFrame
SetParagraphGap sets the space between paragraphs, in points, 0 or more: from the bottom of the text of a paragraph to the top of the text of the next, so paragraphs never overlap. The default is one empty line in the size of the next paragraph, so a heading is not followed by an empty line of its own size. A negative gap is taken as 0.
func (*TextFrame) SetWidth
func (tf *TextFrame) SetWidth(w float32) *TextFrame
SetWidth sets the width at which the lines wrap.
type TextLine
type TextLine struct { // contains filtered or unexported fields }
TextLine is used to create text line objects.
func NewEmptyTextLine
func NewEmptyTextLine(font *Font) *TextLine
NewEmptyTextLine is constructor for creating empty text line objects.
- font: the font to use.
func NewTextLine
func NewTextLine(font *Font, text string) *TextLine
NewTextLine is constructor for creating text line objects.
- font: the font to use.
- text: the text.
func (*TextLine) DrawOn
func (textLine *TextLine) DrawOn(page *Page) [2]float32
DrawOn draws this text line on the specified page and returns the x and y coordinates of its bottom right corner. It draws nothing when the page is nil or the text is empty.
func (*TextLine) GetAltDescription
func (textLine *TextLine) GetAltDescription() string
GetAltDescription gets the alternate description of this text line.
func (*TextLine) GetAscent
func (textLine *TextLine) GetAscent() float32
GetAscent returns how far above its baseline this text line reaches: the ascent of the font at the font size of this text line.
func (*TextLine) GetDecorationColor
func (textLine *TextLine) GetDecorationColor() [3]float32
GetDecorationColor returns the color of the underline and strikeout lines.
func (*TextLine) GetDescent
func (textLine *TextLine) GetDescent() float32
GetDescent returns how far below its baseline this text line reaches: the descent of the font at the font size of this text line.
func (*TextLine) GetDestination
func (textLine *TextLine) GetDestination() string
GetDestination returns the name of the destination that DrawOn adds to the page, or "".
func (*TextLine) GetFallbackFont
func (textLine *TextLine) GetFallbackFont() *Font
GetFallbackFont returns the fallback font. Returns the fallback font.
func (*TextLine) GetFont
func (textLine *TextLine) GetFont() *Font
GetFont gets the font to use for this text line. Returns font the font to use.
func (*TextLine) GetFontSize
func (textLine *TextLine) GetFontSize() float32
GetFontSize returns the font size.
func (*TextLine) GetGoToAction
func (textLine *TextLine) GetGoToAction() string
GetGoToAction returns the GoTo action string. Returns the GoTo action string.
func (*TextLine) GetHeight
func (textLine *TextLine) GetHeight() float32
GetHeight returns the height of this TextLine. Returns the height.
func (*TextLine) GetHighlightColors
func (textLine *TextLine) GetHighlightColors() map[string]int32
GetHighlightColors returns the colors used to highlight words in the text.
func (*TextLine) GetLanguage
func (textLine *TextLine) GetLanguage() string
GetLanguage returns the language of the text.
func (*TextLine) GetLocation
func (textLine *TextLine) GetLocation() [2]float32
GetLocation returns the x coordinate of the start of the text and the y coordinate of its baseline.
func (*TextLine) GetScriptPosition
func (textLine *TextLine) GetScriptPosition() scriptposition.ScriptPosition
GetScriptPosition returns the script position. Returns the script position.
func (*TextLine) GetStrikeout
func (textLine *TextLine) GetStrikeout() bool
GetStrikeout returns the strikeout flag. Returns the strikeout flag.
func (*TextLine) GetText
func (textLine *TextLine) GetText() string
GetText returns the text.
func (*TextLine) GetTextColor
func (textLine *TextLine) GetTextColor() [3]float32
GetTextColor returns the text color.
func (*TextLine) GetTextRotation
func (textLine *TextLine) GetTextRotation() int
GetTextRotation returns the text direction. Returns the text direction.
func (*TextLine) GetURIAction
func (textLine *TextLine) GetURIAction() string
GetURIAction returns the action URI. Returns the action URI.
func (*TextLine) GetURIActualText
func (textLine *TextLine) GetURIActualText() string
GetURIActualText returns the actual text of the link annotation.
func (*TextLine) GetURIAltDescription
func (textLine *TextLine) GetURIAltDescription() string
GetURIAltDescription returns the alternate description of the link annotation.
func (*TextLine) GetURILanguage
func (textLine *TextLine) GetURILanguage() string
GetURILanguage returns the language of the link annotation.
func (*TextLine) GetUnderline
func (textLine *TextLine) GetUnderline() bool
GetUnderline returns the underline flag. Returns the underline flag.
func (*TextLine) GetVerticalOffset
func (textLine *TextLine) GetVerticalOffset() float32
GetVerticalOffset returns the vertical text offset: the one set with SetVerticalOffset, or that of the script position at the font and font size of this text line.
func (*TextLine) GetWidth
func (textLine *TextLine) GetWidth() float32
GetWidth returns the width of this TextLine. Returns the width.
func (*TextLine) SetAltDescription
func (textLine *TextLine) SetAltDescription(altDescription string) *TextLine
SetAltDescription sets the alternate description of this text line.
- altDescription: the alternate description of the text line.
Returns this TextLine.
func (*TextLine) SetDecorationColor
func (textLine *TextLine) SetDecorationColor(c int32) *TextLine
SetDecorationColor sets the color of the underline and strikeout lines as a 0xRRGGBB value. color.Transparent leaves it unchanged.
func (*TextLine) SetDecorationColorRGB
func (textLine *TextLine) SetDecorationColorRGB(c [3]float32) *TextLine
SetDecorationColorRGB sets the color of the underline and strikeout lines from the red, green and blue components, from 0.0 to 1.0.
func (*TextLine) SetDestination
func (textLine *TextLine) SetDestination(name string) *TextLine
SetDestination sets the name of a destination that DrawOn adds to the page, a font size above the baseline, so that a GoTo action with the name, which SetGoToAction sets, goes to this line.
- name: the destination name, or "" for none.
Returns this TextLine.
func (*TextLine) SetFallbackFont
func (textLine *TextLine) SetFallbackFont(fallbackFont *Font) *TextLine
SetFallbackFont sets the fallback font.
- fallbackFont: the fallback font.
Returns this TextLine.
func (*TextLine) SetFont
func (textLine *TextLine) SetFont(font *Font) *TextLine
SetFont sets the font to use for this text line. The fallback font changes with it, unless a different fallback font was set.
- font: the font to use.
Returns this TextLine.
func (*TextLine) SetFontSize
func (textLine *TextLine) SetFontSize(fontSize float32) *TextLine
SetFontSize sets the font size to use for this text line.
- fontSize: the fontSize to use.
Returns this TextLine.
func (*TextLine) SetGoToAction
func (textLine *TextLine) SetGoToAction(key string) *TextLine
SetGoToAction sets the destination key for the action.
- key: the destination name.
Returns this TextLine.
func (*TextLine) SetHighlightColors
func (textLine *TextLine) SetHighlightColors(colorMap map[string]int32) *TextLine
SetHighlightColors sets the colors used to highlight words in the text.
func (*TextLine) SetLanguage
func (textLine *TextLine) SetLanguage(language string) *TextLine
SetLanguage sets the language of the text, for example "en-US".
func (*TextLine) SetLocation
func (textLine *TextLine) SetLocation(x, y float32) Drawable
SetLocation sets the location where this text line will be drawn on the page.
- x: the x coordinate of the text line.
- y: the y coordinate of the text line.
Returns this TextLine.
func (*TextLine) SetScriptPosition
func (textLine *TextLine) SetScriptPosition(scriptPosition scriptposition.ScriptPosition) *TextLine
SetScriptPosition sets the script position: scriptposition.Normal, scriptposition.Subscript or scriptposition.Superscript. The offset of a superscript or subscript follows the font and font size of this text line when it is drawn.
func (*TextLine) SetStrikeout
func (textLine *TextLine) SetStrikeout(strikeout bool) *TextLine
SetStrikeout sets the strike variable. If the value of the strike variable is 'true' - a strike line is drawn through the text.
- strikeout: the strikeout flag.
Returns this TextLine.
func (*TextLine) SetStructureType
func (textLine *TextLine) SetStructureType(structureType structelem.StructElem) *TextLine
SetStructureType sets the structure element type of this text line, for example structelem.P or structelem.H1.
func (*TextLine) SetText
func (textLine *TextLine) SetText(text string) *TextLine
SetText sets the text.
- text: the text.
Returns this TextLine.
func (*TextLine) SetTextColor
func (textLine *TextLine) SetTextColor(c int32) *TextLine
SetTextColor sets the text color as a 0xRRGGBB value. color.Transparent leaves it unchanged.
func (*TextLine) SetTextColorRGB
func (textLine *TextLine) SetTextColorRGB(c [3]float32) *TextLine
SetTextColorRGB sets the text color from the red, green and blue components, from 0.0 to 1.0.
func (*TextLine) SetTextRotation
func (textLine *TextLine) SetTextRotation(degrees int) *TextLine
SetTextRotation sets the rotation of the text. A positive angle turns clockwise, as every rotation in PDFjet turns, and a negative angle counterclockwise.
- degrees: the angle in degrees.
Returns this TextLine.
func (*TextLine) SetURIAction
func (textLine *TextLine) SetURIAction(uri string) *TextLine
SetURIAction sets the URI for the "click text line" action.
- uri: the URI
Returns this TextLine.
func (*TextLine) SetURIActualText
func (textLine *TextLine) SetURIActualText(uriActualText string) *TextLine
SetURIActualText sets the actual text of the link annotation.
func (*TextLine) SetURIAltDescription
func (textLine *TextLine) SetURIAltDescription(uriAltDescription string) *TextLine
SetURIAltDescription sets the alternate description of the link annotation.
func (*TextLine) SetURILanguage
func (textLine *TextLine) SetURILanguage(uriLanguage string) *TextLine
SetURILanguage sets the language of the link annotation.
func (*TextLine) SetUnderline
func (textLine *TextLine) SetUnderline(underline bool) *TextLine
SetUnderline sets the underline variable. If the value of the underline variable is 'true' - the text is underlined.
- underline: the underline flag.
Returns this TextLine.
func (*TextLine) SetVerticalOffset
func (textLine *TextLine) SetVerticalOffset(verticalOffset float32) *TextLine
SetVerticalOffset sets the vertical offset of the text, which replaces the offset of the script position until SetScriptPosition is called again.
type TextParameters
type TextParameters struct { // contains filtered or unexported fields }
TextParameters holds configuration for text rendering
func NewTextParameters
func NewTextParameters() *TextParameters
NewTextParameters creates a new TextParameters with default values
func (*TextParameters) SetFont
func (tp *TextParameters) SetFont(font *Font) *TextParameters
SetFont sets the font and returns the receiver for chaining
func (*TextParameters) SetFontSize
func (tp *TextParameters) SetFontSize(fontSize float32) *TextParameters
SetFontSize sets the font size and returns the receiver for chaining
func (*TextParameters) SetLocation
func (tp *TextParameters) SetLocation(x, y float32) *TextParameters
SetLocation sets the X, Y location and returns the receiver for chaining
func (*TextParameters) SetText
func (tp *TextParameters) SetText(text string) *TextParameters
SetText sets the text content and returns the receiver for chaining
type Title
type Title struct { // contains filtered or unexported fields }
Title is used to create title objects that have prefix and text. Please see Example_41
func NewTitle
func NewTitle(font *Font, text string, x, y float32) *Title
NewTitle is the constructor.
func (*Title) DrawOn
func (title *Title) DrawOn(page *Page) [2]float32
DrawOn draws the title.
func (*Title) GetPrefix
func (title *Title) GetPrefix() *TextLine
GetPrefix returns the prefix of the title.
func (*Title) GetTextLine
func (title *Title) GetTextLine() *TextLine
GetTextLine returns the text line of the title.
func (*Title) SetLocation
func (title *Title) SetLocation(x, y float32) Drawable
SetLocation sets the location of the prefix; the title text keeps its offset from it.
- x: the x coordinate.
- y: the y coordinate.
Returns this Title.
func (*Title) SetOffset
func (title *Title) SetOffset(offset float32) *Title
SetOffset sets the distance from the start of the prefix to the start of the title text, to make room for the prefix.
func (*Title) SetPrefix
func (title *Title) SetPrefix(text string) *Title
SetPrefix sets the prefix text.
Directories
| IBMPlexMath | Package IBMPlexMath provides the paths to the IBM Plex Math fonts. |
| IBMPlexMono | Package IBMPlexMono provides the paths to the IBM Plex Mono fonts. |
| IBMPlexSans | Package IBMPlexSans provides the paths to the IBM Plex Sans fonts. |
| IBMPlexSansArabic | Package IBMPlexSansArabic provides the paths to the IBM Plex Sans Arabic fonts. |
| IBMPlexSansHebrew | Package IBMPlexSansHebrew provides the paths to the IBM Plex Sans Hebrew fonts. |
| IBMPlexSansJP | Package IBMPlexSansJP provides the paths to the IBM Plex Sans JP fonts. |
| IBMPlexSansKR | Package IBMPlexSansKR provides the paths to the IBM Plex Sans KR fonts. |
| IBMPlexSansSC | Package IBMPlexSansSC provides the paths to the IBM Plex Sans SC fonts. |
| IBMPlexSansTC | Package IBMPlexSansTC provides the paths to the IBM Plex Sans TC fonts. |
| IBMPlexSansThai | Package IBMPlexSansThai provides the paths to the IBM Plex Sans Thai fonts. |
| JetBrainsMono | Package JetBrainsMono provides the paths to the JetBrains Mono fonts. |
| NotoSans | Package NotoSans provides the paths to the Noto Sans fonts. |
| SourceSerif4 | Package SourceSerif4 provides the paths to the Source Serif 4 fonts. |
| a3 | Package a3 defines the A3 page size in points. |
| a4 | Package a4 defines the A4 page size in points. |
| a5 | Package a5 defines the A5 page size in points. |
| alignment | Package alignment defines the horizontal and vertical alignments. |
| b5 | Package b5 defines the B5 page size, the ISO 216 B5 of 176 by 250 mm, in points. |
| border | Package border defines the constants that control the borders of a TextBox. |
| capstyle | Package capstyle defines the line cap styles. |
| cjkfont | Package cjkfont defines the Chinese, Japanese and Korean fonts. |
| color | Package color defines the named colors as 0xRRGGBB values. |
| compliance | Package compliance defines the PDF/UA and PDF/A compliance levels. |
| content | Package content reads the contents of files and readers. |
| corefont | Package corefont defines the metrics of the 14 standard PDF fonts. |
| datamatrix | Package datamatrix creates Data Matrix barcodes. |
| direction | Package direction defines the text writing directions. |
| encryption | |
| errorcorrectionlevel | Package errorcorrectionlevel defines the error correction levels of a QR code. |
| executive | Package executive defines the executive page size in points. |
| jisb5 | Package jisb5 defines the JIS B5 page size, the Japanese B5 of 182 by 257 mm, in points. |
| joinstyle | Package joinstyle defines the line join styles. |
| legal | Package legal defines the legal page size in points. |
| letter | Package letter defines the letter page size in points. |
| mark | Package mark defines the check marks of a CheckBox. |
| pagelayout | Package pagelayout defines the page layouts used when the document is opened. |
| pagemode | Package pagemode defines the page modes used when the document is opened. |
| pagesize | Package pagesize defines the PageSize type, the width and height of a page in points. |
| pathoperator | Package pathoperator defines the path painting operators, such as stroke and fill. |
| pdf417 | Package pdf417 creates PDF417 barcodes. |
| qrcode | Package qrcode creates QR code barcodes. |
| relationship | Package relationship defines how a file attached to the document relates to what the document shows. |
| scriptposition | Package scriptposition defines the positions of text: normal, subscript and superscript. |
| shape | Package shape defines the point shapes. |
| structelem | Package structelem has the structure element types of a tagged (PDF/UA) document, as in ISO 32000-1 section 14.8.4. |
| tabloid | Package tabloid defines the tabloid page size in points. |
| xmlparser | Package xmlparser reads XML into elements: their names, their namespaces, their attributes in the order they are written, and their text. |