annotator

package
v0.0.0-...-fb73569 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCircleAnnotation

func CreateCircleAnnotation(circDef CircleAnnotationDef) (*pdf.PdfAnnotation, error)

CreateCircleAnnotation creates a circle/ellipse annotation object with appearance stream that can be added to page PDF annotations.

func CreateLineAnnotation

func CreateLineAnnotation(lineDef LineAnnotationDef) (*pdf.PdfAnnotation, error)

CreateLineAnnotation creates a line annotation object that can be added to page PDF annotations.

func CreateRectangleAnnotation

func CreateRectangleAnnotation(rectDef RectangleAnnotationDef) (*pdf.PdfAnnotation, error)

CreateRectangleAnnotation creates a rectangle annotation object that can be added to page PDF annotations.

func NewCheckboxField

func NewCheckboxField(page *model.PdfPage, name string, rect []float64, opt CheckboxFieldOptions) (*model.PdfFieldButton, error)

NewCheckboxField generates a new checkbox field with partial name `name` at location `rect` on specified `page` and with field specific options `opt`.

func NewComboboxField

func NewComboboxField(page *model.PdfPage, name string, rect []float64, opt ComboboxFieldOptions) (*model.PdfFieldChoice, error)

NewComboboxField generates a new combobox form field with partial name `name` at location `rect` on specified `page` and with field specific options `opt`.

func NewSignatureField

func NewSignatureField(signature *model.PdfSignature, lines []*SignatureLine, opts *SignatureFieldOpts) (*model.PdfFieldSignature, error)

NewSignatureField returns a new signature field with a visible appearance containing the specified signature lines and styled according to the specified options.

func NewTextField

func NewTextField(page *model.PdfPage, name string, rect []float64, opt TextFieldOptions) (*model.PdfFieldText, error)

NewTextField generates a new text field with partial name `name` at location specified by `rect` on given `page` and with field specific options `opt`.

Types

type AppearanceStyle

type AppearanceStyle struct {
	// How much of Rect height to fill when autosizing text.
	AutoFontSizeFraction float64
	// CheckmarkRune is a rune used for check mark in checkboxes (for ZapfDingbats font).
	CheckmarkRune rune

	BorderSize  float64
	BorderColor model.PdfColor
	FillColor   model.PdfColor

	// Multiplier for lineheight for multi line text.
	MultilineLineHeight   float64
	MultilineVAlignMiddle bool // Defaults to top.

	// Visual guide checking alignment of field contents (debugging).
	DrawAlignmentReticle bool

	// Allow field MK appearance characteristics to override style settings.
	AllowMK bool
}

AppearanceStyle defines style parameters for appearance stream generation.

type CheckboxFieldOptions

type CheckboxFieldOptions struct {
	Checked bool
}

CheckboxFieldOptions defines optional parameters for a checkbox field a form.

type CircleAnnotationDef

type CircleAnnotationDef struct {
	X             float64
	Y             float64
	Width         float64
	Height        float64
	FillEnabled   bool // Show fill?
	FillColor     *pdf.PdfColorDeviceRGB
	BorderEnabled bool // Show border?
	BorderWidth   float64
	BorderColor   *pdf.PdfColorDeviceRGB
	Opacity       float64 // Alpha value (0-1).
}

type ComboboxFieldOptions

type ComboboxFieldOptions struct {
	// Choices is the list of string values that can be selected.
	Choices []string
}

ComboboxFieldOptions defines optional parameters for a combobox form field.

type FieldAppearance

type FieldAppearance struct {
	OnlyIfMissing        bool
	RegenerateTextFields bool
	// contains filtered or unexported fields
}

FieldAppearance implements interface model.FieldAppearanceGenerator and generates appearance streams for fields taking into account what value is in the field. A common use case is for generating the appearance stream prior to flattening fields.

If `OnlyIfMissing` is true, the field appearance is generated only for fields that do not have an appearance stream specified. If `RegenerateTextFields` is true, all text fields are regenerated (even if OnlyIfMissing is true).

func (FieldAppearance) GenerateAppearanceDict

func (fa FieldAppearance) GenerateAppearanceDict(form *model.PdfAcroForm, field *model.PdfField, wa *model.PdfAnnotationWidget) (*core.PdfObjectDictionary, error)

GenerateAppearanceDict generates an appearance dictionary for widget annotation `wa` for the `field` in `form`. Implements interface model.FieldAppearanceGenerator.

func (*FieldAppearance) SetStyle

func (fa *FieldAppearance) SetStyle(style AppearanceStyle)

SetStyle applies appearance `style` to `fa`.

func (FieldAppearance) Style

func (fa FieldAppearance) Style() AppearanceStyle

Style returns the appearance style of `fa`. If not specified, returns default style.

func (FieldAppearance) WrapContentStream

func (fa FieldAppearance) WrapContentStream(page *model.PdfPage) error

WrapContentStream ensures that the entire content stream for a `page` is wrapped within q ... Q operands. Ensures that following operands that are added are not affected by additional operands that are added. Implements interface model.ContentStreamWrapper.

type LineAnnotationDef

type LineAnnotationDef struct {
	X1               float64
	Y1               float64
	X2               float64
	Y2               float64
	LineColor        *pdf.PdfColorDeviceRGB
	Opacity          float64 // Alpha value (0-1).
	LineWidth        float64
	LineEndingStyle1 draw.LineEndingStyle // Line ending style of point 1.
	LineEndingStyle2 draw.LineEndingStyle // Line ending style of point 2.
}

LineAnnotationDef defines a line between point 1 (X1,Y1) and point 2 (X2,Y2). The line ending styles can be none (regular line), or arrows at either end. The line also has a specified width, color and opacity.

type RectangleAnnotationDef

type RectangleAnnotationDef struct {
	X             float64
	Y             float64
	Width         float64
	Height        float64
	FillEnabled   bool // Show fill?
	FillColor     *pdf.PdfColorDeviceRGB
	BorderEnabled bool // Show border?
	BorderWidth   float64
	BorderColor   *pdf.PdfColorDeviceRGB
	Opacity       float64 // Alpha value (0-1).
}

RectangleAnnotationDef is a rectangle defined with a specified Width and Height and a lower left corner at (X,Y). The rectangle can optionally have a border and a filling color. The Width/Height includes the border (if any specified).

type SignatureFieldOpts

type SignatureFieldOpts struct {
	// Rect represents the area the signature annotation is displayed on.
	Rect []float64

	// AutoSize specifies if the content of the appearance should be
	// scaled to fit in the annotation rectangle.
	AutoSize bool

	// Font specifies the font of the text content.
	Font *model.PdfFont

	// FontSize specifies the size of the text content.
	FontSize float64

	// LineHeight specifies the height of a line of text in the appearance annotation.
	LineHeight float64

	// TextColor represents the color of the text content displayed.
	TextColor model.PdfColor

	// FillColor represents the background color of the appearance annotation area.
	FillColor model.PdfColor

	// BorderSize represents border size of the appearance annotation area.
	BorderSize float64

	// BorderColor represents the border color of the appearance annotation area.
	BorderColor model.PdfColor
}

SignatureFieldOpts represents a set of options used to configure an appearance widget dictionary.

func NewSignatureFieldOpts

func NewSignatureFieldOpts() *SignatureFieldOpts

NewSignatureFieldOpts returns a new initialized instance of options used to generate a signature appearance.

type SignatureLine

type SignatureLine struct {
	Desc string
	Text string
}

SignatureLine represents a line of information in the signature field appearance.

func NewSignatureLine

func NewSignatureLine(desc, text string) *SignatureLine

NewSignatureLine returns a new signature line displayed as a part of the signature field appearance.

type TextFieldOptions

type TextFieldOptions struct {
	MaxLen int    // Ignored if <= 0.
	Value  string // Ignored if empty ("").
}

TextFieldOptions defines optional parameter for a text field in a form.

Jump to

Keyboard shortcuts

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